예제 #1
0
    public static void AddJob()
    {
        IMyJob          myJob     = new MyJob();                                                    //This Constructor needs to be parameterless
        JobDetailImpl   jobDetail = new JobDetailImpl("Job1", "Group1", myJob.GetType());
        CronTriggerImpl trigger   = new CronTriggerImpl("Trigger1", "Group1", "0 0/1 * 1/1 * ? *"); //run every minute between the hours of 8am and 5pm

        _scheduler.ScheduleJob(jobDetail, trigger);
        DateTimeOffset?nextFireTime = trigger.GetNextFireTimeUtc();

        Console.WriteLine("Next Fire Time:" + nextFireTime.Value);
    }
        private void CheckDates()
        {
            if (MainWindow.remindScheduler.scheduleStructure != null && MainWindow.remindScheduler.scheduleStructure.Count > 0)
            {
                DateTime nowTime      = DateTime.Now;
                DateTime plusHourTime = nowTime.AddMinutes(60);

                DateTime dayPlusMax = nowTime.AddMinutes(1470);
                DateTime dayPlusMin = nowTime.AddMinutes(1410);

                foreach (var savedDate in MainWindow.remindScheduler.scheduleStructure)
                {
                    if (savedDate.DatetimeEvent > nowTime && savedDate.DatetimeEvent < plusHourTime)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise in {1:mm} minutes", savedDate.Title, savedDate.DatetimeEvent - nowTime);
                        //MessageBox.Show(remindString);
                        MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });

                        MainWindow.raisedEvent.Enqueue(savedDate);
                    }

                    if (savedDate.DatetimeEvent > dayPlusMin && savedDate.DatetimeEvent < dayPlusMax)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise tomorrow ({1:dd/MM/yyyy})", savedDate.Title, dayPlusMax);
                        //MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });
                    }
                }

                foreach (var eventNod in MainWindow.raisedEvent)
                {
                    counterAlarms++;
                    int               transferMins = (int)(eventNod.DatetimeEvent - nowTime).Minutes;
                    IMyJob            myJob        = new MyJob();
                    JobDetailImpl     jobDetail    = new JobDetailImpl(counterAlarms.ToString(), null, myJob.GetType());
                    SimpleTriggerImpl trigger2     = new SimpleTriggerImpl("Trigger" + counterAlarms.ToString(), null, DateTime.Now.AddSeconds(transferMins * 60), null, 0, TimeSpan.Zero);
                    RaiseReminder(myJob, jobDetail, trigger2);
                }
            }
        }