Add new Hcs.Broker to communicate with ГИС ЖКХ via CryptoPro LibCore

This commit is contained in:
2025-09-28 15:45:15 +09:00
parent 904988780a
commit 2b49320014
171 changed files with 185618 additions and 0 deletions

View File

@ -0,0 +1,43 @@
using Hcs.Broker.Logger;
using System.Text;
namespace Hcs.Broker.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 Exception("index value exceeds maxIndex value");
}
fileName = index.ToString("D3") + "_" + (sent ? "message" : "response") + ".xml";
if (!string.IsNullOrEmpty(directory))
{
fileName = Path.Combine(directory, fileName);
}
}
while (File.Exists(fileName));
logger?.WriteLine($"Capturing message to file {fileName}...");
File.WriteAllText(fileName, messageBody, Encoding.UTF8);
}
}
}