Beispiel #1
0
 public static void Test()
 {
     Console.WriteLine("+++++++++++++++++PlanTimeTest+++++++++++++++++");
     PlanTime time = new PlanTime(2013, 11, 12, 4, 26, 12);
     {
         Console.WriteLine("-----------------OneOff-------------------");
         PlanTime time2 = PlanTime.Parse("2013-01-12 02:03:40");
         Console.WriteLine("String:{0}", time2.ToString());
         Console.WriteLine("ToDateTime:{0}", time2.ToDateTime());
         Console.WriteLine("GetNextTime:{0}", time2.GetNextTime());
     }
     {
         Console.WriteLine("-----------------Daily-------------------");
         PlanTime time2 = PlanTime.Parse("03:16:05");
         Console.WriteLine("String:{0}", time2.ToString());
         Console.WriteLine("ToDateTime:{0}", time2.ToDateTime());
         Console.WriteLine("GetNextTime:{0}", time2.GetNextTime());
     }
     {
         Console.WriteLine("-----------------Weekly-------------------");
         PlanTime time2 = PlanTime.Parse("23:58:05 Sunday");
         Console.WriteLine("String:{0}", time2.ToString());
         Console.WriteLine("ToDateTime:{0}", time2.ToDateTime());
         Console.WriteLine("GetNextTime:{0}", time2.GetNextTime());
     }
 }
Beispiel #2
0
 /// <summary>
 /// 创建Howell.Schedules.WorkSheetItem对象
 /// </summary>
 /// <param name="beginTime">工作表项的开始时间</param>
 /// <param name="endTime">工作表项的结束时间</param>
 /// <param name="content">工作表项的内容</param>
 /// <param name="enabled">是否启用提示功能</param>
 public WorkSheetItem(PlanTime beginTime, PlanTime endTime, String content, Boolean enabled)
 {
     this.Plan            = new PlanPeriod(Guid.NewGuid().ToString(), beginTime, endTime);
     this.Plan.Beginning += new EventHandler <EventArgs>(Plan_Beginning);
     this.Plan.Ending    += new EventHandler <EventArgs>(Plan_Ending);
     this.Plan.Content    = content;
     this.Plan.Enabled    = enabled;
 }
Beispiel #3
0
 /// <summary>
 /// 将现有的Howell.Schedules.ProgrammeItem 添加到集合中。
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="time">节目时间</param>
 /// <param name="content">节目内容</param>
 /// <returns>已添加到集合中的 Howell.Schedules.ProgrammeItem。</returns>
 public virtual ProgrammeItem Add(String key, PlanTime time, String content)
 {
     lock (this)
     {
         if (ContansKey(key) == true)
         {
             throw new System.InvalidOperationException(String.Format("Key {0} has already contained.", key));
         }
         ProgrammeItem item = new ProgrammeItem(key, time, content);
         return(this.Add(item));
     }
 }
Beispiel #4
0
 /// <summary>
 /// 创建PlanTime对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="year">年</param>
 /// <param name="month">月</param>
 /// <param name="day">日</param>
 /// <param name="hour">时</param>
 /// <param name="minute">分</param>
 /// <param name="second">秒</param>
 /// <param name="dayOfWeek">星期几</param>
 /// <param name="repeatTimes">重复提示次数,取值范围:[1,5],默认为1次</param>
 /// <param name="repeatInterval">重复提示的间隔时间,取值范围: (5秒至30分钟),默认为30秒.</param>
 /// <param name="enabled">是否启用计划,注意:如果在提示期间Enabled的值被修改,将不再继续RepeatTimes的后续提示,而是转而等待下次计划的触发。</param>
 internal Plan(String id, Nullable <Int32> year, Nullable <Int32> month, Nullable <Int32> day, Int32 hour, Int32 minute, Int32 second, Nullable <DayOfWeek> dayOfWeek, Int32 repeatTimes, TimeSpan repeatInterval, Boolean enabled)
 {
     this.Tag            = null;
     this.Id             = id;
     this.m_Time         = new PlanTime(year, month, day, hour, minute, second, dayOfWeek);
     this.RepeatTimes    = repeatTimes;
     this.RepeatInterval = repeatInterval;
     m_RaiseTimer        = null;
     this.Enabled        = enabled;
     lock (typeof(Plan))
     {
         Plan.Plans.Add(this);
     }
 }
Beispiel #5
0
            /// <summary>
            /// 判断时间段是否和集合内的时间段有冲突
            /// </summary>
            /// <param name="beginHour">需要判断的时间段开始时间的小时值</param>
            /// <param name="beginMinute">需要判断的时间段开始时间的分钟值</param>
            /// <param name="beginSecond">需要判断的时间段开始时间的秒值</param>
            /// <param name="endHour">需要判断的时间段结束时间的小时值</param>
            /// <param name="endMinute">需要判断的时间段结束时间的分钟值</param>
            /// <param name="endSecond">需要判断的时间段结束时间的秒值</param>
            /// <returns>如果和集合内的时间段有冲突则返回true,否则返回false。</returns>
            public Boolean IsConflict(Int32 beginHour, Int32 beginMinute, Int32 beginSecond, Int32 endHour, Int32 endMinute, Int32 endSecond)
            {
                PlanTime beginTime = new PlanTime(beginHour, beginMinute, beginSecond, m_Owner.DayOfWeek);
                PlanTime endTime   = new PlanTime(endHour, endMinute, endSecond, m_Owner.DayOfWeek);

                for (int i = 0; i < m_Items.Count; ++i)
                {
                    if (beginTime.IsInRange(m_Items[i].BeginTime, m_Items[i].EndTime) || endTime.IsInRange(m_Items[i].BeginTime, m_Items[i].EndTime))
                    {
                        return(true);
                    }
                }
                return(false);
            }
