public static void AddJob()
        {
            try
            {
                isSchedulerStart = true;

                log.Error(" Now Job is Called for RecordSales ");

                IRecordSalesJob myJob = new RecordSalesJob();
                //JobDetailImpl jobDetail = new JobDetailImpl("Job1", "Group1", myJob.GetType());
                JobDetailImpl jobDetail = new JobDetailImpl("JobRecordSales", "GroupRecordSales", myJob.GetType());
                //CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "0 * 8-17 * * ?"); //run every minute between the hours of 8am and 5pm
                 // per minute 0 */1 * * * ?
                //Night 2 o' clock === 0 0 2 * * ?
                CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "GroupRecordSales", "0 0 3 * * ?"); //run every minute between the hours of 8am and 5pm
                _scheduler.ScheduleJob(jobDetail, trigger);

                DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
            }
            catch (Exception ex)
            {
                log.Error("Exception in run AddJob ", ex);
            }
        }
Exemplo n.º 2
0
        public Service1()
        {
            InitializeComponent();

            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            ISchedulerFactory schedFact = new StdSchedulerFactory();

            _scheduler = schedFact.GetScheduler();

            var parseJob = new JobDetailImpl("ParseJob", "ParserStuff", typeof(ParseJob));

            var parseTrigger = new CronTriggerImpl("ParseTime", "ParserStuff", "0 0/10 * * * ?") // Exactly every ten minutes
            {
                StartTimeUtc = DateTime.UtcNow
            };
            _scheduler.ScheduleJob(parseJob, parseTrigger);

            var summaryJob = new JobDetailImpl("SummaryJob", "SummaryStuff", typeof(SummaryJob));

            var summaryTrigger = new CronTriggerImpl("SummaryTime", "SummaryStuff", "0 0 4 1/1 * ? *") // At 04:00 AM every night
            {
                StartTimeUtc = DateTime.UtcNow
            };
            _scheduler.ScheduleJob(summaryJob, summaryTrigger);
        }
Exemplo n.º 3
0
    public async void Run(List <JobList> jobLists)
    {
        if (Log != null)
        {
            LogProvider.SetCurrentLogProvider(new QuartzLogProvider(Log));
        }
        try
        {
            var props = new NameValueCollection
            {
                { "quartz.serializer.type", "binary" }
            };
            var factory   = new StdSchedulerFactory(props);
            var scheduler = await factory.GetScheduler();

            await scheduler.Start();

            foreach (var jobList in jobLists)
            {
                var job     = JobBuilder.Create(jobList.JobType.GetType()).WithIdentity(jobList.Name, jobList.Group).Build();
                var trigger = new Quartz.Impl.Triggers.CronTriggerImpl(jobList.Name, jobList.Group, jobList.CronExpression);
                await scheduler.ScheduleJob(job, trigger);
            }
        }
        catch (SchedulerException se)
        {
            Log?.Invoke(se.Message, se);
        }
    }
        public virtual void AddSelfUpdaterCheckJob()
        {
            try {
                if (ConfigurationManager.AppSettings["SelfUpdaterCronTrigger"] != null)
                {
                    try
                    {
                        var jobDetail = new JobDetailImpl("SelfUpdaterChecker", null, typeof(SelfUpdaterCheckJob));
                        HttpContext.Current.Application.Lock();
                        var executeJob = !bool.Parse(HttpContext.Current.Application["NugetSelfUpdatesToInstall"].ToString());
                        HttpContext.Current.Application.UnLock();
                        jobDetail.JobDataMap.Add("ExcecuteJob", executeJob);
                        var cronExpression = ConfigurationManager.AppSettings["SelfUpdaterCronTrigger"];
                        var trigger = new CronTriggerImpl("TriggerSelfUpdaterChecker", "SelfUpdaterChecker", cronExpression);
                        _sched.ScheduleJob(jobDetail, trigger);

                    }
                    catch (Exception e)
                    {
                        ErrorHandler.Publish(LogLevel.Error, "Failed to add selfUpdater job", e);
                    }
                }
            }
            catch (Exception e) {
                ErrorHandler.Publish(LogLevel.Error, "Failed to add selfUpdater job", e);
            }
        }
