コード例 #1
0
        private ClientRequestLog ProcessCLientRequest(Type type, MethodInfo method, IDictionary <string, object> arguments)
        {
            var auditInfo = new ClientRequestLog()
            {
                ServiceName     = type != null ? type.FullName : "",
                MethodName      = method.Name,
                Parameters      = ConvertArgumentsToJson(arguments),
                ExecutionTime   = DateTime.Now,
                ClientIpAddress = _HttpContextClientInfoProvider.ClientIpAddress,
                BrowserInfo     = _HttpContextClientInfoProvider.BrowserInfo
            };

            return(auditInfo);
        }
コード例 #2
0
        public override Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
        {
            var model = new APIResultModel(200);

            if (!EnumHelper.IsDefined(typeof(CommonEnumInternal.LanguageType), ClientContext.Current.ClientLanguage))
            {
                model.code = 1000002; // 客户端语言设置错误
            }

            if (!EnumHelper.IsDefined(typeof(CommonEnumInternal.PlatformType), ClientContext.Current.PlatformType) ||
                ClientContext.Current.PlatformType == (byte)CommonEnumInternal.PlatformType.Unknown)
            {
                model.code = 1000003; // 客户端识别码设置错误
            }

            if (model.code == model.RightCode)
            {
                #region "过滤器代码区"

                // TO DO

                #region "请求日志"

                if (CachedFileConfigContext.Current.SiteConfig.ClientRequestWriteLog)
                {
                    var message = new ClientRequestLog
                    {
                        Url          = HttpContext.Current.Request.Url.ToString(),
                        QueryParas   = SerializationHelper.Newtonsoft_Serialize(HttpContext.Current.Request.QueryString),
                        FormParas    = SerializationHelper.Newtonsoft_Serialize(HttpContext.Current.Request.Form),
                        HeaderParas  = SerializationHelper.Newtonsoft_Serialize(HttpContext.Current.Request.Headers),
                        IPAddress    = WebHelper.UserIPAddress,
                        UserID       = ClientContext.Current.UserInfo != null ? ClientContext.Current.UserInfo.UserID : 0,
                        PlatformType = ClientContext.Current.PlatformType
                    };
                    Log4NetHelper.Info(LoggerType.ClientRequestLog, message, null);
                }

                #endregion

                #region "参数解密"

                #endregion

                #region "签名校验"

                #endregion

                #region "参数过滤"

                if (!actionContext.Request.Content.IsMimeMultipartContent())
                {
                    var actionParas = new Dictionary <string, object>(actionContext.ActionArguments);
                    actionContext.ActionArguments.Clear();
                    foreach (var item in actionParas)
                    {
                        if (item.Value != null)
                        {
                            if (item.Value.IsReferenceObject())
                            {
                                item.Value.ReplaceSQLKeywords();
                                actionContext.ActionArguments.Add(item.Key, item.Value);
                            }
                            else
                            {
                                actionContext.ActionArguments.Add(item.Key, ConvertHelper.GetString(item.Value).ReplaceSQLKeywords());
                            }
                        }
                    }
                }

                #endregion

                #endregion
            }

            if (model.code != model.RightCode)
            {
                actionContext.Response = new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.OK,
                    Content    = new ObjectContent <APIResultModel>(model, new JsonMediaTypeFormatter())
                };
            }

            return(base.OnActionExecutingAsync(actionContext, cancellationToken));
        }
コード例 #3
0
 public void SaveClientReQuest(ClientRequestLog model)
 {
     _RequestlogCommand.Insert(model);
 }