public ScheduledTaskSpecification(string name, string exeAbsolutePath, int scheduledHour, int scheduledMinute, int executionTimeLimitInMinutes, RepetitionSpecification repetitionSpecification)
        {
            Guard.NotNullNorEmpty(name, "name");
              Guard.NotNullNorEmpty(exeAbsolutePath, "exeAbsolutePath");
              Guard.NotNull(repetitionSpecification, "repetitionSpecification");

              if (!Path.IsPathRooted(exeAbsolutePath))
              {
            throw new ArgumentException(string.Format("Executable path ('{0}') is not an absolute path.", exeAbsolutePath), "exeAbsolutePath");
              }

              if (scheduledHour < 0 || scheduledHour > 23)
              {
            throw new ArgumentException("Hour must be between 0 and 23 (inclusive).", "scheduledHour");
              }

              if (scheduledMinute < 0 || scheduledMinute > 59)
              {
            throw new ArgumentException("Minute must be between 0 and 59 (inclusive).", "scheduledMinute");
              }

              if (executionTimeLimitInMinutes < 0)
              {
            throw new ArgumentException("Execution time limit must be a non-negative integer.", "executionTimeLimitInMinutes");
              }

              Name = name;
              ExeAbsolutePath = exeAbsolutePath;
              ScheduledHour = scheduledHour;
              ScheduledMinute = scheduledMinute;
              ExecutionTimeLimitInMinutes = executionTimeLimitInMinutes;
              RepetitionSpecification = repetitionSpecification;
        }
Beispiel #2
0
        public ScheduledTaskSpecification(string name, string exeAbsolutePath, int scheduledHour, int scheduledMinute, int executionTimeLimitInMinutes, RepetitionSpecification repetitionSpecification)
        {
            Guard.NotNullNorEmpty(name, "name");
            Guard.NotNullNorEmpty(exeAbsolutePath, "exeAbsolutePath");
            Guard.NotNull(repetitionSpecification, "repetitionSpecification");

            if (!Path.IsPathRooted(exeAbsolutePath))
            {
                throw new ArgumentException(string.Format("Executable path ('{0}') is not an absolute path.", exeAbsolutePath), "exeAbsolutePath");
            }

            if (scheduledHour < 0 || scheduledHour > 23)
            {
                throw new ArgumentException("Hour must be between 0 and 23 (inclusive).", "scheduledHour");
            }

            if (scheduledMinute < 0 || scheduledMinute > 59)
            {
                throw new ArgumentException("Minute must be between 0 and 59 (inclusive).", "scheduledMinute");
            }

            if (executionTimeLimitInMinutes < 0)
            {
                throw new ArgumentException("Execution time limit must be a non-negative integer.", "executionTimeLimitInMinutes");
            }

            Name                        = name;
            ExeAbsolutePath             = exeAbsolutePath;
            ScheduledHour               = scheduledHour;
            ScheduledMinute             = scheduledMinute;
            ExecutionTimeLimitInMinutes = executionTimeLimitInMinutes;
            RepetitionSpecification     = repetitionSpecification;
        }
Beispiel #3
0
        private static DailyTrigger CreateTaskTrigger(ScheduledTaskSpecification scheduledTaskSpecification)
        {
            DateTime now = DateTime.Now;

            var dailyTrigger =
                new DailyTrigger
            {
                DaysInterval  = 1,
                StartBoundary =
                    new DateTime(
                        now.Year,
                        now.Month,
                        now.Day,
                        scheduledTaskSpecification.ScheduledHour,
                        scheduledTaskSpecification.ScheduledMinute,
                        0),
            };

            if (scheduledTaskSpecification.ExecutionTimeLimitInMinutes > 0)
            {
                dailyTrigger.ExecutionTimeLimit =
                    TimeSpan.FromMinutes(scheduledTaskSpecification.ExecutionTimeLimitInMinutes);
            }

            if (scheduledTaskSpecification.RepetitionSpecification.Enabled)
            {
                RepetitionSpecification repetitionSpecification = scheduledTaskSpecification.RepetitionSpecification;
                RepetitionPattern       repetitionPattern       = dailyTrigger.Repetition;

                repetitionPattern.Duration          = repetitionSpecification.Duration;
                repetitionPattern.Interval          = repetitionSpecification.Interval;
                repetitionPattern.StopAtDurationEnd = repetitionSpecification.StopAtDurationEnd;
            }

            return(dailyTrigger);
        }