public static void TeacherChanged(Models.Base.UITeacher teacher, string localID, Rule rule, AlgoRule algo, CLCase cl, bool hasPatern)
        {
            if (cl != null)
            {
                cl.Classes?.ForEach(c =>
                {
                    c.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                });

                cl.ClassHours?.ForEach(ch =>
                {
                    ch.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                });

                if (hasPatern)
                {
                    cl.SerializePatternCase(localID);
                }
                else
                {
                    cl.Serialize(localID);
                }
            }

            if (rule != null)
            {
                rule.TeacherTimes?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxGapsPerDay?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxDaysPerWeek?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxHoursDaily?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                if (hasPatern)
                {
                    rule.SerializePatternRule(localID);
                }
                else
                {
                    rule.Serialize(localID);
                }
            }

            if (algo != null)
            {
                algo.TeacherMaxGapsPerDays?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxHoursDailys?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxDaysPerWeeks?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherNotAvailableTimes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                if (hasPatern)
                {
                    algo.SerializePatternAlgo(localID);
                }
                else
                {
                    algo.Serialize(localID);
                }
            }
        }
示例#2
0
        void TeacherModify(Models.Base.UITeacher teacher)
        {
            if (teacher != null)
            {
                this.SelectTeacher = teacher;

                var firstCourse = this.Courses.FirstOrDefault(c => c.ShowSelectClassCountArea);
                if (firstCourse != null)
                {
                    this.SelectCourse = firstCourse;
                }
            }
        }
        public static void TeacherChanged(Models.Base.UITeacher teacher, string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetMixedRule(localID);
            var algo = CommonDataManager.GetMixedAlgoRule(localID);
            var cl   = CommonDataManager.GetCLCase(localID);

            if (cl != null)
            {
                cl.Classes?.ForEach(c =>
                {
                    c.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                });

                cl.ClassHours?.ForEach(ch =>
                {
                    ch.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                });

                cl.Serialize(localID);
            }

            if (rule != null)
            {
                rule.TeacherTimes?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxGapsPerDay?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxDaysPerWeek?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.MaxHoursDaily?.RemoveAll(t => t.TeacherID.Contains(teacher.ID));
                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.TeacherMaxGapsPerDays?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxHoursDailys?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxDaysPerWeeks?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherNotAvailableTimes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.Serialize(localID);
            }
        }
        public static void TeacherChanged(Models.Base.UITeacher teacher, string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetAminRule(localID);
            var algo = CommonDataManager.GetAminAlgoRule(localID);
            var cp   = CommonDataManager.GetCPCase(localID);

            if (cp != null)
            {
                cp.Classes?.ForEach(c =>
                {
                    c.Settings?.ForEach(s =>
                    {
                        s.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                    });
                });

                cp.ClassHours?.ForEach(ch =>
                {
                    ch.TeacherIDs?.RemoveAll(t => t.Contains(teacher.ID));
                });

                cp.Serialize(localID);
            }

            if (rule != null)
            {
                rule.TeacherTimes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.MasterApprenttices?.RemoveAll(t => t.MasterID.Equals(teacher.ID));
                rule.MasterApprenttices?.ForEach(m =>
                {
                    m.ApprenticeIDs?.RemoveAll(a => a.Equals(teacher.ID));
                });
                rule.PlanFlushes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.AmPmNoContinues?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.MaxGapsPerDay?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.MaxDaysPerWeek?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.MaxHoursDaily?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.ContinuousPlanFlushes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.ClassHourPriorityBalance?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                rule.LimitInSpecialTime?.ForEach(t =>
                {
                    t.TeacherIDs?.RemoveAll(ti => ti.Equals(teacher.ID));
                });
                rule.HalfDayWork?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));

                var teacherCourses = cp.GetCourses(teacher.ID);
                if (rule.TimeTableLockedTimes != null)
                {
                    rule.TimeTableLockedTimes.LockedTimeTable?.RemoveAll(lt => lt.LockedCourseTimeTable.Any(lct => teacherCourses.Any(tc => tc.ID.Equals(lct.CourseID))));
                }

                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.TeacherMaxGapsPerDays?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxHoursDailys?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherMaxDaysPerWeeks?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
                algo.TeacherNotAvailableTimes?.RemoveAll(t => t.TeacherID.Equals(teacher.ID));
            }
        }