Beispiel #1
0
        private CronTrigger(string expression, DateTime?expiration = null, DateTime?effective = null)
        {
            try
            {
                _expression = Cronos.CronExpression.Parse(expression, Cronos.CronFormat.IncludeSeconds);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"The specified '{expression}' is an illegal Cron expression.", ex);
            }

            this.Expression     = _expression.ToString();
            this.ExpirationTime = expiration;
            this.EffectiveTime  = effective;
        }
Beispiel #2
0
        private CronTrigger(string expression, DateTime?expiration = null, DateTime?effective = null, string description = null)
        {
            if (string.IsNullOrWhiteSpace(expression))
            {
                throw new ArgumentNullException(nameof(expression));
            }

            try
            {
                _expression = Cronos.CronExpression.Parse(expression, Cronos.CronFormat.IncludeSeconds);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"The specified '{expression}' is an illegal cron expression.", ex);
            }

            this.Expression     = _expression.ToString();
            this.EffectiveTime  = effective.HasValue && effective.Value.ToUniversalTime() <= DateTime.UtcNow ? null : effective;
            this.ExpirationTime = expiration.HasValue && expiration.Value.ToUniversalTime() <= DateTime.UtcNow ? DateTime.MinValue : expiration;
            this.Description    = description;
        }