예제 #1
0
        public static bool isSign(respTengModel model)
        {
            var data = TengDepository.Order <respTengModel>(model);
            //拼接签名
            StringBuilder sb = new StringBuilder();

            foreach (var item in data)
            {
                if (item.Key != "sign" && item.Key != "backState")
                {
                    sb.AppendFormat("{0}={1}&", item.Key, item.Value);
                }
            }

            string str = sb.ToString().Trim('&');

            return(ITOrm.Utility.Encryption.SecurityHelper.GetMD5String($"{str}&key={TengDepository.respMd5Key}").ToUpper() == model.sign);
        }
예제 #2
0
        /// <summary>
        /// 公共方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="requestId"></param>
        /// <param name="action"></param>
        /// <param name="json"></param>
        /// <param name="logPath"></param>
        /// <returns></returns>
        public static T PostUrl <T>(int requestId, string action, JObject data, string logPath)
        {
            try
            {
                bool   flag   = false;
                string result = string.Empty;

                //拼接签名
                StringBuilder sb      = new StringBuilder();
                var           reqData = JObject.FromObject(data["EncryptionData"]);
                foreach (var item in reqData)
                {
                    sb.AppendFormat("{0}={1}&", item.Key, item.Value);
                }
                string str = sb.ToString().Trim('&');

                string sign = ITOrm.Utility.Encryption.SecurityHelper.GetMD5String($"{str}&key={reqMd5Key}").ToUpper();
                str = $"{str}&sign={sign}";
                data["EncryptionData"]["sign"] = sign;
                //请求前日志记录
                Logs.WriteLog("提交参数:" + data.ToString(), TengLogDic, logPath);
                yeepayLogParasDao.Init(requestId, data.ToString(), 0);


                //执行请求
                int responseState = ITOrm.Utility.Client.HttpHelper.HttpPost(TengDomain + action, str, Encoding.UTF8, out result);
                if (responseState != 200)
                {
                    result = $"{{\"respCode\":\"{responseState}\", \"respMsg\":\"{result}\"}}";
                }
                //返回后日志记录
                Logs.WriteLog("返回参数:" + result, TengLogDic, logPath);
                yeepayLogParasDao.Init(requestId, result, 1);
                //易宝日志状态更新
                respTengModel resp = JsonConvert.DeserializeObject <respTengModel>(result);
                flag = yeepayLogDao.UpdateState(requestId, resp.respCode, resp.respMsg, resp.backState == 0 ? 1 : resp.backState);
                Logs.WriteLog($"易宝日志状态更新:requestId:{requestId},respCode:{resp.respCode},respMsg:{ resp.respMsg},State:{flag}", TengDomain, logPath);
                return(JsonConvert.DeserializeObject <T>(result));
            }
            catch (Exception e)
            {
                return(JsonConvert.DeserializeObject <T>($"{{\"respCode\":\"-1000\", \"respMsg\":\"{e.Message}\"}}"));
            }
        }