コード例 #1
0
        /// <summary>
        /// 呼叫本地logic
        /// </summary>
        /// <param name="url">请求的路由,格式:/xxxx/yyyy</param>
        /// <param name="method">请求的method,post,get,patch等</param>
        /// <param name="header">额外附加的header信息</param>
        /// <param name="query_string">额外附加的query_string信息</param>
        /// <param name="post_data">额外附加的post_data信息</param>
        /// <returns></returns>
        public object CallLocalLogic(string url, string method, FrameDLRObject header = null, FrameDLRObject query_string = null, FrameDLRObject post_data = null)
        {
            object obj = new EWRAData();
            var    dp  = CallContext_Parameter.DeepCopy <EWRAParameter>();

            dp.RequestUri         = new Uri(ServerInfo.SiteHostUrl + url);
            dp.RequestRoute       = url;
            dp.RestResourcesArray = url.Split('/');
            dp.MethodName         = method;

            if (header != null)
            {
                foreach (var item in header.Items)
                {
                    dp.SetValue(DomainKey.HEADER, item.Key, item.Value);
                }
            }
            if (query_string != null)
            {
                foreach (var item in query_string.Items)
                {
                    dp.SetValue(DomainKey.QUERY_STRING, item.Key, item.Value);
                }
            }
            if (post_data != null)
            {
                foreach (var item in post_data.Items)
                {
                    dp.SetValue(DomainKey.POST_DATA, item.Key, item.Value);
                }
            }

            GlobalCommon.Proxys["busi"].CallModule(ref obj, new object[] { dp });
            return(((EWRAData)obj).Result);
        }
コード例 #2
0
        protected override void DoProcess(EWRAParameter p, EWRAData d)
        {
            base.DoProcess(p, d);
            //if (d.ContentType == EFFC.Frame.Net.Module.Extend.EWRA.Constants.RestContentType.HTML)
            //{
            //    SetCacheEnable(false);
            //    var tagp = new TagParameter();
            //    object tagd = new TagData();
            //    tagp.RootPath = MyConfig.GetConfiguration("View", "Template_Path");
            //    var viewpath = ComFunc.nvl(d.ExtentionObj.viewpath).Replace("~", tagp.RootPath);

            //    if (File.Exists(viewpath))
            //    {
            //        FrameDLRObject bindobject = FrameDLRObject.CreateInstance(d.Result, FrameDLRFlags.SensitiveCase);
            //        foreach (var item in bindobject.Items)
            //        {
            //            ((TagData)tagd).Context.AddBindObject(item.Key, item.Value);
            //        }
            //        tagp.Text = File.ReadAllText(viewpath);
            //        GlobalCommon.Proxys["tag"].CallModule(ref tagd, tagp);
            //        d.Result = ((TagData)tagd).ParsedText;
            //        d.StatusCode = EFFC.Frame.Net.Module.Extend.EWRA.Constants.RestStatusCode.OK;
            //    }
            //    else
            //    {
            //        d.StatusCode = EFFC.Frame.Net.Module.Extend.EWRA.Constants.RestStatusCode.NOT_FOUND;
            //    }

            //}
        }
コード例 #3
0
        protected override void DoProcess(EWRAParameter p, EWRAData d)
        {
            var validattr = d.InvokeMethod.GetCustomAttributes <EWRAValidAttribute>(true);
            var errormsg  = "校验不通过";

            if (IsValid(p, d, ref errormsg, validattr.ToArray()))
            {
                base.DoProcess(p, d);
            }
            else
            {
                d.StatusCode = RestStatusCode.INVALID_REQUEST;

                d.Error = errormsg;
            }
        }
コード例 #4
0
        /// <summary>
        /// 方法执行之前的校验操作,如果所有的校验都通过则为true,否则为false
        /// 特别说明:无属性时则不做任何校验,返回true
        /// </summary>
        /// <param name="p"></param>
        /// <param name="d"></param>
        /// <param name="errormsg"></param>
        /// <param name="validAttributes"></param>
        /// <returns></returns>
        protected virtual bool IsValid(EWRAParameter p, EWRAData d, ref string errormsg, params EWRAValidAttribute[] validAttributes)
        {
            if (validAttributes == null)
            {
                return(true);
            }
            else
            {
                foreach (var a in validAttributes)
                {
                    if (!a.IsValid(p, d))
                    {
                        errormsg = a.ErrorMsg;
                        return(false);
                    }
                }

                return(true);
            }
        }
