Пример #1
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     int fineCount = 0;
     if (lClasses == null)
     { return fineCount; }
     int classTime = schedule.GetTimeOfTempClass();
     int dayOfWeek = Constants.GetDayOfClass(classTime);
     int lectureCount = 0;
     foreach (StudentSubGroup subGroup in schedule.GetTempClass().SubGroups)
     {
         lectureCount = CountLectureClassesInDay(schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayOfWeek), lClasses);
         if (lectureCount > 3)
         {
             fineCount++;
         }
     }
     if (fineCount != 0)
     {
         if (isBlock)
             return Constants.BLOCK_FINE;
         else
             return fineCount * fine;
     }
     return fineCount;
 }
Пример #2
0
 public static bool LotOfClassesInWeek(int maxCountClassesInWeek, StudentsClass[,] sClasses, ISchedule schedule, StudentsClass specialClass)
 {
     int rowClass = -1;
     //если пара есть в списке "особых пар" - получаю номер строки, в которой располагаются другие "особые" пары
     if ((rowClass = GetRow(sClasses, specialClass)) != -1)
     {
         int weekCount1 = 0; //количество "особых" пар из полученной строки, поставленных на первую неделю
         int weekCount2 = 0; //количество "особых" пар из полученной строки, поставленных на вторую неделю
         for (int classIndex = 0; classIndex < sClasses.GetLength(1); classIndex++)
         {
             if (sClasses[rowClass, classIndex] == null)
                 continue;
             StudentsClassPosition? position = schedule.GetClassPosition(sClasses[rowClass, classIndex]);
             if (position.HasValue)//если пара установлена
             {
                 if (Constants.GetWeekOfClass(position.Value.Time) == 0)//если пара располагается на первой неделе
                     weekCount1++;
                 else//на второй
                     weekCount2++;
             }
         }
         if (weekCount1 > maxCountClassesInWeek || weekCount2 > maxCountClassesInWeek)
         {
             return true;
         }
     }
     return false;
 }
Пример #3
0
		public MovingVoyage (VoyageNumber number, ISchedule schedule, int movementIndex)
			: base(number, schedule)
		{
			if(movementIndex < 0 || movementIndex >= schedule.MovementsCount)
				throw new ArgumentOutOfRangeException("movementIndex");
			_movementIndex = movementIndex;
		}
Пример #4
0
 public int GetFineOfFullSchedule(ISchedule schedule, EntityStorage eStorage)
 {
     int fineResult = 0;
     foreach (StudentSubGroup subGroup in eStorage.StudentSubGroups)
     {
         for (int dayIndex = 0; dayIndex < Constants.DAYS_IN_WEEK; dayIndex++)
         {
             StudentsClass[] subGroupDay = schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayIndex);
             for (int classIndex = 0; classIndex < subGroupDay.Length; classIndex++)
             {
                 if (Array.Find<StudentsClass>(sClassesList.ToArray(), (c) => c == subGroupDay[classIndex]) != null)
                 {
                     StudentsClassPosition? firstClassPosition = schedule.GetClassPosition(subGroupDay[classIndex]);
                     StudentsClass secondClass = schedule.GetClassByRoomAndPosition(firstClassPosition.Value.ClassRoom,
                         firstClassPosition.Value.Time + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK);
                     if (secondClass != null)
                     {
                         int firstClassRow = ClassesInWeek.GetRow(sClasses, subGroupDay[classIndex]);
                         int secondClassRow = ClassesInWeek.GetRow(sClasses, secondClass);
                         if (secondClassRow == -1 || secondClassRow != firstClassRow)
                         {
                             if (isBlock)
                                 return Constants.BLOCK_FINE;
                             else
                                 fineResult += fine;
                         }
                     }
                 }
             }
         }
     }
     return fineResult;
 }
Пример #5
0
 public void AddSchedule(ISchedule schedule)
 {
     lock (_schedulesSyncro)
     {
         _schedules.Add(schedule);
     }
 }
Пример #6
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     StudentSubGroup[] groups = schedule.GetTempClass().SubGroups;
     int classTime = schedule.GetTimeOfTempClass();
     //Считаем день недели последней добавленной пары
     int dayOfWeek = Constants.GetDayOfClass(classTime);
     //Считаем номер пары в этот день
     int classOfDay = Constants.GetTimeOfClass(classTime);
     int otherWeekDay;
     int fineResult = 0;
     if (dayOfWeek < Constants.DAYS_IN_WEEK)
     {
         otherWeekDay = Constants.DAYS_IN_WEEK;
     }
     else
     {
         otherWeekDay = -Constants.DAYS_IN_WEEK;
     }
     if (dayOfWeek == Constants.DAYS_IN_WEEK - 1)
     {
         foreach (StudentSubGroup subGroup in groups)
         {
             StudentsClass[] classes = schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayOfWeek + otherWeekDay);
             if (classes[classOfDay] == null)
             {
                 if (isBlock)
                     return Constants.BLOCK_FINE;
                 else
                     fineResult += fine;
             }
         }
     }
     return fineResult;
 }
