Beispiel #1
0
        public JobDefinition Define(string uniqueName, string typeName)
        {
            var existing = this.definitions.FirstOrDefault(d => string.Equals(d.UniqueName, uniqueName, StringComparison.OrdinalIgnoreCase));

            if (existing != null)
            {
                existing.ClrType = typeName;
                return(existing);
            }

            var definition = new JobDefinition()
            {
                UniqueName = uniqueName, ClrType = typeName
            };

            this.definitions.Add(definition);

            this.HasConfiguration = true;

            return(definition);
        }
Beispiel #2
0
        private static void AddTrigger(IJobStorageProvider storage, JobTriggerBase trigger, JobDefinition jobDef, long jobId)
        {
            trigger.IsActive   = true;
            trigger.JobId      = jobId;
            trigger.Parameters = trigger.Parameters;

            Logger.InfoFormat("Adding trigger (type: '{0}' to job '{1}' (JobId: '{2}')", trigger.GetType().Name, jobDef.UniqueName, jobId);

            var scheduledTrigger = trigger as ScheduledTrigger;

            if (scheduledTrigger != null)
            {
                storage.AddTrigger(jobId, scheduledTrigger);
            }

            var recurringTrigger = trigger as RecurringTrigger;

            if (recurringTrigger != null)
            {
                storage.AddTrigger(jobId, recurringTrigger);
            }
        }