Exemplo n.º 1
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码


           


            worker.ReportProgress(3, "开始导入支付记录...\r\n");
            //导入代理商
            AgentInvoicePaymentDao agentInvoicePaymentDao = new AgentInvoicePaymentDao();
            AgentDao agentDao = new AgentDao();
            WechatAction wechatAction = new WechatAction();
            for (int i = 0; i < dgInvoicePayment.RowCount; i++)
            {
                AgentInvoicePayment agentInvoicePayment = new AgentInvoicePayment();
                agentInvoicePayment.agentNo = dgInvoicePayment[0, i].Value.ToString();
                agentInvoicePayment.agentName = dgInvoicePayment[1, i].Value.ToString();
                agentInvoicePayment.processTime = dgInvoicePayment[2, i].Value.ToString();
                agentInvoicePayment.invoiceFee = dgInvoicePayment[3, i].Value.ToString();
                agentInvoicePayment.payFee = dgInvoicePayment[4, i].Value.ToString();
                agentInvoicePayment.summary = dgInvoicePayment[5, i].Value.ToString();
                agentInvoicePayment.payStatus = dgInvoicePayment[6, i].Value.ToString();
                Agent agent = agentDao.Get(agentInvoicePayment.agentNo);
                 if (agent != null && !String.IsNullOrEmpty(agent.agentName))
                 {
                     agentInvoicePaymentDao.Delete(agentInvoicePayment);
                     agentInvoicePaymentDao.Add(agentInvoicePayment);
                     dgInvoicePayment["result", i].Value = "导入成功";
                     String message = String.Format(Settings.Default.InvoicePayment_Wechat_Message, agentInvoicePayment.processTime, agentInvoicePayment.invoiceFee, agentInvoicePayment.payFee, agentInvoicePayment.summary, agentInvoicePayment.payStatus);
                     wechatAction.sendTextMessageToWechat(agentInvoicePayment.agentNo, message, Settings.Default.Wechat_Secret, Settings.Default.Wechar_Invoice_AppId);

                 }
                 else
                 {
                     dgInvoicePayment["result", i].Value = "导入失败,代理商编号:" + agentInvoicePayment.agentNo + "不存在,请先导入代理商.";
                 }

            }
            worker.ReportProgress(4, "导入支付记录完成...\r\n");



            //MessageBox.Show("数据上传完毕");

        }