Exemplo n.º 5
0
        public override ISchedule CreateSchedule(ScheduleType scheduleType, string name, IDictionary<string, object> parameters)
        {
            switch (scheduleType)
            {
                case ScheduleType.Periodic:
                    var triggerSettings = new PeriodicScheduleParameters(parameters);
                    var trigger = new SimpleTriggerImpl
                    {
                        Name = name,
                        RepeatCount = triggerSettings.RepeatCount, 
                        StartTimeUtc = triggerSettings.Start, 
                        RepeatInterval = triggerSettings.Interval
                    };
                    return new TriggerWrapper(trigger, scheduleType);
                
                case ScheduleType.CronBased:
                    var triggerSettingsCron = new CronScheduleParameters(parameters);
                    var triggerCron = new CronTriggerImpl
                    {
                        Name = name,
                        CronExpressionString = triggerSettingsCron.CronString
                    };
                    return new TriggerWrapper(triggerCron, scheduleType);

                default:
                    throw new Exception("Unsupported schedule type " + scheduleType.ToString());
            }
        }
Exemplo n.º 6
0
 public void TestPrecision()
 {
     IOperableTrigger trigger = new CronTriggerImpl();
     trigger.StartTimeUtc = new DateTime(1982, 6, 28, 13, 5, 5, 233);
     Assert.IsFalse(trigger.HasMillisecondPrecision);
     Assert.AreEqual(0, trigger.StartTimeUtc.Millisecond);
 }
Exemplo n.º 7
0
        public void TestTriggerFireExclusion()
        {
            sched.Start();
            TestJob.JobHasFired = false;
            JobDetailImpl myDesc = new JobDetailImpl("name", "group", typeof(TestJob));
            IOperableTrigger trigger = new CronTriggerImpl("trigName", "trigGroup", "0/15 * * * * ?");
            AnnualCalendar calendar = new AnnualCalendar();

            calendar.SetDayExcluded(DateTime.Now, true);
            sched.AddCalendar("calendar", calendar, true, true);
            trigger.CalendarName = "calendar";
            sched.ScheduleJob(myDesc, trigger);
            IOperableTrigger triggerreplace = new CronTriggerImpl("foo", "trigGroup", "name", "group", "0/15 * * * * ?");
            triggerreplace.CalendarName = "calendar";
            sched.RescheduleJob(new TriggerKey("trigName", "trigGroup"), triggerreplace);
            Thread.Sleep(1000 * 20);
            Assert.IsFalse(TestJob.JobHasFired, "task must not be neglected - it is forbidden by the calendar");

            calendar.SetDayExcluded(DateTime.Now, false);
            sched.AddCalendar("calendar", calendar, true, true);
            Thread.Sleep(1000 * 20);
            Assert.IsTrue(TestJob.JobHasFired, "task must be neglected - it is permitted by the calendar");

            sched.DeleteJob(new JobKey("name", "group"));
            sched.DeleteCalendar("calendar");

            sched.Shutdown();
        }
Exemplo n.º 8
0
        public void Start()
        {
            IJobDetail berthInUasgeJob = new JobDetailImpl("NpcMmsJob", "NpcMessageJob", typeof(NpcMmsJob));
            var trigger = new CronTriggerImpl("NpcMmsJobTrigger", "NpcMessageJob", "00 0/10 * * * ? *");

            _scheduler.ScheduleJob(berthInUasgeJob, trigger);
            _scheduler.Start();
        }
Exemplo n.º 9
0
        public static void Init()
        {
            var scheduler = StdSchedulerFactory.GetDefaultScheduler();
            scheduler.Start();

            var job = new JobDetailImpl("SearchJob", "jobs", typeof(SearchJob));
            var trigger = new CronTriggerImpl("SearchTrigger", "jobs", ConfigurationManager.AppSettings["CronTrigger"]);
            scheduler.ScheduleJob(job, trigger);
        }
Exemplo n.º 10
0
 public void UpdateJob(List<JobInfo> jobInfos)
 {
     foreach (var job in jobInfos)
     {
         if (_jobKeys.ContainsKey(job))
         {
             var trigger = new CronTriggerImpl(job.Name, null, job.Corn);
             _sched.RescheduleJob(_triggerKeys[job], trigger);
         }
     }
 }
