当前位置: 首页>>代码示例>>C#>>正文


C# WorkContext.Log方法代码示例

本文整理汇总了C#中WorkContext.Log方法的典型用法代码示例。如果您正苦于以下问题:C# WorkContext.Log方法的具体用法?C# WorkContext.Log怎么用?C# WorkContext.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorkContext的用法示例。


在下文中一共展示了WorkContext.Log方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoAfterWork

 protected override void DoAfterWork(WorkContext work, JSONDataMap matched)
 {
     work.Log(
        matched[VAR_TYPE].AsEnum<MessageType>(MessageType.Info),
        matched[VAR_TEXT].AsString(work.About),
        matched[VAR_FROM].AsString("{0}.After".Args(GetType().FullName)),
        pars: matched.ToJSON(JSONWritingOptions.CompactASCII)
        );
 }
开发者ID:itadapter,项目名称:nfx,代码行数:9,代码来源:LoggingFilter.cs

示例2: HandleException

      /// <summary>
      /// Handles the exception by responding appropriately with error page with conditional level of details and logging
      /// </summary>
      public static void HandleException(WorkContext work, 
                                         Exception error,
                                         OrderedRegistry<WorkMatch> showDumpMatches,
                                         OrderedRegistry<WorkMatch> logMatches,
                                         string securityRedirectURL = null,
                                         Type customPageType = null
                                         )
      {
          if (work==null || error==null) return;
          
          var showDump = showDumpMatches != null ? 
                         showDumpMatches.OrderedValues.Any(m => m.Make(work)!=null) : false;

          if (work.Response.Buffered)
            work.Response.CancelBuffered();

          var json = false;
          
          if (work.Request!=null && work.Request.AcceptTypes!=null)//if needed for some edge HttpListener cases when Request or Request.AcceptTypes are null
               json = work.Request.AcceptTypes.Any(at=>at.EqualsIgnoreCase(ContentType.JSON));

          var actual = error;
          if (actual is FilterPipelineException)
            actual = ((FilterPipelineException)actual).RootException;

          if (json)
          {
             work.Response.ContentType = ContentType.JSON;
             work.Response.WriteJSON(error.ToClientResponseJSONMap(showDump));
          }
          else
          {
            if (securityRedirectURL.IsNotNullOrWhiteSpace() && (actual is NFX.Security.AuthorizationException || actual.InnerException is NFX.Security.AuthorizationException))
              work.Response.RedirectAndAbort(securityRedirectURL);
            else
            {
              WaveTemplate errorPage = null;

              if (customPageType!=null)
                try
                {
                  errorPage = Activator.CreateInstance(customPageType) as WaveTemplate;
                  if (errorPage==null) throw new WaveException("not WaveTemplate");
                }
                catch(Exception actErr)
                {
                  work.Log(Log.MessageType.Error, 
                            StringConsts.ERROR_PAGE_TEMPLATE_TYPE_ERROR.Args(customPageType.FullName, actErr.ToMessageWithType()),
                            typeof(ErrorFilter).FullName+".ctor(customPageType)",
                            actErr);
                }
              
              if (errorPage==null)
                errorPage =  new ErrorPage(work, error, showDump);
                
              errorPage.Render(work, error);
            }
          }

         
          
          if (actual is HTTPStatusException)
          {
            var se = (HTTPStatusException)actual;
            work.Response.StatusCode = se.StatusCode;
            work.Response.StatusDescription = se.StatusDescription;
          }

          if (logMatches!=null && logMatches.Count>0)
          {
            JSONDataMap matched = null;
            foreach(var match in logMatches.OrderedValues)
            {
              matched = match.Make(work);
              if (matched!=null) break;
            }
            if (matched!=null)
              work.Log(Log.MessageType.Error, error.ToMessageWithType(), typeof(ErrorFilter).FullName, pars: matched.ToJSON(JSONWritingOptions.CompactASCII));
          }  

      }
开发者ID:vlapchenko,项目名称:nfx,代码行数:84,代码来源:ErrorFilter.cs


注:本文中的WorkContext.Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。