Esempio n. 1
0
 private void statusNotify()
 {
     while (true)
     {
         try
         {
             StateHandle      handle        = new StateHandle();
             List <OrderInfo> phoneInfoList = handle.statusNotify(this);
             if (phoneInfoList == null || phoneInfoList.Count <= 0)
             {
                 Thread.Sleep(2000);
             }
             else
             {
                 Thread.Sleep(2000);
             }
         }
         catch (Exception ex)
         {
             View.write(Share.ExceptionToStringForView(ex));
             log.Debug(Share.ExceptionToStringForView(ex));
             Thread.Sleep(1000);//异常时休息
         }
     }
 }
Esempio n. 2
0
 private void submitCharge()
 {
     while (true)
     {
         try
         {
             this.tbxLastRunTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             StateHandle handle    = new StateHandle();
             OrderInfo   phoneInfo = handle.submitOrderService(this);
             if (phoneInfo == null)
             {
                 Thread.Sleep(2000);
             }
             else
             {
                 Thread.Sleep(2000);
             }
         }
         catch (Exception ex)
         {
             View.write(Share.ExceptionToStringForView(ex));
             log.Debug(Share.ExceptionToStringForView(ex));
             Thread.Sleep(2000);//异常时休息
         }
     }
 }
Esempio n. 3
0
 private void submitOrderBtn_Click(object sender, EventArgs e)
 {
     // 当程序要结束时,进行判断当时时的状态
     if (this.submitOrderBtn.Text == submitOrderEnd || this.submitOrderBtn.Text == "结束中")
     {
         if (SubmitChargeThread != null && SubmitChargeThread.IsAlive)
         {
             SubmitChargeThread.Abort();
             SubmitChargeThread = null;
         }
         this.submitOrderBtn.Text = submitOrderStart;
         log.Debug("自动提单程序结束运行");
         View.write("自动提单程序结束运行");
     }
     else
     {
         try
         {
             #region 记录日志
             log.Debug("自动提单程序准备开始");
             View.write("自动提单程序准备开始");
             #endregion
             this.submitOrderBtn.Text = submitOrderEnd;
             timer1.Enabled           = true;
             String cookie = Share.GetCookie(webBrowserLogin.Url.ToString());
             Share.UpdateCookieContainer(cookie, "http://chongzhi.jd.com");
             Share.UpdateCookieContainerOrder(cookie, "http://order.jd.com");
             SubmitChargeThread = new Thread(new ThreadStart(submitCharge));
             SubmitChargeThread.ApartmentState = ApartmentState.STA;
             SubmitChargeThread.Start();
             #region 记录日志
             log.Debug("自动提单程序已经开始自动运行");
             View.write("自动提单程序已经开始自动运行");
             #endregion
         }
         catch (Exception exp)
         {
             log.Error(Share.ExceptionToStringForLog(exp));
             MessageBox.Show(Share.ExceptionToStringForView(exp));
         }
     }
 }
Esempio n. 4
0
 private void statusNotifyBtn_Click(object sender, EventArgs e)
 {
     // 当程序要结束时,进行判断当时时的状态
     if (this.statusNotifyBtn.Text == statusNotifyEnd || this.statusNotifyBtn.Text == "结束中")
     {
         if (statusNotifyThread != null && statusNotifyThread.IsAlive)
         {
             statusNotifyThread.Abort();
             statusNotifyThread = null;
         }
         this.statusNotifyBtn.Text = statusNotifyStart;
         log.Debug("状态通知程序结束运行");
         View.write("状态通知程序结束运行");
     }
     else
     {
         try
         {
             #region 记录日志
             log.Debug("状态通知程序准备开始");
             View.write("状态通知程序准备开始");
             #endregion
             this.statusNotifyBtn.Text         = statusNotifyEnd;
             statusNotifyThread                = new Thread(new ThreadStart(statusNotify));
             statusNotifyThread.ApartmentState = ApartmentState.STA;
             statusNotifyThread.Start();
             #region 记录日志
             log.Debug("状态通知程序已经开始自动运行");
             View.write("状态通知程序已经开始自动运行");
             #endregion
         }
         catch (Exception exp)
         {
             log.Error(Share.ExceptionToStringForLog(exp));
             MessageBox.Show(Share.ExceptionToStringForView(exp));
         }
     }
 }
Esempio n. 5
0
 private void queryOrderStatusBtn_Click(object sender, EventArgs e)
 {
     // 当程序要结束时,进行判断当时时的状态
     if (this.queryOrderStatusBtn.Text == queryOrderStatusEnd || this.queryOrderStatusBtn.Text == "结束中")
     {
         if (queryOrderStatusThread != null && queryOrderStatusThread.IsAlive)
         {
             queryOrderStatusThread.Abort();
             queryOrderStatusThread = null;
         }
         this.queryOrderStatusBtn.Text = queryOrderStatusStart;
         log.Debug("订单查询序结束运行");
         View.write("订单查询程序结束运行");
     }
     else
     {
         try
         {
             #region 记录日志
             log.Debug("订单查询程序准备开始");
             View.write("订单查询程序准备开始");
             #endregion
             this.queryOrderStatusBtn.Text         = queryOrderStatusEnd;
             queryOrderStatusThread                = new Thread(new ThreadStart(queryOrderStatus));
             queryOrderStatusThread.ApartmentState = ApartmentState.STA;
             queryOrderStatusThread.Start();
             #region 记录日志
             log.Debug("订单查询程序已经开始自动运行");
             View.write("订单查询程序已经开始自动运行");
             #endregion
         }
         catch (Exception exp)
         {
             log.Error(Share.ExceptionToStringForLog(exp));
             MessageBox.Show(Share.ExceptionToStringForView(exp));
         }
     }
 }