예제 #1
0
        private void BuildErrorLoggerData(Exception exception, ILoggerData logger)
        {
            logger.StatusCode = 500;
            logger.ErrorTrace = exception.StackTrace;

            logger.Error();
        }
예제 #2
0
 private void BuildResponseLoggerData(HttpResponse response, MemoryStream ms, ILoggerData logger)
 {
     ms.Position         = 0;
     logger.ResponseBody = new StreamReader(ms).ReadToEnd();
     logger.StatusCode   = response.StatusCode;
     logger.Success();
 }
예제 #3
0
        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();
        }
예제 #4
0
        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;
                    }
                }
            }
        }
예제 #5
0
        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();
        }
예제 #6
0
        private void PrepareRequestBody(ILoggerData loggerData)
        {
            if (string.IsNullOrEmpty(loggerData.Body))
            {
                return;
            }

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(loggerData.Body.ConvertJsonString());

            tbRequestBody.Text = stringBuilder.ToString();
        }
예제 #7
0
        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;
            }
        }
예제 #8
0
        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);
        }
예제 #9
0
        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();
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
 public ValuesController(ILoggerData loggerData)
 {
     _loggerData = loggerData;
 }
예제 #12
0
 public frmDetail(ILoggerData loggerData)
 {
     _loggerData = loggerData;
     InitializeComponent();
 }