Beispiel #1
0
        /// <summary>
        /// 京广快递专用的加密方式
        /// </summary>
        /// <param name="FuncName"></param>
        /// <param name="JsonText"></param>
        /// <returns></returns>
        public static NameValueCollection GetNameValueCollection(Model.Mode.DataMode.PostMode R)
        {
            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("FunctionName", R.FunctionName);
            nvc.Add("JsonData", R.JsonData);
            nvc.Add("CusID", R.CusID);
            nvc.Add("KeyMd5", HttpHelper.GetMD5Hash(R.JsonData + R.Key));
            return(nvc);
        }
Beispiel #2
0
        /// <summary>
        /// 检查Post数据准确性
        /// </summary>
        public static DataMode.AllCheckReturn CheckPostData(HttpRequestBase Request, Type NowType, string FunctionName, string JsonData, string CusID, string KeyMd5)
        {
            DataMode.AllCheckReturn CheckReturn = new DataMode.AllCheckReturn();
            CheckReturn.State = false;
            var _RetObject = new Model.GeneralReturns();

            _RetObject.State   = true;
            _RetObject.MsgText = string.Empty;
            string CusKey = InsertData.SaveClientInfo(GetIp(Request), FunctionName, CusID, KeyMd5);

            if (CusKey == string.Empty)
            {
                _RetObject.State   = false;
                _RetObject.MsgText = "错误的CusID";
            }
            else
            {
                if (HttpHelper.GetMD5Hash(JsonData + CusKey) != KeyMd5)
                {
                    _RetObject.State   = false;
                    _RetObject.MsgText = "Key验证错误";
                }
                else
                {
                    JsonData = HttpUtility.UrlDecode(JsonData, Encoding.UTF8);
                    JsonData = UniDecode(JsonData);
                    string str = System.Text.RegularExpressions.Regex.Replace(JsonData, @"\\s*|\t|\r|\n|\\", "");
                    var    Obj = HttpHelper.JsonToObject(str, NowType);
                    if (HttpHelper.JsonErrorText != string.Empty)
                    {
                        _RetObject.State   = false;
                        _RetObject.MsgText = "错误的Json格式数据[" + HttpHelper.JsonErrorText + "]";
                    }
                    else
                    {
                        CheckReturn.State      = true;
                        CheckReturn.JsonObject = Obj;
                    }
                }
            }
            CheckReturn.ReturnMode = _RetObject;
            return(CheckReturn);
        }