private void ApplyOverrideParams(JobConfigurationBase configuration, Dictionary<string, string> overrideParams) { foreach(string name in overrideParams.Keys) { var propInfo = configuration.GetType().GetProperty(name); if(propInfo == null) { throw new ArgumentException(string.Format("Unable to override configuration {0} in type {1}, property not found", name, configuration.GetType().FullName)); } var type = propInfo.PropertyType; if(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) { type = type.GetGenericArguments()[0]; } object newValue; if(type == typeof(DateTime)) { newValue = DateTime.SpecifyKind(DateTime.Parse(overrideParams[name]), DateTimeKind.Utc); } else { newValue = Convert.ChangeType(overrideParams[name], type); } propInfo.SetValue(configuration, newValue, null); } }
private void ApplyOverrideParams(JobConfigurationBase configuration, Dictionary <string, string> overrideParams) { foreach (string name in overrideParams.Keys) { var propInfo = configuration.GetType().GetProperty(name); if (propInfo == null) { throw new ArgumentException(string.Format("Unable to override configuration {0} in type {1}, property not found", name, configuration.GetType().FullName)); } var type = propInfo.PropertyType; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = type.GetGenericArguments()[0]; } object newValue; if (type == typeof(DateTime)) { newValue = DateTime.SpecifyKind(DateTime.Parse(overrideParams[name]), DateTimeKind.Utc); } else { newValue = Convert.ChangeType(overrideParams[name], type); } propInfo.SetValue(configuration, newValue, null); } }
public void UpdateSimpleJob(int id, string jobName, Guid jobGuid, string assemblyName, string className, int intervalMinutes, int delayStartMinutes, JobConfigurationBase configuration = null) { if(jobGuid == Guid.Empty) { jobGuid = Guid.NewGuid(); } var item = this.LoadJobDefinition(id); item.JobName = jobName; item.AssemblyName = assemblyName; item.ClassName = className; item.JobGuid = jobGuid; var schedule = item.Schedule as JobSimpleSchedule; if(schedule == null) { item.Schedule = schedule = new JobSimpleSchedule(); } schedule.IntervalMinutes = intervalMinutes; schedule.DelayStartMinutes = delayStartMinutes; if(configuration != null) { item.Configuration = configuration; } this.DocumentSession.SaveChanges(); }
public void UpdateCronJob(int id, string jobName, Guid jobGuid, string assemblyName, string className, string cronScheduleExpression, JobConfigurationBase configuration=null) { if(jobGuid == Guid.Empty) { jobGuid = Guid.NewGuid(); } var item = this.LoadJobDefinition(id); item.JobName = jobName; item.AssemblyName = assemblyName; item.ClassName = className; item.JobGuid = jobGuid; var schedule = item.Schedule as JobCronSchedule; if (schedule == null) { item.Schedule = schedule = new JobCronSchedule(); } schedule.CronScheduleExpression = cronScheduleExpression; if(configuration != null) { item.Configuration = configuration; } this.DocumentSession.SaveChanges(); }
public void UpdateSimpleJob(int id, string jobName, Guid jobGuid, string assemblyName, string className, int intervalMinutes, int delayStartMinutes, JobConfigurationBase configuration = null) { if (jobGuid == Guid.Empty) { jobGuid = Guid.NewGuid(); } var item = this.LoadJobDefinition(id); item.JobName = jobName; item.AssemblyName = assemblyName; item.ClassName = className; item.JobGuid = jobGuid; var schedule = item.Schedule as JobSimpleSchedule; if (schedule == null) { item.Schedule = schedule = new JobSimpleSchedule(); } schedule.IntervalMinutes = intervalMinutes; schedule.DelayStartMinutes = delayStartMinutes; if (configuration != null) { item.Configuration = configuration; } this.DocumentSession.SaveChanges(); }
public void UpdateCronJob(int id, string jobName, Guid jobGuid, string assemblyName, string className, string cronScheduleExpression, JobConfigurationBase configuration = null) { if (jobGuid == Guid.Empty) { jobGuid = Guid.NewGuid(); } var item = this.LoadJobDefinition(id); item.JobName = jobName; item.AssemblyName = assemblyName; item.ClassName = className; item.JobGuid = jobGuid; var schedule = item.Schedule as JobCronSchedule; if (schedule == null) { item.Schedule = schedule = new JobCronSchedule(); } schedule.CronScheduleExpression = cronScheduleExpression; if (configuration != null) { item.Configuration = configuration; } this.DocumentSession.SaveChanges(); }