예제 #1
0
		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);
			}
		}
예제 #2
0
 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);
     }
 }
예제 #3
0
		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();
		}
예제 #4
0
		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();
		}
예제 #5
0
        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();
        }
예제 #6
0
        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();
        }