public void CanSubmitEmptyCollection() { var request = new JobCollection { companyid = 348 }; var serializer = new XmlSerializer(typeof(JobCollection)); var writer = new StringWriter(); serializer.Serialize(writer, request); writer.Flush(); var requestXml = writer.ToString(); string response; var channel = _channelManager.Create(); try { response = channel.Sync(requestXml, Username, Password); } catch (Exception) { _channelManager.Abort(channel); throw; } _channelManager.Close(channel); Assert.AreEqual("0 rows processed", response); }
public override void OnThreadTaskStart() { using (TransactionScope scope = TransactionScopeFactory.Create()) { JobCollection jobs = FetchStandByJobs(this.Params.BatchCount); foreach (JobBase job in jobs) { try { if (job.CanStart(TimeSpan.FromSeconds(10))) { job.SetCurrentJobBeginStatus(); try { Task.Factory.StartNew(() => StartJob(job)); } finally { job.SetCurrentJobEndStatus(); } } } catch (Exception ex) { WriteJobException(job, this.Params.Log, "调度", ex); } } scope.Complete(); } }
private SoT CreateSoT(out JobServer manager, string projectDirectory) { var sot = CreateOnServer(out manager, server => server.CreateSoT(), projectDirectory); JobCollection.AddSoT(sot); return(sot); }
private Job CreateJob(out JobServer manager, string projectDirectory) { var job = CreateOnServer(out manager, server => server.CreateJob(), projectDirectory); JobCollection.AddJob(job); return(job); }
public static void Main() { var jobCollection = new JobCollection(); EmployeeFactory employeeFactory = new EmployeeFactory(); IDictionary <string, IEmployee> employeesByName = new Dictionary <string, IEmployee>(); string command = Console.ReadLine(); while (command != "End") { string[] commandArgs = command.Split(); string commandName = commandArgs[0]; switch (commandName) { case "Job": CreateJob(employeesByName, commandArgs, jobCollection); break; case "Pass": PassWeek(jobCollection); break; case "Status": PrintJobsStatus(jobCollection); break; default: CreateEmployee(employeeFactory, employeesByName, commandArgs); break; } command = Console.ReadLine(); } }
public ActionResult DeleteConfirmed(int id) { try { using (var ctx = new SchedulerDbContext()) { //Get collection from db JobCollection collection = ctx.Collections.Find(id); if (User.IsInRole("SystemAdministrator") || collection.TenantId == CurrentTenant.TenantId) { //Remove collection from db ctx.Collections.Remove(collection); ctx.SaveChanges(); } } } catch (Exception ex) { LogService.Info("Collections not found", ex.Message, ex.InnerException); } return(RedirectToAction("Index")); }
public void JobBaseAdapterTest() { JobBase job = new StartWorkflowJob(); job.JobID = Guid.NewGuid().ToString(); job.Name = "NameTest" + DateTime.Now.ToString(); job.Description = "DescTest" + DateTime.Now.ToString(); job.Creator = new OguUser("6872ac4c-48a2-47fc-a12f-05415dc50042"); //张媛媛 var schedule = CreateMonthlySchedule(); JobScheduleAdapter.Instance.Update(schedule); job.Schedules.Add(schedule); JobBaseAdapter.Instance.Update(job); job.LastExecuteTime = DateTime.Now; JobBaseAdapter.Instance.Update(job); JobCollection coll = JobBaseAdapter.Instance.Load(p => p.AppendItem("JOB_ID", job.JobID)); Assert.IsTrue(coll.Count == 1); Assert.AreEqual(job.Description, coll[0].Description); Assert.AreEqual(job.Schedules[0].Description, coll[0].Schedules[0].Description); JobBaseAdapter.Instance.Delete(job); coll = JobBaseAdapter.Instance.Load(p => p.AppendItem("JOB_ID", job.JobID)); Assert.IsTrue(coll.Count == 0); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //Create the model var model = new JobCollectionViewModel(); var collection = new JobCollection(); try { using (var ctx = new SchedulerDbContext()) { // Get the collection db collection = ctx.Collections.Where(i => i.CollectionId == id).Include("Tenant").Include("Application").FirstOrDefault(); if (User.IsInRole("SystemAdministrator") || collection.TenantId == CurrentTenant.TenantId) { //Add collection to model model.Collection = collection; } else { return(View("Authorize")); } } // Create the breadcrumb var breadcrumb = new List <BreadcrumbItemViewModel>(); breadcrumb.Add(new BreadcrumbItemViewModel() { Text = "Collections", Link = "/Collections" }); breadcrumb.Add(new BreadcrumbItemViewModel() { Text = collection.Name, Link = "/Collections/" + id + "/Details" }); breadcrumb.Add(new BreadcrumbItemViewModel() { Text = "Delete Confirm" }); ViewBag.Breadcrumb = breadcrumb; } catch (Exception ex) { LogService.Info("Collections not found", ex.Message, ex.InnerException); } return(View(model)); }
public static void Main() { EmployeeCollection employeeCollection = new EmployeeCollection(); JobCollection jobCollection = new JobCollection(); Engine engine = new Engine(employeeCollection, jobCollection); engine.Run(); }
/// <summary> /// Initializes a new instance of the <see cref="JobManager"/> class. /// </summary> internal JobManager() { _id = Guid.NewGuid().ToString("N").Substring(0, 10).ToLower(); _providerJobs = new Dictionary<JobProvider, JobCollection>(); _jobLockProviders = new JobLockProviderCollection(); _defaultJobLockProvider = new DefaultJobLockProvider(); _jobProviders = new JobProviderCollection(); _jobs = new JobCollection(); _jobProviderTimer = new Timer(OnJobProviderCallback); }
public JobRunner(IOptionsMonitor <JobRunnerOptions> options, JobCollection jobs, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { _timers = new List <IDisposable>(); _options = options?.CurrentValue ?? throw new ArgumentNullException(nameof(options)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _jobs = jobs ?? throw new ArgumentNullException(nameof(jobs)); options.OnChange(Restart); }
static void Main(string[] args) { ServerConnection conn = new ServerConnection(SqlServer); Server server = new Server(conn); JobCollection jobs = server.JobServer.Jobs; foreach (Job job in jobs) { Console.WriteLine(job.Name); } }
public void RemoveItem() { if (_selectedItem == null) { return; } JobCollection.Remove(_selectedItem); NotifyOfPropertyChange(() => JobCollection); SelectedItem = null; }
private void AddJob(EncodeInfo inJob) { try { JobCollection.Add(inJob); NotifyOfPropertyChange(() => JobCollection); } catch (Exception ex) { Log.Error(ex); } }
public void Load() { JobCollection.Clear(); DAL dal = new DAL(); DataTable dt = dal.Read("select JobRequest_Id,bit_job_type.Job_Type,bit_job_type.Job_Type_Id,RequestDate,Priority,Comments,Status,bit_client_location.Location_Name,bit_client_location.Location_Id from bit_job_request, bit_job_type, bit_client_location where bit_job_request.Job_Type_Id = bit_job_type.Job_Type_Id and bit_job_request.Location_Id = bit_client_location.Location_Id and Status in('Requested','Acknowledged') order by JobRequest_Id"); foreach (DataRow dr in dt.Rows) { JobAssignment job = new JobAssignment(dr); JobCollection.Add(job); } }
public void CanSubmitJob() { var category = new JobCategory { id = 27, name = "Compensation/Return-to-work" }; var job = new Job { id = "187526", title = "This is a TEST job", description = "<strong>This is a TEST Job - Please dont apply</strong> Lorem ipsum dolor sit amet", reference = "Dont Apply", startdate = DateTime.Now, startdateSpecified = true, categories = new[] { category }, jobtype = new JobType { id = 5, name = "Casual" }, region = new JobRegion { id = "20-163-5", name = "Sydney" }, application = new JobApplication { emailto = "*****@*****.**", url = "http://ahri.com/Portal/JobApplication.aspx?Job=187526&Source=93310682-4273-4865-889c-0fff01d66ab7" }, }; var request = new JobCollection { companyid = 348, jobs = new[] { job } }; var serializer = new XmlSerializer(typeof(JobCollection)); var writer = new StringWriter(); serializer.Serialize(writer, request); writer.Flush(); var requestXml = writer.ToString(); string response; var channel = _channelManager.Create(); try { response = channel.Sync(requestXml, Username, Password); } catch (Exception) { _channelManager.Abort(channel); throw; } _channelManager.Close(channel); Assert.AreEqual("1 rows processed, 1 updated", response, "Note: if it's been a while since this test was run this *may* say '1 renewed'. Re-running the test will resolve"); }
private JobCollection InitializeCollection(DataTable dt) { JobCollection retVal = null; if (dt != null && dt.Columns.Count > 0) { retVal = new JobCollection(); foreach (DataRow row in dt.Rows) { Job item = InitializeObject(row); retVal.Add(item); } } return(retVal); }
private void BindTaskList() { WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("ENABLED", "1"); whereBuilder.AppendItem("JOB_STATUS", 0); string category = txtCategory.Text.Trim(); string name = txtName.Text.Trim(); if (string.IsNullOrEmpty(category) == false) whereBuilder.AppendItem("JOB_CATEGORY", category); if (string.IsNullOrEmpty(name) == false) whereBuilder.AppendItem("JOB_NAME", name); this.WfJobs = JobBaseAdapter.Instance.UPDLOCKLoadJobs(decimal.ToInt32(numericUpDown1.Value), whereBuilder); this.dataGridView1.DataSource = this.WfJobs; }
private void QueueCompleted(object sender, QueueCompletedEventArgs args) { _queueProcessor.QueueCompleted -= QueueCompleted; _queueProcessor.QueueProgressChanged -= QueueProgressChanged; _queueProcessor.QueueStarted -= QueueStarted; Execute.OnUIThread(() => { var finishedList = JobCollection.Where(encodeInfo => encodeInfo.NextStep == EncodingStep.Done).ToList(); foreach (var encodeInfo in finishedList) { JobCollection.Remove(encodeInfo); } }); Close(); }
private void PostJobs(string method, List <Job> posts) { #region Log Logger.Raise(Event.Information, method, string.Format("Posting {0} job ads...", posts.Count)); #endregion var request = new JobCollection { companyid = RemoteCompanyId, jobs = posts.ToArray() }; var serializer = new XmlSerializer(typeof(JobCollection)); var writer = new StringWriter(); serializer.Serialize(writer, request); writer.Flush(); var requestXml = writer.ToString(); string response; // Send request. var service = _serviceManager.Create(); try { response = service.Sync(requestXml, RemoteUsername, RemotePassword); } catch (Exception ex) { _serviceManager.Abort(service); _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent { Success = false, IntegratorUserId = _integratorUser.Id, Failed = posts.Count, JobAds = posts.Count }); #region Log Logger.Raise(Event.CriticalError, method, string.Format("Aborting Service. {0}", ex)); #endregion throw; } _serviceManager.Close(service); _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdExportPostEvent { Success = true, IntegratorUserId = _integratorUser.Id, Posted = posts.Count, JobAds = posts.Count }); #region Log Logger.Raise(Event.Information, method, string.Format("Processing complete. {0}", response)); #endregion }
public void RefreshJobList() { try { List <Job> jobList = DataController.GetInstance.GetJobs(); jc = Application.Current.Resources["JobCollection"] as JobCollection; jc.Clear(); foreach (Job job in jobList) { jc.Add(job); } Application.Current.Resources["JobCollection"] = jc; } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
public ActionResult Create([Bind(Include = "CollectionId,TenantId,ApplicationId,Name,Created,Status")] JobCollection collection) { try { using (SchedulerDbContext ctx = new SchedulerDbContext()) { if (User.IsInRole("SystemAdministrator") || collection.TenantId == CurrentTenant.TenantId) { if (ModelState.IsValid) { ctx.Collections.Add(collection); ctx.SaveChanges(); return(RedirectToAction("Index")); } } else { return(View("Authorize")); } } } catch (Exception ex) { LogService.Info("Collections not found", ex.Message, ex.InnerException); } using (var saasDb = new SaasDbContext()) { if (User.IsInRole("SystemAdministrator")) { ViewBag.TenantId = new SelectList(saasDb.Tenants.ToList(), "TenantId", "Name"); ViewBag.ApplicationId = new SelectList(saasDb.Applications.ToList(), "Id", "Name"); } else { ViewBag.TenantId = new SelectList(saasDb.Tenants.Where(i => i.TenantId == CurrentTenant.TenantId).ToList(), "TenantId", "Name"); ViewBag.ApplicationId = new SelectList(saasDb.Applications.Where(a => a.TenantId == CurrentTenant.TenantId).ToList(), "Id", "Name"); } } return(View(collection)); }
public void SearchJobList(string searchTerm) { if (searchTerm.Length == 0 || searchTerm.Equals("Search")) { jlc = jc; Application.Current.Resources["JobListCollection"] = jlc; } else { JobCollection tempList = new JobCollection(); foreach (Job job in jc) { if (job.Job_Number.ToLower().Contains(searchTerm.ToLower()) || job.Job_Status.ToLower().Contains(searchTerm.ToLower())) { tempList.Add(job); } } Application.Current.Resources["JobListCollection"] = tempList; } }
async Task CanConstructJobCollection() { var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "JobCollection.GetAsync.xml")); using (var context = new Context(Scheme.Https, "localhost", 8089)) { var expectedNames = new string[] { "scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401390000_866", "scheduler__admin__search__RMD54d0063ad31759fca_at_1401390000_867", "scheduler__admin__search__RMD581bb7159c0bb0bbb_at_1401390000_862", "scheduler__admin__search__RMD58306e622619a7dcd_at_1401390000_863", "scheduler__admin__search__RMD5a7321db12d7631bf_at_1401390000_865", "scheduler__admin__search__RMD5e658dbdf77ae86f8_at_1401390000_864", "scheduler__admin__search__RMD5f8965a6a2fa31c5d_at_1401390000_861", "scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401386400_859", "scheduler__admin__search__RMD54d0063ad31759fca_at_1401386400_860", "scheduler__admin__search__RMD581bb7159c0bb0bbb_at_1401386400_855", "scheduler__admin__search__RMD58306e622619a7dcd_at_1401386400_856", "scheduler__admin__search__RMD5a7321db12d7631bf_at_1401386400_858", "scheduler__admin__search__RMD5e658dbdf77ae86f8_at_1401386400_857", "scheduler__admin__search__RMD5f8965a6a2fa31c5d_at_1401386400_854" }; var jobs = new JobCollection(context, feed); Assert.Equal(expectedNames.Length, jobs.Count); var names = from job in jobs select job.Name; Assert.Equal(expectedNames, names); CheckCommonProperties("jobs", jobs); for (int i = 0; i < jobs.Count; i++) { var entry = feed.Entries[i]; var job = jobs[i]; CheckJob(entry, job); } } }
private void BindTaskList() { WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("ENABLED", "1"); whereBuilder.AppendItem("JOB_STATUS", 0); string category = txtCategory.Text.Trim(); string name = txtName.Text.Trim(); if (string.IsNullOrEmpty(category) == false) { whereBuilder.AppendItem("JOB_CATEGORY", category); } if (string.IsNullOrEmpty(name) == false) { whereBuilder.AppendItem("JOB_NAME", name); } this.WfJobs = JobBaseAdapter.Instance.UPDLOCKLoadJobs(decimal.ToInt32(numericUpDown1.Value), whereBuilder); this.dataGridView1.DataSource = this.WfJobs; }
public static void Main() { JobCollection jobs = new JobCollection(); Dictionary <string, IEmployee> employees = new Dictionary <string, IEmployee>(); string command = Console.ReadLine(); while (command != "End") { string[] commandArgs = command.Split().ToArray(); if (commandArgs[0] == "PartTimeEmployee") { employees.Add(commandArgs[1], new PartTimeEmployee(commandArgs[1])); } else if (commandArgs[0] == "StandardEmployee") { employees.Add(commandArgs[1], new StandardEmployee(commandArgs[1])); } else if (commandArgs[0] == "Job") { string employeeName = commandArgs[3]; var employee = employees[employeeName]; IJob job = new Job(commandArgs[1], int.Parse(commandArgs[2]), employee); jobs.AddJob(job); } else if (commandArgs[0] == "Pass") { jobs.PassWeek(); } else if (commandArgs[0] == "Status") { jobs.Status(); } command = Console.ReadLine(); } }
/// <summary> /// Finishes queued job. /// </summary> /// <param name="job">Job instance to finish.</param> private static void FinishJob(Job job) { Type type = typeof(JobManager); // Use _queuedJobs collection to remove the job from the queue. FieldInfo queuedFI = type.GetField("_queuedJobs", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); // Use private method of JobManager class to finish the job. MethodInfo finishJobMI = type.GetMethod("FinishJob", BindingFlags.Static | BindingFlags.NonPublic); if (queuedFI != null && finishJobMI != null) { JobCollection queuedJobs = queuedFI.GetValue(null) as JobCollection; if (queuedJobs != null && finishJobMI != null) { // Remove the job from queuedJobs collection. queuedJobs.Remove(job); queuedFI.SetValue(null, queuedJobs); // Move the job to finishedJobs collection. finishJobMI.Invoke(null, new object[] { job }); } } }
public void StartJobManager(string projectDirectory) { try { Server = (JobServer)Activator.GetObject(typeof(JobServer), JobServerConnection.OriginalString); // the proxy won't throw until property access/method call JobCollection = Server.CreateAndAddJobCollection(JobCollectionID); Started = true; } catch (RemotingException) { // n.b. Assembly.Location is wrong with Shadow Copy enabled string assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); string exe = Path.Combine(assemblyDir, "JobManager.exe"); if (!File.Exists(exe)) { exe = Path.GetFullPath(Path.Combine(assemblyDir, "..\\..\\..\\JobManager\\JobManager\\bin\\Release\\JobManager.exe")); } if (!File.Exists(exe)) { exe = Path.Combine(assemblyDir, "..\\..\\..\\JobManager\\JobManager\\bin\\Debug\\JobManager.exe"); } if (File.Exists(exe)) { CreateProcessWithExplicitHandles(exe, exe, projectDirectory); Server = (JobServer)Activator.GetObject(typeof(JobServer), JobServerConnection.OriginalString); JobCollection = Server.CreateAndAddJobCollection(JobCollectionID); Started = true; } else { throw new Exception("Job Manager was not found on your computer. Make sure your META installer is healthy."); } } }
//static readonly string conn = "Data Source=BDC4B-D-75CMX52;Initial Catalog=msdb;Integrated Security=True"; private void sqlJob() { textBox4.Text = ""; ServerConnection conn = new ServerConnection(SqlServer); Server server = new Server(conn); JobCollection jobs = server.JobServer.Jobs; foreach (Job job in jobs) { textBox4.AppendText(job.Name + "" + job.LastRunOutcome); //textBox4.AppendText("Last Run staus" +job.LastRunOutcome); StreamWriter log; if (!File.Exists("Log.txt")) { log = new StreamWriter("Log.txt"); } else { log = File.AppendText(@"C:\Backup\Log.txt"); } log.WriteLine(DateTime.Now + "\t" + "Job Name " + job.Name + "\t" + "Last Run staus" + job.LastRunOutcome + "\t" + "JOb last run date" + job.LastRunDate); log.Flush(); log.Close(); String Connection = ConfigurationManager.AppSettings["SqlConnection"]; SqlConnection conn1 = new SqlConnection(Connection); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn1; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_BP_BackupDetails"; cmd.Parameters.Add("@JobName", SqlDbType.VarChar).Value = job.Name; cmd.Parameters.Add("@LastJobRanStatus", SqlDbType.VarChar).Value = job.LastRunOutcome; cmd.Parameters.Add("@LastJobRanDate", SqlDbType.DateTime).Value = job.LastRunDate; conn1.Open(); cmd.ExecuteNonQuery(); conn1.Close(); } }
private static JobCollection CreateStartWorkflowJob() { JobCollection jobs = new JobCollection(); StartWorkflowJob sJob = new StartWorkflowJob(); sJob.JobID = UuidHelper.NewUuidString(); sJob.ProcessKey = "DefaultApprovalProcess"; sJob.JobID = Guid.NewGuid().ToString(); sJob.Name = "启动流程测试"; sJob.Description = "小测一下"; sJob.Creator = new OguUser("6872ac4c-48a2-47fc-a12f-05415dc50042"); //zhangyy sJob.Operator = new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff"); //wangli5 JobSchedule schedule = CreateSchedule(); JobSchedule schedule0 = CreateSchedule(); sJob.Schedules.Add(schedule); sJob.Schedules.Add(schedule0); jobs.Add(sJob); return(jobs); }
public MainViewModel() { mainWindow = ((MainWindow)Application.Current.MainWindow); slc = Application.Current.Resources["StockListCollection"] as StockPartCollection; jlc = Application.Current.Resources["JobListCollection"] as JobCollection; llc = Application.Current.Resources["LogListCollection"] as LogCollection; CheckInList = new ObservableCollection <Part>() { new Part() { Part_Number = "" } }; CheckOutList = new ObservableCollection <Part>() { new Part() { Part_Number = "" } }; }
private static JobCollection CreateStartWorkflowJob() { JobCollection jobs = new JobCollection(); StartWorkflowJob sJob = new StartWorkflowJob(); sJob.JobID = UuidHelper.NewUuidString(); sJob.ProcessKey = "DefaultApprovalProcess"; sJob.JobID = Guid.NewGuid().ToString(); sJob.Name = "启动流程测试"; sJob.Description = "小测一下"; sJob.Creator = new OguUser("6872ac4c-48a2-47fc-a12f-05415dc50042"); //zhangyy sJob.Operator = new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff"); //wangli5 JobSchedule schedule = CreateSchedule(); JobSchedule schedule0 = CreateSchedule(); sJob.Schedules.Add(schedule); sJob.Schedules.Add(schedule0); jobs.Add(sJob); return jobs; }
public void ClearList() { JobCollection.Clear(); NotifyOfPropertyChange(() => JobCollection); }
/// <summary> /// Asynchronously retrieves a collection of running search jobs. /// </summary> /// <param name="args"> /// Specification of the collection of running search jobs to retrieve. /// </param> /// <remarks> /// This method uses the <a href="http://goo.gl/ja2Sev">GET /// search/jobs</a> endpoint to get the <see cref="JobCollelction"/> /// specified by <see cref="args"/>. /// </remarks> public async Task<JobCollection> GetJobsAsync(JobCollectionArgs args = null) { var jobs = new JobCollection(this.Context, this.Namespace, args); await jobs.GetAsync(); return jobs; }
public JobCollection GetJobsByGroup(string group) { var jobs = new JobCollection(); lock (_initLock) { foreach (var job in _jobs) { if (job.Group == group) jobs.Add(job); } } return jobs; }
private void AddJobs(IEnumerable<IJobConfiguration> jobs, JobProvider provider) { if (jobs == null) return; foreach (var jobConfiguration in jobs) { Type jobType = Type.GetType(jobConfiguration.Type, false, true); if (jobType == null) throw new ConfigurationErrorsException( string.Format("Could not load type '{0}' for job '{1}'.", jobConfiguration.Type, jobConfiguration.Name)); JobLockProvider jobLockProvider = _defaultJobLockProvider; if (!string.IsNullOrEmpty(jobConfiguration.JobLockProvider)) { // first try getting from provider collection jobLockProvider = _jobLockProviders[jobConfiguration.JobLockProvider]; if (jobLockProvider == null) { // next, try loading type Type lockType = Type.GetType(jobConfiguration.JobLockProvider, false, true); if (lockType == null) throw new ConfigurationErrorsException( string.Format("Could not load job lock type '{0}' for job '{1}'.", jobConfiguration.JobLockProvider, jobConfiguration.Name)); jobLockProvider = Activator.CreateInstance(lockType) as JobLockProvider; } // if not found in provider collection or couldn't create type. if (jobLockProvider == null) throw new ConfigurationErrorsException( string.Format("Could not find job lock provider '{0}' for job '{1}'.", jobConfiguration.JobLockProvider, jobConfiguration.Name)); } JobHistoryProvider jobHistoryProvider = null; if (!string.IsNullOrEmpty(jobConfiguration.JobHistoryProvider)) { Type historyType = Type.GetType(jobConfiguration.JobHistoryProvider, false, true); if (historyType == null) throw new ConfigurationErrorsException( string.Format("Could not load job history type '{0}' for job '{1}'.", jobConfiguration.JobHistoryProvider, jobConfiguration.Name)); jobHistoryProvider = Activator.CreateInstance(historyType) as JobHistoryProvider; } var j = new JobRunner(jobConfiguration, jobType, jobLockProvider, jobHistoryProvider); _jobs.Add(j); // keep track of jobs for providers so they can be sync'd later if (provider == null) continue; JobCollection providerJobs; if (!_providerJobs.TryGetValue(provider, out providerJobs)) { providerJobs = new JobCollection(); _providerJobs.Add(provider, providerJobs); } providerJobs.Add(j); } }
private void OnJobProviderCallback(object state) { bool wasReloaded = false; // make thread safe by making sure this can't run when Initialize is running lock (_initLock) { foreach (JobProvider provider in _jobProviders) { if (!provider.IsReloadRequired(_lastInitilize)) continue; Trace.TraceInformation("Reload jobs for provider {0}.", provider.ToString()); //reload this provider JobCollection providerJobs; if (!_providerJobs.TryGetValue(provider, out providerJobs)) { providerJobs = new JobCollection(); _providerJobs.Add(provider, providerJobs); } //remove jobs foreach (JobRunner job in providerJobs) { job.Stop(true); _jobs.Remove(job); } providerJobs.Clear(); //add jobs back AddJobs(provider.GetJobs(), provider); wasReloaded = true; foreach (JobRunner job in providerJobs) job.Start(); } } if (wasReloaded) _lastInitilize = DateTime.Now; }