Exemple #1
0
        public void Run()
        {
            Debug.WriteLine("Unit test: " + TDL);

            // Test input vs. parsed output
            ISchedule sched  = TDLParser.Parse(TDL);
            string    verify = sched.ToString();

            Assert.AreEqual(TDLVerify, verify, "TDL Parse result mismatch.");

            // Test parsed output vs. re-parsed output's output
            ISchedule sched2  = TDLParser.Parse(verify);
            string    verify2 = sched2.ToString();

            Assert.AreEqual(verify, verify2, "TDL Parse #2 result mismatch.");

            Debug.WriteLine(string.Format("{0}: \"{1}\" evaluates to: \"{2}\"", ExplDiagnostics.CallingMethod, TDL, verify));
        }
Exemple #2
0
        /// <summary>
        /// Parse user input TDL and date range.
        /// Populate datagrid with generated TimedEvents.
        /// </summary>
        private void ParseTDL()
        {
            ClearAll();

            DateTime StartRange = DateTime.MinValue, EndRange = DateTime.MinValue;

            try {
                StartRange = DateTime.Parse(textBox_StartRange.Text);
            }
            catch {
                toolStripStatusLabel1.Text = "Error parsing StartRange datetime.";
                return;
            }

            try {
                EndRange = DateTime.Parse(textBox_EndRange.Text);
            }
            catch {
                toolStripStatusLabel1.Text = "Error parsing EndRange datetime.";
                return;
            }

            try {
                // Parse TDL.
                var sched = TDLParser.Parse(textBox_TDL.Text);

                parsedEvents = sched.GetRange(StartRange, EndRange)
                               .Take(10000);

                // Clear tab page populate flags.
                tabPopulateFlags.Clear();

                PopulateCurrentTab();

                toolStripStatusLabel1.Text = string.Format("TDL parsed successfully.  Generated {0} events.", parsedEvents.Count());
            }
            catch {
                toolStripStatusLabel1.Text = "Error parsing TDL.";
                return;
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // TDL expression.
            string tdlExpression = "every T30";

            // Parse to ISchedule.
            ISchedule schedule = TDLParser.Parse(tdlExpression);

            // Forecast timed events for the next hour.
            IEnumerable <TimedEvent> events = schedule.GetRange(DateTime.Now, DateTime.Now.AddHours(1));

            int eventCount = events.Count();

            Console.WriteLine("Found {0:d} events.", eventCount);

            // Print to screen.
            foreach (TimedEvent e in events)
            {
                Console.WriteLine("Event time: {0:G}", e.StartTime);
            }
        }
Exemple #4
0
 public ExampleSchedule(string name, string tdl)
 {
     this.Name     = name;
     this.Schedule = TDLParser.Parse(tdl);
 }