/// <summary>
        /// 处理Request中的基本数据信息
        /// </summary>
        /// <param name="p"></param>
        /// <param name="d"></param>
        protected virtual void ProcessRequestInfo(TParameter p, TData d)
        {
            var context = p.CurrentHttpContext;

            p.IsNeedSessionAbandon = false;
            p.IsWebSocket          = CurrentContext.WebSockets.IsWebSocketRequest;
            //设置serverinfo
            p[DomainKey.APPLICATION_ENVIRONMENT, "server_servername"] = Environment.MachineName;
            p[DomainKey.APPLICATION_ENVIRONMENT, "serverinfo_ip"]     = CurrentContext.Connection.LocalIpAddress;
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "ServerRootPath", ((IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment))).ContentRootPath);
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "ServerRootPath_URL", $"{context.Request.Scheme}://{context.Request.Host}");
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "WebPath", $"{context.Request.Scheme}://{context.Request.Host}");
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "Domain", p.RequestUri.Host);
            //设置clientinfo
            var ip = CurrentContext.Connection.RemoteIpAddress.ToString();

            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_ip"]             = ip;
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_browserversion"] = CurrentContext.Request.GetBrowserType();
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_platform"]       = CurrentContext.Request.GetBrowserType();
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_userhostname"]   = CurrentContext.Connection.RemoteIpAddress.ToString();

            //设置框架信息
            var fai = FrameAssemblyInfo.From(typeof(ComFunc));

            p[DomainKey.APPLICATION_ENVIRONMENT, "effcinfo_base_version"]         = fai.Version;
            p[DomainKey.APPLICATION_ENVIRONMENT, "effcinfo_base_product_version"] = fai.ProductVersion;

            //解析请求body数据
            context.Request.LoadEFFCParameters <TParameter>(ref p);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理Request中的基本数据信息
        /// </summary>
        /// <param name="p"></param>
        /// <param name="d"></param>
        protected virtual void ProcessRequestInfo(TParameter p, TData d)
        {
            var context = p.CurrentHttpContext;

            p.RequestUri = new Uri($"{context.Request.Scheme}://{context.Request.Host}{context.Request.Path}{context.Request.QueryString}");
            //设置serverinfo
            p[DomainKey.APPLICATION_ENVIRONMENT, "server_servername"] = Environment.MachineName;
            p[DomainKey.APPLICATION_ENVIRONMENT, "serverinfo_ip"]     = CurrentContext.Connection.LocalIpAddress;
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "ServerRootPath", ((IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment))).ContentRootPath);
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "ServerRootPath_URL", $"{context.Request.Scheme}://{context.Request.Host}");
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "WebPath", $"{context.Request.Scheme}://{context.Request.Host}");
            p.SetValue(DomainKey.APPLICATION_ENVIRONMENT, "Domain", p.RequestUri.Host);
            //设置clientinfo
            var ip = CurrentContext.Connection.RemoteIpAddress.ToString();

            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_ip"]             = ip;
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_browserversion"] = CurrentContext.Request.GetBrowserType();
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_platform"]       = CurrentContext.Request.GetBrowserType();
            p[DomainKey.APPLICATION_ENVIRONMENT, "clientinfo_userhostname"]   = CurrentContext.Connection.RemoteIpAddress.ToString();
            p.IsNeedSessionAbandon = false;
            p.IsWebSocket          = CurrentContext.WebSockets.IsWebSocketRequest;

            //设置框架信息
            var fai = FrameAssemblyInfo.From(typeof(ComFunc));

            p[DomainKey.APPLICATION_ENVIRONMENT, "effcinfo_base_version"]         = fai.Version;
            p[DomainKey.APPLICATION_ENVIRONMENT, "effcinfo_base_product_version"] = fai.ProductVersion;
            //抓取请求资源
            var url = p.RequestUri.AbsoluteUri.Replace("\\", "/");

            if (url == "" && url == "/")
            {
                url = Settings.StartPage;
            }

            p.RequestResourcePath = ComFunc.nvl(context.Request.Path);
            var ext = Path.GetExtension(p.RequestResourcePath);

            if (ext != "")
            {
                string   reqpath = Path.GetFileNameWithoutExtension(p.RequestResourcePath);
                string[] ss      = reqpath.Split('.');
                p.Action = ss.Length > 1 ? ss[1] : "";
                p.RequestResourceName = ss.Length > 0 ? ss[0] : "";
                p.RequestResources    = ss;
            }
            else
            {
                var turl = p.RequestResourcePath.Replace("~", "");
                turl = turl.StartsWith("/") ? turl.Substring(1) : turl;
                string[] ss = turl.Split('/');
                p.Action = ss.Length > 1 ? ss[1] : "";
                p.RequestResourceName = ss.Length > 0 ? ss[0] : "";
                p.RequestResources    = ss;
            }

            //解析请求body数据
            context.Request.LoadEFFCParameters <TParameter>(ref p);
        }