Пример #7
0
 public static bool ClassAtTheSameTimeOnOtherWeek(ISchedule schedule, StudentsClass[] sClasses, int dayOfWeek, int classOfDay)
 {
     StudentsClass tempClass = schedule.GetTempClass();
     if (dayOfWeek < Constants.DAYS_IN_WEEK)
     {
         foreach (StudentSubGroup subGroup in tempClass.SubGroups)
         {
             StudentsClass secondClass = schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayOfWeek + Constants.DAYS_IN_WEEK)[classOfDay];
             if (!IsSameClassesAtTheSameTimeOnOtherWeek(sClasses, tempClass, secondClass))
             {
                 return false;
             }
         }
     }
     else
     {
         foreach (StudentSubGroup subGroup in tempClass.SubGroups)
         {
             StudentsClass secondClass = schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayOfWeek - Constants.DAYS_IN_WEEK)[classOfDay];
             if (!IsSameClassesAtTheSameTimeOnOtherWeek(sClasses, tempClass, secondClass))
             {
                 return false;
             }
         }
     }
     return true;
 }
Пример #8
0
        public int GetFineOfFullSchedule(ISchedule schedule, EntityStorage eStorage)
        {
            int lectureCount = 0;
            int fineCount = 0;
            foreach (StudentSubGroup subGroup in eStorage.StudentSubGroups)
            {
                for (int dayIndex = 0; dayIndex < Constants.DAYS_IN_WEEK * Constants.WEEKS_IN_SCHEDULE; dayIndex++)
                {

                    lectureCount = CountLectureClassesInDay(schedule.GetPartialSchedule(subGroup).GetClassesOfDay(dayIndex), lClasses);
                    if (lectureCount > 3)
                    {
                        fineCount++;
                    }
                }
            }
            if (fineCount != 0)
            {
                if (isBlock)
                    return Constants.BLOCK_FINE;
                else
                    return fineCount * fine;
            }
            return fineCount;
        }
        public int GetFineOfFullSchedule(ISchedule schedule, EntityStorage eStorage)
        {
            int fineResult = 0;
            if (sClasses == null)
            { return fineResult; }
            for (int groupIndex = 0; groupIndex < eStorage.StudentSubGroups.Length; groupIndex++)
            {
                PartialSchedule groupSchedule = schedule.GetPartialSchedule(eStorage.StudentSubGroups[groupIndex]);
                for (int dayIndex = 0; dayIndex < Constants.WEEKS_IN_SCHEDULE * Constants.DAYS_IN_WEEK; dayIndex++)
                {
                    for (int classIndex = 0; classIndex < Constants.CLASSES_IN_DAY; classIndex++)
                    {
                        if (!SameClasses.ClassAtTheSameTimeOnOtherWeek(schedule, sClasses, dayIndex, classIndex))
                        {
                            if (isBlock)
                                return Constants.BLOCK_FINE;
                            else
                                fineResult += fine;
                        }

                    }
                }
            }
            return fineResult;
        }
Пример #10
0
 public static bool ClassesAtSameTime(StudentsClass c1, StudentsClass c2, ISchedule schedule)
 {
     StudentsClassPosition? firstClassPosition = schedule.GetClassPosition(c1);
     StudentsClassPosition? secondClassPosition = schedule.GetClassPosition(c2);
     if (firstClassPosition.HasValue && secondClassPosition.HasValue)
     {
         if (firstClassPosition.Value.Time > secondClassPosition.Value.Time)
         {
             if (secondClassPosition.Value.Time + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK
                 != firstClassPosition.Value.Time)
             {
                 return false;
             }
         }
         else if (secondClassPosition.Value.Time > firstClassPosition.Value.Time)
         {
             if (firstClassPosition.Value.Time + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK
                 != secondClassPosition.Value.Time)
             {
                 return false;
             }
         }
     }
     return true;
 }
Пример #11
0
 public static bool ClassesAtSameTime(ISchedule schedule, int classRow, StudentsClass[,] sClasses)
 {
     StudentsClassPosition? firstClassPosition = schedule.GetClassPosition(sClasses[classRow, 0]);
     StudentsClassPosition? secondClassPosition = schedule.GetClassPosition(sClasses[classRow, 1]);
     if (firstClassPosition.HasValue && secondClassPosition.HasValue)
     {
         if (firstClassPosition.Value.Time > secondClassPosition.Value.Time)
         {
             if (secondClassPosition.Value.Time + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK
                 != firstClassPosition.Value.Time)
             {
                 return false;
             }
         }
         else if (secondClassPosition.Value.Time > firstClassPosition.Value.Time)
         {
             if (firstClassPosition.Value.Time + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK
                 != secondClassPosition.Value.Time)
             {
                 return false;
             }
         }
     }
     return true;
 }
Пример #12
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     int fineResult = 0;
     StudentsClass tempClass = schedule.GetTempClass();
     int classTime = schedule.GetTimeOfTempClass();
     int roomIndex = schedule.GetClassPosition(schedule.GetTempClass()).Value.ClassRoom;
     int weekOfClass = Constants.GetWeekOfClass(classTime);
     if (Array.Find(sClassesList.ToArray(), (c) => c == schedule.GetTempClass()) != null)
     {
         StudentsClass secondClass;
         if (weekOfClass == 0)
             secondClass = schedule.GetClassByRoomAndPosition(roomIndex, classTime + Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK);
         else
             secondClass = schedule.GetClassByRoomAndPosition(roomIndex, classTime - Constants.CLASSES_IN_DAY * Constants.DAYS_IN_WEEK);
         if (secondClass != null)
         {
             int firstClassRow = ClassesInWeek.GetRow(sClasses, tempClass);
             int secondClassRow = ClassesInWeek.GetRow(sClasses, secondClass);
             if (secondClassRow == -1 || secondClassRow != firstClassRow)
             {
                 if (isBlock)
                     return Constants.BLOCK_FINE;
                 else
                     fineResult += fine;
             }
         }
     }
     return fineResult;
 }
