示例#1
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;
            //    }

            //}
        }
        protected override ParameterStd ConvertParameters(object[] obj)
        {
            var fea = FrameExposedArray.From(obj);
            var rtn = new EWRAParameter();

            rtn.CurrentHttpContext = fea.defaulthttpcontext.value;
            return(rtn);
        }
        protected override ParameterStd ConvertParameters(object[] obj)
        {
            var rtn = new EWRAParameter();

            if (obj.Length > 0 && (obj[0] is EWRAParameter))
            {
                rtn = (EWRAParameter)obj[0];
            }
            return(rtn);
        }
        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;
            }
        }
        /// <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);
            }
        }
        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);
            }
        }
        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"]);
        }
        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);
                }
            }
        }
示例#9
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);
            }
        }
 protected override void InvokeAction(EWRAParameter p, EWRAData d)
 {
     base.InvokeAction(p, d);
 }
示例#11
0
 protected virtual bool DoValid(EWRAParameter ep, EWRAData ed)
 {
     return(true);
 }
示例#12
0
        /// <summary>
        /// 进行校验,判定校验是否有效
        /// </summary>
        /// <returns></returns>
        public bool IsValid(EWRAParameter ep, EWRAData ed)
        {
            var rtn = DoValid(ep, ed);

            return(rtn);
        }