Exemplo n.º 11
0
        static IOperableTrigger CreateTriggerCore(this IXpandJobTrigger jobTrigger, Type jobType) {
            IOperableTrigger trigger = null;
            if (jobTrigger is IXpandSimpleTrigger)
                trigger = new SimpleTriggerImpl(jobTrigger.Name, jobType.FullName);
            if (jobTrigger is IXpandCronTrigger)
                trigger = new CronTriggerImpl(jobTrigger.Name, jobType.FullName);

            if (trigger != null) {
                return trigger;
            }
            throw new NotImplementedException(jobTrigger.GetType().FullName);
        }
Exemplo n.º 12
0
 public static void AddJob()
 {
     log.Debug(" Called AddJob Method of Common Scheduler");
     IRunAllJob myJob = new RunAllJob();
     //JobDetailImpl jobDetail = new JobDetailImpl("Job1", "Group1", myJob.GetType());
     JobDetailImpl jobDetail = new JobDetailImpl("AllJob", "AllGroup", myJob.GetType());
     //CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "0 * 8-17 * * ?"); //run every minute between the hours of 8am and 5pm
     // per minute 0 */1 * * * ?
     CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "AllGroup", "0 */1 * * * ?"); //run every minute between the hours of 8am and 5pm
     _scheduler.ScheduleJob(jobDetail, trigger);
     DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
 }
Exemplo n.º 13
0
        public void TestClone()
        {
            CronTriggerImpl trigger = new CronTriggerImpl();
            trigger.Name =("test");
            trigger.Group = ("testGroup");
            trigger.CronExpressionString = ("0 0 12 * * ?");
            ICronTrigger trigger2 = (ICronTrigger)trigger.Clone();

            Assert.AreEqual(trigger, trigger2, "Cloning failed");

            // equals() doesn't test the cron expression
            Assert.AreEqual("0 0 12 * * ?", trigger2.CronExpressionString, "Cloning failed for the cron expression");
        }
Exemplo n.º 14
0
        public static void AddJob()
        {
            isSchedulerStart = true;

            log.Error(" Now Job is Called for Deposti ");
            IDepositJob myJob = new DepositJob();
            JobDetailImpl jobDetail = new JobDetailImpl("JobDeposit", "GroupDeposit", myJob.GetType());
            //CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "0 * 8-17 * * ?"); //run every minute between the hours of 8am and 5pm
            // per minute 0 */1 * * * ?
            // Night 2 o'clock==== 0 0 2 * * ?
            CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "GroupDeposit", "0 0 2 * * ?"); //run every minute between the hours of 8am and 5pm
            _scheduler.ScheduleJob(jobDetail, trigger);
            DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
        }
Exemplo n.º 15
0
        public static void AddHealthMonitoringJob()
        {
            const string trigger1 = "HealthMonitoring";
            const string timeToRun = "0 0/10 * * * ?";

            IMyJob myJob = new HealthMonitiorJob(); //This Constructor needs to be parameterless
            var jobDetail = new JobDetailImpl(trigger1 + Job, Group1, myJob.GetType());
            var trigger = new CronTriggerImpl(trigger1, Group1, timeToRun)
            {TimeZone = TimeZoneInfo.Utc};
            _scheduler.ScheduleJob(jobDetail, trigger);
            DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
            if (nextFireTime != null)
                Log.Info(string.Format("{0}+{1}", Group1, trigger1), new Exception(nextFireTime.Value.ToString("u")));
        }
Exemplo n.º 16
0
        public static void AddBirthdayJob()
        {
            const string trigger1 = "EmailTasksTrigger";
            const string jobName = trigger1 + Job;
            const string timeToRun = "0 0 2 * * ?";

            IMyJob myJob = new BirthdayJob(); //This Constructor needs to be parameterless
            var jobDetail = new JobDetailImpl(jobName, Group1, myJob.GetType());
            var trigger = new CronTriggerImpl(trigger1, Group1, timeToRun)
            {TimeZone = TimeZoneInfo.Utc};
            _scheduler.ScheduleJob(jobDetail, trigger);
            DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
            if (nextFireTime != null)
                Log.Debug(string.Format("{0}+{1}", Group1, trigger1), new Exception(nextFireTime.Value.ToString("u")));
        }