Пример #13
0
 public void ScheduleJob(string jobName, ISchedule schedule, Action action)
 {
     var jobDetail = new JobDetailImpl(jobName, typeof (ActionJob));
     jobDetail.JobDataMap[ActionJob.ActionParamName] = action;
     _quartzScheduler.ScheduleJob(jobDetail, ((TriggerWrapper) schedule).QuartzTrigger);
     _quartzScheduler.Start();
 }
Пример #14
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     int fineResult = 0;
     StudentsClass tClass = schedule.GetTempClass();
     int tTime = schedule.GetClassPosition(tClass).Value.Time;
     if (sClasses.FindAll((c) => c.sClass == tClass).Count() > 0)
     {
         FixedClasses vipClass = sClasses.Find((c) => c.sClass == tClass);
         if (vipClass.Room != schedule.GetClassRoom(tClass) || vipClass.Time != tTime)
         {
             if (isBlock)
                 return Constants.BLOCK_FINE;
             else
                 fineResult += fine;
         }
     }
     else
     {
         if (sClasses.FindAll((c) => c.Time == tTime && StudentsClass.StudentClassContainsEvenOneSubGroup(tClass, c.sClass)).Count() > 0)
         {
             if (isBlock)
                 return Constants.BLOCK_FINE;
             else
                 fineResult += fine;
         }
     }
     return fineResult;
 }
Пример #15
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     StudentSubGroup[] groups = schedule.GetTempClass().SubGroups;
     int day = Constants.GetDayOfClass(schedule.GetTimeOfTempClass());
     List<StudentsClass[]> groupDaySchedule = new List<StudentsClass[]>();
     int fineResult = 0;
     //Проверка является ли добавленная пара пятой
     for (int groupIndex = 0; groupIndex < groups.Length; groupIndex++)
     {
         groupDaySchedule.Add(schedule.GetPartialSchedule(groups[groupIndex]).GetClassesOfDay(day));
         if (schedule.GetTempClass() != groupDaySchedule[groupIndex][Constants.CLASSES_IN_DAY - 2])
         {
             return 0;
         }
     }
     //Проверка отсутствия первой пары
     for (int groupIndex = 0; groupIndex < groups.Length; groupIndex++)
     {
         if (groupDaySchedule[groupIndex][Constants.CLASSES_IN_DAY - 6] == null)
         {
             if (isBlock)
                 return Constants.BLOCK_FINE;
             else
                 fineResult += fine;
         }
     }
     return fineResult;
 }
Пример #16
0
 public int GetFineOfFullSchedule(ISchedule schedule, EntityStorage eStorage)
 {
     int fineResult = 0;
     for (int groupIndex = 0; groupIndex < eStorage.StudentSubGroups.Length; groupIndex++)
     {
         PartialSchedule groupSchedule = schedule.GetPartialSchedule(eStorage.StudentSubGroups[groupIndex]);
         for (int dayIndex = 0; dayIndex < Constants.DAYS_IN_WEEK; dayIndex++)
         {
             StudentsClass[] sClass = groupSchedule.GetClassesOfDay(dayIndex);
             for (int classIndex = 0; classIndex < sClass.Length; classIndex++)
             {
                 if (sClasses.FindAll((c) => c.sClass == sClass[classIndex]).Count() > 0)
                 {
                     FixedClasses vipClass = sClasses.Find((c) => c.sClass == sClass[classIndex]);
                     if (vipClass.Room != schedule.GetClassRoom(sClass[classIndex]) && vipClass.Time != schedule.GetClassPosition(sClass[classIndex]).Value.Time)
                     {
                         if (isBlock)
                             return Constants.BLOCK_FINE;
                         else
                             fineResult += fine;
                     }
                 }
             }
         }
     }
     return fineResult;
 }
Пример #17
0
 public void DeleteSchedule(ISchedule schedule)
 {
     lock (_schedulesSyncro)
     {
         _schedules.Remove(schedule);
     }
 }
Пример #18
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     StudentSubGroup[] groups = schedule.GetTempClass().SubGroups;
     int fineResult = 0;
     if (IsSaturday(Constants.GetDayOfClass(schedule.GetTimeOfTempClass())))
     {
         for (int groupIndex = 0; groupIndex < groups.Length; groupIndex++)
         {
             PartialSchedule groupSchedule = schedule.GetPartialSchedule(groups[groupIndex]);
             int day = Constants.GetDayOfClass(schedule.GetTimeOfTempClass());
             if (Array.FindAll<StudentsClass>(groupSchedule.GetClassesOfDay(day), (c) => c != null).Count() > 0)
             {
                 if (isBlock)
                     return Constants.BLOCK_FINE;
                 else
                     fineResult += fine;
             }
         }
     }
     else
     {
         return 0;
     }
     return fineResult;
 }
