public MinuteIntervalsScheduleAttribute(string name, int minute, string queue, Type clientKey) : base(name, Cron.MinuteIntervals(minute), queue, clientKey) { }
private static async Task MainAsync(string[] args, CancellationToken cancellationToken) { var loggerFactory = new LoggerFactory().AddConsole(LogLevel.Debug); var logger = loggerFactory.CreateLogger <Program>(); // Setup DI var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterModule(new QuidjiboModule(typeof(Program).Assembly)); containerBuilder.RegisterInstance <ILogger>(logger); var container = containerBuilder.Build(); // Setup Quidjibo var quidjiboBuilder = new QuidjiboBuilder() .ConfigureLogging(loggerFactory) .UseAutofac(container) .UseAes(Encoding.ASCII.GetBytes(WorkerConfig.PayloadKey)) .UseSqlServer(WorkerConfig.WorkerDbConnectionString) .ConfigurePipeline(pipeline => pipeline.UseDefault()); // Quidjibo Client var client = quidjiboBuilder.BuildClient(); // Long Running Jobs await client.PublishAsync(new SystemQueueProcessorCommand(8), cancellationToken); await client.PublishAsync(new QueuesProcessorCommand(4), cancellationToken); // Scheduled Jobs await client.ScheduleAsync("Calendar Notifications", new CalendarNotificationCommand(1), Cron.MinuteIntervals(20), cancellationToken); await client.ScheduleAsync("Call Email Import", new CallEmailImportCommand(2), Cron.MinuteIntervals(5), cancellationToken); await client.ScheduleAsync("Call Pruning", new CallPruneCommand(3), Cron.MinuteIntervals(60), cancellationToken); await client.ScheduleAsync("Report Delivery", new ReportDeliveryTaskCommand(5), Cron.MinuteIntervals(60), cancellationToken); await client.ScheduleAsync("Shift Notifier", new ShiftNotiferCommand(6), Cron.MinuteIntervals(60), cancellationToken); await client.ScheduleAsync("Staffing Schedule", new Commands.StaffingScheduleCommand(7), Cron.MinuteIntervals(15), cancellationToken); await client.ScheduleAsync("Training Notifier", new TrainingNotiferCommand(9), Cron.MinuteIntervals(60), cancellationToken); // Quidjibo Server using (var workServer = quidjiboBuilder.BuildServer()) { // Start Quidjibo workServer.Start(); cancellationToken.WaitHandle.WaitOne(); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { var aes = Aes.Create(); var key = string.Join(",", aes.Key); //System.Console.CancelKeyPress += (s, e) => { cancellationToken..Cancel(); }; _logger.Log(LogLevel.Information, "Starting Scheduler"); var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var logger = loggerFactory.CreateLogger <Program>(); // Setup DI var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterModule(new QuidjiboModule(typeof(Program).Assembly)); containerBuilder.RegisterInstance <ILogger>(logger); var container = containerBuilder.Build(); // Setup Quidjibo var quidjiboBuilder = new QuidjiboBuilder() .ConfigureLogging(loggerFactory) .UseAutofac(container) .UseAes(Encoding.ASCII.GetBytes(WorkerConfig.PayloadKey)) .UseSqlServer(WorkerConfig.WorkerDbConnectionString) .ConfigurePipeline(pipeline => pipeline.UseDefault()); // Quidjibo Client var client = quidjiboBuilder.BuildClient(); _logger.Log(LogLevel.Information, "Scheduler Started"); //// Long Running Jobs ////await client.PublishAsync(new SystemQueueProcessorCommand(8), cancellationToken); ////await client.PublishAsync(new QueuesProcessorCommand(4), cancellationToken); var isEventsOnly = Environment.GetEnvironmentVariable("RESGRID__EVENTSONLY"); if (String.IsNullOrWhiteSpace(isEventsOnly) || isEventsOnly.ToLower() == "false") { _logger.Log(LogLevel.Information, "Starting Scheduled Jobs"); // Scheduled Jobs _logger.Log(LogLevel.Information, "Scheduling Calendar Notifications"); await client.ScheduleAsync("Calendar Notifications", new CalendarNotificationCommand(1), Cron.MinuteIntervals(20), stoppingToken); //System.Console.WriteLine("Scheduling Calendar Notifications"); //await client.ScheduleAsync("Call Email Import", // new CallEmailImportCommand(2), // Cron.MinuteIntervals(5), // cancellationToken); _logger.Log(LogLevel.Information, "Scheduling Call Pruning"); await client.ScheduleAsync("Call Pruning", new CallPruneCommand(3), Cron.MinuteIntervals(60), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Report Delivery"); await client.ScheduleAsync("Report Delivery", new ReportDeliveryTaskCommand(5), Cron.MinuteIntervals(14), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Shift Notifier"); await client.ScheduleAsync("Shift Notifier", new ShiftNotiferCommand(6), Cron.MinuteIntervals(720), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Staffing Schedule"); await client.ScheduleAsync("Staffing Schedule", new Commands.StaffingScheduleCommand(7), Cron.MinuteIntervals(5), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Training Notifier"); await client.ScheduleAsync("Training Notifier", new TrainingNotiferCommand(9), Cron.MinuteIntervals(30), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Status Schedule"); await client.ScheduleAsync("Status Schedule", new Commands.StatusScheduleCommand(11), Cron.MinuteIntervals(5), stoppingToken); } else { _logger.Log(LogLevel.Information, "Starting in Events Only Mode!"); } // Quidjibo Server using (var workServer = quidjiboBuilder.BuildServer()) { // Start Quidjibo workServer.Start(); stoppingToken.WaitHandle.WaitOne(); } //while (!cancellationToken.IsCancellationRequested) //{ // await Task.Delay(TimeSpan.FromSeconds(1)); //} }