Exemplo n.º 17
0
        static IOperableTrigger CreateTriggerCore(this IXpandJobTrigger jobTrigger, Type jobType) {
            IOperableTrigger trigger = null;
            if (jobTrigger is IXpandSimpleTrigger)
                trigger = new SimpleTriggerImpl(jobTrigger.Name, jobType.FullName);
            if (jobTrigger is IXpandCronTrigger)
                trigger = new CronTriggerImpl(jobTrigger.Name, jobType.FullName);
            if (jobTrigger is INthIncludedDayTrigger)
                trigger = new NthIncludedDayTrigger(jobTrigger.Name, jobType.FullName);

            if (trigger != null) {
//                trigger.AddTriggerListener(new XpandTriggerListener().Name);
                return trigger;
            }
            throw new NotImplementedException(jobTrigger.GetType().FullName);
        }
        public void AddTask(string taskName, string cronConfig, Action action)
        {
            // get a scheduler
            _sched = schedFact.GetScheduler();

            // construct job info
            var task = new CronTask(taskName, cronConfig, action);

            var jobDetail = new JobDetailImpl(task.TaskName, typeof (CronTask));
            jobDetail.JobDataMap.Put("taskName", task);

            var trigger = new CronTriggerImpl(task.TaskName, "Group1", task.CronConfig);

            _sched.ScheduleJob(jobDetail, trigger);
        }
Exemplo n.º 19
0
 public void TestCronTriggerTimeZone_TimeZoneShouldChangeWhenChanged()
 {
     string tzStr = "FLE Standard Time";
     if (TimeZoneInfo.Local.Id == tzStr)
     {
         tzStr = "GMT Standard Time";
     }
     TimeZoneInfo tz = TimeZoneUtil.FindTimeZoneById(tzStr);
     CronTriggerImpl trigger = new CronTriggerImpl();
     trigger.Name = "Quartz-579";
     trigger.Group = SchedulerConstants.DefaultGroup;
     trigger.TimeZone = tz;
     trigger.CronExpressionString = "0 0 12 * * ?";
     Assert.AreEqual(tz, trigger.TimeZone, "TimeZone was changed");
 }
Exemplo n.º 20
0
        public void TestMmsJob()
        {
            ISchedulerFactory sf = new StdSchedulerFactory();
            var scheduler = sf.GetScheduler();

            IJobDetail berthInUasgeJob = new JobDetailImpl("berthInUsage", "IntelligentParking", typeof(NpcMmsJob));
            var trigger = new CronTriggerImpl("berthInUsageTrigger", "IntelligentParking", "00 0/5 * * * ? *");

            scheduler.ScheduleJob(berthInUasgeJob, trigger);
            scheduler.Start();

            scheduler.TriggerJob(new JobKey("berthInUsage", "IntelligentParking"));

            Thread.Sleep(1000000);
            scheduler.Clear();
            scheduler.Shutdown();
        }
Exemplo n.º 21
0
        public static void Execute()
        {
            ISchedulerFactory factory = new StdSchedulerFactory();
            IScheduler schedule = factory.GetScheduler();
            schedule.Start();
            IJobDetail job = JobBuilder.Create<SampleJob>().WithIdentity("SampleJob", "JobGroup1").Build();
            ITrigger trigger = TriggerBuilder.Create().StartNow().Build();

            //Quartz.MisfireInstruction.CronTrigger 
            //Quartz.MisfireInstruction.CronTrigger trigger2 = new Quartz.MisfireInstruction.CronTrigger("trigger1", "group1", "job1", "group1"); 
            IOperableTrigger trigger2 = new CronTriggerImpl("trigName", "group1", "1/2 * * * * ?");

            schedule.ScheduleJob(job, trigger2);
            schedule.UnscheduleJob(trigger2.Key);
            //schedule.PauseTrigger
            schedule.Shutdown(false);
        }
