Пример #1
0
        /// <summary>
        /// Reads crontab file and produces list of rules.
        /// </summary>
        /// <returns>List of crontab rules read from a file.</returns>
        public CrontabRuleList GetRuleList()
        {
            //TODO - can't parse */2 value format
            if (this.filename.Equals(string.Empty))
            {
                return new CrontabRuleList();
            }
            CrontabRuleList tasks = new CrontabRuleList();
            TextReader r = new StreamReader(this.filename);
            String line = String.Empty;
            while ((line = r.ReadLine()) != null)
            {

                Regex reg = new Regex(@"^\s*" +
                    @"^(?<minute>[0-9]+(?:(?:\,|\-)[0-9]+)*|\*)\s+" +
                    @"(?<hour>[0-9]+(?:(?:\,|\-)[0-9]+)*|\*)\s+" +
                    @"(?<day>[0-9]+(?:(?:\,|\-)[0-9]+)*|\*)\s+" +
                    @"(?<month>[0-9]+(?:(?:\,|\-)[0-9]+)*|\*)\s+" +
                    @"(?<weekday>[0-9]+(?:(?:\,|\-)[0-9]+)*|\*)\s+(?<taskName>.*)", RegexOptions.Singleline);
                if (reg.IsMatch(line))
                {
                    Match m = reg.Match(line);
                    GroupCollection gc = m.Groups;
                    //Console.WriteLine(gc["minute"]);
                    if (gc["minute"].Success && gc["hour"].Success && gc["day"].Success && gc["month"].Success && gc["weekday"].Success
                        && gc["taskName"].Success)
                    {
                        CrontabRawRule t = new CrontabRawRule();
                        t.Minute = this.validateRawValue(gc["minute"].Value);
                        t.Hour = this.validateRawValue(gc["hour"].Value);
                        t.Day = this.validateRawValue(gc["day"].Value);
                        t.Month = this.validateRawValue(gc["month"].Value);
                        t.Weekday = this.validateRawValue(gc["weekday"].Value);
                        t.TaskName = gc["taskName"].Value;
                        CrontabRule cr = t.GetRule();
                        tasks.Add(cr);
                    }
                }

            }
            r.Close();
            return tasks;
        }
Пример #2
0
 /// <summary>
 /// Refreshes rule grid view.
 /// Allows to apply filters to a list of rules.
 /// Also refreshes instance grid view.
 /// </summary>
 public void RefreshRuleList()
 {
     if (this.isFileOpen)
     {
         CrontabRawRuleReader r = new CrontabRawRuleReader(this.crontabFileName);
         this.ruleList = r.GetRuleList();
         if (this.FilterMode == FilterWindow.FilterMode.Exclude)
         {
             this.ruleList = this.ruleList.FilterByNames(this.ExcludedByFilterNames, true);
         }
         else
         {
             this.ruleList = this.ruleList.FilterByNames(this.ExcludedByFilterNames, false);
         }
     }
     else
     {
         this.ruleList = new CrontabRuleList();
     }
     this.ruleGridView.DataSource = this.ruleList;
     this.RefreshInstanceList();
 }
Пример #3
0
 /// <summary>
 /// Refreshes rule grid view.
 /// Allows to apply filters to a list of rules.
 /// Also refreshes instance grid view.
 /// </summary>
 public void RefreshRuleList()
 {
     if (this.isFileOpen)
     {
         CrontabRawRuleReader r = new CrontabRawRuleReader(this.crontabFileName);
         this.ruleList = r.GetRuleList();
         if (this.FilterMode == FilterWindow.FilterMode.Exclude)
         {
             this.ruleList = this.ruleList.FilterByNames(this.ExcludedByFilterNames, true);
         }
         else
         {
             this.ruleList = this.ruleList.FilterByNames(this.ExcludedByFilterNames, false);
         }
     }
     else
     {
         this.ruleList = new CrontabRuleList();
     }
     this.ruleGridView.DataSource = this.ruleList;
     this.RefreshInstanceList();
 }
Пример #4
0
 /// <summary>
 /// Create crontab parser based on crontab rule list and selected date.
 /// </summary>
 /// <param name="cr">crontab rule list from which instances should be created</param>
 /// <param name="selectedDay">selected date for which instances should be created</param>
 public CrontabRuleParser(CrontabRuleList cr, DateTime selectedDay)
     : this()
 {
     this.rules.AddRange(cr);
     this.selectedDay = selectedDay;
 }
Пример #5
0
 /// <summary>
 /// Creates default, parser object.
 /// </summary>
 public CrontabRuleParser()
 {
     this.rules = new CrontabRuleList();
     this.instances = new CrontabInstanceList();
 }