Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Quartz;
- using Quartz.Impl;
- namespace Tasks
- {
- public class MaintenanceJob : IJob
- {
- public void Execute(IJobExecutionContext context)
- {
- var ftpLocation = context.JobDetail.JobDataMap.Get("ftp.location");
- // zip old log files
- // delete the files once zip is completed
- // sftp the zip to another location
- }
- }
- public class Triggers
- {
- public static ITrigger TimeTrigger()
- {
- return TriggerBuilder.Create()
- .WithDailyTimeIntervalSchedule
- (s =>
- s.WithIntervalInHours(24)
- .OnEveryDay()
- .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0))
- )
- .Build();
- }
- public static ITrigger CRONTrigger()
- {
- return TriggerBuilder.Create()
- .WithCronSchedule("At 8:00am every Monday through Friday", s => s.WithMisfireHandlingInstructionDoNothing())
- .Build();
- }
- }
- public class JobScheduler
- {
- public static void Start()
- {
- IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
- scheduler.Start();
- IJobDetail job = JobBuilder.Create<MaintenanceJob>().Build();
- job.JobDataMap.Add("ftp.location", "ftp://SomeFileLocation");
- scheduler.ScheduleJob(job, Triggers.TimeTrigger());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement