public void HandleMessage(WebMessageTrace messageTrace)
        {
            var httpTransportDto = new HttpTransportItem { Id = messageTrace.Id, Server = messageTrace.Server };

            var message = messageTrace.Messages.FirstOrDefault(x => x.Type == WebMessageType.Request);
            {
                httpTransportDto.RequestData = MaskPassword(message);
                httpTransportDto.RequestHeader = new HttpTransportRequestHeader(message.Headers);
                httpTransportDto.RequestTimestamp = message.Timestamp;
                httpTransportDto.Method = message.Method;
                httpTransportDto.RequestUri = message.AbsolutePath;
            }

            message = messageTrace.Messages.FirstOrDefault(x => x.Type == WebMessageType.Response);
            if (message != null)
            {
                httpTransportDto.ResponseData = message.Details;
                httpTransportDto.ResponseHeader = new HttpTransportResponseHeader(message.Headers);
                TimeSpan span = message.Timestamp.Subtract(httpTransportDto.RequestTimestamp);
                httpTransportDto.TimeTaken = string.Format("{0}:{1}:{2}.{3}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
            }

            message = messageTrace.Messages.FirstOrDefault(x => x.Type == WebMessageType.Error);
            if (message != null)
            {
                httpTransportDto.Error = message.Details;
                httpTransportDto.ResponseHeader = new HttpTransportResponseHeader(message.Headers);
                TimeSpan span = message.Timestamp.Subtract(httpTransportDto.RequestTimestamp);
                httpTransportDto.TimeTaken = string.Format("{0}:{1}:{2}.{3}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
            }
            cachedCollection.Add(httpTransportDto);
        }
Exemple #2
0
 public void Publish(WebMessageTrace message)
 {
     if (_canPublish)
     {
         foreach (var action in _subscribers)
         {
             action.Invoke(message);
         }
     }
 }
Exemple #3
0
        private void Notify(Guid messageId, HttpResponse response)
        {
            var trace = new WebMessageTrace(messageId)
            {
                Messages = new List <WebMessage>
                {
                    new WebMessage(WebMessageType.Response)
                    {
                        Details = response.Data,
                        Headers = HttpWebRequestHelper.GetHeaders(response.Headers)
                    }
                }
            };

            Publish(trace);
        }
Exemple #4
0
        private void Notify(Guid messageId, WebException exception)
        {
            var trace = new WebMessageTrace(messageId)
            {
                Messages = new List <WebMessage>
                {
                    new WebMessage(WebMessageType.Error)
                    {
                        Details = string.Format("Message - {0} Stack Trace - {1}", exception.Message, exception.StackTrace),
                        Headers = HttpWebRequestHelper.GetHeaders(exception.Response.Headers)
                    }
                }
            };

            Publish(trace);
        }
Exemple #5
0
        private void Notify(Guid messageId, WebRequest request, string data)
        {
            var trace = new WebMessageTrace(messageId)
            {
                Messages = new List <WebMessage>
                {
                    new WebMessage(WebMessageType.Request)
                    {
                        Details      = data,
                        Headers      = HttpWebRequestHelper.GetHeaders(request.Headers),
                        Method       = request.Method,
                        AbsolutePath = request.RequestUri.AbsolutePath
                    }
                }
            };

            Publish(trace);
        }
Exemple #6
0
        private void Notify(Guid messageId, HttpRequest request, HttpResponse response, Exception exception)
        {
            var trace = new WebMessageTrace(messageId);

            if (response != null)
            {
                trace.Messages.Add(
                    new WebMessage(WebMessageType.Response)
                {
                    Details   = response.Data,
                    Headers   = HttpWebRequestHelper.GetHeaders(response.Headers),
                    Timestamp = DateTime.UtcNow
                });
            }

            if (request != null)
            {
                trace.Server = request.Server;
                trace.Messages.Add(
                    new WebMessage(WebMessageType.Request)
                {
                    Details      = request.Data,
                    Headers      = HttpWebRequestHelper.GetHeaders(request.Headers),
                    Method       = request.Request.Method,
                    AbsolutePath = request.Request.RequestUri.AbsolutePath,
                    Timestamp    = request.Timestamp
                });
            }
            if (exception != null)
            {
                trace.Messages.Add(
                    new WebMessage(WebMessageType.Error)
                {
                    Details   = string.Format("Message - {0} Stack Trace - {1}", exception.Message, exception.StackTrace),
                    Headers   = exception.GetType() == typeof(WebException) && ((WebException)exception).Response != null ? HttpWebRequestHelper.GetHeaders(((WebException)exception).Response.Headers) : new Dictionary <string, string>(),
                    Timestamp = DateTime.UtcNow
                });
            }

            Publish(trace);
        }
 private void Notify(Guid messageId, HttpResponse response)
 {
     var trace = new WebMessageTrace(messageId)
     {
         Messages = new List<WebMessage>
         {
             new WebMessage(WebMessageType.Response)
             {
                 Details = response.Data,
                 Headers = HttpWebRequestHelper.GetHeaders(response.Headers)
             }
         }
     };
     Publish(trace);
 }
 public void Publish(WebMessageTrace message)
 {
     if (_canPublish)
     {
         foreach (var action in _subscribers)
             action.Invoke(message);
     }
 }
        private void Notify(Guid messageId, HttpRequest request, HttpResponse response, Exception exception)
        {
            var trace = new WebMessageTrace(messageId);

            if(response!= null)
                trace.Messages.Add(
                    new WebMessage(WebMessageType.Response)
                    {
                        Details = response.Data,
                        Headers = HttpWebRequestHelper.GetHeaders(response.Headers),
                        Timestamp = DateTime.UtcNow
                    });

            if (request != null)
            {
                trace.Server = request.Server;
                trace.Messages.Add(
                        new WebMessage(WebMessageType.Request)
                        {
                            Details = request.Data,
                            Headers = HttpWebRequestHelper.GetHeaders(request.Headers),
                            Method = request.Request.Method,
                            AbsolutePath = request.Request.RequestUri.AbsolutePath,
                            Timestamp = request.Timestamp
                        });
            }
            if(exception!= null)
               trace.Messages.Add(
                    new WebMessage(WebMessageType.Error)
                    {
                        Details = string.Format("Message - {0} Stack Trace - {1}", exception.Message , exception.StackTrace),
                        Headers = exception.GetType() == typeof(WebException) && ((WebException)exception).Response != null ? HttpWebRequestHelper.GetHeaders(((WebException)exception).Response.Headers) : new Dictionary<string, string>(),
                        Timestamp = DateTime.UtcNow
                    });

            Publish(trace);
        }
 private void Notify(Guid messageId, WebException exception)
 {
     var trace = new WebMessageTrace(messageId)
     {
         Messages = new List<WebMessage>
         {
             new WebMessage(WebMessageType.Error)
             {
                 Details = string.Format("Message - {0} Stack Trace - {1}", exception.Message , exception.StackTrace),
                 Headers = HttpWebRequestHelper.GetHeaders(exception.Response.Headers)
             }
         }
     };
     Publish(trace);
 }
 private void Notify(Guid messageId, WebRequest request, string data)
 {
     var trace = new WebMessageTrace(messageId)
     {
         Messages = new List<WebMessage>
         {
             new WebMessage(WebMessageType.Request)
             {
                 Details = data,
                 Headers = HttpWebRequestHelper.GetHeaders(request.Headers),
                 Method = request.Method,
                 AbsolutePath = request.RequestUri.AbsolutePath
             }
         }
     };
     Publish(trace);
 }