Exemplo n.º 22
0
        //
        // Uses Quartz.NET package to schedule jobs
        public static void ConfigureQuartzJobs()
        {
            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler
            IScheduler sched = schedFact.GetScheduler();
            sched.Start();

            /* Trigger to lock timesheets every Tuesday and Wednesday morning at 12:00am.
             * Timesheets won't be locked on Tuesday if there was a holiday, and won't be
             * locked on Wednesday if there wasn't a holiday
             */
            JobDetailImpl job1 = new JobDetailImpl("lockTimesheetsJob", typeof(TARS.ScheduledJobs.TarsScheduledJobs));
            job1.Description = "lockTimesheets";
            CronTriggerImpl lockTimesheetsTrigger = new CronTriggerImpl("lockTimesheetTrigger",
                                                                         null,
                                                                         "lockTimesheetsJob",
                                                                         null,
                                                                         "0 0 0 ? * TUE,WED"
                                                                       );
            sched.ScheduleJob(job1, lockTimesheetsTrigger);

            // trigger to send reminder email to employees to submit timesheets by end of day Saturday
            JobDetailImpl job2 = new JobDetailImpl("remindSubmitTimesheetJob", typeof(TARS.ScheduledJobs.TarsScheduledJobs));
            job2.Description = "remindSubmitTimesheet";
            CronTriggerImpl remindSubmitTsTrigger = new CronTriggerImpl("remindSubmitTimesheetTrigger",
                                                                         null,
                                                                         "remindSubmitTimesheetJob",
                                                                         null,
                                                                         "0 0 0 ? * SAT"
                                                                       );
            sched.ScheduleJob(job2, remindSubmitTsTrigger);

            // trigger to send reminder email to managers and admin when a PCA or Work Effort expires that week
            JobDetailImpl job3 = new JobDetailImpl("remindPcaWeExpireJob", typeof(TARS.ScheduledJobs.TarsScheduledJobs));
            job3.Description = "remindPcaOrWeExpires";
            CronTriggerImpl remindPcaWeExpireTrigger = new CronTriggerImpl("remindPcaWeExpireTrigger",
                                                                            null,
                                                                            "remindPcaWeExpireJob",
                                                                            null,
                                                                            "0 0 0 ? * SUN"
                                                                          );
            sched.ScheduleJob(job3, remindPcaWeExpireTrigger);
        }
Exemplo n.º 23
0
        public void ExceptionJobUnscheduleFiringTrigger()
        {
            sched.Start();
            string jobName = "ExceptionPolicyUnscheduleFiringTrigger";
            string jobGroup = "ExceptionPolicyUnscheduleFiringTriggerGroup";
            JobDetailImpl myDesc = new JobDetailImpl(jobName, jobGroup, typeof (ExceptionJob));
            myDesc.Durable = true;
            sched.AddJob(myDesc, false);
            string trigGroup = "ExceptionPolicyFiringTriggerGroup";
            IOperableTrigger trigger = new CronTriggerImpl("trigName", trigGroup, "0/2 * * * * ?");
            trigger.JobKey = new JobKey(jobName, jobGroup);

            ExceptionJob.ThrowsException = true;
            ExceptionJob.LaunchCount = 0;
            ExceptionJob.Refire = false;
            ExceptionJob.UnscheduleFiringTrigger = true;
            ExceptionJob.UnscheduleAllTriggers = false;

            sched.ScheduleJob(trigger);

            Thread.Sleep(7*1000);
            sched.DeleteJob(trigger.JobKey);
            Assert.AreEqual(1, ExceptionJob.LaunchCount,
                            "The job shouldn't have been refired (UnscheduleFiringTrigger)");


            ExceptionJob.LaunchCount = 0;
            ExceptionJob.UnscheduleFiringTrigger = true;
            ExceptionJob.UnscheduleAllTriggers = false;

            sched.AddJob(myDesc, false);
            trigger = new CronTriggerImpl("trigName", trigGroup, "0/2 * * * * ?");
            trigger.JobKey = new JobKey(jobName, jobGroup);
            sched.ScheduleJob(trigger);
            trigger = new CronTriggerImpl("trigName1", trigGroup, "0/3 * * * * ?");
            trigger.JobKey = new JobKey(jobName, jobGroup);
            sched.ScheduleJob(trigger);
            Thread.Sleep(7*1000);
            sched.DeleteJob(trigger.JobKey);
            Assert.AreEqual(2, ExceptionJob.LaunchCount,
                            "The job shouldn't have been refired(UnscheduleFiringTrigger)");
        }
