Beispiel #1
0
        /// <summary>
        ///     放款通知银行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btn_GrantBank_Click(object sender, EventArgs e)
        {
            try
            {
                this.lblshwMsg3.Text       = "正在执行.......";
                this.btn_GrantBank.Enabled = false;
                BrokeredMessage brokeredMessage;
                this.txb__GrantBankSNums.Text = "0";
                this.txb_GrantBankFnums.Text  = "0";
                do
                {
                    brokeredMessage = this.messageReceiverAdvanceDebt.Receive();
                    if (brokeredMessage != null)
                    {
                        string  batchBookCreditInfos = brokeredMessage.GetBody <string>();
                        JObject jObject = JObject.Parse(batchBookCreditInfos);
                        if (jObject == null)
                        {
                            continue;
                        }
                        //转json
                        AdvanceDebtRequest advanceDebtRequest = jObject["MessageData"].ToString().FromJson <AdvanceDebtRequest>();
                        //重试5次执行数据
                        for (int i = 0; i < 5; i++)
                        {
                            bool result = await YemApiService.SendAdvanceDebt(this.loadAppSettings.AssetApiUrl, advanceDebtRequest, "SendAdvanceDebtLogs");

                            if (result)
                            {
                                this.UpdateTxtInfos(this.txb__GrantBankSNums);
                                break;
                            }
                            else
                            {
                                if (i == 4)
                                {
                                    this.UpdateTxtInfos(this.txb_GrantBankFnums);
                                    //记录下来数据
                                    Logger.LoadData(@"SendAdvanceDebtInfos\ErrorDeadLineInfos.txt", advanceDebtRequest.ToJson());
                                    Logger.LoadData(@"SendAdvanceDebtInfos\ErrorDeadLineInfos.txt", "\r\n");
                                }
                            }
                        }
                    }
                } while (brokeredMessage != null);
                this.btn_GrantBank.Enabled = true;
                MessageBox.Show("本轮次执行完毕");
            }
            catch (Exception exception)
            {
                this.lblshwMsg3.Text       = "发生一个错误" + exception.Message;
                this.btn_GrantBank.Enabled = true;
                Logger.LoadData(@"SendAdvanceDebtInfos\Errors.txt", exception.Message);
            }
        }
Beispiel #2
0
        //调用放款
        public static async Task <bool> SendAdvanceDebt(string url, AdvanceDebtRequest request, string logFolderName)
        {
            HttpResponseMessage httpResponseMesage = new HttpResponseMessage();

            try
            {
                //DebtForBank/SendAdvanceDebt
                httpResponseMesage = await InitialHttpClient().PostAsJsonAsync($"{url}DebtForBank/SendAdvanceDebt", request);

                CommonResult <bool> response = await httpResponseMesage.Content.ReadAsAsync <CommonResult <bool> >();

                if (response.Result)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                //log记录日志
                Logger.LoadData(Path.Combine(logFolderName, "Error.txt"), ex.Message + "---------" + await httpResponseMesage.Content.ReadAsStringAsync() + "----" + request.ToJson());
                return(false);
            }
        }