Beispiel #6
0
        /// <summary>
        /// 创建时间段计划对象
        /// </summary>
        /// <param name="id"></param>
        /// <param name="beginYear"></param>
        /// <param name="beginMonth"></param>
        /// <param name="beginDay"></param>
        /// <param name="beginHour"></param>
        /// <param name="beginMinute"></param>
        /// <param name="beginSecond"></param>
        /// <param name="beginDayOfWeek"></param>
        /// <param name="endYear"></param>
        /// <param name="endMonth"></param>
        /// <param name="endDay"></param>
        /// <param name="endHour"></param>
        /// <param name="endMinute"></param>
        /// <param name="endSecond"></param>
        /// <param name="endDayOfWeek"></param>
        internal PlanPeriod(String id, Nullable <Int32> beginYear, Nullable <Int32> beginMonth, Nullable <Int32> beginDay, Int32 beginHour, Int32 beginMinute, Int32 beginSecond, Nullable <DayOfWeek> beginDayOfWeek,
                            Nullable <Int32> endYear, Nullable <Int32> endMonth, Nullable <Int32> endDay, Int32 endHour, Int32 endMinute, Int32 endSecond, Nullable <DayOfWeek> endDayOfWeek)
        {
            this.Tag    = null;
            this.Id     = id;
            m_BeginTime = new PlanTime(beginYear, beginMonth, beginDay, beginHour, beginMinute, beginSecond, beginDayOfWeek);
            m_EndTime   = new PlanTime(endYear, endMonth, endDay, endHour, endMinute, endSecond, endDayOfWeek);
            m_Begun     = false;
            if (m_BeginTime.Type != m_EndTime.Type)
            {
                throw new ArgumentException("PlanPeriod constructor error, the begin time type must be the same as the end time.");
            }

            if (m_BeginTime.ToDateTime() >= m_EndTime.ToDateTime())
            {
                throw new ArgumentException("PlanPeriod constructor error, the begin time must be less than the end time.");
            }
            lock (typeof(PlanPeriod))
            {
                PlanPeriod.PlanPeriods.Add(this);
            }
            this.Enabled = true;
        }
Beispiel #7
0
 /// <summary>
 /// 创建时间段计划对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="beginTime"></param>
 /// <param name="endTime"></param>
 internal PlanPeriod(String id, PlanTime beginTime, PlanTime endTime)
     : this(id, beginTime.Year, beginTime.Month, beginTime.Day, beginTime.Hour, beginTime.Minute, beginTime.Second, beginTime.DayOfWeek, endTime.Year, endTime.Month, endTime.Day, endTime.Hour, endTime.Minute, endTime.Second, endTime.DayOfWeek)
 {
 }
Beispiel #8
0
 /// <summary>
 /// 创建 Howell.Schedules.ProgrammeItem 对象
 /// </summary>
 /// <param name="key">建</param>
 /// <param name="plannedTime">计划时间</param>
 /// <param name="content">节目内容</param>
 public ProgrammeItem(String key, PlanTime plannedTime, String content)
 {
     Plan            = new Plan(key, plannedTime);
     Plan.Content    = content;
     Plan.Reminding += new EventHandler <EventArgs>(Plan_Reminding);
 }
Beispiel #9
0
 /// <summary>
 /// 创建 Howell.Schedules.ProgrammeItem 对象
 /// </summary>
 /// <param name="key">建</param>
 /// <param name="plannedTime">计划时间</param>
 public ProgrammeItem(String key, PlanTime plannedTime)
     : this(key, plannedTime, String.Empty)
 {
 }
Beispiel #10
0
 /// <summary>
 /// 创建Howell.Schedules.WorkSheetItem对象
 /// </summary>
 /// <param name="beginTime">工作表项的开始时间</param>
 /// <param name="endTime">工作表项的结束时间</param>
 public WorkSheetItem(PlanTime beginTime, PlanTime endTime)
     : this(beginTime, endTime, String.Empty, true)
 {
 }
Beispiel #11
0
 /// <summary>
 /// 创建PlanTime对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="time">计划时间</param>
 internal Plan(String id, PlanTime time)
     : this(id, time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second, time.DayOfWeek, 1, TimeSpan.FromSeconds(30), true)
 {
 }
Beispiel #12
0
 /// <summary>
 ///  创建计划
 /// </summary>
 /// <param name="time"></param>
 public Plan(PlanTime time)
     : this(time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second, time.DayOfWeek)
 {
 }