public void Execute(IJobExecutionContext context) { #if DEBUG DateTime benchTime = DateTime.Now.AddYears(-1); #else JobDataMap data = context.JobDetail.JobDataMap; var interval = data.ContainsKey("intervalofmins") ? data.GetInt("intervalofmins") : 1; if (!data.ContainsKey("benchtime")) { data.Put("benchtime", DateTime.Now.AddMinutes(-interval)); } else { data["benchtime"] = data.GetDateTimeValue("benchtime").AddMinutes(interval); } var benchTime = data.GetDateTime("benchtime"); #endif ILog logger = LogManager.GetLogger(this.GetType()); ExecuteResult executeInfo = null; var analytic = ActionTimer.Perform(() => { var productSyncExecutor = new OrderSyncExecutor(benchTime, logger); executeInfo = productSyncExecutor.Execute(); }); if (executeInfo.Status != ExecuteStatus.Succeed) { foreach (var msg in executeInfo.MessageList) { logger.Error(msg); } } else { logger.Info(string.Format("Sync order succeed : {0}, failed :{1}, total: {2}, elapsed:{3}, ratio: {4}", executeInfo.SucceedCount, executeInfo.FailedCount, executeInfo.TotalCount, analytic.TotalSeconds, executeInfo.SucceedCount/analytic.TotalSeconds)); } }
protected override void Do() { var benchTime = DateTime.Now.AddDays(-10); ExecuteResult executeInfo = null; var productSyncExecutor = new OrderSyncExecutor(benchTime, Logger); executeInfo = productSyncExecutor.Execute(); if (executeInfo.Status != ExecuteStatus.Succeed) { foreach (var msg in executeInfo.MessageList) { Logger.Error(msg); } } else { this.Execute(benchTime); Console.WriteLine("Sync orders {0}, failed {1}, error {2}", executeInfo.SucceedCount, executeInfo.FailedCount, executeInfo.TotalCount); } }