public static void StartUp() { Console.WriteLine("Daemon Job launches ..."); JobScheduler.StartUp(); var jobList = JobScheduler.JobList; //if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(FreeAgentAutoClockIn).AssemblyQualifiedName)) //{ // JobScheduler.AddJob(new JobItem // { // AssemblyQualifiedName = typeof(FreeAgentAutoClockIn).AssemblyQualifiedName, // Description = "自由教練打卡", // Schedule = DateTime.Today.Add(new TimeSpan(0, 0, 0)) // }); //} if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(ReviewProfessionalLevelEachQuarter).AssemblyQualifiedName)) { JobScheduler.AddJob(new JobItem { AssemblyQualifiedName = typeof(ReviewProfessionalLevelEachQuarter).AssemblyQualifiedName, Description = "檢查教練等級", Schedule = (new DateTime(DateTime.Today.Year, (DateTime.Today.Month - 1) / 3 * 3 + 1, 16)).AddMonths(3).Add(new TimeSpan(0, 10, 0)), Pending = true, }); } if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(CheckInvoiceDispatch).AssemblyQualifiedName)) { JobScheduler.AddJob(new JobItem { AssemblyQualifiedName = typeof(CheckInvoiceDispatch).AssemblyQualifiedName, Description = "檢查電子發票傳送大平台LOG", Schedule = DateTime.Today.Add(new TimeSpan(0, 0, 0)) }); } if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(MonthlyJob).AssemblyQualifiedName)) { JobScheduler.AddJob(new JobItem { AssemblyQualifiedName = typeof(MonthlyJob).AssemblyQualifiedName, Description = "每月登錄員工福利課", Schedule = DateTime.Today.Add(new TimeSpan(0, 0, 0)) }); } if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(DailyJob).AssemblyQualifiedName)) { JobScheduler.AddJob(new JobItem { AssemblyQualifiedName = typeof(DailyJob).AssemblyQualifiedName, Description = "每日檢查過期合約", Schedule = DateTime.Today.Add(new TimeSpan(0, 0, 0)) }); } }
/// <summary> /// Creation of a job to create the next reminder /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task CreateNextReminderJobAsync() { var timeStamp = DateTime.Now.AddHours(2); await using (var unused = (await _lockFactory.CreateLockAsync().ConfigureAwait(false)).ConfigureAwait(false)) { if (_currentJobName != null) { _jobScheduler.RemoveJob(_currentJobName); _currentJobName = null; _currentJob = null; } using (var dbFactory = RepositoryFactory.CreateInstance()) { var next = await dbFactory.GetRepository <FractalRegistrationRepository>() .GetQuery() .Where(obj => obj.AppointmentTimeStamp > timeStamp) .GroupBy(obj => new { obj.ConfigurationId, obj.AppointmentTimeStamp }) .Select(obj => new { TimeStamp = obj.Key.AppointmentTimeStamp, Count = obj.Count() }) .Where(obj => obj.Count >= 5) .Select(obj => (DateTime?)obj.TimeStamp) .OrderBy(obj => obj) .FirstOrDefaultAsync() .ConfigureAwait(false); if (next != null) { _currentJob = new FractalReminderJob(next.Value); _currentJobName = _jobScheduler.AddJob(_currentJob, next.Value.AddHours(-2)); } } } }
public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("SqlAzureBackup.Worker entry point called", "Information"); Trace.WriteLine("Setting up jobs", "Info"); var jobScheduler = new JobScheduler <SqlAzureBackupJobContext>( blobNextExecutionTimeName: "sql-azure-backups/azure-backup-next-execution-time.txt", jobContext: new SqlAzureBackupJobContext(), frequency: new TimeSpan(AzureHelper.BackupFrequencyInHours, 0, 0)); jobScheduler.AddJob(new ResolveDatacenterJob()); jobScheduler.AddJob(new ExportBacpacJob()); jobScheduler.AddJob(new CheckBacpacStatusJob()); jobScheduler.AddJob(new SendFileViaFTP()); Trace.WriteLine("Starting the WorkerRole loop", "Info"); while (true) { jobScheduler.TryExecuteJobs(); Thread.Sleep(1000); } }
public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("SqlAzureBackup.Worker entry point called", "Information"); Trace.WriteLine("Setting up jobs", "Info"); var jobScheduler = new JobScheduler<SqlAzureBackupJobContext>( blobNextExecutionTimeName: "sql-azure-backups/azure-backup-next-execution-time.txt", jobContext: new SqlAzureBackupJobContext(), frequency: new TimeSpan(AzureHelper.BackupFrequencyInHours, 0, 0)); jobScheduler.AddJob(new ResolveDatacenterJob()); jobScheduler.AddJob(new ExportBacpacJob()); jobScheduler.AddJob(new CheckBacpacStatusJob()); jobScheduler.AddJob(new SendFileViaFTP()); Trace.WriteLine("Starting the WorkerRole loop", "Info"); while (true) { jobScheduler.TryExecuteJobs(); Thread.Sleep(1000); } }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, CatalogDbContext catalogDbContext, IBrokerEndpointsConfigurationBuilder endpoints, JobScheduler jobScheduler) { ConfigureRequestPipeline(app); catalogDbContext.Database.Migrate(); endpoints .AddOutbound <IIntegrationEvent>( FileSystemEndpoint.Create("catalog-events", _configuration["Broker:Path"])) .Connect(); jobScheduler.AddJob("outbound-queue-worker", TimeSpan.FromMilliseconds(100), s => s.GetRequiredService <OutboundQueueWorker>().ProcessQueue()); // Configure outbound worker }
public static void StartUp() { Console.WriteLine("Daemon Job launches ..."); JobScheduler.StartUp(Settings.Default.CheckMessageIntervalInMinutes * 60000); var jobList = JobScheduler.JobList; if (jobList == null || !jobList.Any(j => j.AssemblyQualifiedName == typeof(CommunityMessageDispatcher).AssemblyQualifiedName)) { var jobItem = new JobItem { AssemblyQualifiedName = typeof(CommunityMessageDispatcher).AssemblyQualifiedName, Description = "檢查BA訊息公告", Schedule = DateTime.Today.Add(new TimeSpan(0, 10, 0)) }; JobScheduler.AddJob(jobItem); JobScheduler.LaunchJob(jobItem); } }
public async Task <ActionResult> Resume(int id) { var task = await _db.Task.FirstOrDefaultAsync(s => s.Id == id); if (task != null) { task.Status = 1; await _db.SaveChangesAsync(); if (await scheduler.IsJobExist(task.Name, task.JobGroup)) { scheduler.ResumeJob(task.Name, task.JobGroup); } else { await scheduler.AddJob(task); } } return(Json(new ApiResultModel <bool>())); }