Exemplo n.º 24
0
 public void Run()
 {
     IJobDetail flowNodeInstanceJob = new JobDetailImpl("FlowNodeInstanceJob", "Npc", typeof( FlowNodeInstanceJob));
     IJobDetail dealFlowNodeFlowToJob = new JobDetailImpl("DealFlowNodeFlowToJob", "Npc", typeof(DealFlowNodeFlowToJob));
     IJobDetail dealFlowJob = new JobDetailImpl("DealFlowJob", "Npc", typeof(DealFlowJob));
     IJobDetail fetchProposalFromMessageJob = new JobDetailImpl("FetchProposalFromMessageJob", "Npc"
         , typeof(FetchProposalFromMessageJob));
     var flowNodeInstanceJobTrigger = new CronTriggerImpl("FlowNodeInstanceJobTrigger", "Npc", "0/15 * * * * ? *");
     var dealFlowNodeFlowToJobTrigger = new CronTriggerImpl("DealFlowNodeFlowToJobTrigger", "Npc", "0/15 * * * * ? *");
     var dealFlowJobTrigger = new CronTriggerImpl("DealFlowJobTrigger", "Npc", "0/15 * * * * ? *");
     var fetchProposalFromMessageJobTrigger = new CronTriggerImpl("FetchProposalFromMessageJobTrigger"
         , "Npc", "0/15 * * * * ? *");
     _scheduler.ScheduleJob(flowNodeInstanceJob, flowNodeInstanceJobTrigger);
     _scheduler.ScheduleJob(dealFlowNodeFlowToJob, dealFlowNodeFlowToJobTrigger);
     _scheduler.ScheduleJob(dealFlowJob, dealFlowJobTrigger);
     _scheduler.ScheduleJob(fetchProposalFromMessageJob, fetchProposalFromMessageJobTrigger);
     _scheduler.Start();
     _logger.InfoFormat("Job已启动");
     //Thread.Sleep(1000000);
 }
Exemplo n.º 25
0
 public void AddJob(List<JobInfo> jobInfos)
 {
     foreach (var job in jobInfos)
     {
         if (!_jobKeys.ContainsKey(job))
         {
             var trigger = new CronTriggerImpl(job.Name, null, job.Corn);
             var key = trigger.Key;
             var jobDetail = new JobDetailImpl(job.Name, null, typeof(JobTracker))
             {
                 JobDataMap = new JobDataMap
                 {
                     {"job", job},
                 }
             };
             _sched.ScheduleJob(jobDetail, trigger);
             _triggerKeys.Add(job, key);
             _jobKeys.Add(job, jobDetail.Key);
         }
     }
 }
        public static void Register(RouteCollection routes,string url,Func<IRedsysService> serviceResolver)
        {
            IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();

            CronTriggerImpl RedsysGatewayTrigger = new CronTriggerImpl("RedsysGatewayTrigger") {CronExpressionString = "0 * * * * ?"};

            JobDetailImpl RedsysGatewayJobDetail = new JobDetailImpl("RedsysGatewayJobDetail", typeof(ProcessRecurringTransactionsJob));
            RedsysGatewayJobDetail.JobDataMap["serviceResolver"] = serviceResolver;
            scheduler.ScheduleJob(RedsysGatewayJobDetail, RedsysGatewayTrigger);

            if (!scheduler.IsStarted)
                scheduler.Start();

            string[] namespaces = {typeof (RedsysController).Namespace};

            string name = Guid.NewGuid()
                              .ToString();
            var route = new {action = "Callback", controller = "Redsys"};

            if (routes != null)
                Route = routes.MapRoute(name, url, route, namespaces);
        }
        /**
            Método que pérmite calendarizar un nuevo job dentro de los cron del Sistema
        **/
        public static void scheduleJob(IJob jobToSchedule, String cronExpression)
        {

            JobDetailImpl       jobDetail = new JobDetailImpl("Job_" + jobCounter, "Group_" + jobCounter, jobToSchedule.GetType());
            CronTriggerImpl     trigger = null;
            DateTimeOffset?     dateTimOffset = null;

            if ( _scheduler == null)
            {
                initScheduler();
            }

            //Se crea el trigeer con el que se va a lanzar el job
            trigger = new CronTriggerImpl("Trigger_" + jobCounter, "Group_" + jobCounter, cronExpression);
            //Se agrega el calendarizador al scheduler
            _scheduler.ScheduleJob(jobDetail, trigger);

            //Se solicita el date Para el siguiente evento del scheduler
            dateTimOffset = trigger.GetNextFireTimeUtc();
            Console.WriteLine("Job Scheduled");
            Console.WriteLine(jobDetail.FullName + " its about to be fired at "  + dateTimOffset.Value );

            jobCounter++;
        }
