Ejemplo n.º 1
0
        public static JobOptions GetDefaults(Type jobType)
        {
            var jobOptions = new JobOptions();

            ApplyDefaults(jobOptions, jobType);
            return(jobOptions);
        }
Ejemplo n.º 2
0
        public static JobOptions GetDefaults(Type jobType)
        {
            var jobOptions   = new JobOptions();
            var jobAttribute = jobType.GetCustomAttribute <JobAttribute>() ?? new JobAttribute();

            jobOptions.Name = jobAttribute.Name;
            if (String.IsNullOrEmpty(jobOptions.Name))
            {
                string jobName = jobType.Name;
                if (jobName.EndsWith("Job"))
                {
                    jobName = jobName.Substring(0, jobName.Length - 3);
                }

                jobOptions.Name = jobName.ToLower();
            }

            jobOptions.Description   = jobAttribute.Description;
            jobOptions.RunContinuous = jobAttribute.IsContinuous;

            if (!String.IsNullOrEmpty(jobAttribute.Interval))
            {
                TimeSpan?interval;
                if (TimeUnit.TryParse(jobAttribute.Interval, out interval))
                {
                    jobOptions.Interval = interval;
                }
            }

            if (!String.IsNullOrEmpty(jobAttribute.InitialDelay))
            {
                TimeSpan?delay;
                if (TimeUnit.TryParse(jobAttribute.InitialDelay, out delay))
                {
                    jobOptions.InitialDelay = delay;
                }
            }

            jobOptions.IterationLimit = jobAttribute.IterationLimit;
            jobOptions.InstanceCount  = jobAttribute.InstanceCount;

            return(jobOptions);
        }
Ejemplo n.º 3
0
 public JobRunner(JobOptions options, ILoggerFactory loggerFactory = null)
 {
     _logger  = loggerFactory?.CreateLogger <JobRunner>() ?? NullLogger <JobRunner> .Instance;
     _options = options;
 }
Ejemplo n.º 4
0
 public JobRunner(JobOptions options, ILoggerFactory loggerFactory = null) {
     _logger = loggerFactory.CreateLogger<JobRunner>();
     _options = options;
 }
Ejemplo n.º 5
0
 public JobRunner(JobOptions options, ILoggerFactory loggerFactory = null)
 {
     _logger  = loggerFactory.CreateLogger <JobRunner>();
     _options = options;
 }
Ejemplo n.º 6
0
 public static void ApplyDefaults <T>(this JobOptions jobOptions)
 {
     JobOptions.ApplyDefaults(jobOptions, typeof(T));
 }