本文整理汇总了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)
);
}
示例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));
}
}