Beispiel #1
0
        public CronJob(string line)
        {
            int fieldcount = 0;

            foreach (Match match in regex.Matches(line))
            {
                fieldcount++;
                if (fieldcount == 6)
                {
                    try
                    {
                        exprstr = line.Substring(0, match.Index - 1).Trim();
                        command = line.Substring(match.Index).Trim();
                        exprobj = CronExpression.Parse(exprstr);
                        next    = exprobj.GetNextOccurrence(DateTimeOffset.Now, TimeZoneInfo.Local)?.DateTime;
                    }
                    catch { }
                    break;
                }
            }
            if (next == null)
            {
                CronService.Logging(string.Format("unable to create job: {0}", line));
            }
            else
            {
                CronService.Logging(string.Format("job created successfully: {0} {1}", exprstr, command));
            }
        }
Beispiel #2
0
 public void Execute()
 {
     if (DateTime.Now > next)
     {
         CronService.Logging(string.Format("run: {0}", command));
         ThreadPool.QueueUserWorkItem(RunCommand);
         next = exprobj.GetNextOccurrence(DateTimeOffset.Now, TimeZoneInfo.Local)?.DateTime;
     }
 }
Beispiel #3
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     CronService.Logging("program terminated");
 }
Beispiel #4
0
 private void clearLogToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CronService.ClearLogFile();
 }
Beispiel #5
0
 private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CronService.OpenLogFile();
 }
Beispiel #6
0
 private void editJobsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CronService.OpenCronFile();
 }
Beispiel #7
0
 public Form1()
 {
     InitializeComponent();
     CronService.Logging("program started");
 }