Пример #19
0
 public static bool LotOfClassesInDay(int maxCountClassesInDay, StudentsClass[,] sClasses, ISchedule schedule, StudentsClass specialClass)
 {
     int rowClass = -1;
     int dayOfSpecialClass = Constants.GetDayOfClass(schedule.GetClassPosition(specialClass).Value.Time);
     //если пара есть в списке "особых пар" - получаю номер строки, в которой располагаются другие "особые" пары
     if ((rowClass = GetRow(sClasses, specialClass)) != -1)
     {
         int dayCount = 0; //количество "особых" пар из полученной строки, поставленных в данный день
         for (int classIndex = 0; classIndex < sClasses.GetLength(1); classIndex++)
         {
             if (sClasses[rowClass, classIndex] == null)
                 continue;
             StudentsClassPosition? position = schedule.GetClassPosition(sClasses[rowClass, classIndex]);
             if (position.HasValue)//если пара установлена
             {
                 if (dayOfSpecialClass == Constants.GetDayOfClass(position.Value.Time))
                     dayCount++;
                 if (dayCount > maxCountClassesInDay)
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Пример #20
0
        private IScheduleVisitor AdvancedPrint(ISchedule schedule)
        {
            // Now try using our custom formatter to generate the description using the Description property.
            // Using our custom formatter will now produce different text saying "Fortnightly" instead of 
            // the standard "Every 2 weeks"
            var formatter = new CustomFormatter(DateTime.Now);

            // there are three options when using the formatter:
            // 1) handle the description changed event, which will be fired each time a schedule
            //    accepts the formatter (good for looping over lists of schedules), or
            // 2) if it's only called for one schedule, use formatter.Description after it's been
            //    accepted as this property will have the last Description generated, or
            // 3) call formatter.Format() if you know the type of your schedule object.
            formatter.DescriptionChanged += (sender, args) =>
            {
                Console.WriteLine(args.Text);
            };

            // visiting the schedule with the formatter will fire the DescriptionChanged event,
            // causing the text output to be printed to the console.
            schedule.Accept(formatter);

            // we'll reuse this formatter
            return formatter;
        }
Пример #21
0
 public Supplement(bool isHourCanceled, DateTime date, ITeachingHour hour, ISchedule schedule, IPerson teacher = null)
 {
     this.IsHourCanceled = isHourCanceled;
     this.Date = date;
     this.Hour = hour;
     this.Schedule = schedule;
     this.Teacher = teacher;
 }
Пример #22
0
 public Subject(string name, int year, IEnumerable<IAbsence> absences, ISchedule schedule, IEnumerable<ITest> tests)
 {
     this.Name = name;
     this.Year = year;
     this.Absences = absences;
     this.Schedule = schedule;
     this.Tests = tests;
 }
Пример #23
0
        public DistinctSchedule(ISchedule baseSchedule)
        {
            if (baseSchedule == null)
            {
                throw new ArgumentNullException("baseSchedule");
            }

            this.BaseSchedule = baseSchedule;
        }
Пример #24
0
        /// <summary> 
        /// ���� ���캯�� 
        /// </summary> 
        /// <param name="_schedule">Ϊÿ�������ƶ�һ��ִ�мƻ�</param> 
        public Task(ISchedule _schedule)
        {
            if (_schedule == null)
            {
                throw (new ArgumentNullException("_schedule"));
            }

            schedule = _schedule;
        }
Пример #25
0
        public static long AddSchedule(ISchedule itm)
        {
            long itmID = getNextScheduleID();
            IBaseQueryData query = new InsertQueryData();
            query.TableName = "Schedules";
            query.Fields.Add(new FieldData { FieldName = "ScheduleID", FieldValue = itmID.ToString(), FieldType = SqlDbType.BigInt });

            if (itm.GetType() == typeof(YearlySchedule))
            {
                YearlySchedule ySched = (YearlySchedule)itm;
                query.Fields.Add(new FieldData { FieldName = "RecurType", FieldValue = "4", FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "StartDate", FieldValue = ySched.StartDate.ToString(Constants.DATE_FORMAT_SQL) , FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "EndDate", FieldValue = ySched.EndDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "RecurUnits", FieldValue = ySched.RecurEveryNoOfYears.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnDay", FieldValue = ySched.OnDay.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnMonth", FieldValue = ySched.OnMonth.ToString(), FieldType = SqlDbType.Int });
            }
            else if (itm.GetType() == typeof(MonthlySchedule))
            {
                MonthlySchedule mSched = (MonthlySchedule)itm;
                query.Fields.Add(new FieldData { FieldName = "RecurType", FieldValue = "3", FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "RecurUnits", FieldValue = mSched.RecurEveryNoOfMonths.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "StartDate", FieldValue = mSched.StartDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "EndDate", FieldValue = mSched.EndDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "OnDay", FieldValue = mSched.OnDay.ToString(), FieldType = SqlDbType.Int });
            }
                else if (itm.GetType() == typeof(WeeklySchedule))
            {
                WeeklySchedule wSched = (WeeklySchedule)itm;
                query.Fields.Add(new FieldData { FieldName = "RecurType", FieldValue = "2", FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "RecurUnits", FieldValue = wSched.RecurEveryNoOfWeeks.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "StartDate", FieldValue = wSched.StartDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "EndDate", FieldValue = wSched.EndDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "OnMondays", FieldValue = wSched.OnMondays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnTuesdays", FieldValue = wSched.OnTuesdays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnWednesdays", FieldValue = wSched.OnWednesdays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnThursdays", FieldValue = wSched.OnThursdays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnFridays", FieldValue = wSched.OnFridays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnSaturdays", FieldValue = wSched.OnSaturdays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "OnSundays", FieldValue = wSched.OnSundays.ToString(), FieldType = SqlDbType.Int });
            }
            else
            {
                DailySchedule dSched = (DailySchedule)itm;
                query.Fields.Add(new FieldData { FieldName = "RecurType", FieldValue = "1", FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "RecurUnits", FieldValue = dSched.RecurEveryNoOfDays.ToString(), FieldType = SqlDbType.Int });
                query.Fields.Add(new FieldData { FieldName = "StartDate", FieldValue = dSched.StartDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "EndDate", FieldValue = dSched.EndDate.ToString(Constants.DATE_FORMAT_SQL), FieldType = SqlDbType.DateTime });
                query.Fields.Add(new FieldData { FieldName = "WeekDaysOnly", FieldValue = dSched.WeekDaysOnly.ToString(), FieldType = SqlDbType.Bit });
            }
            if (!SQLWrapper.ExecuteQuery(query))
            {
                itmID = 0;
            }
            return itmID;
        }
Пример #26
0
        /// <summary>
        /// ���� ���캯��
        /// </summary>
        /// <param name="_schedule">����ִ�мƻ�</param>
        /// <param name="_param">�������</param>
        public Task(ISchedule _schedule, object _param)
        {
            if (_schedule == null)
            {
                throw (new ArgumentNullException("_schedule"));
            }

            schedule = _schedule;
            param = _param;
        }
Пример #27
0
        public DateLimitSchedule(ISchedule baseSchedule, DateTime onOrBefore)
        {
            if (baseSchedule == null)
            {
                throw new ArgumentNullException("baseSchedule");
            }

            this.BaseSchedule = baseSchedule;
            this.OnOrBefore = onOrBefore;
        }
Пример #28
0
 public int GetFineOfAddedClass(ISchedule schedule, EntityStorage eStorage)
 {
     if (ClassesInWeek.LotOfClassesInWeek(3, sClasses, schedule, schedule.GetTempClass()))
     {
         if (isBlock)
             return Constants.BLOCK_FINE;
         else
             return fine;
     }
     return 0;
 }
Пример #29
0
        public WeekendAdjustSchedule(ISchedule baseSchedule, WeekdayAdjustmentDirection saturdayAdjustment, WeekdayAdjustmentDirection sundayAdjustment)
        {
            if (baseSchedule == null)
            {
                throw new ArgumentNullException("baseSchedule");
            }

            this.BaseSchedule = baseSchedule;
            this.SaturdayAdjustment = saturdayAdjustment;
            this.SundayAdjustment = sundayAdjustment;
        }
Пример #30
0
 /// <summary>
 /// Constructor for schedule list.
 /// <remarks>Will only enumerate the first two items from the list.</remarks>
 /// </summary>
 /// <param name="List">Enumerable list of ISchedule objects.</param>
 public BoolIntersectionSchedule(IEnumerable<ISchedule> List)
 {
     var Iter = List.GetEnumerator();
      if (Iter.MoveNext()) {
     _ScheduleA = Iter.Current;
     if (Iter.MoveNext())
        _ScheduleB = Iter.Current;
     else
        _ScheduleB = new VoidSchedule();
      }
      else {
     _ScheduleA = _ScheduleB = new VoidSchedule();
      }
 }
Пример #31
0
 public HourOfDaySchedule(ISchedule schedule, int[] hoursOfDay)
 {
     if (hoursOfDay is object)
     {
         foreach (var hourOfDay in hoursOfDay)
         {
             if (hourOfDay < 0 || hourOfDay > 23)
             {
                 throw new ArgumentException("hourOfDay < 0 || hourOfDay > 23", nameof(hourOfDay));
             }
         }
     }
     _schedule   = schedule.OrEvery(TimeUnit.Hour);
     _hoursOfDay = hoursOfDay?.ToHashSet() ?? new HashSet <int>();
 }
Пример #32
0
        public void Ctor_01(int index)
        {
            // arrange:
            VoyageNumber number   = new VoyageNumber("VYGTEST01");
            ISchedule    schedule = MockRepository.GenerateStrictMock <ISchedule>();

            schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();

            // act:
            StoppedVoyage state = new StoppedVoyage(number, schedule, index);

            // assert:
            Assert.AreSame(schedule, state.Schedule);
            Assert.IsFalse(state.IsMoving);
        }
 public SecondOfMinuteSchedule(ISchedule schedule, int[] secondsOfMinute)
 {
     if (secondsOfMinute is object)
     {
         foreach (var secondOfMinute in secondsOfMinute)
         {
             if (secondOfMinute < 0 || secondOfMinute > 59)
             {
                 throw new ArgumentException($"secondOfMinute < 0 || secondOfMinute > 59", nameof(secondOfMinute));
             }
         }
     }
     _schedule        = schedule.OrEvery(TimeUnit.Second);
     _secondsOfMinute = secondsOfMinute?.ToHashSet() ?? new HashSet <int>();
 }
 public MonthOfYearSchedule(ISchedule schedule, int[] months)
 {
     if (months is object)
     {
         foreach (var month in months)
         {
             if (month < 1 || month > 12)
             {
                 throw new ArgumentException("month < 1 || month > 12", nameof(month));
             }
         }
     }
     _schedule     = schedule.OrEvery(TimeUnit.Month);
     _monthsOfYear = months?.ToHashSet() ?? new HashSet <int>();
 }
Пример #35
0
 public MillisecondOfSecondSchedule(ISchedule schedule, int[] millisecondsOfSecond)
 {
     if (millisecondsOfSecond is object)
     {
         foreach (var millisecondOfSecond in millisecondsOfSecond)
         {
             if (millisecondOfSecond < 0 || millisecondOfSecond > 999)
             {
                 throw new ArgumentException("millisecondOfSecond < 0 || millisecondOfSecond > 999", nameof(millisecondOfSecond));
             }
         }
     }
     _schedule             = schedule.OrEvery(TimeUnit.Millisecond);
     _millisecondsOfSecond = millisecondsOfSecond?.ToHashSet() ?? new HashSet <int>();
 }
Пример #36
0
        public void Next(IIterationId id, ISchedule schedule)
        {
            long timerTicks = _timer.Value.Ticks;
            long delta      = timerTicks + ScheduleAheadTicks - _next;

            if (delta >= 0)
            {
                long current = Interlocked.Add(ref _next, _delayTicks);
                schedule.ExecuteAt(TimeSpan.FromTicks(current));
            }
            else
            {
                schedule.Idle(TimeSpan.FromTicks(Math.Abs(delta) + TimeSpan.TicksPerMillisecond));
            }
        }
Пример #37
0
        public ScheduleContent(int DayInt, ISchedule schedule)
        {
            this._schedule = schedule;

            this.FileName     = FileNameGenerator.GetContentFileName(DayInt);
            this.DayInt       = DayInt;
            this.FullFileName = FileNameGenerator.GetContentFullFileName(DayInt, schedule);

            if (!File.Exists(this.FullFileName))
            {
                File.WriteAllText(this.FullFileName, "schedule content file, do not modify\r\n");
            }

            this.ValueConverter = ObjectContainer.GetConverter <TValue>();
        }
Пример #38
0
        /// <summary>
        /// Updates the postal tariff of the specified mailing event.
        /// </summary>
        /// <param name="eventId">Internal identifier of the event.</param>
        /// <param name="postalTariff">Postal tariff of the mailing event.</param>
        /// <param name="notes">Notes of the mailing event.</param>
        /// <param name="userId">Internal identifier of the user.</param>
        public void UpdatePostalTariff(int eventId, string postalTariff, string notes,
                                       int userId)
        {
            // Get an instance of the Schedule DAO using the DALFactory
            ISchedule dao = (ISchedule)DALFactory.DAO.Create(DALFactory.Module.Schedule);

            try
            {
                dao.UpdatePostalTariff(eventId, postalTariff, notes, userId);
            }
            catch
            {
                throw;
            }
        }
Пример #39
0
        /// <summary>
        /// Updates the event entry of the specified mailing event.
        /// </summary>
        /// <param name="farmId">Internal identifier of the farm.</param>
        /// <param name="plotId">Internal identifier of the plot.</param>
        /// <param name="eventId">Internal identifier of the event.</param>
        /// <param name="messageId">Internal identifier of the message.</param>
        /// <param name="userId">Internal identifier of the user.</param>
        public void UpdateEventEntry(int farmId, int plotId, int eventId, int messageId,
                                     int userId)
        {
            // Get an instance of the Schedule DAO using the DALFactory
            ISchedule dao = (ISchedule)DALFactory.DAO.Create(DALFactory.Module.Schedule);

            try
            {
                dao.UpdateEventEntry(farmId, plotId, eventId, messageId, userId);
            }
            catch
            {
                throw;
            }
        }
Пример #40
0
 public DayOfYearSchedule(ISchedule schedule, int[] daysOfYear)
 {
     if (daysOfYear is object)
     {
         foreach (var dayOfYear in daysOfYear)
         {
             if (dayOfYear < 1 || dayOfYear > 366)
             {
                 throw new ArgumentException("dayOfYear < 1 || dayOfYear > 366", nameof(dayOfYear));
             }
         }
     }
     _schedule   = schedule.OrEvery(TimeUnit.Day);
     _daysOfYear = daysOfYear?.ToHashSet() ?? new HashSet <int>();
 }
Пример #41
0
 internal bool HasConsistentLocation(ISchedule service, bool isMain)
 {
     try
     {
         var stop = service.GetStop(Main.AtLocation, Main.Sequence);
         return(isMain ? stop.IsMainConsistent(Category) : stop.IsAssociatedConsistent(Category));
     }
     catch (Exception e)
     {
         Logger.Warning(e,
                        "Error when matching association location {location} {service} {association}:{main}",
                        Main.AtLocation, service, this, isMain);
         return(false);
     }
 }
Пример #42
0
        /// <summary>
        /// Creates a new instance of the <see cref="ScheduleDefinition"/> class.
        /// </summary>
        /// <param name="containingGroup">The ID of the group that has registered the schedule.</param>
        /// <param name="schedule">The schedule.</param>
        /// <param name="actions">The collection that maps a schedule element to an action.</param>
        /// <param name="conditions">The collection that maps a schedule element to a condition.</param>
        /// <returns>The newly created definition.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="containingGroup"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="schedule"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="actions"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="conditions"/> is <see langword="null" />.
        /// </exception>
        public static ScheduleDefinition CreateDefinition(
            GroupRegistrationId containingGroup,
            ISchedule schedule,
            IDictionary <ScheduleElementId, ScheduleActionRegistrationId> actions,
            IDictionary <ScheduleElementId, ScheduleConditionRegistrationId> conditions)
        {
            {
                Lokad.Enforce.Argument(() => containingGroup);
                Lokad.Enforce.Argument(() => schedule);
                Lokad.Enforce.Argument(() => actions);
                Lokad.Enforce.Argument(() => conditions);
            }

            return(new ScheduleDefinition(containingGroup, schedule, actions, conditions));
        }
Пример #43
0
        public void WillStopOverAt_nullLocation_throwsArgumentNullException()
        {
            // arrange:
            VoyageNumber number   = new VoyageNumber("VYG01");
            ISchedule    schedule = MockRepository.GenerateStrictMock <ISchedule>();
            VoyageState  state    = MockRepository.GeneratePartialMock <VoyageState>(number, schedule);

            // act:
            IVoyage voyage = MockRepository.GeneratePartialMock <Challenge00.DDDSample.Voyage.Voyage>(state);

            // assert:
            Assert.Throws <ArgumentNullException>(delegate { voyage.WillStopOverAt(null); });
            state.VerifyAllExpectations();
            schedule.VerifyAllExpectations();
        }
Пример #44
0
 public MinuteOfHourSchedule(ISchedule schedule, int[] minutesOfHour)
 {
     if (minutesOfHour is object)
     {
         foreach (var minuteOfHour in minutesOfHour)
         {
             if (minuteOfHour < 0 || minuteOfHour > 59)
             {
                 throw new ArgumentException("minuteOfHour < 0 || minuteOfHour > 59", nameof(minuteOfHour));
             }
         }
     }
     _schedule      = schedule.OrEvery(TimeUnit.Minute);
     _minutesOfHour = minutesOfHour?.ToHashSet() ?? new HashSet <int>();
 }
Пример #45
0
        /// <summary>
        /// Adds the <see cref="ISchedule"/> object with the variables it affects and the dependencies for that schedule.
        /// </summary>
        /// <param name="schedule">The schedule that should be stored.</param>
        /// <param name="name">The name of the schedule that is being described by this information object.</param>
        /// <param name="description">The description of the schedule that is being described by this information object.</param>
        /// <returns>An object identifying and describing the schedule.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="schedule"/> is <see langword="null" />.
        /// </exception>
        public ScheduleInformation Add(
            ISchedule schedule,
            string name,
            string description)
        {
            {
                Lokad.Enforce.Argument(() => schedule);
            }

            var id   = new ScheduleId();
            var info = new ScheduleInformation(id, name, description);

            m_Schedules.Add(id, new ScheduleMap(info, schedule));

            return(info);
        }
Пример #46
0
        public void Append_02()
        {
            // arrange:
            ICarrierMovement m1    = MockRepository.GenerateStrictMock <ICarrierMovement>();
            ISchedule        empty = new Schedule();

            // act:
            ISchedule schedule = empty.Append(m1);

            // assert:
            Assert.IsFalse(schedule.Equals(empty));
            Assert.IsTrue(schedule.Equals(schedule));
            Assert.AreSame(m1, schedule[0]);
            Assert.AreEqual(1, schedule.Count());
            Assert.AreEqual(1, schedule.MovementsCount);
        }
Пример #47
0
        public void EnabledTest()
        {
            TimeSpan  triggerPeriod = new TimeSpan(5, 0, 0);
            ISchedule target        = theScheduler.Add(triggerPeriod, false);

            Assert.IsFalse(target.Enabled);

            target.Enabled = true;
            DateTime nextDueTime = DateTime.Now + target.Period;

            Assert.AreNotEqual(target.NextDueTime, DateTime.MaxValue);
            Assert.AreEqual(target.NextDueTime, nextDueTime);

            target.Enabled = false;
            Assert.AreEqual(target.NextDueTime, DateTime.MaxValue);
        }
Пример #48
0
        private void UpdateScheduleDetails(ISchedule schedule)
        {
            string   channelName = string.Empty;
            IChannel channel;

            if (_tvHandler.ChannelAndGroupInfo != null && _tvHandler.ChannelAndGroupInfo.GetChannel(schedule.ChannelId, out channel))
            {
                channelName = channel.Name;
            }

            StartTime    = schedule.StartTime;
            EndTime      = schedule.EndTime;
            ChannelName  = channelName;
            ScheduleName = schedule.Name;
            ScheduleType = string.Format("[SlimTvClient.ScheduleRecordingType_{0}]", schedule.RecordingType);
        }
Пример #49
0
        public void Equals_04(int index)
        {
            // arrange:
            VoyageNumber number   = new VoyageNumber("VYGTEST01");
            ISchedule    schedule = MockRepository.GenerateStrictMock <ISchedule>();

            schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
            schedule.Expect(s => s.Equals(schedule)).Return(true).Repeat.Any();

            // act:
            StoppedVoyage state1 = new StoppedVoyage(number, schedule, index);
            VoyageState   state2 = new MovingVoyage(number, schedule, index);

            // assert:
            Assert.IsFalse(state1.Equals(state2));
            schedule.VerifyAllExpectations();
        }
Пример #50
0
        private void ChainNotify(GameAction action, ActionState state)
        {
            chainState = state;
            ChainCallback currentChain = chainCallback;

            ISchedule scheduledAction = action as ISchedule;

            switch (state)
            {
            case ActionState.Fired:
            case ActionState.Started:
            case ActionState.Rescheduled:
                DbPersistance.Current.Save(action);
                if (scheduledAction != null)
                {
                    Scheduler.Current.Put(scheduledAction);
                }

                DbPersistance.Current.Save(this);

                Scheduler.Current.Put(new ChainExecuter(currentChain, state));
                return;

            case ActionState.Completed:
            case ActionState.Failed:
                ActionIdGenerator.Release(action.ActionId);
                DbPersistance.Current.Delete(action);
                break;

            default:
                throw new Exception("Unexpected state " + state);
            }

            //current action is completed by either success or failure
            if (scheduledAction != null)
            {
                Scheduler.Current.Remove(scheduledAction);
            }

            action.IsDone    = true;
            action.OnNotify -= ChainNotify;
            Current          = null;
            DbPersistance.Current.Save(this);

            Scheduler.Current.Put(new ChainExecuter(currentChain, state));
        }
Пример #51
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledExecutionEvent"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="operationExecuted">The <see cref="IVoidOperation"/> executed.</param>
        /// <param name="schedule">The <see cref="ISchedule"/> evaluated.</param>
        /// <param name="previousExecutionTimestampUtc">The previous execution timestamp in UTC format.</param>
        /// <param name="timestampUtc">The timestamp of the event in UTC format.</param>
        /// <param name="tags">The tags associated with the reaction.</param>
        public ScheduledExecutionEvent(
            string id,
            IVoidOperation operationExecuted,
            ISchedule schedule,
            DateTime?previousExecutionTimestampUtc,
            DateTime timestampUtc,
            IReadOnlyCollection <NamedValue <string> > tags = null) : base(id, timestampUtc)
        {
            operationExecuted.MustForArg(nameof(operationExecuted)).NotBeNull();
            schedule.MustForArg(nameof(schedule)).NotBeNull();
            previousExecutionTimestampUtc.MustForArg(nameof(previousExecutionTimestampUtc)).BeUtcDateTimeWhenNotNull();

            this.OperationExecuted             = operationExecuted;
            this.Schedule                      = schedule;
            this.PreviousExecutionTimestampUtc = previousExecutionTimestampUtc;
            this.Tags = tags;
        }
Пример #52
0
        public static ScheduledFunction <T> Add <T>(
            [NotNull] ScheduledFunction <T> .SchedulableDueCancellableFunctionAsync function,
            [NotNull] ISchedule schedule,
            int maximumHistory       = -1,
            Duration maximumDuration = default(Duration))
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }

            return(Add(true, function, schedule, maximumHistory, maximumDuration));
        }
Пример #53
0
 public GameObject(ILocation?location = null, FrozenTraitStore?traits = null)
 {
     if (location == null)
     {
         location = new OffscreenLocation();
     }
     if (traits == null)
     {
         traits = FrozenTraitStore.Empty();
     }
     this.traits = new MirrorTraitStore(traits);
     Location    = location;
     Location.BeEntered(this);
     Schedule = Location.Schedule;
     contents = new HashSet <GameObject>();
     Name     = new SimpleName("nameless object");
 }
Пример #54
0
 public bool RemoveSchedule(ISchedule schedule)
 {
     try
     {
         CpAction       action       = GetAction(Consts.ACTION_REMOVE_SCHEDULE);
         IList <object> inParameters = new List <object> {
             schedule
         };
         IList <object> outParameters = action.InvokeAction(inParameters);
         return((bool)outParameters[0]);
     }
     catch (Exception ex)
     {
         NotifyException(ex);
         return(false);
     }
 }
Пример #55
0
        public static bool TryGetSchedule([NotNull] string name, out ISchedule schedule)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            ScheduleInfo scheduleInfo;

            if (_schedules.TryGetValue(name, out scheduleInfo))
            {
                schedule = scheduleInfo.Schedule;
                return(true);
            }
            schedule = null;
            return(false);
        }
Пример #56
0
        public EditSchedule(ISchedule schedule, List <ITeam> teams)
        {
            if (schedule != null)
            {
                ScheduleId        = schedule.ScheduleId;
                TeamId            = schedule.TeamId;
                UserId            = schedule.UserId;
                SupportLevel      = schedule.SupportLevel;
                StartDate         = schedule.StartDate.ToLocalTime();
                EndDate           = schedule.EndDate.ToLocalTime();
                UserIdPlaceholder = schedule.UserId;
            }

            FillTeamSelectList(teams);
            FillSupportLevelSelectList();
            UserSelectList = new List <SelectListItem>();
        }
Пример #57
0
        private static ISchedule AddSchedule([NotNull] ISchedule schedule, bool isFromConfiguration)
        {
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }
            if (schedule.Name == null)
            {
                throw new ArgumentNullException("schedule", Resource.Scheduler_AddSchedule_SchenduleNameNull);
            }

            ScheduleInfo info = new ScheduleInfo(isFromConfiguration, schedule);

            // ReSharper disable AssignNullToNotNullAttribute
            return(_schedules.AddOrUpdate(schedule.Name, info, (k, v) => Equals(v, info) ? v : info).Schedule);
            // ReSharper restore AssignNullToNotNullAttribute
        }
Пример #58
0
        public string GetViaText(ISchedule schedule)
        {
            //HACK Destination can be null when not in the Stations file.
            //TODO Fix, need better locations: ideally would be IDMS.
            if (_rules.TryGetValue(schedule.Destination?.Location ?? Location.NotSet, out var destinationRules))
            {
                foreach (var rule in destinationRules)
                {
                    if (rule.IsSatisfied(schedule))
                    {
                        return(rule.Text);
                    }
                }
            }

            return(string.Empty);
        }
Пример #59
0
        public void Equals_06()
        {
            // arrange:
            VoyageNumber number   = new VoyageNumber("VYGTEST01");
            ISchedule    schedule = MockRepository.GenerateStrictMock <ISchedule>();

            schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();

            // act:
            CompletedVoyage state1 = new CompletedVoyage(number, schedule);
            VoyageState     state2 = MockRepository.GeneratePartialMock <VoyageState>(number, schedule);

            // assert:
            Assert.IsFalse(state1.Equals(state2));
            schedule.VerifyAllExpectations();
            state2.VerifyAllExpectations();
        }
Пример #60
0
        public static ScheduledFunction <T> Add <T>(
            [NotNull] ScheduledFunction <T> .SchedulableDueFunction function,
            [NotNull] ISchedule schedule,
            int maximumHistory       = -1,
            Duration maximumDuration = default(Duration))
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }

            return(Add(true, (d, t) => Task.FromResult(function(d)), schedule, maximumHistory, maximumDuration));
        }