public async Task RunMain() { try { // construct a scheduler factory NameValueCollection props = new NameValueCollection { { "quartz.serializer.type", "binary" } }; StdSchedulerFactory factory = new StdSchedulerFactory(props); // get a scheduler IScheduler sched = await factory.GetScheduler(); await sched.Start(); // define the job and tie it to our DumbJob class IList <DateTimeOffset> myStateData = new List <DateTimeOffset>(); // ReSharper disable once UseObjectOrCollectionInitializer JobDataMap newJobDataMap = new JobDataMap(); newJobDataMap.Add("jobSays", "MoreAboutJobsMerged running..."); newJobDataMap.Add("myStateData", myStateData); newJobDataMap.Add("myFloatValue", 3.141f); IJobDetail job = JobBuilder.Create <DumbJobMerged>() .WithIdentity("myJob", "group1") // name "myJob", group "group1" .UsingJobData("guid", Guid.NewGuid().ToString()) .SetJobData(newJobDataMap) .Build(); // Trigger the job to run now, and then every 40 seconds ITrigger trigger = TriggerBuilder.Create() .WithIdentity("myTrigger", "group1") .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(2) .RepeatForever()) .Build(); await sched.ScheduleJob(job, trigger); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task StartAsync(CancellationToken cancellationToken) { var endpoints = _dashboardService.EndpointService.GetScheduledEndpoints(); var props = new NameValueCollection { { "quartz.serializer.type", "binary" } }; var factory = new StdSchedulerFactory(props); _scheduler = await factory.GetScheduler(); await _scheduler.Start(); foreach (var endpoint in endpoints.Where(m => m.Schedule != null)) { var dataMap = new JobDataMap(); dataMap.Add(nameof(ScheduledEndpointJob.Endpoint), endpoint); dataMap.Add(nameof(ScheduledEndpointJob.ExecutionService), _executionService); dataMap.Add(nameof(ScheduledEndpointJob.MemoryCache), _memoryCache); var job = JobBuilder.Create <ScheduledEndpointJob>() .UsingJobData(dataMap) .Build(); ITrigger trigger = null; if (endpoint.Schedule.Cron != null) { trigger = TriggerBuilder.Create() .StartNow() .WithSchedule(CronScheduleBuilder.CronSchedule(endpoint.Schedule.Cron)) .Build(); } else { trigger = TriggerBuilder.Create() .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds((int)endpoint.Schedule.Every.TotalSeconds) .RepeatForever()) .Build(); } await _scheduler.ScheduleJob(job, trigger); } }
private JobDataMap GetImportJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)aadApplicationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.InputDir, inputFolderTextBox.Text }, { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.UploadErrorsDir, uploadErrorsFolderTextBox.Text }, { SettingsConstants.Company, legalEntityTextBox.Text }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked.ToString() }, { SettingsConstants.ExecutionJobPresent, useMonitoringJobCheckBox.Checked.ToString() }, { SettingsConstants.SearchPattern, searchPatternTextBox.Text }, { SettingsConstants.OrderBy, orderByComboBox.SelectedItem.ToString() }, { SettingsConstants.ReverseOrder, orderDescendingRadioButton.Checked.ToString() }, { SettingsConstants.ExecuteImport, executeImportCheckBox.Checked.ToString() }, { SettingsConstants.OverwriteDataProject, overwriteDataProjectCheckBox.Checked.ToString() }, { SettingsConstants.DataProject, dataProject.Text }, { SettingsConstants.PackageTemplate, packageTemplateTextBox.Text }, { SettingsConstants.RetryCount, retriesCountUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked.ToString() }, { SettingsConstants.GetAzureWriteUrlActionPath, getAzureWriteUrlPath }, { SettingsConstants.ImportFromPackageActionPath, importFromPackagePath }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked.ToString() }, { SettingsConstants.DelayBetweenFiles, numericUpDownInterval.Value.ToString(CultureInfo.InvariantCulture) } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
private JobDataMap GetUploadJobDataMap() { var dataJob = (DataJob)dataJobComboBox.SelectedItem; var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)appRegistrationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.InputDir, inputFolderTextBox.Text }, { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.UploadErrorsDir, uploadErrorsFolderTextBox.Text }, { SettingsConstants.Company, legalEntityTextBox.Text }, { SettingsConstants.EntityName, dataJob.EntityName }, { SettingsConstants.IsDataPackage, isDataPackageCheckBox.Checked }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.UseADAL, instance.UseADAL }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.ActivityId, dataJob.ActivityId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked }, { SettingsConstants.ProcessingJobPresent, useMonitoringJobCheckBox.Checked }, { SettingsConstants.SearchPattern, searchPatternTextBox.Text }, { SettingsConstants.OrderBy, orderByComboBox.SelectedItem.ToString() }, { SettingsConstants.ReverseOrder, orderDescendingRadioButton.Checked }, { SettingsConstants.RetryCount, retriesCountUpDown.Value }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked }, { SettingsConstants.DelayBetweenFiles, numericUpDownIntervalUploads.Value }, { SettingsConstants.LogVerbose, verboseLoggingCheckBox.Checked } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
private JobDataMap GetJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)appRegistrationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.DownloadSuccessDir, downloadFolder.Text }, { SettingsConstants.DownloadErrorsDir, errorsFolder.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.UseADAL, instance.UseADAL }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UnzipPackage, unzipCheckBox.Checked }, { SettingsConstants.AddTimestamp, addTimestampCheckBox.Checked }, { SettingsConstants.DeletePackage, deletePackageCheckBox.Checked }, { SettingsConstants.DataProject, dataProject.Text }, { SettingsConstants.Company, legalEntity.Text }, { SettingsConstants.DelayBetweenFiles, delayBetweenAttemptsNumericUpDown.Value }, { SettingsConstants.DelayBetweenStatusCheck, delayBetweenStatusCheckNumericUpDown.Value }, { SettingsConstants.RetryCount, retriesCountUpDown.Value }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked }, { SettingsConstants.ExportToPackageActionPath, exportToPackageTextBox.Text }, { SettingsConstants.GetExecutionSummaryStatusActionPath, getExecutionSummaryStatusTextBox.Text }, { SettingsConstants.GetExportedPackageUrlActionPath, getExportedPackageUrlTextBox.Text }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked }, { SettingsConstants.LogVerbose, verboseLoggingCheckBox.Checked }, { SettingsConstants.PostDownloadScript, postDownloadScript.Text }, { SettingsConstants.PostTaskScript, postTaskScript.Text }, }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
private static async Task RunScheduler() { // 创建作业调度器 ISchedulerFactory factory = new StdSchedulerFactory(); IScheduler scheduler = await factory.GetScheduler(); // 开始运行调度器 await scheduler.Start(); // Job的附属信息 var jobDataMap = new JobDataMap(); jobDataMap.Add("name", "beck"); jobDataMap.Add("times", 1); // 创建一个作业 IJobDetail job = JobBuilder.Create <HelloJob>() .WithIdentity("job1", "jobGroup1") .UsingJobData(jobDataMap) .StoreDurably() .Build(); // Trigger的附属信息 var triggerDataMap = new JobDataMap(); triggerDataMap.Add("age", 28); // 创建一个触发器 ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger1", "triggerGroup1") .UsingJobData(triggerDataMap) .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(2) .WithRepeatCount(10)) .Build(); // 加入作业调度器中 await scheduler.ScheduleJob(job, trigger); await Task.Delay(TimeSpan.FromMinutes(2)); // 关闭scheduler await scheduler.Shutdown(true); }
private JobDataMap GetExecutionJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)appRegistrationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingSuccessDir, processingSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingErrorsDir, processingErrorsFolderTextBox.Text }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.UseADAL, instance.UseADAL }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked }, { SettingsConstants.RetryCount, retriesCountUpDown.Value }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked }, { SettingsConstants.GetExecutionSummaryStatusActionPath, getExecutionSummaryStatusTextBox.Text }, { SettingsConstants.GetExecutionSummaryPageUrlActionPath, getExecutionSummaryPageUrlTextBox.Text }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked }, { SettingsConstants.GetImportTargetErrorKeysFile, downloadErrorKeysFileCheckBox.Checked }, { SettingsConstants.GetImportTargetErrorKeysFileUrlPath, getImportTargetErrorKeysFileUrlTextBox.Text }, { SettingsConstants.GenerateImportTargetErrorKeysFilePath, generateImportTargetErrorKeysFileTextBox.Text }, { SettingsConstants.PackageTemplate, packageTemplateTextBox.Text }, { SettingsConstants.DelayBetweenStatusCheck, statusCheckDelayNumericUpDown.Value }, { SettingsConstants.GetExecutionErrors, getExecutionErrorsCheckBox.Checked }, { SettingsConstants.GetExecutionErrorsPath, getExecutionErrorsTextBox.Text }, { SettingsConstants.LogVerbose, verboseLoggingCheckBox.Checked } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
public void UpdateMap <T>(T data, JobDataMap map) where T : class, new() { IEnumerable <PropertyInfo> properties = GetProperies <T>(); foreach (PropertyInfo p in properties) { map.Add(p.Name, p.GetValue(data)); } }
public void JobDataMap() { var expected = new JobDataMap(); expected.Add("key1", "value1"); expected.Add("key2", 234.5); expected.Add("key3", true); expected.Add("key4", "{ \"name\": \"Jim\" }"); var bsonDoc = expected.ToBsonDocument(); var actual = BsonSerializer.Deserialize <JobDataMap>(bsonDoc); foreach (var key in expected.Keys) { Assert.AreEqual(expected[key], actual[key]); } }
private JobDataMap GetImportJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)aadApplicationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.InputDir, inputFolderTextBox.Text }, { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.UploadErrorsDir, uploadErrorsFolderTextBox.Text }, { SettingsConstants.Company, legalEntityTextBox.Text }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked.ToString() }, { SettingsConstants.ExecutionJobPresent, useMonitoringJobCheckBox.Checked.ToString() }, { SettingsConstants.SearchPattern, searchPatternTextBox.Text }, { SettingsConstants.OrderBy, orderByComboBox.SelectedItem.ToString() }, { SettingsConstants.ReverseOrder, orderDescendingRadioButton.Checked.ToString() }, { SettingsConstants.ExecuteImport, executeImportCheckBox.Checked.ToString() }, { SettingsConstants.OverwriteDataProject, overwriteDataProjectCheckBox.Checked.ToString() }, { SettingsConstants.DataProject, dataProject.Text }, { SettingsConstants.PackageTemplate, packageTemplateTextBox.Text }, //Start - DManc - 2017/10/13 { SettingsConstants_M.SSISPackage, ssisPackage.Text }, { SettingsConstants_M.SSISOutputPathParmName, ssisOutputPathParmName.Text }, { SettingsConstants_M.TempDir, tempDirTextBox.Text } //End - DManc - 2017/10/13 }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
private static JobDataMap GetJobDataMap(ISchJob job) { var res = new JobDataMap(); foreach (var p in job.Job_JobParam_List) { res.Add(p.Name, p.Value); } return(res); }
/// <summary> /// 获取请求参数 /// </summary> /// <param name="input"></param> /// <returns></returns> private static JobDataMap GetJobDataMap(ScheduleJobInput input) { JobDataMap map = new JobDataMap(); foreach (var param in input.Parameters) { map.Add(param.Key, param.Value); } return(map); }
/// <summary> /// Starte den Quartz-Service /// </summary> /// <returns></returns> public async Task runScheduledService() { // construct a scheduler factory StdSchedulerFactory factory = new StdSchedulerFactory(); // get a scheduler IScheduler scheduler = await factory.GetScheduler(); await scheduler.Start(); // job data map JobDataMap jobData = new JobDataMap(); jobData.Add("service", userCheckSevice); jobData.Add("service1", contactCheckDateService); TimeSpan addToCheckDate = TimeSpan.FromDays(1); TimeSpan.TryParse(Configuration["DeleteInactiveUsers:AddToCheckDate"], out addToCheckDate); jobData.Add("addToCheckDate", addToCheckDate); // define the job and tie it to our ExecuteJob class IJobDetail job = JobBuilder.Create <ExecuteJob>() .UsingJobData(jobData) .WithIdentity("myJob", "group") .Build(); TimeSpan schedule = TimeSpan.FromHours(4); TimeSpan.TryParse(Configuration["DeleteInactiveUsers:ScheduleInterval"], out schedule); // Trigger the job to run now, and then every x hours (see configuration) ITrigger trigger = TriggerBuilder.Create() .WithIdentity("myTrigger", "group") .StartNow() .WithSimpleSchedule(x => x .WithInterval(schedule) .RepeatForever()) .Build(); await scheduler.ScheduleJob(job, trigger); }
private JobDataMap GetExecutionJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)aadApplicationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingSuccessDir, processingSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingErrorsDir, processingErrorsFolderTextBox.Text }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked.ToString() }, { SettingsConstants.RetryCount, retriesCountUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked.ToString() }, { SettingsConstants.GetExecutionSummaryStatusActionPath, getExecutionSummaryStatusPath }, { SettingsConstants.GetExecutionSummaryPageUrlActionPath, getExecutionSummaryPageUrlPath }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked.ToString() }, { SettingsConstants.GetImportTargetErrorKeysFile, downloadErrorKeysFileCheckBox.Checked.ToString() }, { SettingsConstants.GetImportTargetErrorKeysFileUrlPath, getImportTargetErrorKeysFileUrlPath }, { SettingsConstants.GenerateImportTargetErrorKeysFilePath, generateImportTargetErrorKeysFilePath } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } map.Add(SettingsConstants.LegalEntityFileSeperator, LegalEntityFileSeperator.Text); return(map); }
private JobDataMap GetJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)aadApplicationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.DownloadSuccessDir, downloadFolder.Text }, { SettingsConstants.DownloadErrorsDir, errorsFolder.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked.ToString() }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UnzipPackage, unzipCheckBox.Checked.ToString() }, { SettingsConstants.AddTimestamp, addTimestampCheckBox.Checked.ToString() }, { SettingsConstants.DeletePackage, deletePackageCheckBox.Checked.ToString() }, { SettingsConstants.DataProject, dataProject.Text }, { SettingsConstants.Company, legalEntity.Text }, { SettingsConstants.Interval, numericUpDownInterval.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.StatusCheckInterval, statusCheckInterval.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.RetryCount, retriesCountUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked.ToString() }, { SettingsConstants.ExportToPackageActionPath, exportToPackagePath }, { SettingsConstants.GetExecutionSummaryStatusActionPath, getExecutionSummaryStatusPath }, { SettingsConstants.GetExportedPackageUrlActionPath, getExportedPackageUrlPath }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked.ToString() } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
public static void IncrementRetryCount(this JobDataMap source) { if (!source.ContainsKey(RetriesCountKey)) { source.Add(RetriesCountKey, 0); } var currentCount = (int)source[RetriesCountKey]; source[RetriesCountKey] = ++currentCount; }
private JobDataMap getJobDataMap() { JobDataMap map = new JobDataMap(); foreach (ListViewItem item in jobDataListView.Items) { map.Add(item.SubItems[0].Text, item.SubItems[1].Text); } return(map); }
public void JobDetailImplTest() { var jobDataMap = new JobDataMap(); jobDataMap.Add("key1", "value1"); jobDataMap.Add("key2", true); var expected = (JobDetailImpl)JobBuilder.Create <Job1>() .WithIdentity("job1", "group1") .WithDescription("Email sender job") .StoreDurably() .UsingJobData(jobDataMap) .Build(); var bsonDoc = expected.ToBsonDocument(); var actual = BsonSerializer.Deserialize <JobDetailImpl>(bsonDoc); Assert.AreEqual(expected, actual); }
public static JobDataMap GetJobDataMap(SchedulesJob job) { var jobDataMap = new JobDataMap(); foreach (var jobEntry in job.JobDataMap) { jobDataMap.Add(jobEntry.Key, jobEntry.Value); } return(jobDataMap); }
/// <summary> /// 刷新Job列表 /// </summary> /// <param name="sched"></param> private void RefreshJobList(IScheduler sched) { try { lock (syncRoot) { logger.Info("更新Job列表..."); jobList = JobManager.Instance().GetJobInfoList(); sched.Clear(); foreach (JobInfo jobInfo in jobList) { try { JobDataMap dataMap = new JobDataMap(); dataMap.Add("JobInfo", jobInfo); IJobDetail job = JobBuilder.Create <JinRi.Job.HttpScheduler.SchedulerJob>().SetJobData(dataMap).WithIdentity(jobInfo.Name, "Job_" + jobInfo.GroupName).WithDescription(jobInfo.JobDescription).Build(); ITrigger trigger = null; switch (jobInfo.TriggerType) { case JobInfoTriggerType.SimpleTrigger: trigger = (ISimpleTrigger)TriggerBuilder.Create().WithIdentity("Trigger_" + jobInfo.Name, "Trigger_" + jobInfo.GroupName) .StartAt(new DateTimeOffset(jobInfo.StartTime)).WithSimpleSchedule(x => x.WithIntervalInMinutes(jobInfo.RepeatInterval).WithRepeatCount(jobInfo.RepeatCount)).Build(); break; case JobInfoTriggerType.CronTrigger: trigger = (ICronTrigger)TriggerBuilder.Create().WithIdentity("Trigger_" + jobInfo.Name, "Trigger_" + jobInfo.GroupName) .WithCronSchedule(jobInfo.CronExpression).Build(); break; default: break; } if (trigger != null) { sched.ScheduleJob(job, trigger); } else { logger.Info(string.Format("{0} trigger is null.", jobInfo.Name)); } } catch (Exception ex) { logger.Error(string.Format("加载JOB信息报错{0}:{1}", jobInfo.Name, ex.ToString())); } } } } catch (Exception ex) { logger.Error("SchedulerService.LoadJobList." + ex.ToString()); } }
private JobDataMap GetQuartzJobDataMap(TriggerDto trigger) { var dataMap = new JobDataMap(); foreach (var item in trigger.DataMap) { var value = 0; dataMap.Add(item.Name, value); } return(dataMap); }
private async void RunTask2() { if (string.IsNullOrEmpty(configM.CornStr)) { MessageBox.Show("请重新获取配置信息!"); return; } try { sched = await schedFact.GetScheduler(); await sched.Start(); JobDataMap map = new JobDataMap(); map.Add("conf", configM); map.Add("url", CURR_URI); map.Add("scm", CURR_SCM); map.Add("sopr", CURR_OPR); map.Add("sbid", CURR_DBID); map.Add("loc", CURR_DIR); map.Add("rm", CURR_RM); map.Add("dload", false); IJobDetail job = JobBuilder.Create <ProdDataUpJob>() .WithIdentity(JobName, Group) .SetJobData(map) .Build(); // 4.创建 trigger DateTime d2 = DateTime.Now; int m = d2.Minute + 1; int h = d2.Hour; string cron = "0 " + m + " " + h + " " + d2.Day + " * ? "; ITrigger trigger = TriggerBuilder.Create() .WithIdentity(TrigName, Group) .WithCronSchedule(cron) .Build(); // 5.使用trigger规划执行任务job await sched.ScheduleJob(job, trigger); pic_state.Image = Resources.work; makeUIEnable(false); btn_start.Enabled = false; btn_stop.Enabled = true; } catch (Exception ex) { logger.Error(ex); MessageBox.Show(ex.Message); } }
private async void RunTask() { if (string.IsNullOrEmpty(configM.CornStr)) { MessageBox.Show("请重新获取配置信息!"); return; } try { sched = await schedFact.GetScheduler(); await sched.Start(); JobDataMap map = new JobDataMap(); map.Add("conf", configM); map.Add("url", CURR_URI); map.Add("scm", CURR_SCM); IJobDetail job = JobBuilder.Create <ProdDataUpJob>() .WithIdentity(JobName, Group) .SetJobData(map) .Build(); // 4.创建 trigger ITrigger trigger = TriggerBuilder.Create() .WithIdentity(TrigName, Group) .WithCronSchedule(configM.CornStr) .Build(); // 5.使用trigger规划执行任务job await sched.ScheduleJob(job, trigger); pic_state.Image = Resources.work; makeUIEnable(false); btn_start.Enabled = false; btn_stop.Enabled = true; } catch (Exception ex) { logger.Error(ex); MessageBox.Show(ex.Message); } }
private JobDataMap GetJobDataMap() { var dataJob = (DataJob)dataJobComboBox.SelectedItem; var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var application = (AadApplication)appRegistrationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.DownloadSuccessDir, downloadFolder.Text }, { SettingsConstants.DownloadErrorsDir, errorsFolder.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.UseADAL, instance.UseADAL }, { SettingsConstants.ActivityId, dataJob.ActivityId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.UnzipPackage, unzipCheckBox.Checked }, { SettingsConstants.AddTimestamp, addTimestampCheckBox.Checked }, { SettingsConstants.DeletePackage, deletePackageCheckBox.Checked }, { SettingsConstants.RetryCount, retriesCountUpDown.Value }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked }, { SettingsConstants.DelayBetweenFiles, delayBetweenFilesNumericUpDown.Value }, { SettingsConstants.LogVerbose, verboseLoggingCheckBox.Checked } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
private async void ExcuteTask() { if (!checkConfigFLDInfo()) { return; } if (!CheckServer()) { return; } sched = await schedFact.GetScheduler(); await sched.Start(); JobDataMap map = new JobDataMap(); map.Add("conf", configM); map.Add("url", CURR_URI); map.Add("scm", CURR_SCM); map.Add("dbid", CURR_DBID); map.Add("opr", CURR_OPR); IJobDetail job = JobBuilder.Create <WeighDataUpJob>() .WithIdentity(JobName, Group) .SetJobData(map) .Build(); // 4.创建 trigger ITrigger trigger = TriggerBuilder.Create() .WithIdentity(TrigName, Group) .WithCronSchedule(configM.CornStr) .Build(); // 5.使用trigger规划执行任务job await sched.ScheduleJob(job, trigger); pic_state.Image = Resources.work; makeUIEnable(false); btn_start.Enabled = false; btn_stop.Enabled = true; }
private JobDataMap GetProcessingJobDataMap() { var instance = (Instance)instanceComboBox.SelectedItem; var user = (User)userComboBox.SelectedItem; var dataJob = (DataJob)dataJobComboBox.SelectedItem; var application = (AadApplication)aadApplicationComboBox.SelectedItem; var map = new JobDataMap { { SettingsConstants.UploadSuccessDir, uploadSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingSuccessDir, processingSuccessFolderTextBox.Text }, { SettingsConstants.ProcessingErrorsDir, processingErrorsFolderTextBox.Text }, { SettingsConstants.StatusFileExtension, statusFileExtensionTextBox.Text }, { SettingsConstants.AadTenant, instance.AadTenant }, { SettingsConstants.AzureAuthEndpoint, instance.AzureAuthEndpoint }, { SettingsConstants.AosUri, instance.AosUri }, { SettingsConstants.AadClientId, application.ClientId }, { SettingsConstants.ActivityId, dataJob.ActivityId }, { SettingsConstants.UseServiceAuthentication, serviceAuthRadioButton.Checked.ToString() }, { SettingsConstants.RetryCount, retriesCountUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.RetryDelay, retriesDelayUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.PauseJobOnException, pauseOnExceptionsCheckBox.Checked.ToString() }, { SettingsConstants.IndefinitePause, pauseIndefinitelyCheckBox.Checked.ToString() }, { SettingsConstants.DelayBetweenStatusCheck, delayBetweenStatusCheckNumericUpDown.Value.ToString(CultureInfo.InvariantCulture) }, { SettingsConstants.GetExecutionErrors, getExecutionErrorsCheckBox.Checked.ToString() }, { SettingsConstants.LogVerbose, verboseLoggingCheckBox.Checked.ToString() } }; if (serviceAuthRadioButton.Checked) { map.Add(SettingsConstants.AadClientSecret, application.Secret); } else { map.Add(SettingsConstants.UserName, user.Login); map.Add(SettingsConstants.UserPassword, user.Password); } return(map); }
public void crearSchedulerEvento(String nombre, int tipoEvento, DateTime fechaIni, Evento even) { JobDataMap jobData = new JobDataMap(); jobData.Add(nombre, even); IJobDetail jobComp = JobBuilder.Create <JobComp>().WithIdentity(nombre, "grupoEjemplo").UsingJobData(jobData).Build(); //ITrigger triggerComp = TriggerBuilder.Create().WithIdentity(nombre, "grupoEjemplo").StartNow() // .WithSimpleSchedule(x => x.WithIntervalInSeconds(5).RepeatForever()).Build(); ITrigger triggerComp = crearTrigger(tipoEvento, fechaIni, nombre); this.agregarTask(jobComp, triggerComp); }
/// <summary> /// 创建作业 /// </summary> /// <returns></returns> protected virtual IJobDetail GetJobDetail() { JobDataMap jobDataMap = new JobDataMap(); jobDataMap.Add("prms", this.T8TaskEntity); var job = JobBuilder.Create <T>() .WithIdentity(JobName, GroupName) .UsingJobData(jobDataMap) .Build(); return(job); }
/// <summary> /// 获取参数,根据JToken(json文件的内容) /// </summary> /// <param name="result"></param> /// <returns></returns> private JobDataMap GetJobDataMap(JToken result) { var data = new JobDataMap(); if (result == null) { return(data); } foreach (var val in result) { var name = val["Name"].ToString(); switch (val["Type"].ToString()) { case "String": data.Add(name, val["Value"].ToString()); break; case "Int": data.Add(name, Convert.ToInt32(val["Value"])); break; case "Double": data.Add(name, Convert.ToDouble(val["Value"])); break; case "Bool": data.Add(name, Convert.ToBoolean(val["Value"])); break; default: data.Add(name, val["Value"].ToJson()); break; } } return(data); }
/// <summary> /// 获取参数,根据字符串(数据库存储的内容) /// </summary> /// <param name="str"></param> /// <returns></returns> private JobDataMap GetJobDataMapByStr(string str) { var result = JObject.Parse(str); var data = new JobDataMap(); if (result != null) { foreach (var val in result.Children()) { var v = ((JValue)((JProperty)val).Value).Value; var t = ((JValue)((JProperty)val).Value).Type.ToString(); switch (t) { case "String": data.Add(val.Path, v.ToString()); break; case "Int": data.Add(val.Path, Convert.ToInt32(v)); break; case "Double": data.Add(val.Path, Convert.ToDouble(v)); break; case "Bool": data.Add(val.Path, Convert.ToBoolean(v)); break; default: data.Add(val.Path, v.ToString()); break; } } } return(data); }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { if (nominalType != typeof(JobDataMap) || actualType != typeof(JobDataMap)) { var message = string.Format("Can't deserialize a {0} with {1}.", nominalType.FullName, this.GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; if (bsonType == BsonType.Document) { JobDataMap item = new JobDataMap(); bsonReader.ReadStartDocument(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { string key = bsonReader.ReadName(); object value = BsonSerializer.Deserialize<object>(bsonReader); item.Add(key, value); } bsonReader.ReadEndDocument(); return item; } else if (bsonType == BsonType.Null) { bsonReader.ReadNull(); return null; } else { var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType); throw new BsonSerializationException(message); } }
public void CanScheduleJobWithData() { JobDataMap dataMap = new JobDataMap(); dataMap.Add("itemId", Guid.NewGuid()); dataMap.Add("date", DateTime.UtcNow); dataMap.Add("int", 6); dataMap.Add("string", "this is a string"); IJobDetail job = JobBuilder.Create<HelloWorldJob>() .WithIdentity("HelloWorld", "HelloWorldGroup") .RequestRecovery(true) .SetJobData(dataMap) .WithDescription("Job that says 'Hello World!'") .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("HelloWorldTrigger", "HelloWorldGroup") .WithDescription("A test trigger") .WithSimpleSchedule(x => x.WithIntervalInMinutes(5).WithRepeatCount(10)) .StartNow() .Build(); scheduler.ScheduleJob(job, trigger); }