Esempio n. 1
0
        // 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;
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 // 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);
 }
Esempio n. 4
0
        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();
             }
        }
Esempio n. 5
0
 public MonthlySchedule(string schid, DateTime startTime, ScheduleJob[] jobs,bool IsPrimary)
     : base(schid, startTime, ScheduleType.MONTHLY, jobs, IsPrimary)
 {
 }
Esempio n. 6
0
 public WeeklySchedule(string schid, DateTime startTime, ScheduleJob[] jobs, bool IsPrimary)
     : base(schid, startTime, ScheduleType.WEEKLY, jobs, IsPrimary)
 {
 }
Esempio n. 7
0
 public DailySchedule(string schid, DateTime startTime, int durationMin, ScheduleJob[] jobs, bool IsPrimary)
     : base(schid, startTime, ScheduleType.DAILY, durationMin, jobs, IsPrimary)
 {
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 //  public int durMin;
 public OneTimeSchedule( string schid, DateTime startTime, ScheduleJob[] jobs,bool IsPrimary)
     : this(schid, startTime, 0, jobs, IsPrimary)
 {
 }