コード例 #1
0
        /// <summary>
        /// Set CallerInfo in only first interceptor. Baseclass will work for every interceptor.
        /// For example, if we would have logging and authorization interceptors, we don't have to set CallerInfo or Session Values twice.
        /// </summary>
        /// <param name="message"></param>
        private void initCallerInfo(HttpRequestMessage message)
        {
            if (Toolkit.CallerInfo == null)
            {
                CallerInfo callerInfo = new CallerInfo();
                using (var operation = new ServiceCallOperations())
                {
                    var res = operation.Add(new ServiceCall()
                    {
                        Uri = message.RequestUri.AbsoluteUri, HttpMethod = message.Method.Method
                    });
                    callerInfo.ServiceCallId = res.Id;
                }

                callerInfo.HttpMethod = message.Method.Method;
                string[] temp = message.RequestUri.LocalPath.Split('/');
                if (temp.Length >= 2)
                {
                    callerInfo.Service = temp[1];
                    callerInfo.Method  = temp.Length == 2 ? string.Empty : temp[2];
                }
                callerInfo.QueryParameters = message.GetQueryNameValuePairs();
                callerInfo.RequestUri      = message.RequestUri.AbsoluteUri;
                callerInfo.RequestHeader   = message.Headers.ToString();
                callerInfo.State           = CallerInfo.PipelineState.OnRequest;
                callerInfo.RequestBody     = message.Content.ReadAsStringAsync().Result;
                Toolkit.OwinContext.Set <CallerInfo>("CallerInfo", callerInfo);
            }
        }
コード例 #2
0
 protected override void Append(LoggingEvent loggingEvent)
 {
     Task.Run(() =>
     {
         lock (_syncLock)
         {
             if (loggingEvent.MessageObject != null)
             {
                 var callerInfo = ((CallerInfo)loggingEvent.MessageObject).Clone() as CallerInfo; //CallerInfo can change while this operation is running in async, so clone the object
                 using (var operation = new ServiceCallOperations())
                 {
                     operation.Add(callerInfo);
                 }
             }
         }
     });
 }
コード例 #3
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            var callerInfo = Toolkit.CallerInfo;

            Task.Run(() =>
            {
                lock (_syncLock)
                {
                    if (loggingEvent.MessageObject != null && callerInfo != null)
                    {
                        var error = ((Error)loggingEvent.MessageObject).Clone() as Error;
                        using (var errorOp = new ErrorOperations())
                        {
                            errorOp.Add(error);
                        }
                        using (var serviceOp = new ServiceCallOperations())
                        {
                            serviceOp.UpdateServiceCallErrorId(callerInfo.ServiceCallId, error.Id);
                        }
                    }
                }
            });
        }