/// <summary>
        /// 实际消息发送
        /// </summary>
        /// <param name="strUrl"></param>
        /// <param name="strInfo"></param>
        /// <param name="strMsgInfo"></param>
        /// <param name="nTimeOut"></param>
        /// <returns></returns>
        private static HttpSendResult SendMsgToServer(string strUrl, string strInfo, string strMsgInfo, int nTimeOut)
        {
            try
            {
                HttpSendResult result      = new HttpSendResult();
                string         strResponse = (string)FKHttp.FKHttpClient.POST(strUrl, strInfo, null, nTimeOut);

                bool   bSuccess         = false;
                string strErrorMsg      = "";
                int    nID              = 0;
                string strNewResponse   = "";
                int    nStatus          = 0;
                string strJavaPublicKey = "";

                // 解析Respone
                ParserResponseMsg(strResponse, out strNewResponse, out bSuccess, out strErrorMsg, out nID, out nStatus, out strJavaPublicKey);

                result.RequestType = strMsgInfo;
                result.ServerUrl   = strUrl;
                result.RequestMsg  = strInfo;
                result.ResponseMsg = strNewResponse;
                result.bSuccess    = bSuccess;
                result.ErrorMsg    = strErrorMsg;
                result.NodeID      = nID;
                result.ErrorStatus = nStatus;
                result.publicKey   = strJavaPublicKey;

                if (bSuccess)
                {
                    // 记录日志
                    LOGGER.DEBUG($"Send http msg type = {strMsgInfo}: \n-\nRequest = {strInfo} \n-\nResponse = {strNewResponse}");
                }
                else
                {
                    LOGGER.ERROR($"Send http msg type = {strMsgInfo}: \n-\nRequest = {strInfo} \n-\nResponse = {strNewResponse} \n-\nStatus = {nStatus} , Error = {strErrorMsg}");
                }

                return(result);
            }
            catch (Exception e)
            {
                LOGGER.ERROR($"Send http request msg to server failed. Error = {e.ToString()}");
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// 从Node中解析一条流水
        /// </summary>
        /// <param name="node"></param>
        /// <param name="billItem"></param>
        private bool ParseOneBillHtmlPage(HtmlNode node, ref SBillTaskResult.SBankBillInfo billItem)
        {
            try
            {
                // 交易卡号全是 --
                string accountNumber = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[2]").InnerHtml).Trim();
                billItem.accountNumber = accountNumber;
                // 日期
                string date = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[3]").InnerHtml).Trim();
                billItem.submitTime = GetTradeTime(date);
                // 支出
                string outMoney = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[4]").InnerHtml).Trim();

                // 收入
                string inMoney = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[5]").InnerHtml).Trim();

                if (outMoney == "--" && inMoney == "--")
                {
                    return(false);
                }
                if (outMoney != "--")
                {
                    billItem.amount = "-" + outMoney;
                }
                else if (inMoney != "--")
                {
                    billItem.amount = inMoney;
                }
                // 余额
                string balance = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[6]").InnerHtml).Trim();

                if (balance == "--")
                {
                    return(false);
                }
                billItem.balance = balance;
                // 对方 格式 ==>招商银行 尾号3085 李欢<==
                string info = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[7]").InnerHtml).Trim();


                // 受理机构 具体银行
                string bank = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[8]").InnerHtml).Trim();
                billItem.accountBankName = bank;
                var infoArr = info.Split(' ');
                if (infoArr.Length >= 1)
                {
                    if (bank == "--")
                    {
                        billItem.accountBankName = infoArr[0];
                    }
                }
                if (infoArr.Length >= 2)
                {
                    if (accountNumber == "--")
                    {
                        billItem.accountNumber = infoArr[1];
                    }
                }
                if (infoArr.Length >= 3)
                {
                    billItem.accountName = infoArr[2];
                }
                // 摘要 客户填写的附言
                string summary = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[9]").InnerHtml).Trim();
                billItem.additionalComment = summary;

                // 状态 ==>完成<==
                string status = System.Net.WebUtility.HtmlDecode(node.SelectSingleNode("./td[10]").InnerHtml).Trim();
                billItem.digest = info + " " + status;
            }
            catch (Exception e)
            {
                LOGGER.WARN($"Parser CITIC one bill failed. Error = {e.ToString()}");
                return(false);
            }

            LOGGER.DEBUG($"Get one bill, info = {billItem.ToString()}");
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 从Node中解析一条流水
        /// </summary>
        /// <param name="node"></param>
        /// <param name="billItem"></param>
        private bool ParseOneBillHtmlPage(HtmlNode node, ref SBillTaskResult.SBankBillInfo billItem)
        {
            try
            {
                billItem.submitTime = GetTradeTime(node.SelectSingleNode("./td[2]").InnerHtml.Trim());

                if (string.IsNullOrEmpty(billItem.submitTime))
                {
                    LOGGER.ERROR("交易时间为空");
                    return(false);
                }
                // 支出cny
                string outMoney = GetTradeAmount(node.SelectSingleNode("./td[3]").InnerHtml.Trim());
                // 收入cny
                string inMoney = GetTradeAmount(node.SelectSingleNode("./td[4]").InnerHtml.Trim());

                if (string.IsNullOrEmpty(inMoney) && string.IsNullOrEmpty(outMoney))
                {
                    LOGGER.ERROR("收入支出项同时为空");
                    return(false);
                }
                if (string.IsNullOrEmpty(outMoney) && !string.IsNullOrEmpty(inMoney))
                {
                    //billItem.amount = Double.Parse(inMoney);
                    billItem.amount = (inMoney);
                }
                else if (string.IsNullOrEmpty(inMoney) && !string.IsNullOrEmpty(outMoney))
                {
                    //billItem.amount = -Double.Parse(outMoney);
                    billItem.amount = "-" + (outMoney);
                }
                else
                {
                    LOGGER.INFO($"进出账同时为空[{inMoney}][{outMoney}]");
                    return(false);
                }
                // 余额cny
                string balance = GetTradeAmount(node.SelectSingleNode("./td[5]").InnerHtml.Trim());

                //billItem.balance = Double.Parse(balance);
                billItem.balance = (balance);
                // 对方账号
                billItem.accountNumber = GetBankCardNumber(node.SelectSingleNode("./script").InnerHtml.Trim());

                // 对方用户名
                billItem.accountName = GetUserName(node.SelectSingleNode("./td[6]").InnerHtml.Trim());

                // 币种
                string currency = GetCurrency(node.SelectSingleNode("./td[7]").InnerHtml.Trim());

                billItem.currency = TransformCurrencyTypeFromString(currency);

                // 摘要
                string summary = GetTradeSummary(node.SelectSingleNode("./td[8]").InnerHtml.Trim());
                billItem.digest = summary;
                // 交易类型
                billItem.tradeType = TransformTradeTypeFromSummary(summary, billItem.amount);

                // 附言
                billItem.additionalComment = GetAdditionalComment(node.SelectSingleNode("./td[9]").InnerHtml.Trim());
            }
            catch (Exception e)
            {
                LOGGER.WARN($"Parser CCB one bill failed. Error = {e.ToString()}");
                return(false);
            }

            LOGGER.DEBUG($"Get one bill, info = {billItem.ToString()}");
            return(true);
        }