コード例 #1
0
        private BaseResponse Excute1006(BaseRequest requestData)
        {
            //var res = GeneralFunction.CreateOrder(requestData as NoticeRequest1006);
            var res = requestData;

            if (requestData.SourceID == "10001")
            {
                //var data = res.DicData["OrderNo"];
                var data    = res;
                var resCode = EnumPlatform.EResponseCode.成功受理了请求;
                return(new BaseResponse
                {
                    Code = resCode,
                    Message = resCode.ToString(),
                    Data = data,
                });

                TxtLoger.SavaLogToTXT("成功受理了请求,code", "a");
            }
            else
            {
                var resCode = (EnumPlatform.EResponseCode)Int16.Parse(res.BizCode);
                return(new BaseResponse
                {
                    Code = resCode,
                    Message = resCode.ToString(),
                    Data = null,
                });
            }
        }
コード例 #2
0
        public ActionResult Index()
        {
            BaseRequest baseRequest;
            var         verifyResult = Verify(out baseRequest);

            TxtLoger.SavaLogToTXT(string.Format("请求数据验证结果:编号:{0};信息:{1}", (int)verifyResult.Code, verifyResult.ErrorMessage), "a");
            //loger.Info(string.Format("请求数据验证结果:编号:{0};信息:{1}", (int)verifyResult.Code, verifyResult.ErrorMessage));
            if (verifyResult.IsPass)
            {
                var response = Excute(baseRequest);
                Notice(response, baseRequest.SourceID);
            }
            else
            {
                if (verifyResult.Code != EnumPlatform.EResponseCode.存在此机构)
                {
                    var response = BaseResponse.CreateBaseResponse(verifyResult.Code, verifyResult.ErrorMessage, null);
                    Notice(response, baseRequest.SourceID);

                    TxtLoger.SavaLogToTXT("response 数据为:" + JsonUtils.Serialize(response), "a");
                }
                else
                {
                    TxtLoger.SavaLogToTXT("不存在此机构,verifyResult.Code =" + verifyResult.Code, "a");
                };
            }
            return(View());
        }
コード例 #3
0
        /// <summary>
        /// 在response中写数据
        /// </summary>
        /// <param name="response"></param>
        protected void WriteResponse(string response)
        {
            var myRequestStream = Response.OutputStream;
            var myStreamWriter  = new StreamWriter(myRequestStream);

            myStreamWriter.Write(response);
            myStreamWriter.Close();
            //loger.Debug(string.Format("处理完返回数据(base64编码 + 签名):{0}", response));
            TxtLoger.SavaLogToTXT(string.Format("处理完返回数据(base64编码 + 签名):{0}", response), "a");
        }
コード例 #4
0
        //public ActionResult Index()
        //{
        //    BaseRequest baseRequest;
        //    var verifyResult = Verify(out baseRequest);
        //    //loger.Info(string.Format("请求数据验证结果:编号:{0};信息:{1}", (int)verifyResult.Code, verifyResult.ErrorMessage));
        //    if (verifyResult.IsPass)
        //    {
        //        var response = Excute(baseRequest);
        //        Notice(response, baseRequest.SourceID);
        //    }
        //    else
        //    {
        //        if (verifyResult.Code != EnumPlatform.EResponseCode.不存在此机构)
        //        {
        //            var response = BaseResponse.CreateBaseResponse(verifyResult.Code, verifyResult.ErrorMessage, null);
        //            Notice(response, baseRequest.SourceID);
        //        };
        //    }
        //    ViewBag.aa = baseRequest.SourceID;
        //    ViewBag.bb = baseRequest.BizCode;
        //    //return Json(JsonUtils.Serialize(verifyResult));
        //    //return View(JsonUtils.Serialize(verifyResult));
        //    return View();
        //}
        /// <summary>
        /// 返回数据给第三方
        /// </summary>
        /// <param name="response"></param>
        /// <param name="sourceId"></param>
        private void Notice(BaseResponse response, string sourceId)
        {
            if (sourceId == null)
            {
                sourceId = "10001";
            }
            var responseData = JsonUtils.Serialize(response);
            var signData     = new SignData(sourceId);
            var signstr      = signData.Sign(responseData);
            //loger.Info(string.Format("处理结果数据(base64编码前):{0}", responseData));
            //loger.Info(string.Format("处理结果较验码(base64编码前):{0}", signstr));
            var httpMessage = new HttpMessage
            {
                data     = Base64Utils.EncodeBase64String(responseData),
                signdata = Base64Utils.EncodeBase64String(signstr)
            };

            TxtLoger.SavaLogToTXT("data=" + Base64Utils.EncodeBase64String(responseData) + " ,signdata=" + Base64Utils.EncodeBase64String(signstr), "a");
            //var responseStr = JsonUtils.Serialize(httpMessage);
            //WriteResponse(httpMessage.ToString());
            WriteResponse(JsonUtils.Serialize(httpMessage));
        }