/// <summary> /// 上传名单 /// </summary> /// <returns></returns> public bool Upload() { if (_LocalLogger == null) { _LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); } try { GetAllCardUserInfos(); GetInUsingMacInfoList(); TeacherWhiteListUpload(); StudentWhiteListUpload(); } catch (Exception ex) { Console.WriteLine(getCWStyle(ex.Message, SystemLog.SystemLog.LogType.Error)); return false; } return true; }
static void Main(string[] args) { try { _LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); Console.WriteLine(getCWStyle("账户金额同步服务启动", SystemLog.SystemLog.LogType.Trace)); Console.WriteLine(getCWStyle("开始配置服务", SystemLog.SystemLog.LogType.Trace)); int iRetryTimes;//服务运行失败后重试最大次数 string strRetryTimes = ConfigurationSettings.AppSettings["iRetryTimes"]; bool blnRetryTimes = int.TryParse(strRetryTimes, out iRetryTimes); if (!blnRetryTimes) iRetryTimes = 5; else if (iRetryTimes < 1) iRetryTimes = 5; Console.WriteLine(getCWStyle("配置【失败重试次数】:" + iRetryTimes.ToString() + "次。", SystemLog.SystemLog.LogType.Trace)); int iRetryInterval;//服务运行失败后重试的时间间隔 string strRetryInterval = ConfigurationSettings.AppSettings["iRetryInterval"]; bool blnRetryInterval = int.TryParse(strRetryInterval, out iRetryInterval); if (!blnRetryInterval) iRetryInterval = 5000; else if (iRetryInterval < 1) iRetryInterval = 5000; Console.WriteLine(getCWStyle("配置【失败重试每次时间间隔】:" + iRetryInterval.ToString() + "ms。", SystemLog.SystemLog.LogType.Trace)); UserAccountFundSyncService service = new UserAccountFundSyncService(); service.LocalLogger = _LocalLogger; service.ErrRetryTimes = iRetryTimes; service.ErrRetryInterval = iRetryInterval; bool blnRes = service.AccountSync(); if (blnRes) Console.WriteLine(getCWStyle("账户金额同步成功", SystemLog.SystemLog.LogType.Trace)); else { Console.WriteLine(getCWStyle("账户金额同步失败", SystemLog.SystemLog.LogType.Trace)); Console.WriteLine(getCWStyle("准备进行失败重试", SystemLog.SystemLog.LogType.Trace)); } int iRetryIdx = 1; while (iRetryIdx <= iRetryTimes && !blnRes) { Console.WriteLine(getCWStyle("重试第 " + iRetryIdx.ToString() + " 次", SystemLog.SystemLog.LogType.Trace)); blnRes = service.AccountSync(); if (blnRes) Console.WriteLine(getCWStyle("成功", SystemLog.SystemLog.LogType.Trace)); else Console.WriteLine(getCWStyle("失败", SystemLog.SystemLog.LogType.Trace)); iRetryIdx++; Thread.Sleep(iRetryInterval); } Console.WriteLine(getCWStyle("账户金额同步服务完毕", SystemLog.SystemLog.LogType.Trace)); //Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(getCWStyle(ex.Message, SystemLog.SystemLog.LogType.Error)); } }
/// <summary> /// 日志记录器初始化 /// </summary> private void InitLogger() { this._LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); this._DBLogger = new Common.General(Common.General.BindDbLogInfo()); }
public CollectionService() { InitializeComponent(); this._ServiceName = ConfigurationSettings.AppSettings["ServiceName"]; if (string.IsNullOrEmpty(this._ServiceName)) { this._ServiceName = "ServRecordCollect"; } this._ServiceName.PadRight(20, ' ').Substring(0, 20).Trim(); this._LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); this._DBLogger = new Common.General(Common.General.BindDbLogInfo()); this._tmrSycnTime = new System.Timers.Timer(); this._tmrSycnTime.Interval = 10000; this._tmrSycnTime.Elapsed += new ElapsedEventHandler(_tmrSycnTime_Elapsed); //this._ListMealTimeSpan = new List<MealTimeSpanInfo>(); this._LocalLogger.WriteLog("服务初始化完毕。", string.Empty, SystemLog.SystemLog.LogType.Trace); }
/// <summary> /// 收集操作 /// </summary> /// <returns></returns> public bool Collect() { if (_LocalLogger == null) { _LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); } try { CollectRecord(); } catch (Exception ex) { Console.WriteLine(getCWStyle(ex.Message, SystemLog.SystemLog.LogType.Error)); return false; } return true; }
/// <summary> /// 上传名单 /// </summary> /// <returns></returns> public bool Upload() { if (_LocalLogger == null) { _LocalLogger = new Common.General(Common.General.BindLocalLogInfo()); } try { DateTime dtBegin = DateTime.Now.Date; DateTime dtEnd = DateTime.Now.Date.AddHours(2); if (dtBegin <= DateTime.Now && DateTime.Now <= dtEnd) { SendContinuedBalckList(); } else { MealListUpload(); } } catch (Exception ex) { Console.WriteLine(getCWStyle(ex.Message, SystemLog.SystemLog.LogType.Error)); return false; } return true; }