예제 #1
0
        /// <summary>
        /// Handler
        /// </summary>
        public void Handler()
        {
            ///SRM交易记录单次传输最大行数
            string srmTranOutDataMaxRows = new ConfigBLL().GetValueByCode("SRM_TRAN_OUT_DATA_MAX_ROWS");

            ///默认为1000行
            if (!int.TryParse(srmTranOutDataMaxRows, out int maxRows))
            {
                maxRows = 1000;
            }
            ///SRM交易记录单次传输最小行数
            string srmTranOutDataMinRows = new ConfigBLL().GetValueByCode("SRM_TRAN_OUT_DATA_MIN_ROWS");

            ///默认为1000行
            if (!int.TryParse(srmTranOutDataMinRows, out int minRows))
            {
                minRows = 20;
            }
            ///未处理数据条件
            string untreatedDataCondition = "[LOG_FID] is NULL and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + " ";
            ///
            int dataCnt = minRows + 1;

            while (dataCnt > minRows)
            {
                ///获取数据,TODO:考虑修改为只获取主键以提高程序执行效率
                List <SrmTranOutInfo> srmTranOutInfos = new SrmTranOutBLL().GetListByPage(untreatedDataCondition, "[ID]", 1, maxRows, out dataCnt);
                if (dataCnt == 0)
                {
                    break;
                }
                Guid logFid = Guid.NewGuid();
                ///生成发送任务
                string sql = BLL.LES.CommonBLL.GetCreateOutboundLogSql("SRM", logFid, "LES-SRM-008", string.Empty, loginUser);
                sql += "update [LES].[TI_IFM_SRM_TRAN_OUT] "
                       + "set [LOG_FID] = N'" + logFid + "',[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE() "
                       + "where [ID] in (" + string.Join(",", srmTranOutInfos.Select(d => d.Id).ToArray()) + ");";
                using (var trans = new TransactionScope())
                {
                    BLL.SYS.CommonBLL.ExecuteNonQueryBySql(sql);
                    trans.Complete();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 发送
        /// </summary>
        /// <param name="logFid"></param>
        /// <param name="interfaceConfigInfo"></param>
        /// <param name="errorCode"></param>
        /// <param name="errorMsg"></param>
        /// <param name="msgContent"></param>
        /// <returns></returns>
        public static ExecuteResultConstants Send(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent)
        {
            msgContent = string.Empty;
            List <SrmTranOutInfo> srmTranOutInfos = new SrmTranOutBLL().GetList("" +
                                                                                "[LOG_FID] = N'" + logFid + "' and " +
                                                                                "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty);

            if (srmTranOutInfos.Count == 0)
            {
                errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认
                return(ExecuteResultConstants.Exception);
            }
            ///发送内容
            List <BFDATranOutInfo> list = new List <BFDATranOutInfo>();

            foreach (var srmTranOutInfo in srmTranOutInfos)
            {
                list.Add(GetSrmTranOutInfo(srmTranOutInfo));
            }
            BFDASRMSendDataInfo <BFDATranOutInfo> sendDataInfo = new BFDASRMSendDataInfo <BFDATranOutInfo>();

            sendDataInfo.List = list;
            ///
            InboundService_pttClient client = new InboundService_pttClient();

            client.Endpoint.Address = new EndpointAddress(interfaceConfigInfo.CallUrl);
            ///数据发送
            msgContent = new XmlWrapper().ObjectToXmlByEncoding(sendDataInfo, Encoding.UTF8, false);
            msgContent = msgContent.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
            string result = client.InboundService(msgContent, out errorCode, out errorMsg);

            if (result == Convert.ToString((int)OutboundReturnStateConstants.FAILURE))
            {
                return(ExecuteResultConstants.Error);
            }
            return(ExecuteResultConstants.Success);
        }