private void BuildErrorLoggerData(Exception exception, ILoggerData logger) { logger.StatusCode = 500; logger.ErrorTrace = exception.StackTrace; logger.Error(); }
private void BuildResponseLoggerData(HttpResponse response, MemoryStream ms, ILoggerData logger) { ms.Position = 0; logger.ResponseBody = new StreamReader(ms).ReadToEnd(); logger.StatusCode = response.StatusCode; logger.Success(); }
private void PrepareQuerystring(ILoggerData loggerData) { if (string.IsNullOrEmpty(loggerData.QueryString)) { return; } var stringBuilder = new StringBuilder(); if (loggerData.QueryString.Contains(';')) { foreach (var item in loggerData.QueryString.Split(';')) { if (item.Contains(':')) { var key = item.Split(':')[0]; var value = item.Split(':')[1]; stringBuilder.AppendLine($"{key}:{value}"); } else { stringBuilder.AppendLine($"{item}"); } } } tbRequestBody.Text = stringBuilder.ToString(); }
private void UpdateListData(ILoggerData data) { if (this.dgvLogs.InvokeRequired) { FlushClient fc = new FlushClient(UpdateListData); this.Invoke(fc, data); } else { if (data.Method != "OPTIONS") { if (!_successCodes.Contains(data.StatusCode)) { data.Result = OperationResult.Error; niErrors.BalloonTipTitle = "Error"; niErrors.BalloonTipIcon = ToolTipIcon.Error; niErrors.BalloonTipText = $"An error happened on [{data.Method}]{data.Url}."; niErrors.ShowBalloonTip(10000); } _loggerDatas.Add(data); if (data.Result == OperationResult.Error || !_onlyError) { var rowId = dgvLogs.Rows.Add(); dgvLogs.Rows[rowId].Cells[0].Value = data.ID; dgvLogs.Rows[rowId].Cells[1].Value = data.Method.ToUpper(); dgvLogs.Rows[rowId].Cells[2].Value = data.Url; dgvLogs.Rows[rowId].Cells[3].Value = data.Result; dgvLogs.Rows[rowId].Cells[4].Value = data.StatusCode; } } } }
private void PrepareDBLogs(ILoggerData loggerData) { var stringBuilder = new StringBuilder(); foreach (var item in loggerData.Items.Where(p => p.LogType == LogType.Query)) { stringBuilder.AppendLine($"{item.Content}"); stringBuilder.AppendLine("-----------------------"); } tbDBLogs.Text = stringBuilder.ToString(); }
private void PrepareRequestBody(ILoggerData loggerData) { if (string.IsNullOrEmpty(loggerData.Body)) { return; } var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(loggerData.Body.ConvertJsonString()); tbRequestBody.Text = stringBuilder.ToString(); }
public EventLogger(ILoggerData loggerData, IApplicationSettings applicationSettings) { this.loggerData = loggerData; this.settings = applicationSettings.Settings.Logger; switch (this.settings.OnStartup) { case "flush": this.FlushAsync().Wait(); break; case "seed": this.ReseedAsync().Wait(); break; } }
private void SendEvents(ILoggerData data) { var factory = new ConnectionFactory() { Uri = new Uri(_logSetting.RabbitMQUrl), UserName = _logSetting.UserName, Password = _logSetting.Password }; IConnection connection = factory.CreateConnection(); IModel channel = connection.CreateModel(); channel.ExchangeDeclare(_logSetting.QueueName, "fanout"); var json = JsonConvert.SerializeObject(data); var bytes = Encoding.UTF8.GetBytes(json); channel.BasicPublish(exchange: _logSetting.QueueName, routingKey: "", basicProperties: null, body: bytes); }
private void PrepareFormData(ILoggerData loggerData) { if (string.IsNullOrEmpty(loggerData.FormData)) { return; } var stringBuilder = new StringBuilder(); foreach (var item in loggerData.FormData.Split(';')) { var key = item.Split(':')[0]; var value = item.Split(':')[1]; stringBuilder.AppendLine($"{key}:{value}"); } tbRequestBody.Text = stringBuilder.ToString(); }
private void BuildRequestLoggerData(HttpRequest request, ILoggerData logger) { var sr = new StreamReader(request.Body); var content = sr.ReadToEnd(); if (!string.IsNullOrEmpty(content)) { logger.Body = content; request.Body.Position = 0; } logger.Cookies = CreateCookieString(request.Cookies); logger.Url = request.Path; logger.Method = request.Method; logger.QueryString = request.QueryString.Value; if (request.ContentType == "multipart/form-data" || request.ContentType == "application/x-www-form-urlencoded") { logger.FormData = BuildFormString(request.Form); } }
public ValuesController(ILoggerData loggerData) { _loggerData = loggerData; }
public frmDetail(ILoggerData loggerData) { _loggerData = loggerData; InitializeComponent(); }