Exemplo n.º 1
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //filterContext.HttpContext.Request.Form;//form表单提交的数据
            //filterContext.HttpContext.Request.QueryString;//Url 参数
            if (filterContext.Exception != null)
            {
                return;
            }
            var           controllerName = filterContext.RouteData.Values["controller"].ToString();
            var           actionName     = filterContext.RouteData.Values["action"].ToString();
            var           areaName       = filterContext.RouteData.Values["area"];
            StringBuilder logContent     = new StringBuilder();

            logContent.Append(Message + ",操作记录:");
            if (!string.IsNullOrEmpty(ParameterNameList))
            {
                Dictionary <string, string> parmsObj = new Dictionary <string, string>();

                foreach (var item in ParameterNameList.Split(',', '|'))
                {
                    var valueProviderResult = filterContext.HttpContext.Items[item];

                    if (valueProviderResult != null && !parmsObj.ContainsKey(item))
                    {
                        parmsObj.Add(item, valueProviderResult.ToString());
                    }
                }
                foreach (KeyValuePair <string, string> kvp in parmsObj)
                {
                    logContent.AppendFormat("{0}:{1} ", kvp.Key, kvp.Value);
                }
            }
            var model = new Entities.LogInfo()
            {
                Date        = DateTime.Now,
                IPAddress   = WebHelper.GetIP(),
                UserName    = (filterContext.Controller as BaseAdminController).CurrentManager.UserName,
                PageUrl     = controllerName + "/" + actionName,
                Description = logContent.ToString()
            };

            Task.Factory.StartNew(() =>
            {
                OperationLogApplication.AddPlatformOperationLog(model);
            });
            base.OnActionExecuted(filterContext);
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            var           controllerName = filterContext.RouteData.Values["controller"].ToString();
            var           actionName     = filterContext.RouteData.Values["action"].ToString();
            StringBuilder logContent     = new StringBuilder();

            logContent.Append(Message + ",操作记录:");
            if (!string.IsNullOrEmpty(ParameterNameList))
            {
                Dictionary <string, string> parmsObj = new Dictionary <string, string>();

                foreach (var item in ParameterNameList.Split(',', '|'))
                {
                    var valueProviderResult = filterContext.Controller.ValueProvider.GetValue(item);

                    if (valueProviderResult != null && !parmsObj.ContainsKey(item))
                    {
                        parmsObj.Add(item, valueProviderResult.AttemptedValue);
                    }
                }
                foreach (KeyValuePair <string, string> kvp in parmsObj)
                {
                    logContent.AppendFormat("{0}:{1} ", kvp.Key, kvp.Value);
                }
            }
            var model = new Entities.LogInfo()
            {
                Date        = DateTime.Now,
                IPAddress   = WebHelper.GetIP(),
                UserName    = (filterContext.Controller as BaseSellerController).CurrentSellerManager.UserName,
                PageUrl     = controllerName + "/" + actionName,
                Description = logContent.ToString(),
                ShopId      = (filterContext.Controller as BaseSellerController).CurrentSellerManager.ShopId,
            };

            Task.Factory.StartNew(() =>
            {
                OperationLogApplication.AddSellerOperationLog(model);
            });
        }
Exemplo n.º 3
0
 /// <summary>
 /// 增加平台日志信息
 /// </summary>
 /// <param name="info"></param>
 public static void AddSellerOperationLog(Entities.LogInfo info)
 {
     _iOperationLogService.AddSellerOperationLog(info);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 增加平台日志信息
 /// </summary>
 /// <param name="info"></param>
 public static void AddPlatformOperationLog(Entities.LogInfo info)
 {
     _iOperationLogService.AddPlatformOperationLog(info);
 }