Пример #1
0
        private void LogRequestLoggingInfo(HttpRequestMessage request)
        {
            dynamic keys = new
            {
                HttpMethod = request.Method.Method,
                UriAccessed = request.RequestUri.AbsoluteUri,
                AbsolutePath = request.RequestUri.AbsolutePath,
                IpAddress = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : "0.0.0.0",
                MessageType = "Request",
                Headers = ExtractMessageHeadersIntoLoggingInfo(request.Headers.ToList()),
                MessageId = (int)EventClassification.WebServiceRequest

            };

            var e = new RetrievePolicyBusinessEvent(EventClassification.WebServiceRequest.ToString()).WithKeys(new RetrievePolicyBusinessKeys
            {
                //ExceedClientId = "asdf",
                //PolicyNumber = "123"

            });

            //if (request.Content != null)
            //{
            //    request.Content.ReadAsByteArrayAsync()
            //        .ContinueWith((task) =>
            //        {
            //            //           keys.BodyContent = UTF8Encoding.UTF8.GetString(task.Result);
            //            e.Raise(EVENT_CLASSIFICATION_SRVC_ACCESSED_REQ, keys);

            //        });

            //    //return;
            //}

            e.Raise(EVENT_CLASSIFICATION_SRVC_ACCESSED_REQ, keys);
        }
Пример #2
0
        private void LogResponseLoggingInfo(HttpResponseMessage response)
        {
            //var info = new ApiLoggingInfo();
            dynamic keys = new
            {
                MessageType = "Response",
                HttpMethod = response.RequestMessage.Method.ToString(),
                ResponseStatusCode = response.StatusCode,
                ResponseStatusMessage = response.ReasonPhrase,
                UriAccessed = response.RequestMessage.RequestUri.AbsoluteUri,
                IpAddress = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : "0.0.0.0",
                Headers = ExtractMessageHeadersIntoLoggingInfo(response.Headers.ToList()),
                MessageId = (int)EventClassification.WebServiceResponse
            };

            var e = new RetrievePolicyBusinessEvent(EventClassification.WebServiceRequest.ToString()).WithKeys(new RetrievePolicyBusinessKeys
            {
                //ExceedClientId = "asdf",
                //PolicyNumber = "123"

            });
            //ExtractMessageHeadersIntoLoggingInfo(info, response.Headers.ToList());

            //if (response.Content != null)
            //{
            //    response.Content.ReadAsByteArrayAsync()
            //        .ContinueWith(t =>
            //        {
            //            //var responseMsg = System.Text.UTF8Encoding.UTF8.GetString(t.Result);
            //            //info.BodyContent = responseMsg;
            //           });

            //    //return;
            //}

            e.Raise(EVENT_CLASSIFICATION_SRVC_ACCESSED_RESP, keys);
        }