/// <summary> /// 更新任务 /// </summary> private DateTime HandleUpdateTask(DateTime suggestEarlistUpdateTime, int nOprationType, string strBankCode) { if (DateTime.Compare(suggestEarlistUpdateTime, DateTime.Now) > 0) { // 还没到预期的刷新时间,什么都不做 return(suggestEarlistUpdateTime); } if (nOprationType == 1) { int nBankType = MainForm.GetBillBankTypeIDByName(strBankCode); // 之前负责的是流水查询任务 switch (nBankType) { case 1: // 建设银行 CCB_AutoBill.Update(); return(suggestEarlistUpdateTime.AddSeconds(CCB_AutoBill.GetUpdateIdleSecond())); case 2: // 交通银行 BCM_AutoBill.Update(); return(suggestEarlistUpdateTime.AddSeconds(BCM_AutoBill.GetUpdateIdleSecond())); case 3: // 招商银行 CMB_AutoBill.Update(); return(suggestEarlistUpdateTime.AddSeconds(CMB_AutoBill.GetUpdateIdleSecond())); case 4: // 招商银行 ABC_AutoBill.Update(); return(suggestEarlistUpdateTime.AddSeconds(ABC_AutoBill.GetUpdateIdleSecond())); case 5: // 中信银行 CITIC_AutoBill.Update(); return(suggestEarlistUpdateTime.AddSeconds(CITIC_AutoBill.GetUpdateIdleSecond())); } } if (nOprationType == 2) { int nBankType = MainForm.GetOutBankTypeIDByName(strBankCode); switch (nBankType) { case 1: // 民生银行 CMBC_AutoOut.Update(); return(suggestEarlistUpdateTime.AddSeconds(CMBC_AutoOut.GetUpdateIdleSecond())); } } return(DateTime.Now); }
/// <summary> /// 实际自动处理一次自动出款 /// </summary> /// <param name="info"></param> /// <param name="result"></param> /// <returns></returns> private bool AutomationOut(SOutTaskInfo info, ref SOutTaskResult result) { // 检查是否支持该银行 int nBankTypeID = GetOutBankTypeIDByName(info.fromBankCode); if (nBankTypeID <= 0) { result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_UnsupportBankCode; return(false); } // 先进行清理 // 为保持长期登录状态,现不进行清理 - added by Frankie.W 2017-07-19 //{ // FKWebAutomatic.FKWebDriver.GetInstance.FKClose(); // ForceShutdownIE(); // Thread.Sleep(1000); //} DateTime startTime = DateTime.Now; bool bSuccessed = false; BankAutoOutBase imp = null; try { switch (nBankTypeID) { case 1: imp = new CMBC_AutoOut(); break; default: break; } if (imp == null) { LOGGER.ERROR($"Auto out failed."); result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_UnknownError; bSuccessed = false; } else { imp.Init(); bSuccessed = imp.AutoDo(info.taskID, info, ref result); imp.Clear(); } } catch (Exception e) { LOGGER.ERROR($"Auto do error occured. Error = {e.ToString()}"); bSuccessed = false; } DateTime endTime = DateTime.Now; TimeSpan span = endTime - startTime; if (!bSuccessed) { LOGGER.ERROR($"Auto do failed."); // 执行失败 result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_AutoProcessFailed; } // 无论成功与否,都要进行清理 // 为保持长期登录状态,现不进行清理 - added by Frankie.W 2017-07-19 //{ // FKWebAutomatic.FKWebDriver.GetInstance.FKClose(); // ForceShutdownIE(); //} // 并记录到日志时间数据库,以便日志查询 FKLog.FKSQLiteLogMgr.GetInstance.AddTaskTimeLog(info.taskID, DateTime.Now); return(bSuccessed); }