private void ProcessTask(OnetimeTask task, int comparison) { if (comparison > 0) { var article = _onetimeService.HideAndCloseSchedule(task.Id); if (article != null && article.Visible) { Logger.Info() .Message( "Article [{id}: {name}] has been hidden on customer code: {customerCode}", article.Id, article.Name, _customer.CustomerName) .Write(); } } if (comparison == 0) { var article = task.EndDateTime.Year == ArticleScheduleConstants.Infinity.Year ? _onetimeService.ShowAndCloseSchedule(task.Id) : _onetimeService.ShowArticle(task.ArticleId); if (article != null && !article.Visible) { Logger.Info() .Message( "Article [{id}: {name}] has been shown on customer code: {customerCode}", article.Id, article.Name, _customer.CustomerName) .Write(); } } }
public void Run(ArticleScheduleTask articleTask) { var task = OnetimeTask.CreateOnetimeTask(articleTask); var currentTime = _onetimeService.GetCurrentDBDateTime(); var comparison = GetTaskRange(task).CompareRangeTo(currentTime); if (ShouldProcessTask(task, currentTime)) { ProcessTask(task, comparison); } }
private static Tuple <DateTime, DateTime> GetTaskRange(OnetimeTask task) => Tuple.Create(task.StartDateTime, task.EndDateTime);
public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck) => ShouldProcessTask(OnetimeTask.CreateOnetimeTask(task), dateTimeToCheck);
public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck, bool forMonitoring = false) { return(ShouldProcessTask(OnetimeTask.CreateOnetimeTask(task), dateTimeToCheck, forMonitoring)); }