Beispiel #1
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest()
        {
            HttpContext context = HttpContext.Current;

            try
            {
                //参数解析
                var action = context.Request.QueryString["action"];
                //var reqContent = context.Request["req"];
                //获取华安响应表单对象
                HanAnMessage message = new HanAnMessage();
                message.verNum  = context.Request.Form["verNum"];
                message.sysdate = context.Request.Form["sysdate"];
                message.systime = context.Request.Form["systime"];
                message.txcode  = context.Request.Form["txcode"];
                message.seqNO   = context.Request.Form["seqNO"];
                message.maccode = context.Request.Form["maccode"];
                message.content = context.Request.Form["content"];
                //AES解密
                //message.content = Utility.AESDecrypt(context.Request.Form["content"], HuaAnConst.AesKey);
                AreaContent = message.content;
                #region 插入日志信息
                Loggers.DEFAULT.Debug(new DebugLogInfo()
                {
                    Message = message.content
                });
                #endregion

                ////分流逻辑处理
                //var rsp = this.ProcessAction(strAPIType, action, message);
            }
            catch (APIException ex)
            {
                Loggers.DEFAULT.Exception(new ExceptionLogInfo(ex));
                ErrorResponse rsp = new ErrorResponse(ex.ErrorCode, ex.Message);
                this.DoResponse(context, rsp.ToJSON());
            }
            catch (ThreadAbortException) { }    //Response.End通过抛出ThreadAbortException异常来实现中止执行后续代码的功能
            catch (Exception ex)
            {
                Loggers.DEFAULT.Exception(new ExceptionLogInfo(ex));
                ErrorResponse rsp = new ErrorResponse(ERROR_CODES.DEFAULT_ERROR, ex.Message);
                this.DoResponse(context, rsp.ToJSON());
            }
        }
        /// <summary>
        /// 获取华安接口中:每万份收益、年化收益率(5002)
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        private void GetProfit()
        {
            DateTime dt = DateTime.Now;

            string seqNO = HuaAnFactory.GenerateSeqNO();

            //处理调用华安请求From表单对象
            //ReceiveProfitSelectMessage entity = AssignmentProfit(dt);  //查询年化收益率
            // ReceivePaySingleQueryMessage entity = AssignmentSingleQuery(dt);  //3001
            ReceiveFundProfitMessage entity = Assignment5000(dt);   //500
            string strContent            = Utility.GetRequsetXml(entity);
            HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, 5001, seqNO);

            IDictionary <string, string> dic = HuaAnFactory.SetFormPara(rMessage);
            HttpWebResponse webResponse      = HttpHelper.CreatePostHttpResponse(HuaAnConfigurationAppSitting.ReservationServletUrl, dic, null, null, Encoding.UTF8, null);
            string          content          = HttpHelper.GetResponseString(webResponse);

            Hashtable    htComm = GetCommonreturn(content);
            HanAnMessage msg    = new HanAnMessage
            {
                verNum  = htComm["verNum"].ToString(),
                sysdate = htComm["sysdate"].ToString(),
                systime = htComm["systime"].ToString(),
                txcode  = htComm["txcode"].ToString(),
                seqNO   = htComm["seqNO"].ToString(),
                maccode = htComm["maccode"].ToString(),
                content = htComm["content"].ToString()
            };


            if (msg != null)
            {
                string decrypt = Utility.AESDecrypt(msg.content, HuaAnConfigurationAppSitting.AesKey);
                SendFundProfitMessage profitMsg = GetProfitMsg(decrypt);
                string[] profitN = profitMsg.Content.Split('\n');
                foreach (var item in profitN)
                {
                    string   profit      = item;
                    string[] profitArray = profit.Split('|');
                }
                //   string[] profit = profitMsg.Content.Split('|');
            }

            Model = rMessage;
        }
