Beispiel #1
0
        private async Task AddLog(string errorMessage, DateTime occurTime)
        {
            TcpListenerLog log = new TcpListenerLog()
            {
                IsError         = true,
                ErrorMessage    = errorMessage,
                ExecuteDuration = 0,
                ListenerName    = _listener.Name,
                RequestContent  = string.Empty,
                RequestTime     = occurTime,
                ResponseContent = string.Empty,
                ResponseTime    = DateTime.UtcNow
            };
            var t = Task.Run(async() =>
            {
                try
                {
                    await log.Add();
                }
                catch (Exception ex)
                {
                    LoggerHelper.LogError(LogCategoryName, $"TcpListener {_listener.Name}, AddLog Error,message:{ex.Message},stack:{ex.StackTrace}");
                }
            });

            await Task.FromResult(0);
        }
Beispiel #2
0
        private async Task AddLog(TcpAcceptContext token)
        {
            TcpListenerLog log = new TcpListenerLog()
            {
                IsError         = !token.ExecuteSuccess,
                ErrorMessage    = token.ExecuteError ?? string.Empty,
                ExecuteDuration = (int)token.Watch.ElapsedMilliseconds,
                ListenerName    = _listener.Name,
                RequestContent  = UTF8Encoding.UTF8.GetString(token.RetrieveBytes.ToArray()),
                RequestTime     = token.RequestDateTime,
                ResponseContent = token.ResponseBytes == null ? string.Empty : UTF8Encoding.UTF8.GetString(token.ResponseBytes.ToArray()),
                ResponseTime    = DateTime.UtcNow
            };
            var t = Task.Run(async() =>
            {
                try
                {
                    await log.Add();
                }
                catch (Exception ex)
                {
                    LoggerHelper.LogError(LogCategoryName, $"TcpListener {_listener.Name}, AddLog Error,message:{ex.Message},stack:{ex.StackTrace}");
                }
            });

            await Task.FromResult(0);
        }
Beispiel #3
0
 public async Task Delete(TcpListenerLog log)
 {
     await _tcplistenerLogStore.Delete(log.ListenerName, log.ID);
 }
Beispiel #4
0
 public async Task Add(TcpListenerLog log)
 {
     await _tcplistenerLogStore.Add(log);
 }