// time range for the day public IntervalSchedule( string schid, DateTime startTime, int secs, TimeSpan fromTime, TimeSpan toTime, ScheduleJob[] jobs, bool IsPrimary) : base(schid, startTime, ScheduleType.INTERVAL, jobs, IsPrimary) { m_fromTime = fromTime; m_toTime = toTime; Interval = secs; }
public Schedule(string schid, DateTime startTime, ScheduleType type, int duationMin, ScheduleJob[] jobs, bool IsPrimary) { StartTime = startTime; m_nextTime = startTime; m_type = type; m_schid = schid; m_durationMin = duationMin; this.jobs = jobs; this.IsPrimary = IsPrimary; }
// Constructor public Schedule(string schid, DateTime startTime, ScheduleType type, ScheduleJob[] jobs, bool IsPrimary) { StartTime = startTime; m_nextTime = startTime; m_type = type; m_schid = schid; m_durationMin = 0; this.jobs = jobs; this.IsPrimary = IsPrimary; foreach (ScheduleJob job in jobs) job.setSchedule(this); }
public static Schedule CreateSchedule(int schid,string schname,int schtype,int isDuration,int durationMin,DateTime dt,int[] weekdays) { System.DateTime starttime=DateTime.MinValue; #if DEBUG // dt = System.DateTime.Now.AddMinutes(1); #endif Schedule schedule=null; if (schtype == 0) //repeat { for (int i = 0; i <= 7; i++) { DateTime invokeTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, dt.Hour, dt.Minute, dt.Second).AddDays(i); if (weekdays[(int)invokeTime.DayOfWeek] == 1 && invokeTime > DateTime.Now) { starttime = invokeTime; break; } } } else //one time if (DateTime.Now < dt) starttime = dt; else throw new Exception(schid + " 過期"); if (starttime == DateTime.MinValue) throw new Exception("Schedule Err:can not find invoke time!"); OdbcConnection cn = new OdbcConnection(Global.Db2ConnectionString); OdbcCommand cmd = new OdbcCommand("select schid,subschid,devicename,command from tblschdetail where schid=" + schid); cmd.Connection = cn; System.Collections.ArrayList ary = new System.Collections.ArrayList(); try { cn.Open(); OdbcDataReader rd = cmd.ExecuteReader(); // int inx = 0; while (rd.Read()) { // int schid = System.Convert.ToInt32(rd[Global.getFiledInx(rd, "schid")]); int subschid = System.Convert.ToInt32(rd[Global.getFiledInx(rd, "subschid")]); string devName = rd[Global.getFiledInx(rd, "devicename")].ToString(); string command =""; if (!rd.IsDBNull(Global.getFiledInx(rd, "command"))) command = rd[Global.getFiledInx(rd, "command")].ToString(); else command = ""; if(command=="") ary.Add( new ScheduleJob(schid,devName, subschid, null)); else ary.Add(new ScheduleJob(schid,devName,subschid,RemoteInterface.Utils.Util.StringToObj(command))); } ScheduleJob[] schjobs= new ScheduleJob[ary.Count]; for (int i = 0; i < ary.Count; i++) schjobs[i] = (ScheduleJob)ary[i]; switch (schtype) { case 0: //repeat schedule = new DailySchedule(schid.ToString(), starttime, (isDuration == 0) ? 0 : durationMin, schjobs, true); break; case 1: //one time schedule = new OneTimeSchedule(schid.ToString(), starttime, (isDuration == 0) ? 0 : durationMin, schjobs, true); break; } for(int i=0;i<7;i++) schedule.SetWeekDay((DayOfWeek)i,(weekdays[i]==1)?true:false); return schedule; } catch (Exception ex) { throw new Exception(ex.Message + "," + ex.StackTrace); } finally { cn.Close(); } }
public MonthlySchedule(string schid, DateTime startTime, ScheduleJob[] jobs,bool IsPrimary) : base(schid, startTime, ScheduleType.MONTHLY, jobs, IsPrimary) { }
public WeeklySchedule(string schid, DateTime startTime, ScheduleJob[] jobs, bool IsPrimary) : base(schid, startTime, ScheduleType.WEEKLY, jobs, IsPrimary) { }
public DailySchedule(string schid, DateTime startTime, int durationMin, ScheduleJob[] jobs, bool IsPrimary) : base(schid, startTime, ScheduleType.DAILY, durationMin, jobs, IsPrimary) { }
public OneTimeSchedule(string schid, DateTime startTime, int durMin, ScheduleJob[] jobs, bool IsPrimary) : base(schid, startTime, ScheduleType.ONETIME, jobs, IsPrimary) { //this.durMin = durMin; this.m_durationMin = durMin; }
// public int durMin; public OneTimeSchedule( string schid, DateTime startTime, ScheduleJob[] jobs,bool IsPrimary) : this(schid, startTime, 0, jobs, IsPrimary) { }