Exemplo n.º 1
0
        /// <summary>
        ///     放款回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btn_grantNotify_Click(object sender, EventArgs e)
        {
            try
            {
                this.lblmsg4.Text            = "正在消耗,请稍等......";
                this.btn_grantNotify.Enabled = false;
                BrokeredMessage brokeredMessage;
                this.txb_GrantNotifySnums.Text = "0";
                this.txb_GrantNotifyFnums.Text = "0";
                do
                {
                    brokeredMessage = this.messageReceiverGrant.Receive();
                    if (brokeredMessage != null)
                    {
                        string  batchBookCreditInfos = brokeredMessage.GetBody <string>();
                        JObject jObject = JObject.Parse(batchBookCreditInfos);
                        if (jObject == null)
                        {
                            continue;
                        }
                        //转json
                        ConfirmAdvanceDebtRequest confirmAdvanceDebtRequest = jObject["data"].ToString().FromJson <ConfirmAdvanceDebtRequest>();
                        //重试5次执行数据
                        for (int i = 0; i < 5; i++)
                        {
                            bool result = await YemApiService.ConfirmAdvanceDebt(this.loadAppSettings.YemApiUrl, confirmAdvanceDebtRequest, "ConfirmAdvanceDebtLogs");

                            if (result)
                            {
                                this.UpdateTxtInfos(this.txb_GrantNotifySnums);
                                break;
                            }
                            else
                            {
                                if (i == 4)
                                {
                                    this.UpdateTxtInfos(this.txb_GrantNotifyFnums);
                                    //记录下来数据
                                    Logger.LoadData(@"ConfirmAdvanceDebtInfos\ErrorDeadLineInfos.txt", confirmAdvanceDebtRequest.ToJson());
                                    Logger.LoadData(@"ConfirmAdvanceDebtInfos\ErrorDeadLineInfos.txt", "\r\n");
                                }
                            }
                        }
                    }
                } while (brokeredMessage != null);
                this.btn_grantNotify.Enabled = true;
                MessageBox.Show("本轮次执行完毕");
            }
            catch (Exception exception)
            {
                this.lblmsg4.Text            = "发生一个错误" + exception.Message;
                this.btn_grantNotify.Enabled = true;
                Logger.LoadData(@"ConfirmAdvanceDebtInfos\Errors.txt", exception.Message);
            }
        }
Exemplo n.º 2
0
        //确认放款成功
        public static async Task <bool> ConfirmAdvanceDebt(string url, ConfirmAdvanceDebtRequest request, string logFolderName)
        {
            HttpResponseMessage httpResponseMesage = new HttpResponseMessage();

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

                ResultResponse <string> response = await httpResponseMesage.Content.ReadAsAsync <ResultResponse <string> >();

                if (response.IsTrue)
                {
                    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);
            }
        }