Ejemplo n.º 1
0
        /// <summary>
        ///     批量债转回调消耗
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btn_batchCreditNotify_Click(object sender, EventArgs e)
        {
            try
            {
                this.lbl2.Text = "正在消耗.......";
                this.btn_batchCreditNotify.Enabled = false;
                BrokeredMessage brokeredMessage;
                this.txb_BatchCreditNotifyFnums.Text = "0";
                this.txb_BatchCreditNotifySnums.Text = "0";
                do
                {
                    brokeredMessage = this.messageReceiverBatchCredit.Receive();
                    if (brokeredMessage != null)
                    {
                        string  batchBookCreditInfos = brokeredMessage.GetBody <string>();
                        JObject jObject = JObject.Parse(batchBookCreditInfos);
                        if (jObject == null)
                        {
                            continue;
                        }
                        //转json
                        NotifyBatchCreditRequest notifyBatchCreditRequest = jObject["data"].ToString().FromJson <NotifyBatchCreditRequest>();
                        //重试5次执行数据
                        for (int i = 0; i < 5; i++)
                        {
                            bool result = await YemApiService.ConfirmDebt(this.loadAppSettings.YemApiUrl, notifyBatchCreditRequest, "BatchCreditNotifyLogs");

                            if (result)
                            {
                                this.UpdateTxtInfos(this.txb_BatchCreditNotifySnums);
                                break;
                            }
                            else
                            {
                                if (i == 4)
                                {
                                    this.UpdateTxtInfos(this.txb_BatchCreditNotifyFnums);
                                    //记录下来数据
                                    Logger.LoadData(@"BatchCreditNotifyInfos\ErrorDeadLineInfos.txt", notifyBatchCreditRequest.ToJson());
                                    Logger.LoadData(@"BatchCreditNotifyInfos\ErrorDeadLineInfos.txt", "\r\n");
                                }
                            }
                        }
                    }
                } while (brokeredMessage != null);
                this.btn_batchCreditNotify.Enabled = true;
                MessageBox.Show("本轮次执行完毕");
            }
            catch (Exception exception)
            {
                this.lbl2.Text = "发生一个错误" + exception.Message;
                this.btn_batchCreditNotify.Enabled = true;
                Logger.LoadData(@"BatchCreditNotifyInfos\Errors.txt", exception.Message + "----------" + exception.StackTrace);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     债转确认消息
        /// </summary>
        /// <param name="url"></param>
        /// <param name="request"></param>
        /// <param name="logFolderName"></param>
        /// <returns></returns>
        public static async Task <bool> ConfirmDebt(string url, NotifyBatchCreditRequest request, string logFolderName)
        {
            //MessageFromBank/ConfirmDebt
            HttpResponseMessage httpResponseMesage = new HttpResponseMessage();

            try
            {
                //DebtForBank/SendAdvanceDebt
                httpResponseMesage = await InitialHttpClient().PostAsJsonAsync($"{url}MessageFromBank/ConfirmDebt", 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);
            }
        }