예제 #1
0
        protected virtual UPPBase OnExecutingBefore(UPPBase _Req, UPPBiz _Biz)
        {
            if (_UPPCONFIG == null)
            {
                throw new ArgumentNullException("UPPClient配置错误,未获取到");
            }
            //校验入参
            _Req.AppId = _Req.AppId.IsNullOrEmptyOfVar() ? _UPPCONFIG.AppId : _Req.AppId;
            _Req.AppId.IsNullOrEmptyOfVar("AppId");
            _Req.Kind.IsNullOrEmptyOfVar("Kind");
            _Req.Mode.IsNullOrEmptyOfVar("Mode");
            _Req.ReqTime = _Req.ReqTime.IsNullOrEmptyOfVar() ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : _Req.ReqTime;
            _Req.Random  = _Req.Random.IsNullOrEmptyOfVar() ? GuidKind.N.BuildRandom() : _Req.Random;

            if (_Biz == null)
            {
                throw new ArgumentNullException("UPPClient业务参数为null");
            }

            //填充业务参数
            _Req.Args = _Biz.ToJson().UrlDecode();

            //加签
            _Req.Sign = _Req.EntityToKeyValue(_UPPCONFIG.Key).BuildCipher("", CipherKind.MD5);
            _Req.Args = _Biz.ToJson();
            LogModule.Info("UPPClient->UPP:入参:" + _Req.EntityToKeyValue(false));
            return(_Req);
        }
예제 #2
0
        public virtual UPPBase OnExcuting(UPPBase _Req, UPPBiz _Biz, MethodKind _MKind = MethodKind.POST, int httpTimeOut = 5)
        {
            _Req = OnExecutingBefore(_Req, _Biz);
            UPPBase res = null;
            var     Url = "UPPUrl".ConfigValue();

            if (!Url.IsNullOrEmptyOfVar())
            {
                _UPPCONFIG.Url = Url;
            }
            if (_MKind == MethodKind.GET)
            {
                res = (_UPPCONFIG.Url + "/" + _Req.Kind + "?" + _Req.EntityToKeyValue(false)).Get().ToEntity <UPPBase>();
            }

            if (_MKind == MethodKind.POST)
            {
                res = (_UPPCONFIG.Url + "/" + _Req.Kind).Post(_Req.EntityToKeyValue(false), timeout: httpTimeOut).ToEntity <UPPBase>();
            }

            res = OnExecutingAfter(res);
            //补充添加APPCODE
            res.AppId = _Req.AppId;
            //返回
            return(res);
        }
예제 #3
0
        protected virtual UPPBase OnExecutingAfter(UPPBase _Res)
        {
            LogModule.Info("UPPClient->UPP:出参:" + _Res.EntityToKeyValue(false));
            //异常返回不再验签
            if (_Res.ResCode == "1001")
            {
                throw new Exception(_Res.ResMsg);
            }

            //验签
            if (_Res.Sign != _Res.EntityToKeyValue(_UPPCONFIG.Key).BuildCipher("", CipherKind.MD5))
            {
                throw new Exception("UPPClient签名验证失败");
            }

            return(_Res);
        }