Cron Expression Parser
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description = string.Empty;

            try
            {
                if (!m_parsed)
                {
                    ExpressionParser parser = new ExpressionParser(m_expression, m_options);
                    m_expressionParts = parser.Parse();
                    m_parsed = true;
                }

                switch (type)
                {
                    case DescriptionTypeEnum.FULL:
                        description = GetFullDescription();
                        break;
                    case DescriptionTypeEnum.TIMEOFDAY:
                        description = GetTimeOfDayDescription();
                        break;
                    case DescriptionTypeEnum.HOURS:
                        description = GetHoursDescription();
                        break;
                    case DescriptionTypeEnum.MINUTES:
                        description = GetMinutesDescription();
                        break;
                    case DescriptionTypeEnum.SECONDS:
                        description = GetSecondsDescription();
                        break;
                    case DescriptionTypeEnum.DAYOFMONTH:
                        description = GetDayOfMonthDescription();
                        break;
                    case DescriptionTypeEnum.MONTH:
                        description = GetMonthDescription();
                        break;
                    case DescriptionTypeEnum.DAYOFWEEK:
                        description = GetDayOfWeekDescription();
                        break;
                    default:
                        description = GetSecondsDescription();
                        break;
                }
            }
            catch (Exception ex)
            {
                if (!m_options.ThrowExceptionOnParseError)
                {
                    description = ex.Message;
                }
                else
                {
                    throw;
                }
            }

            return description;
        }
예제 #2
0
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description = string.Empty;

            try
            {
                if (!m_parsed)
                {
                    ExpressionParser parser = new ExpressionParser(m_expression, m_options);
                    m_expressionParts = parser.Parse();
                    m_parsed          = true;
                }

                switch (type)
                {
                case DescriptionTypeEnum.FULL:
                    description = GetFullDescription();
                    break;

                case DescriptionTypeEnum.TIMEOFDAY:
                    description = GetTimeOfDayDescription();
                    break;

                case DescriptionTypeEnum.HOURS:
                    description = GetHoursDescription();
                    break;

                case DescriptionTypeEnum.MINUTES:
                    description = GetMinutesDescription();
                    break;

                case DescriptionTypeEnum.SECONDS:
                    description = GetSecondsDescription();
                    break;

                case DescriptionTypeEnum.DAYOFMONTH:
                    description = GetDayOfMonthDescription();
                    break;

                case DescriptionTypeEnum.MONTH:
                    description = GetMonthDescription();
                    break;

                case DescriptionTypeEnum.DAYOFWEEK:
                    description = GetDayOfWeekDescription();
                    break;

                case DescriptionTypeEnum.YEAR:
                    description = GetYearDescription();
                    break;

                default:
                    description = GetSecondsDescription();
                    break;
                }
            }
            catch (Exception ex)
            {
                if (!m_options.ThrowExceptionOnParseError)
                {
                    description = ex.Message;
                }
                else
                {
                    throw;
                }
            }

            return(description);
        }
        /// <summary>
        ///     Generates a human readable string for the Cron Expression
        /// </summary>
        /// <param name="type">Which part(s) of the expression to describe</param>
        /// <returns>The cron expression description</returns>
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description;

            try
            {
                if (!_parsed)
                {
                    var parser = new ExpressionParser(_expression, _options);
                    _expressionParts = parser.Parse();
                    _parsed = true;
                }

                switch (type)
                {
                    case DescriptionTypeEnum.Full:
                        description = GetFullDescription();
                        break;
                    case DescriptionTypeEnum.Timeofday:
                        description = GetTimeOfDayDescription();
                        break;
                    case DescriptionTypeEnum.Hours:
                        description = GetHoursDescription();
                        break;
                    case DescriptionTypeEnum.Minutes:
                        description = GetMinutesDescription();
                        break;
                    case DescriptionTypeEnum.Seconds:
                        description = GetSecondsDescription();
                        break;
                    case DescriptionTypeEnum.DayOfmonth:
                        description = GetDayOfMonthDescription();
                        break;
                    case DescriptionTypeEnum.Month:
                        description = GetMonthDescription();
                        break;
                    case DescriptionTypeEnum.DayOfweek:
                        description = GetDayOfWeekDescription();
                        break;
                    case DescriptionTypeEnum.Year:
                        description = GetYearDescription();
                        break;
                    default:
                        description = GetSecondsDescription();
                        break;
                }
            }
            catch (Exception exception)
            {
                if (!_options.ThrowExceptionOnParseError)
                    description = exception.Message;
                else
                    throw;
            }

            return description;
        }
예제 #4
0
        /// <summary>
        /// Generates a human readable string for the Cron Expression
        /// </summary>
        /// <param name="type">Which part(s) of the expression to describe</param>
        /// <returns>The cron expression description</returns>
        public string GetDescription(DescriptionTypeEnum type)
        {
            string description = string.Empty;

            try
            {
                if (!m_parsed)
                {
                    ExpressionParser parser = new ExpressionParser(m_expression, m_options);
                    m_expressionParts = parser.Parse();
                    m_parsed          = true;
                }

                switch (type)
                {
                case DescriptionTypeEnum.FULL:
                    description = GetFullDescription();
                    break;

                case DescriptionTypeEnum.TIMEOFDAY:
                    description = GetTimeOfDayDescription();
                    break;

                case DescriptionTypeEnum.HOURS:
                    description = GetHoursDescription();
                    break;

                case DescriptionTypeEnum.MINUTES:
                    description = GetMinutesDescription();
                    break;

                case DescriptionTypeEnum.SECONDS:
                    description = GetSecondsDescription();
                    break;

                case DescriptionTypeEnum.DAYOFMONTH:
                    description = GetDayOfMonthDescription();
                    break;

                case DescriptionTypeEnum.MONTH:
                    description = GetMonthDescription();
                    break;

                case DescriptionTypeEnum.DAYOFWEEK:
                    description = GetDayOfWeekDescription();
                    break;

                case DescriptionTypeEnum.YEAR:
                    description = GetYearDescription();
                    break;

                default:
                    description = GetSecondsDescription();
                    break;
                }
            }
            catch (Exception ex)
            {
                if (!m_options.ThrowExceptionOnParseError)
                {
                    description = ex.Message;
                }
                else
                {
                    throw;
                }
            }

            // Uppercase the first letter
            description = description.Length == 0 ? GetString("ComaEveryMinute") : string.Concat(m_culture.TextInfo.ToUpper(description[0]), description.Substring(1));

            return(description);
        }