예제 #1
0
 public bool onPause()
 {
     try
     {
         scheduler.Shutdown();
         LogsSingleton.WriteText("Job shutdown successful.", "Quarzt");
         return(true);
     }
     catch (Exception ex)
     {
         LogsSingleton.WriteText("Job shutdown failed. Error detail: \n" + ex.Message, "Quarzt");
         return(false);
     }
 }
예제 #2
0
 public bool createJobbyCron <T>(string nameTrigger, string nameGroupnameTrigger, string nameJob, string nameGroup, string cron) where T : IJob
 {
     try
     {
         addCron <T>(nameJob, nameGroup, nameTrigger, nameGroupnameTrigger, cron);
         LogsSingleton.WriteText("Create cron successful", "Quarzt");
         return(true);
     }
     catch (Exception ex)
     {
         LogsSingleton.WriteText("Create cron failed. Error detail: \n " + ex.Message, "Quarzt");
         return(false);
     }
 }
예제 #3
0
 public bool onStart()
 {
     try
     {
         scheduler.Start();
         LogsSingleton.WriteText("Job start successful.", "Quarzt");
         //QuarztSingleton.Instance.createJob<onValidateHolidayAsync>("ValdateHolidateTrig", "sys", "ValdateHolidateJob", "sys", "00:00:60");
         return(true);
     }
     catch (Exception ex)
     {
         LogsSingleton.WriteText("Job failed. Error detail: \n " + ex.Message, "Quarzt");
         return(false);
     }
 }
예제 #4
0
        public bool createJob <T>(string nameJob, string nameGroup, string nameTrigger, string nameGroupnameTrigger, string time) where T : IJob
        {
            try
            {
                int hours   = int.Parse(time.Substring(0, 2).ToString().TrimStart());
                int minutes = int.Parse(time.Substring(3, 2).ToString().TrimStart());
                int second  = int.Parse(time.Substring(6, 2).ToString().TrimStart());

                scheduler.ScheduleJob(addJob <T>(nameJob, nameGroup), addTrigger(nameTrigger, nameGroupnameTrigger, second));
                scheduler.Start();
                LogsSingleton.WriteText("Create job successful.", "Quarzt");

                return(true);
            }
            catch (Exception ex)
            {
                LogsSingleton.WriteText("Create job failed. Error detail: \n " + ex.Message, "Quarzt");

                return(false);
            }
        }
예제 #5
0
        public Task Execute(IJobExecutionContext context)
        {
            HolidayCalendar calendar = new HolidayCalendar();

            DayOfWeek toDay = DateTime.Now.DayOfWeek;

            if ((toDay == DayOfWeek.Saturday) || (toDay == DayOfWeek.Sunday))
            {
                calendar.AddExcludedDate(DateTime.Now);
                QuarztSingleton.scheduler.AddCalendar("Holiday", calendar, true, true);

                ITrigger       trigger = QuarztSingleton.scheduler.GetTrigger(new TriggerKey("NamHTtrigger", "NamHT")).GetAwaiter().GetResult();
                TriggerBuilder tb      = trigger.GetTriggerBuilder();

                ITrigger UpdateTrigger = tb.ModifiedByCalendar("Holiday").Build();

                QuarztSingleton.scheduler.RescheduleJob(new TriggerKey("NamHTtrigger", "NamHT"), UpdateTrigger);

                LogsSingleton.WriteText("Hôm nay, ngày nghỉ Job đi nhậu với bạn đây.", "Quarzt");
            }
            return(Task.FromResult("done"));
        }