Add project

Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
This commit is contained in:
2025-08-12 11:21:10 +09:00
parent bbcbe841a7
commit 33ab055b43
546 changed files with 176950 additions and 0 deletions

View File

@ -0,0 +1,45 @@
using System.Text;
namespace Hcs.ClientApi
{
/// <summary>
/// Реализация механизма захвата содержимого сообщений SOAP записывающая
/// каждое сообщение в отдельный файл на диске
/// </summary>
public class HcsFileWriterMessageCapture : IHcsMessageCapture
{
private string directory;
private IHcsLogger logger;
public HcsFileWriterMessageCapture()
{
}
public HcsFileWriterMessageCapture(string directory, IHcsLogger logger)
{
this.directory = directory;
this.logger = logger;
}
public void CaptureMessage(bool sent, string body)
{
int index = 0;
int maxIndex = 1000000;
string fileName;
do
{
index += 1;
if (index > maxIndex) throw new HcsException("Превышен максимум индекса файлов захвата сообщений");
fileName = index.ToString("D3") + "_" + (sent ? "message" : "response") + ".xml";
if (!string.IsNullOrEmpty(directory))
{
fileName = System.IO.Path.Combine(directory, fileName);
}
} while (System.IO.File.Exists(fileName));
if (logger != null) logger.WriteLine($"Writing message file: {fileName}...");
System.IO.File.WriteAllText(fileName, body, Encoding.UTF8);
}
}
}