Beispiel #1
0
 public TableData(int taskScheduleIid, int taskId, string taskName,
                  int argId, string userName,
                  bool enabled, TaskSchedule.TimeUnitEnum timeUnit, int intervalNum,
                  DateTime startTime, DateTime endTime, int dayOfWeekMask, int monthOfYearMask,
                  int dayOfMonth, FirstLastEnum firstLast, bool deleteWhenDone,
                  string taskComment, bool execMissedTasks,
                  string schedString, DateTime lastSuccess, DateTime nextExecTime)
 {
     TaskScheduleIid = taskScheduleIid;
     TaskId          = taskId;
     TaskName        = taskName;
     ArgId           = argId;
     UserName        = userName;
     Enabled         = enabled;
     TimeUnit        = timeUnit;
     IntervalNum     = intervalNum;
     StartTime       = startTime;
     EndTime         = endTime;
     DayOfWeekMask   = dayOfWeekMask;
     MonthOfYearMask = monthOfYearMask;
     DayOfMonth      = dayOfMonth;
     FirstLast       = firstLast;
     DeleteWhenDone  = deleteWhenDone;
     TaskComment     = taskComment;
     ExecMissedTasks = execMissedTasks;
     SchedString     = schedString;
     LastSuccess     = lastSuccess;
     NextExecTime    = nextExecTime;
 }
Beispiel #2
0
        // make a string that describes the schedule
        static string MakeSchedString(TimeUnitEnum timeUnit, int intervalNum,
                                      DateTime startTime, int dayOfWeekMask, int monthOfYearMask,
                                      int dayOfMonth, FirstLastEnum firstLast)
        {
            string strSchedString = "";
            string strFirstLast   = "";
            string DayString      = "";

            string[] DayNames = { MainClass.StringTable.GetString("Sunday"),
                                  MainClass.StringTable.GetString("Monday"),
                                  MainClass.StringTable.GetString("Tuesday"),
                                  MainClass.StringTable.GetString("Wednesday"),
                                  MainClass.StringTable.GetString("Thursday"),
                                  MainClass.StringTable.GetString("Friday"),
                                  MainClass.StringTable.GetString("Saturday"),
                                  MainClass.StringTable.GetString("day") };

            // one time
            if (timeUnit == TimeUnitEnum.Once)
            {
                //strSchedString = startTime.ToString("yyyy/MM/dd HH:mm:ss");
                strSchedString = startTime.ToShortDateString() + " " + startTime.ToLongTimeString();
            }


            // daily
            else if (timeUnit == TimeUnitEnum.Day)
            {
                if (intervalNum == 1)
                {
                    strSchedString = MainClass.StringTable.GetString("DailyAtSpace") + startTime.ToLongTimeString();
                }
                else
                {
                    strSchedString = MainClass.StringTable.GetString("EverySpace") + intervalNum + MainClass.StringTable.GetString("SpaceDaysAtSpace") + startTime.ToLongTimeString();
                }
            }

            // weekly
            else if (timeUnit == TimeUnitEnum.Week)
            {
                if (intervalNum == 1)
                {
                    strSchedString = MainClass.StringTable.GetString("EverySpace") + MakeDayString(dayOfWeekMask, startTime) + MainClass.StringTable.GetString("SpaceAtSpace") + startTime.ToLongTimeString();
                }
                else
                {
                    strSchedString = MainClass.StringTable.GetString("EverySpace") + intervalNum + MainClass.StringTable.GetString("SpaceWeeksOnSpace") + MakeDayString(dayOfWeekMask, startTime) + MainClass.StringTable.GetString("SpaceAtSpace") + startTime.ToLongTimeString();
                }
            }

            // monthly
            else if (timeUnit == TimeUnitEnum.Month)
            {
                if (dayOfMonth > 0)
                {
                    if (monthOfYearMask == (int)MonthMask.AllMonths)
                    {
                        strSchedString = MakeDayNumberString(dayOfMonth) + MainClass.StringTable.GetString("SpaceOfEveryMonthAtSpace") + startTime.ToLongTimeString();
                    }
                    else
                    {
                        strSchedString = MakeDayNumberString(dayOfMonth) + MainClass.StringTable.GetString("SpaceOfEverySpace") + MakeMonthString(monthOfYearMask) + MainClass.StringTable.GetString("SpaceAtSpace") + startTime.ToLongTimeString();
                    }
                }
                else
                {
                    if (firstLast == FirstLastEnum.First)
                    {
                        strFirstLast = MainClass.StringTable.GetString("First");
                        DayString    = MakeDayString(dayOfWeekMask, DateTime.MinValue);
                    }
                    else if (firstLast == FirstLastEnum.Second)
                    {
                        strFirstLast = MainClass.StringTable.GetString("Second");
                        DayString    = MakeDayString(dayOfWeekMask, DateTime.MinValue);
                    }
                    else if (firstLast == FirstLastEnum.Third)
                    {
                        strFirstLast = MainClass.StringTable.GetString("Third");
                        DayString    = MakeDayString(dayOfWeekMask, DateTime.MinValue);
                    }
                    else if (firstLast == FirstLastEnum.Fourth)
                    {
                        strFirstLast = MainClass.StringTable.GetString("Fourth");
                        DayString    = MakeDayString(dayOfWeekMask, DateTime.MinValue);
                    }
                    else if (firstLast == FirstLastEnum.Last)
                    {
                        strFirstLast = MainClass.StringTable.GetString("Last");
                        DayString    = MakeDayString(dayOfWeekMask, DateTime.MinValue);
                    }
                    else
                    {
                        string err = "bad firstLast value: " + firstLast;
                        ServiceMessages.InsertRec(MainClass.AppName, "TaskSchedule", "MakeSchedString", err);
                    }
                    if (monthOfYearMask == (int)MonthMask.AllMonths)
                    {
                        strSchedString = strFirstLast + " " + DayString + MainClass.StringTable.GetString("SpaceOfEveryMonthAtSpace") + startTime.ToLongTimeString();
                    }
                    else
                    {
                        strSchedString = strFirstLast + " " + DayString + MainClass.StringTable.GetString("SpaceOfSpace") + MakeMonthString(monthOfYearMask) + MainClass.StringTable.GetString("SpaceAtSpace") + startTime.ToLongTimeString();
                    }
                }
            }

            return(strSchedString);
        }