Add migrated to .NET 8.0 variant of Hcs.Client

This commit is contained in:
2025-09-26 19:48:32 +09:00
parent da127df8f6
commit 6cd2fb82e9
503 changed files with 223796 additions and 0 deletions

View File

@ -0,0 +1,43 @@
using Hcs.ClientNet.Logger;
using System.Text;
namespace Hcs.ClientNet.MessageCapturer
{
/// <summary>
/// Реализация механизма захвата содержимого сообщений SOAP, записывающая
/// каждое сообщение в отдельный файл на диске
/// </summary>
public class FileMessageCapturer(string directory, ILogger logger) : IMessageCapturer
{
private readonly string directory = directory;
private readonly ILogger logger = logger;
public void CaptureMessage(bool sent, string messageBody)
{
var index = 0;
var maxIndex = 1000000;
string fileName;
do
{
index += 1;
if (index > maxIndex)
{
throw new System.Exception("index value exceeds maxIndex value");
}
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));
logger?.WriteLine($"Capturing message to file {fileName}...");
System.IO.File.WriteAllText(fileName, messageBody, Encoding.UTF8);
}
}
}