예제 #1
0
        /// <summary>
        /// 根据请求参数 返回结果
        /// </summary>
        /// <param name="parmaKeyDict"></param>
        /// <returns></returns>
        private DataResult GetResult(ExHashTable parmaKeyDict)
        {
            //记录日志
            StringBuilder sbLog      = new StringBuilder();
            ExHashTable   retKeyDict = new ExHashTable();

            try
            {
                //检测
                Utils.PayCheckData((string)parmaKeyDict.Get("ThirdLogNo"), (string)parmaKeyDict.Get("CounterId"));
                //获取请求报文
                BankInterface msg = new BankInterface();
                //调用函数生成请求的而完整报文
                List <string> messageList     = msg.GetBankEnterpriseMessageReq(parmaKeyDict, this.IsSpecialLine);
                var           pinganPayConfig = GlobalData.LoadPinganConfig();
                string        reqMessage      = string.Join("", (pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.TeleProtocol == "01" ? messageList.ToArray() : messageList.GetRange(1, 2).ToArray()));
                sbLog.AppendFormat("时间:{0}\r\n", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                sbLog.AppendFormat("请求:{0}\r\n", reqMessage);
                //发送请求报文  //获取银行返回报文
                string recvMessage = msg.SendMessage(reqMessage, pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.TeleProtocol);
                sbLog.AppendFormat("响应:{0}\r\n", recvMessage);
                //解析返回结果
                retKeyDict = msg.ParsingBankEnterpriseMessageString(recvMessage);
                sbLog.AppendFormat("解析结果:\r\n{0}\r\n", retKeyDict.ToString());
            }
            catch (Exception ex)
            {
                sbLog.AppendFormat("异常信息:{0}\r\n", ex.Message);
                throw ex;
            }
            finally
            {
                //写入日志
                if (GlobalData.LoadPinganConfig().OpenLog)
                {
                    FileHelper.SaveFile(string.Format("Log\\Req\\ReqData_{0}.txt", System.DateTime.Now.ToString("yyyyMMdd")), sbLog.ToString() + "\r\n\r\n");
                }
            }
            //转换
            return(Utils.ToDataResult(retKeyDict, GlobalData.DirectErpBankVersion));
        }
예제 #2
0
        /// <summary>
        /// 根据请求参数 返回结果
        /// </summary>
        /// <param name="parmaKeyDict"></param>
        /// <returns></returns>
        private DataResult GetResult(ExHashTable parmaKeyDict)
        {
            //记录日志
            StringBuilder sbLog      = new StringBuilder();
            ExHashTable   retKeyDict = new ExHashTable();

            try
            {
                //检测
                Utils.PayCheckData((string)parmaKeyDict.Get("ThirdLogNo"), (string)parmaKeyDict.Get("CounterId"));
                //获取请求报文
                BankInterface msg = new BankInterface();
                //调用函数生成请求的而完整报文
                string reqMessage = msg.GetTranMessageReq(parmaKeyDict, this.IsSpecialLine);
                sbLog.AppendFormat("时间:{0}\r\n", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                sbLog.AppendFormat("请求:{0}\r\n", reqMessage);
                //发送请求报文  //获取银行返回报文
                string recvMessage = msg.SendMessage(reqMessage);
                sbLog.AppendFormat("响应:{0}\r\n", recvMessage);
                //解析返回结果
                retKeyDict = msg.ParsingTranMessageString(recvMessage);
                sbLog.AppendFormat("解析结果:\r\n{0}\r\n", retKeyDict.ToString());
            }
            catch (Exception ex)
            {
                sbLog.AppendFormat("异常信息:{0}\r\n", ex.Message);
                throw ex;
            }
            finally
            {
                //写入日志
                if (GlobalData.LoadPinganConfig().OpenLog)
                {
                    FileHelper.SaveFile(string.Format("Log\\Req\\ReqData_{0}.txt", System.DateTime.Now.ToString("yyyyMMdd")), sbLog.ToString() + "\r\n\r\n");
                }
            }
            //转换
            return(Utils.ToDataResult(retKeyDict, GlobalData.B2BSpotVersion));
        }
예제 #3
0
        public void MyMainMethod()
        {
            //设置银行客户端端地址和端口
            //string ServerIPAddress = "127.0.0.1";
            //int ServerPort = 7072;//默认端口

            //定义报文参数字典
            ExHashTable parmaKeyDict = new ExHashTable(); //用于存放生成请求报文的参数
            ExHashTable retKeyDict   = new ExHashTable(); //用于存放

            /**
             * 第一部分:生成发送银行的请求的报文的实例
             *
             */

            //生成随机数: 当前精确到秒的时间再加6位的数字随机序列
            string rdNum      = System.DateTime.Now.ToString("yyyyMMddHHmmss");//设置日期格式
            Random random     = new Random();
            int    ird        = random.Next(0, 999999);
            string srd        = ird.ToString().PadLeft(6, '0');
            string thirdLogNo = rdNum + srd;

            //报文参数赋值
            parmaKeyDict.Add("TranFunc", "1330");             //交易码,此处以【1320】接口为例子 1330
            parmaKeyDict.Add("Qydm", "00102079900001231000"); //8545

            parmaKeyDict.Add("ThirdLogNo", thirdLogNo);       //请求流水号,特别重要
            parmaKeyDict.Add("FuncFlag", "1");                //1:签到 2:签退
            parmaKeyDict.Add("TxDate", "20151125");
            parmaKeyDict.Add("Reserve", "保留域");

            //获取请求报文
            BankInterface msg         = new BankInterface();
            string        tranMessage = msg.GetTranMessageReq(parmaKeyDict);//调用函数生成报文

            //输出报文结果
            Console.Write("[输出报文结果]:" + tranMessage);
            // FileHelper.SaveFile("out.txt", tranMessage + "\r\n");

            /**
             * 第二部分:获取银行返回的报文的实例
             *
             */
            //发送请求报文  //获取银行返回报文
            string recvMessage = msg.SendMessage(tranMessage);

            //输出报文结果
            Console.Write("第二部分:获取银行返回的报文");
            Console.Write(recvMessage);
            Console.Write("-------------------------------");

            /**
             * 第三部分:解析银行返回的报文的实例
             *
             */
            retKeyDict = msg.ParsingTranMessageString(recvMessage);
            string rspCode    = (string)retKeyDict.Get("RspCode");    //银行返回的应答码
            string rspMsg     = (string)retKeyDict.Get("RspMsg");     //银行返回的应答描述
            string bodyMsg    = (string)retKeyDict.Get("BodyMsg");
            string frontLogNo = (string)retKeyDict.Get("FrontLogNo"); //银行返回的前置流水号

            //输出报文结果
            Console.Write("第三部分:解析银行返回的报文");
            Console.Write("返回应答码:");
            Console.Write(rspCode);
            Console.Write("返回应答码描述:");
            Console.Write(rspMsg);
            Console.Write("返回报文体:");
            Console.Write(bodyMsg);
            Console.Write("返回前置流水号:");
            Console.Write(frontLogNo);
            Console.Write("-------------------------------");

            Console.ReadLine();
        }