Beispiel #3
0
 /// <summary>
 /// 赎回回调处理。
 /// </summary>
 /// <returns></returns>
 private string Ransom(HanAnMessage message)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 /// <summary>
 /// 过户。
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 private string Transfer(HanAnMessage message)
 {
     throw new NotImplementedException();
 }
        public void ProcessRequest(HttpContext context)
        {
            Loggers.DEFAULT.Debug(new DebugLogInfo {
                Message = "华安RetUrl回调Handler."
            });
            try
            {
                HttpContext httpContext = context;
                //参数解析
                var action = httpContext.Request.QueryString["action"];
                if (string.IsNullOrEmpty(action))
                {
                    Loggers.DEFAULT.Debug(new DebugLogInfo {
                        Message = "Action is empty, skip process."
                    });
                    return;
                }

                //获取华安响应表单对象
                var message = new HanAnMessage
                {
                    verNum  = httpContext.Request.Form["verNum"],
                    sysdate = httpContext.Request.Form["sysdate"],
                    systime = httpContext.Request.Form["systime"],
                    txcode  = httpContext.Request.Form["txcode"],
                    seqNO   = httpContext.Request.Form["seqNO"],
                    maccode = httpContext.Request.Form["maccode"],
                    content = httpContext.Request.Form["content"]
                };
#if (DEBUG)
                Loggers.DEFAULT.Debug(new DebugLogInfo {
                    Message = "RetUrl表单交易代码:" + message.txcode
                });
                Loggers.DEFAULT.Debug(new DebugLogInfo {
                    Message = "RetUrl表单内容:" + message.content
                });
#endif

                //AES解密
                string content = Utility.AESDecrypt(message.content, HuaAnConfigurationAppSitting.AesKey);
                message.content = content;

                #region 插入日志信息

                Loggers.DEFAULT.Debug(new DebugLogInfo {
                    Message = "RetUrl message:" + message.ToJSON()
                });
                #endregion

                // 启动工作线程
                string[] data = { action, content };
                ThreadPool.QueueUserWorkItem(o =>
                {
                    var d = o as string[];
                    if (d == null)
                    {
                        Loggers.DEFAULT.Debug(new DebugLogInfo {
                            Message = "RetUrl callback: 无效的参数"
                        });
                        return;
                    }

                    var act = d[0];
                    var con = d[1];
#if (DEBUG)
                    Loggers.DEFAULT.Debug(new DebugLogInfo {
                        Message = "启动RetUrl callback线程."
                    });
#endif
                    try
                    {
                        // 等待30秒,确保前端的PageUrl回调已经结束。
                        Thread.Sleep(30000);
                        // 验证回调是否执行过
                        if (Common.Verify(act, con))
                        {
                            return;
                        }

                        switch (action)
                        {
                        case "BuyCallBack":     //基金购买。
                            Common.BuyCallBack(content);
                            break;

                        case "RansomCallBack":     //赎回。
                            Common.RansomCallBack(content);
                            break;

                        case "TransferCallBack":     //用号
                            Common.TransferCallBack(content);
                            break;

                        default:
                            Loggers.DEFAULT.Debug(new DebugLogInfo {
                                Message = string.Format("未实现Action名为{0}的处理.", action)
                            });
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Loggers.DEFAULT.Exception(new ExceptionLogInfo {
                            ErrorMessage = "RetCallback action process异常:" + ex.Message
                        });
                    }
                }, data);

                httpContext.Response.Write(DateTime.Now + ": RetCallbackHandler ok.");
                httpContext.Response.End();
            }
            catch (Exception ex)
            {
                Loggers.DEFAULT.Exception(new ExceptionLogInfo {
                    ErrorMessage = "RetCallbackHandler异常:" + ex.Message
                });
            }
        }
        public void ProcessRequest(HttpContext pContext)
        {
            Loggers.DEFAULT.Debug(new DebugLogInfo {
                Message = "华安PageUrl回调Handler."
            });
            try
            {
                HttpContext httpContext = pContext;
                //参数解析
                var action = httpContext.Request.QueryString["action"];
                if (string.IsNullOrEmpty(action))
                {
                    return;
                }
                //获取华安响应表单对象
                var message = new HanAnMessage
                {
                    verNum  = httpContext.Request.Form["verNum"],
                    sysdate = httpContext.Request.Form["sysdate"],
                    systime = httpContext.Request.Form["systime"],
                    txcode  = httpContext.Request.Form["txcode"],
                    seqNO   = httpContext.Request.Form["seqNO"],
                    maccode = httpContext.Request.Form["maccode"],
                    content = httpContext.Request.Form["content"]
                };
                //AES解密
                string content = Utility.AESDecrypt(message.content, HuaAnConfigurationAppSitting.AesKey);
                message.content = content;

                #region 插入日志信息

                Loggers.DEFAULT.Debug(new DebugLogInfo {
                    Message = message.ToJSON()
                });
                #endregion

                //验证回调是否执行过
                if (Common.Verify(action, content))
                {
                    return;
                }
                switch (action)
                {
                case "BuyCallBack":      //基金购买。
                    Common.BuyCallBack(content);
                    break;

                case "RansomCallBack":      //赎回。
                    Common.RansomCallBack(content);
                    break;

                case "TransferCallBack":      //用号
                    Common.TransferCallBack(content);
                    break;

                default:
                    throw new APIException(string.Format("未实现Action名为{0}的处理.", action))
                          {
                              ErrorCode = 201
                          };
                }
            }
            catch (Exception ex)
            {
                Loggers.DEFAULT.Exception(new ExceptionLogInfo {
                    ErrorMessage = ex.Message
                });
            }
        }