Ejemplo n.º 1
0
 public BlockWrapper(IScheduledItem item, string StrBase, string BeginOffset, string EndOffset)
 {
     _Item  = item;
     _Begin = new ScheduledTime(StrBase, BeginOffset);
     _End   = new ScheduledTime(StrBase, EndOffset);
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="channelRef"></param>
        private static void StartTimer(ChannelRefInfo channelRef)
        {
            // Creazione timer
            Schedule.ScheduleTimer timer = new Schedule.ScheduleTimer();
            timer.Error += new Schedule.ExceptionEventHandler(OnScheduleError);


            if (channelRef.ExecutionConfiguration.IntervalType != JobExecutionConfigurations.IntervalTypesEnum.Block)
            {
                long ticks;
                long.TryParse(channelRef.ExecutionConfiguration.ExecutionTicks, out ticks);

                Schedule.ScheduledTime interval = new Schedule.ScheduledTime(
                    (Schedule.EventTimeBase)Enum.Parse(typeof(Schedule.EventTimeBase), channelRef.ExecutionConfiguration.IntervalType.ToString(), true),
                    TimeSpan.FromTicks(ticks));
                timer.AddJob(interval, new Schedule.ScheduledEventHandler(Publish), channelRef);
            }
            else
            {
                string[] spans           = channelRef.ExecutionConfiguration.ExecutionTicks.Split('|');
                string   strIntervalBase = string.Empty;
                string   strStartTime    = string.Empty;
                string   strStopTime     = string.Empty;
                if (spans.Length > 0)
                {
                    strIntervalBase = spans[0];
                }
                if (spans.Length > 1)
                {
                    strStartTime = spans[1];
                }
                if (spans.Length > 2)
                {
                    strStopTime = spans[2];
                }

                long intervalBase;
                long.TryParse(strIntervalBase, out intervalBase);

                long startTime;
                long.TryParse(strStartTime, out startTime);

                long stopTime;
                long.TryParse(strStopTime, out stopTime);

                Schedule.BlockWrapper interval = new Schedule.BlockWrapper(
                    new Schedule.SimpleInterval(DateTime.Parse("01/01/2000"), TimeSpan.FromTicks(intervalBase)),
                    "Daily",
                    new DateTime(startTime).ToString(),
                    new DateTime(stopTime).ToString());
                timer.AddJob(interval, new Schedule.ScheduledEventHandler(Publish), channelRef);
            }


            // Avvio timer
            timer.Start();

            // Creazione entry
            StartedChannelTimer entry = new StartedChannelTimer
            {
                Timer = timer,
                StartExecutionDate  = channelRef.StartExecutionDate,
                MachineName         = channelRef.MachineName,
                PublisherServiceUrl = channelRef.PublisherServiceUrl
            };

            lock (_dictionary)
                _dictionary.Add(channelRef.GetKey(), entry);
        }