コード例 #5
0
        protected override bool DoValid(EWRAParameter ep, EWRAData ed)
        {
            if (fields == null)
            {
                return(true);
            }
            else
            {
                foreach (var f in fields)
                {
                    var v = ep[DomainKey.POST_DATA, f];
                    v = v == null ? ep[DomainKey.QUERY_STRING, f] : v;
                    if (v == null || ComFunc.nvl(v) == "")
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
コード例 #6
0
        protected override void ProcessRequestInfo(EWRAParameter p, EWRAData d)
        {
            base.ProcessRequestInfo(p, d);
            //微信相关信息
            p.ExtentionObj.weixin                     = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase);
            p.ExtentionObj.weixin.signature           = ComFunc.nvl(p[DomainKey.QUERY_STRING, "signature"]);
            p.ExtentionObj.weixin.timestamp           = ComFunc.nvl(p[DomainKey.QUERY_STRING, "timestamp"]);
            p.ExtentionObj.weixin.nonce               = ComFunc.nvl(p[DomainKey.QUERY_STRING, "nonce"]);
            p.ExtentionObj.weixin.token               = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_token"]);
            p.ExtentionObj.weixin.encrypt_type        = ComFunc.nvl(p[DomainKey.QUERY_STRING, "encrypt_type"]);
            p.ExtentionObj.weixin.encrypt_key         = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_encry_key"]);
            p.ExtentionObj.weixin.appid               = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_Appid"]);
            p.ExtentionObj.weixin.appsecret           = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_Appsecret"]);
            p.ExtentionObj.weixin.weixin_mch_ssl_path = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_Mch_SSL_Path"]);
            p.ExtentionObj.weixin.weixin_mch_ssl_pass = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_Mch_SSL_Pass"]);
            p.ExtentionObj.weixin.agentid             = ComFunc.nvl(p[DomainKey.CONFIG, "weixin_AgentId"]);

            p.ExtentionObj.weixinmp                       = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase);
            p.ExtentionObj.weixinmp.appid                 = ComFunc.nvl(p[DomainKey.CONFIG, "weixinmp_Appid"]);
            p.ExtentionObj.weixinmp.appsecret             = ComFunc.nvl(p[DomainKey.CONFIG, "weixinmp_Appsecret"]);
            p.ExtentionObj.weixinmp.weixinmp_mch_ssl_path = ComFunc.nvl(p[DomainKey.CONFIG, "weixinmp_Mch_SSL_Path"]);
            p.ExtentionObj.weixinmp.weixinmp_mch_ssl_pass = ComFunc.nvl(p[DomainKey.CONFIG, "weixinmp_Mch_SSL_Pass"]);
        }
コード例 #7
0
        protected override void LoadConfig(EWRAParameter p, EWRAData d)
        {
            base.LoadConfig(p, d);
            bool bvalue = true;

            foreach (var item in MyConfig.GetConfigurationList("Weixin"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }
            foreach (var item in MyConfig.GetConfigurationList("WeixinMP"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }
        }
コード例 #8
0
        protected override bool DoValid(EWRAParameter ep, EWRAData ed)
        {
            if (fields == null)
            {
                return(true);
            }
            else
            {
                foreach (var f in fields)
                {
                    var ispostdata    = ep.ContainsKey(DomainKey.POST_DATA, f);
                    var isquerystring = ep.ContainsKey(DomainKey.QUERY_STRING, f);
                    var v             = ComFunc.nvl(ep[DomainKey.POST_DATA, f]);
                    v = v == "" ? ComFunc.nvl(ep[DomainKey.QUERY_STRING, f]) : v;
                    if (is_check_empty_error)
                    {
                        if (!IntStd.IsInt(v))
                        {
                            return(false);
                        }
                        else
                        {
                            if (is_convert)
                            {
                                if (ispostdata)
                                {
                                    ep[DomainKey.POST_DATA, f] = int.Parse(v);
                                }
                                if (isquerystring)
                                {
                                    ep[DomainKey.QUERY_STRING, f] = int.Parse(v);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (v != "" && !IntStd.IsInt(v))
                        {
                            return(false);
                        }
                        else
                        {
                            if (v != "")
                            {
                                if (is_convert)
                                {
                                    if (ispostdata)
                                    {
                                        ep[DomainKey.POST_DATA, f] = int.Parse(v);
                                    }
                                    if (isquerystring)
                                    {
                                        ep[DomainKey.QUERY_STRING, f] = int.Parse(v);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }
        }
コード例 #9
0
 protected override void InvokeAction(EWRAParameter p, EWRAData d)
 {
     base.InvokeAction(p, d);
 }
コード例 #10
0
 protected virtual bool DoValid(EWRAParameter ep, EWRAData ed)
 {
     return(true);
 }
コード例 #11
0
        /// <summary>
        /// 进行校验,判定校验是否有效
        /// </summary>
        /// <returns></returns>
        public bool IsValid(EWRAParameter ep, EWRAData ed)
        {
            var rtn = DoValid(ep, ed);

            return(rtn);
        }