Example #1
0
    void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext)
    {
        //if (System.Web.HttpContext.Current.Application["TraceLogState"] == null ||
        //    System.Web.HttpContext.Current.Application["TraceLogState"].ToString() != "ON") return;
        if (TRACE_LEVEL_EXIT < 1)
        {
            return;
        }

        var sb = new StringBuilder();

        sb.Append("Exit: ");
        DiscoverObjectProperties(sb, filterContext.Result, TRACE_LEVEL_EXIT);
        var message = sb.ToString();

        ContactListContext.LogTrace(message);
    }
Example #2
0
    void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
    {
        //if (System.Web.HttpContext.Current.Application["TraceLogState"] == null ||
        //    System.Web.HttpContext.Current.Application["TraceLogState"].ToString() != "ON") return;
        if (TRACE_LEVEL_ENTRY < 1)
        {
            return;
        }

        var sb = new StringBuilder();

        sb.Append("Enter: ");
        sb.Append("ActionName:").Append(filterContext.ActionDescriptor.ActionName).Append("; ");
        sb.Append("ControllerName:")
        .Append(filterContext.ActionDescriptor.ControllerDescriptor.ControllerName)
        .Append("; ");
        sb.Append("ActionParameters:{");
        var keys = filterContext.ActionParameters.Keys.ToArray();

        for (int i = 0; i < keys.Count(); i++)
        {
            sb.Append(keys[i]).Append(":");
            var value = filterContext.ActionParameters[keys[i]];
            if (keys[i].ToUpper().Contains(PASSWORD_STRING))
            {
                sb.Append("xxxxxxxx");
            }
            else
            {
                ParseParameterProperties(sb, value, TRACE_LEVEL_ENTRY);
            }
            if (i + 1 < keys.Count())
            {
                sb.Append("; ");
            }
        }
        sb.Append("} ");
        var message = sb.ToString();

        ContactListContext.LogTrace(message);
    }