コード例 #1
0
 public RequestProcTimeMiddleware(OwinMiddleware next, RequestProcTimeOption requestProcTimeOption = null)
     : base(next)
 {
     _next = next;
     //第一个参数是固定的,后边还可以添加自定义的其它参数
     _requestProcTimeOption = requestProcTimeOption;
 }
コード例 #2
0
 public void ConfigureRequestProcTime(IAppBuilder app)
 {
     RequestProcTimeOption requestProcTimeOption = new RequestProcTimeOption();
     requestProcTimeOption.RequestProcTimeAction = (data) =>
     {
         var messageInfo = new MessageInfo();
         messageInfo.Message = "请求时间日志";
         messageInfo.Body = data;
         messageInfo.Action = (messageData) =>
         {
             var bodyData = messageData.Body as RequestProcData;
             if (bodyData == null) return;
             //var requestProcTimeLog = new RequestProcTimeLog
             //{
             //    BeginRequestDateTime = bodyData.BeginRequestDateTime,
             //    EndRequestDateTime = bodyData.EndRequestDateTime,
             //    RequestIp = bodyData.RequestIp,
             //    RequestResponseInterval = bodyData.RequestResponseInterval,
             //    RequestUrl = bodyData.RequestUrl
             //};
             var requestProcTimeLog = Mapper.MapNew<RequestProcData, RequestProcTimeLog>(bodyData);
             var mongoDbRepository = new MongoDBRepository<RequestProcTimeLog>();
             mongoDbRepository.Insert(requestProcTimeLog);
         };
         QueueManagement.getInstance().PushData(messageInfo);
     };
     app.UseRequestProcTime(requestProcTimeOption);
 }
コード例 #3
0
 /// <summary>
 /// 请求处理时间
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="requestProcTimeOption">请求处理时间选项</param>
 /// <returns></returns>
 public static IAppBuilder UseRequestProcTime(this IAppBuilder builder,
     RequestProcTimeOption requestProcTimeOption=null)
 {
     return builder.Use<RequestProcTimeMiddleware>(requestProcTimeOption);
 }