示例#1
0
        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();
                }
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 private static Tuple <DateTime, DateTime> GetTaskRange(OnetimeTask task) => Tuple.Create(task.StartDateTime, task.EndDateTime);
示例#4
0
 public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck) => ShouldProcessTask(OnetimeTask.CreateOnetimeTask(task), dateTimeToCheck);
示例#5
0
 public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck, bool forMonitoring = false)
 {
     return(ShouldProcessTask(OnetimeTask.CreateOnetimeTask(task), dateTimeToCheck, forMonitoring));
 }