public void Customize(string parent, INode node, IDictionary <string, string> parameters, ILogger logger)
        {
            if (parent != "schedule")
            {
                return;
            }

            IAttribute cronAttr;

            if (!node.TryAttribute("cron", out cronAttr))
            {
                return;
            }

            var value = cronAttr.Value.ToString();

            if (value == string.Empty)
            {
                logger.Error("A cron attribute can't be empty.");
            }

            try {
                var expression = new global::Quartz.CronExpression(value);
                var date       = expression.GetNextValidTimeAfter(new DateTimeOffset(DateTime.UtcNow));
                if (date == null)
                {
                    logger.Error($"The expression {value} is invalid.");
                }
            } catch (Exception ex) {
                logger.Error($"The expression {value} is invalid. {ex.Message}");
            }
        }
Example #2
0
        public void Validate(string name, string value, IDictionary <string, string> parameters, ILogger logger)
        {
            if (value == null)
            {
                logger.Error("A null value was passed into the CronExpressionValidator");
            }

            if (value == string.Empty)
            {
                return;
            }

            try {
                var expression = new global::Quartz.CronExpression(value);
                var date       = expression.GetNextValidTimeAfter(new DateTimeOffset(DateTime.UtcNow));
                if (date == null)
                {
                    logger.Error($"The expression {value} is invalid.");
                }
            } catch (Exception ex) {
                logger.Error($"The expression {value} is invalid. {ex.Message}");
            }
        }