Exemplo n.º 28
0
        private void Scheduler()
        {
            ISchedulerFactory schedulePool = new StdSchedulerFactory();
            IScheduler sched = schedulePool.GetScheduler();
            sched.Start();

            JobDetailImpl makeReminder = new JobDetailImpl("reminder", typeof(SendReminderJob));
            JobDetailImpl makeWarning = new JobDetailImpl("warning", typeof(SendWarningJob));

            /*
             * Only support eastern timezone for prototype
             * 10 AM Reminder
             * 5 PM Warning
             */
            CronTriggerImpl reminderTrigger = new CronTriggerImpl("reminderTrigger");
            reminderTrigger.CronExpressionString = "0 0 14 * * ?";
            reminderTrigger.StartTimeUtc = DateTime.UtcNow;
            sched.ScheduleJob(makeReminder, reminderTrigger);

            CronTriggerImpl warningTrigger = new CronTriggerImpl("warningTrigger");
            warningTrigger.CronExpressionString = "0 0 21 * * ?";
            reminderTrigger.StartTimeUtc = DateTime.UtcNow;
            sched.ScheduleJob(makeWarning, warningTrigger);
        }
Exemplo n.º 29
0
        public void TestQuartz558()
        {
            CronTriggerImpl trigger = new CronTriggerImpl();
            trigger.Name =("test");
            trigger.Group = ("testGroup");
            ICronTrigger trigger2 = (ICronTrigger)trigger.Clone();

            Assert.AreEqual(trigger, trigger2, "Cloning failed");
        }
Exemplo n.º 30
0
        public void ShouldGetScheduleBuilderWithSameSettingsAsTrigger()
        {
            var startTime = DateTimeOffset.UtcNow;
            var endTime = DateTimeOffset.UtcNow.AddDays(1);
            var trigger = new CronTriggerImpl("name", "group", "jobname", "jobgroup", startTime, endTime, "0 0 12 * * ?", TimeZoneInfo.Utc);
            trigger.MisfireInstruction = MisfireInstruction.CronTrigger.FireOnceNow;
            var scheduleBuilder = trigger.GetScheduleBuilder();

            var cloned = (CronTriggerImpl)scheduleBuilder.Build();
            Assert.That(cloned.MisfireInstruction, Is.EqualTo(trigger.MisfireInstruction));
            Assert.That(cloned.TimeZone, Is.EqualTo(trigger.TimeZone));
            Assert.That(cloned.CronExpressionString, Is.EqualTo(trigger.CronExpressionString));
        }
Exemplo n.º 31
-2
        public void BasicCronTriggerTest()
        {
            CronTriggerImpl trigger = new CronTriggerImpl();
            trigger.Name = "Quartz-Sample";
            trigger.Group = SchedulerConstants.DefaultGroup;
            trigger.CronExpressionString = "0 0 12 1 1 ? 2099";
            trigger.StartTimeUtc = new DateTimeOffset(2099, 1, 1, 12, 0, 1, TimeSpan.Zero);
            trigger.EndTimeUtc = new DateTimeOffset(2099, 1, 1, 12, 0, 1, TimeSpan.Zero);

            Assert.IsNull(trigger.ComputeFirstFireTimeUtc(null));
        }