public void Start( Button StartButton //图片自动删除 , TextBox tbxImggeSuccess , TextBox tbxImggeFail //自动审核 , TextBox tbxAuditSuccess , TextBox tbxAuditFail //自动设置费率 , TextBox tbxSetRateSuccess , TextBox tbxSetRateFail //自动结算 , TextBox tbxWithDrawApiSuccess , TextBox tbxWithDrawApiFail //定时任务 , TextBox tbxTimedTaskSuccess , TextBox tbxTimedTaskFail //资金队列 , TextBox tbxAccountQueueSuccess , TextBox tbxAccountQueueFail //结算检查 , TextBox tbxWithDrawSuccess , TextBox tbxWithDrawFail //开始时间 , TextBox StartTime ) { _StartButton = StartButton; //图片自动删除 _tbxImggeSuccess = tbxImggeSuccess; _tbxImggeFail = tbxImggeFail; //自动审核 _tbxAuditSuccess = tbxAuditSuccess; _tbxAuditFail = tbxAuditFail; //自动设置费率 _tbxSetRateSuccess = tbxSetRateSuccess; _tbxSetRateFail = tbxSetRateFail; //自动结算 _tbxWithDrawApiSuccess = tbxWithDrawApiSuccess; _tbxWithDrawApiFail = tbxWithDrawApiFail; //定时任务 _tbxTimedTaskSuccess = tbxTimedTaskSuccess; _tbxTimedTaskFail = tbxTimedTaskFail; //资金队列 _tbxAccountQueueSuccess = tbxAccountQueueSuccess; _tbxAccountQueueFail = tbxAccountQueueFail; //结算检查 _tbxWithDrawSuccess = tbxWithDrawSuccess; _tbxWithDrawFail = tbxWithDrawFail; //开始时间 _StartTime = StartTime; _StartTime.Text = DateTime.Now.ToString(); switch (runState) { case RunNing.已暂停: runState = RunNing.运行中; _StartButton.Text = "运行中……(可暂停)"; if (_Thread == null) { _Thread = new Thread(new ThreadStart(Run)); _Thread.IsBackground = true; _Thread.Start(); } break; case RunNing.运行中: runState = RunNing.暂停等待中; _StartButton.Text = RunNing.暂停等待中.ToString(); _StartButton.Enabled = false; break; case RunNing.运行等待中: _Thread.Abort(); break; case RunNing.暂停等待中: break; } }
private void Run() { Log objL = new Log(); try { while (runState == RunNing.运行中) { //处理图片 UserImageHandle(); //处理审核 AuditHandle(); //处理费率 SetFeeHandle(); //结算 WithDrawApiHandle(); //定时任务 TimedTaskHandle(); //资金队列 AccountQueueHandle(); //结算检查 WithDrawHandle(); Thread.Sleep(1000); if (runState == RunNing.暂停等待中) { this.runState = RunNing.已暂停; _StartButton.Text = "开始"; _StartButton.Enabled = true; break; } runState = RunNing.运行等待中; int i = ConfigInfo.BatchWaitMilliSecond; while (i > 0 && runState == RunNing.运行等待中) { _StartButton.Text = "运行等待中……" + i / 1000 + "秒(可暂停)"; Thread.Sleep(1000); i = i - 1000; } runState = RunNing.运行中; _StartButton.Text = "运行中……(可暂停)"; _StartButton.Enabled = true; } } catch (ThreadAbortException) { runState = RunNing.已暂停; _StartButton.Text = "开始"; } catch (Exception e) { objL.fLog(e.ToString()); string[] ss = ConfigInfo.GetMobile.Split(','); foreach (var s in ss) { //发送短信 var resultMsg = SystemSendMsg.Send(Logic.EnumSendMsg.自动处理程序出错, s); SendMsg model = new SendMsg(); model.TypeId = (int)Logic.EnumSendMsg.自动处理程序出错; model.Context = resultMsg.content; model.CTime = DateTime.Now; model.IP = ITOrm.Utility.Client.Ip.GetClientIp(); model.Merchant = resultMsg.Merchant; model.Mobile = s; model.Platform = (int)Logic.Platform.系统; model.Service = "sys_auto"; model.RelationId = resultMsg.relationId; model.State = resultMsg.backState ? 2 : 1; model.UTime = DateTime.Now; int result = sendMsgDao.Insert(model); //SMShelper.SendMsg(s, ConfigInfo.merchantCode + "存管自动处理程序异常停止!"); } runState = RunNing.已暂停; _StartButton.Text = "开始"; } finally { _Thread = null; } }