示例#1
0
        protected internal virtual void ProcessInternal(string xml)
        {
            ClearValidationExceptions();

            scheduledJobs.Clear();
            jobsToSchedule.Clear();
            calsToSchedule.Clear();

            ValidateXmlIfNeeded(xml);

            // deserialize as object model
            XmlSerializer xs   = new XmlSerializer(typeof(quartz));
            quartz        data = (quartz)xs.Deserialize(new StringReader(xml));

            // process data

            // add calendars
            if (data.calendar != null)
            {
                foreach (calendarType ct in data.calendar)
                {
                    CalendarBundle c = CreateCalendarFromXmlObject(ct);
                    AddCalendarToSchedule(c);
                }
            }

            // add job scheduling bundles
            ProcessJobs(data);

            if (data.joblistener != null)
            {
                // go through listeners
                foreach (joblistenerType jt in data.joblistener)
                {
                    Type listenerType = Type.GetType(jt.type);
                    if (listenerType == null)
                    {
                        throw new SchedulerConfigException("Unknown job listener type " + jt.type);
                    }
                    IJobListener listener = (IJobListener)ObjectUtils.InstantiateType(listenerType);
                    // set name of trigger with reflection, this might throw errors
                    NameValueCollection properties = new NameValueCollection();
                    properties.Add("Name", jt.name);

                    try
                    {
                        ObjectUtils.SetObjectProperties(listener, properties);
                    }
                    catch (Exception)
                    {
                        throw new SchedulerConfigException(string.Format("Could not set name for job listener of type '{0}', do you have public set method defined for property 'Name'?", jt.type));
                    }
                    AddListenerToSchedule(listener);
                }
            }
            MaybeThrowValidationException();
        }
示例#2
0
        private static CalendarBundle CreateCalendarFromXmlObject(calendarType ct)
        {
            CalendarBundle c = new CalendarBundle();

            // set type name first as it creates the actual inner instance
            c.TypeName     = ct.type;
            c.Description  = ct.description;
            c.CalendarName = ct.name;
            c.Replace      = ct.replace;

            if (ct.basecalendar != null)
            {
                c.CalendarBase = CreateCalendarFromXmlObject(ct.basecalendar);
            }
            return(c);
        }
		/// <summary>
		/// Adds a calendar.
		/// </summary>
		/// <param name="sched">The sched.</param>
		/// <param name="calendarBundle">calendar bundle.</param>
		/// <throws>  SchedulerException if the Calendar cannot be added to the Scheduler, or </throws>
		public virtual void AddCalendar(IScheduler sched, CalendarBundle calendarBundle)
		{
			sched.AddCalendar(calendarBundle.CalendarName, calendarBundle.Calendar, calendarBundle.Replace, true);
		}
		public virtual void AddCalendarToSchedule(CalendarBundle cal)
		{
			calsToSchedule.Add(cal);
		}
	    private static CalendarBundle CreateCalendarFromXmlObject(calendarType ct)
	    {
            CalendarBundle c = new CalendarBundle(); 
            
            // set type name first as it creates the actual inner instance
	        c.TypeName = ct.type;
            c.Description = ct.description;
            c.CalendarName = ct.name;
            c.Replace = ct.replace;

            if (ct.basecalendar != null)
            {
                c.CalendarBase = CreateCalendarFromXmlObject(ct.basecalendar);
            }
            return c;
	    }
示例#6
0
 /// <summary>
 /// Adds a calendar.
 /// </summary>
 /// <param name="sched">The sched.</param>
 /// <param name="calendarBundle">calendar bundle.</param>
 /// <throws>  SchedulerException if the Calendar cannot be added to the Scheduler, or </throws>
 public virtual void AddCalendar(IScheduler sched, CalendarBundle calendarBundle)
 {
     sched.AddCalendar(calendarBundle.CalendarName, calendarBundle.Calendar, calendarBundle.Replace, true);
 }
示例#7
0
 public virtual void AddCalendarToSchedule(CalendarBundle cal)
 {
     calsToSchedule.Add(cal);
 }