/// <summary>
        /// 时间发生改变(清除所有时间规则)
        /// </summary>
        public static void TimeChanged(string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetMixedRule(localID);
            var algo = CommonDataManager.GetMixedAlgoRule(localID);

            if (rule != null)
            {
                rule.TeacherTimes?.Clear();
                rule.CourseLimits?.Clear();
                rule.CourseTimes?.Clear();
                rule.ArrangeContinuous?.Clear();
                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.TeacherNotAvailableTimes?.Clear();
                algo.ClassHourRequiredStartingTimes?.Clear();
                algo.ClassHourRequiredTimes?.Clear();
                algo.ClassHoursRequiredStartingTimes?.Clear();
                algo.ClassHoursRequiredTimes?.Clear();
                algo.ClassHourRequiredStartingTime?.Clear();
                algo.ClassHoursMaxConcurrencyInSelectedTimes?.Clear();
                algo.ClassHoursOccupyMaxTimeFromSelections?.Clear();
                algo.Serialize(localID);
            }
        }
 public InitLoginViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService) : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
 }
        public WaitGameStartFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }

                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
            PlayerId        = CommonDataManager.PlayerId;

            _isExecuting = false;
        }
        /// <summary>
        /// 时间发生改变(清除所有时间规则)
        /// </summary>
        public static void TimeChanged(string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetAminRule(localID);
            var algo = CommonDataManager.GetAminAlgoRule(localID);

            if (rule != null)
            {
                rule.TeacherTimes?.Clear();
                rule.CourseLimits?.Clear();
                rule.CourseTimes?.Clear();
                rule.CourseArranges?.Clear();
                rule.MinorCourseAvoidTime?.Clear();
                rule.MajorCoursePreferredTime?.Clear();
                rule.LimitInSpecialTime?.Clear();
                rule.TimeTableLockedTimes = null;
                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.TeacherNotAvailableTimes?.Clear();
                algo.ClassHourRequiredStartingTimes?.Clear();
                algo.ClassHourRequiredTimes?.Clear();
                algo.ClassHoursRequiredStartingTimes?.Clear();
                algo.ClassHoursRequiredTimes?.Clear();
                algo.ClassHourRequiredStartingTime?.Clear();
                algo.ClassHoursMaxConcurrencyInSelectedTimes?.Clear();
                algo.ClassHoursOccupyMaxTimeFromSelections?.Clear();
                algo.Serialize(localID);
            }
        }
 public CreatePlayerViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService)
     : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
 }
Esempio n. 6
0
 public TemplateInitializer(
     ConfigGenConfiguration conf,
     ICommonDataManager commonData,
     IDesignTimeConfigStorage designTimeStorage)
 {
     Configuration     = conf;
     CommonData        = commonData;
     DesignTimeStorage = designTimeStorage;
 }
 public CreatePlayerFlowViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService,
     ISessionIdGenerator sessionIdGenerator)
     : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
     _sessionIdGenerator      = sessionIdGenerator;
 }
        protected ServiceCallViewModel(ICommonDataManager commonDataManager, IServiceCallInvoker serviceCallInvoker)
        {
            CommonDataManager  = commonDataManager;
            ServiceCallInvoker = serviceCallInvoker;

            ServiceUrl     = CommonDataManager.ServerUrl;
            Username       = CommonDataManager.Username;
            TeamName       = CommonDataManager.TeamName;
            Password       = CommonDataManager.Password;
            SessionId      = CommonDataManager.SessionId;
            SequenceNumber = CommonDataManager.SequenceNumber;

            CalculateAuthCode();

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "ServerUrl")
                {
                    ServiceUrl = CommonDataManager.ServerUrl;
                }
                else if (args.PropertyName == "Username")
                {
                    Username = CommonDataManager.Username;
                }
                else if (args.PropertyName == "TeamName")
                {
                    TeamName = CommonDataManager.TeamName;
                }
                else if (args.PropertyName == "Password")
                {
                    Password = CommonDataManager.Password;
                }
                else if (args.PropertyName == "SessionId")
                {
                    SessionId = CommonDataManager.SessionId;
                }
                else if (args.PropertyName == "SequenceNumber")
                {
                    SequenceNumber = CommonDataManager.SequenceNumber;
                }
            };

            this.PropertyChanged += (sender, args) =>
            {
                string[] authcodeProps = new string[] { "TeamName", "Username", "SessionId", "SequenceNumber", "Password" };
                if (Array.IndexOf(authcodeProps, args.PropertyName) >= 0)
                {
                    CalculateAuthCode();
                }
            };
        }
Esempio n. 9
0
        protected ServiceCallViewModel(ICommonDataManager commonDataManager, IServiceCallInvoker serviceCallInvoker)
        {
            CommonDataManager  = commonDataManager;
            ServiceCallInvoker = serviceCallInvoker;

            PropertyChanged += OnPropertyChanged;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "ServerUrl")
                {
                    ServiceUrl = CommonDataManager.ServerUrl;
                }

                if (args.PropertyName == "Username")
                {
                    Username = CommonDataManager.Username;
                }

                if (args.PropertyName == "TeamName")
                {
                    TeamName = CommonDataManager.TeamName;
                }

                if (args.PropertyName == "Password")
                {
                    Password = CommonDataManager.Password;
                }

                if (args.PropertyName == "SessionId")
                {
                    SessionId = CommonDataManager.SessionId;
                }

                if (args.PropertyName == "SequenceNumber")
                {
                    SequenceNumber = CommonDataManager.SequenceNumber;
                }
            };

            ServiceUrl     = CommonDataManager.ServerUrl;
            Username       = CommonDataManager.Username;
            TeamName       = CommonDataManager.TeamName;
            Password       = CommonDataManager.Password;
            SessionId      = CommonDataManager.SessionId;
            SequenceNumber = CommonDataManager.SequenceNumber;
        }
        public LeaveGameViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService           = messageBoxDialogService;
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            PlayerId = CommonDataManager.PlayerId;
        }
Esempio n. 11
0
        public CompleteLoginViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
        }
Esempio n. 12
0
        public GetTurnResultViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;
        }
Esempio n. 13
0
        public CreatePlayerFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
            SessionId       = CommonDataManager.SessionId;
        }
        public FilterView()
        {
            InitializeComponent();

            _commonDataManager = CacheManager.Instance.UnityContainer.Resolve <ICommonDataManager>();

            var cp = _commonDataManager.GetCPCase(_commonDataManager.LocalID);

            if (cp != null)
            {
                var teachers     = cp.Teachers.ToList();
                var firstTeacher = new XYKernel.OS.Common.Models.Administrative.TeacherModel
                {
                    ID   = string.Empty,
                    Name = string.Empty
                };
                teachers.Insert(0, firstTeacher);

                cmb_teacher.ItemsSource   = teachers;
                cmb_teacher.SelectedIndex = 0;

                var courses     = cp.Courses.ToList();
                var firstCourse = new XYKernel.OS.Common.Models.Administrative.CourseModel()
                {
                    ID   = string.Empty,
                    Name = string.Empty
                };
                courses.Insert(0, firstCourse);
                cmb_subject.ItemsSource   = courses;
                cmb_subject.SelectedIndex = 0;

                var classes    = cp.Classes.ToList();
                var firstClass = new XYKernel.OS.Common.Models.Administrative.ClassModel()
                {
                    ID   = string.Empty,
                    Name = string.Empty
                };

                classes.Insert(0, firstClass);
                cmb_class.ItemsSource   = classes;
                cmb_class.SelectedIndex = 0;
            }
        }
        public static void ClassHourChanged(string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetAminRule(localID);
            var algo = CommonDataManager.GetAminAlgoRule(localID);
            var cp   = CommonDataManager.GetCPCase(localID);

            if (rule != null)
            {
                rule.ClassHourSameOpens?.Clear();
                rule.CourseTimes?.Clear();
                rule.CourseArranges?.Clear();
                rule.ClassHourAverages?.Clear();
                rule.AmPmClassHours?.Clear();
                rule.PlanFlushes?.Clear();
                rule.ClassHourPriorityBalance?.Clear();
                rule.ContinuousPlanFlushes?.Clear();
                rule.TimeTableLockedTimes = null;

                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.ClassHoursSameStartingDays?.Clear();
                algo.ClassHoursSameStartingTimes?.Clear();
                algo.ClassHoursSameStartingHours?.Clear();
                algo.TwoClassHoursContinuous?.Clear();
                algo.TwoClassHoursOrdered?.Clear();
                algo.TwoClassHoursGrouped?.Clear();
                algo.ThreeClassHoursGrouped?.Clear();
                algo.MinDaysBetweenClassHours?.Clear();
                algo.ClassHourRequiredStartingTimes?.Clear();
                algo.ClassHourRequiredTimes?.Clear();
                algo.MaxDaysBetweenClassHours?.Clear();
                algo.ClassHoursNotOverlaps?.Clear();
                algo.ClassHourRequiredStartingTime?.Clear();
                algo.ClassHoursMaxConcurrencyInSelectedTimes?.Clear();
                algo.ClassHoursOccupyMaxTimeFromSelections?.Clear();
                algo.Serialize(localID);
            }
        }
        public CommonDataViewModel(ICommonDataManager commonDataManager)
        {
            _commonDataManager = commonDataManager;
            _commonDataManager.PropertyChanged += (sender, args) =>
            {
                switch (args.PropertyName)
                {
                case "SessionId":
                    OnPropertyChanged(() => SessionId);
                    break;

                case "SequenceNumber":
                    OnPropertyChanged(() => SequenceNumber);
                    break;

                case "PlayerId":
                    OnPropertyChanged(() => PlayerId);
                    break;
                }
            };
        }
Esempio n. 17
0
        public WaitNextTurnViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;
            Turn     = CommonDataManager.Turn;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Turn")
                {
                    Turn = CommonDataManager.Turn;
                }
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };
        }
        public static void ClassHourChanged(string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetMixedRule(localID);
            var algo = CommonDataManager.GetMixedAlgoRule(localID);
            var cl   = CommonDataManager.GetCLCase(localID);

            if (rule != null)
            {
                OSKernel.Presentation.Models.Enums.MixedRuleEnum.ClassHourSameOpen.DeleteRule(localID);
                rule.ClassHourSameOpens?.Clear();
                rule.ClassHourAverages?.Clear();
                rule.CourseTimes?.Clear();
                rule.ArrangeContinuous?.Clear();
                rule.AmPmClassHours?.Clear();

                rule.Serialize(localID);
            }

            if (algo != null)
            {
                algo.ClassHoursSameStartingDays?.Clear();
                algo.ClassHoursSameStartingTimes?.Clear();
                algo.ClassHoursSameStartingHours?.Clear();
                algo.TwoClassHoursContinuous?.Clear();
                algo.TwoClassHoursOrdered?.Clear();
                algo.TwoClassHoursGrouped?.Clear();
                algo.ThreeClassHoursGrouped?.Clear();
                algo.MinDaysBetweenClassHours?.Clear();
                algo.ClassHourRequiredStartingTimes?.Clear();
                algo.ClassHourRequiredTimes?.Clear();
                algo.MaxDaysBetweenClassHours?.Clear();
                algo.ClassHoursNotOverlaps?.Clear();
                algo.ClassHourRequiredStartingTime?.Clear();
                algo.ClassHoursMaxConcurrencyInSelectedTimes?.Clear();
                algo.ClassHoursOccupyMaxTimeFromSelections?.Clear();
                algo.Serialize(localID);
            }
        }
Esempio n. 19
0
        public static Tuple <bool, string> CanReplacePosition(string localID, string classID, List <ResultDetailModel> sourceItem, List <ResultDetailModel> targetItem, ResultModel resultModel)
        {
            ICommonDataManager commonDataManager = CacheManager.Instance.UnityContainer.Resolve <ICommonDataManager>();
            var cp   = commonDataManager.GetCPCase(localID);
            var rule = commonDataManager.GetAminRule(localID);
            var algo = commonDataManager.GetAminAlgoRule(localID);

            var positionsSource = GetMovablePositons(localID, classID, sourceItem, resultModel);
            var positionsTarget = GetMovablePositons(localID, classID, targetItem, resultModel);

            DayPeriodModel dpSource = sourceItem.FirstOrDefault().DayPeriod;
            DayPeriodModel dpTarget = targetItem.FirstOrDefault().DayPeriod;

            if (dpTarget != null && positionsSource.Item1.Exists(dp => dp.Day == dpTarget.Day && dp.PeriodName == dpTarget.PeriodName) &&
                dpSource != null && positionsTarget.Item1.Exists(dp => dp.Day == dpSource.Day && dp.PeriodName == dpSource.PeriodName))
            {
                return(Tuple.Create(true, string.Empty));
            }
            else
            {
                var sourceToTargetWarning = positionsSource.Item2.Where(dp => dp.DayPeriod.Day == dpTarget.Day && dp.DayPeriod.PeriodName == dpTarget.PeriodName).ToList();
                var targetToSourceWarning = positionsTarget.Item2.Where(dp => dp.DayPeriod.Day == dpSource.Day && dp.DayPeriod.PeriodName == dpSource.PeriodName).ToList();

                StringBuilder sb = new StringBuilder(100);

                sourceToTargetWarning?.ForEach(w =>
                {
                    sb.AppendLine(w.WaringMessage);
                });

                targetToSourceWarning?.ForEach(w =>
                {
                    sb.AppendLine(w.WaringMessage);
                });

                return(Tuple.Create(false, sb.ToString()));
            }
        }
Esempio n. 20
0
        private static Tuple <List <DayPeriodModel>, List <PostionWithWarningInfo> > GetMovablePositons(string localID, string classID, List <ResultDetailModel> item, ResultModel resultModel)
        {
            //可用课位,最后取反返回不可用课位
            var dayPeriods   = new List <DayPeriodModel>();
            var notReachable = new List <PostionWithWarningInfo>();

            ICommonDataManager commonDataManager = CacheManager.Instance.UnityContainer.Resolve <ICommonDataManager>();
            var cp   = commonDataManager.GetCPCase(localID);
            var rule = commonDataManager.GetAminRule(localID);
            var algo = commonDataManager.GetAminAlgoRule(localID);

            //获取方案可用时间
            dayPeriods = cp?.Positions?.Where(p => p.IsSelected &&
                                              p.Position != XYKernel.OS.Common.Enums.Position.AB &&
                                              p.Position != XYKernel.OS.Common.Enums.Position.Noon &&
                                              p.Position != XYKernel.OS.Common.Enums.Position.PB)
                         ?.Select(d => d.DayPeriod)?.ToList() ?? new List <DayPeriodModel>();

            cp?.Positions?.Where(p => !p.IsSelected &&
                                 p.Position != XYKernel.OS.Common.Enums.Position.AB &&
                                 p.Position != XYKernel.OS.Common.Enums.Position.Noon &&
                                 p.Position != XYKernel.OS.Common.Enums.Position.PB)
            ?.Select(d => d.DayPeriod)?.ToList()?.ForEach(p => {
                notReachable.Add(new PostionWithWarningInfo()
                {
                    DayPeriod = p, WaringMessage = $"方案不可用时间!"
                });
            });

            //TODO: 是否基于现有模型更新结果模型中的教师信息?
            item?.ForEach(it =>
            {
                List <string> teachers = new List <string>();
                teachers = it?.Teachers == null ? new List <string>() : it.Teachers.ToList();

                //1.0 移除教师在其他班级的课位
                if (teachers.Count > 0)
                {
                    resultModel.ResultClasses?.Where(c => c.ClassID != classID)?.ToList()?.ForEach(c =>
                    {
                        c.ResultDetails?.Where(rd => rd.Teachers != null && rd.Teachers.Intersect(teachers).Count() > 0)?.ToList()?.ForEach(t =>
                        {
                            notReachable.Add(new PostionWithWarningInfo()
                            {
                                DayPeriod = t.DayPeriod, WaringMessage = $"教师在课位({TimeOperation.GetDateInfo(t.DayPeriod)})安排有其他班级课程!"
                            });
                            dayPeriods.RemoveAll(p => p.Day == t.DayPeriod.Day && p.PeriodName == t.DayPeriod.PeriodName);
                        });
                    });
                }

                //2.0 检查批量规则 - 仅查权重为高级的规则
                rule?.TeacherTimes?.Where(t => t.Weight == 1 && teachers.Contains(t.TeacherID))?.ToList()?.ForEach(x =>
                {
                    if (x.ForbidTimes != null)
                    {
                        dayPeriods = TimeOperation.TimeSlotDiff(dayPeriods, x.ForbidTimes);

                        x.ForbidTimes.ForEach(fb =>
                        {
                            notReachable.Add(new PostionWithWarningInfo()
                            {
                                DayPeriod = fb, WaringMessage = $"教师在课位({TimeOperation.GetDateInfo(fb)})有禁止规则!"
                            });
                        });
                    }

                    if (x.MustTimes != null)
                    {
                        //必须时间暂不必查
                    }
                });

                rule?.CourseTimes?.Where(c => c.Weight == 1 && c.ClassID == classID && c.CourseID == it.CourseID)?.ToList()?.ForEach(x =>
                {
                    if (x.ForbidTimes != null)
                    {
                        dayPeriods = TimeOperation.TimeSlotDiff(dayPeriods, x.ForbidTimes);

                        x.ForbidTimes.ForEach(fb =>
                        {
                            notReachable.Add(new PostionWithWarningInfo()
                            {
                                DayPeriod = fb, WaringMessage = $"课程在课位({TimeOperation.GetDateInfo(fb)})有禁止规则!"
                            });
                        });
                    }

                    if (x.MustTimes != null)
                    {
                        int classHourNumber = cp.ClassHours.Where(ch => ch.ClassID == classID && ch.CourseID == it.CourseID).Count();

                        if (x.MustTimes.Count >= classHourNumber)
                        {
                            dayPeriods.ForEach(dp =>
                            {
                                if (!x.MustTimes.Exists(mt => mt.Day == dp.Day && mt.PeriodName == dp.PeriodName))
                                {
                                    notReachable.Add(new PostionWithWarningInfo()
                                    {
                                        DayPeriod = dp, WaringMessage = "课程应先满足排到必须规则指定课位内!"
                                    });
                                }
                            });

                            dayPeriods = TimeOperation.TimeSlotInterSect(dayPeriods, x.MustTimes);
                        }
                        else
                        {
                            List <DayPeriodModel> classHourTimes = resultModel.ResultClasses.Where(c => c.ClassID == classID)
                                                                   ?.SelectMany(c => c.ResultDetails)
                                                                   ?.Where(c => c.CourseID == it.CourseID)
                                                                   ?.Select(c => c.DayPeriod).ToList() ?? new List <DayPeriodModel>()
                            {
                            };

                            List <DayPeriodModel> classHoursInMust = TimeOperation.TimeSlotInterSect(x.MustTimes, classHourTimes);
                            if (classHoursInMust.Count < x.MustTimes.Count)
                            {
                                dayPeriods.ForEach(dp =>
                                {
                                    if (!x.MustTimes.Exists(mt => mt.Day == dp.Day && mt.PeriodName == dp.PeriodName))
                                    {
                                        notReachable.Add(new PostionWithWarningInfo()
                                        {
                                            DayPeriod = dp, WaringMessage = "课程应先满足排到必须规则指定课位内!"
                                        });
                                    }
                                });

                                dayPeriods = TimeOperation.TimeSlotInterSect(dayPeriods, x.MustTimes);
                            }
                            else
                            {
                                //如果课位在必须时间内,则只能和本班课时互换以保障课时优先在必须时间内
                                List <DayPeriodModel> mustTempTimes = TimeOperation.TimeSlotInterSect(x.MustTimes, new List <DayPeriodModel>()
                                {
                                    it.DayPeriod
                                });
                                if (mustTempTimes.Count == 1)
                                {
                                    dayPeriods.ForEach(dp =>
                                    {
                                        if (!classHourTimes.Exists(mt => mt.Day == dp.Day && mt.PeriodName == dp.PeriodName))
                                        {
                                            notReachable.Add(new PostionWithWarningInfo()
                                            {
                                                DayPeriod = dp, WaringMessage = "课程应先满足排到必须规则指定课位内!"
                                            });
                                        }
                                    });

                                    dayPeriods = TimeOperation.TimeSlotInterSect(dayPeriods, classHourTimes);
                                }
                            }
                        }
                    }
                });

                rule?.AmPmClassHours?.Where(a => a.Weight == 1 && a.ClassID == classID && a.CourseID == it.CourseID)?.ToList()?.ForEach(x =>
                {
                    int pmNumber     = 0;
                    int amNumber     = 0;
                    var timePosition = cp.Positions.Where(p => p.DayPeriod.Day == it.DayPeriod.Day && p.DayPeriod.PeriodName == it.DayPeriod.PeriodName).FirstOrDefault();
                    var classHours   = resultModel.ResultClasses?.Where(c => c.ClassID == classID)
                                       ?.SelectMany(c => c.ResultDetails)?.Where(c => c.CourseID == it.CourseID)?.ToList();

                    classHours?.ForEach(c =>
                    {
                        var tPosition = cp.Positions.Where(p => p.DayPeriod.Day == c.DayPeriod.Day && p.DayPeriod.PeriodName == c.DayPeriod.PeriodName).FirstOrDefault();
                        if (tPosition != null)
                        {
                            if (tPosition.Position == XYKernel.OS.Common.Enums.Position.AM)
                            {
                                amNumber = amNumber + 1;
                            }

                            if (tPosition.Position == XYKernel.OS.Common.Enums.Position.PM)
                            {
                                pmNumber = pmNumber + 1;
                            }
                        }
                    });

                    //If current time slot is AM, And PMMax is full, Disable PM
                    if (timePosition.Position == XYKernel.OS.Common.Enums.Position.AM)
                    {
                        if (x.PmMax > 0 && pmNumber >= x.PmMax)
                        {
                            //Disable PM
                            var pmTimes = cp.Positions.Where(p => p.IsSelected && p.Position == XYKernel.OS.Common.Enums.Position.PM).Select(p => p.DayPeriod).ToList();
                            dayPeriods  = TimeOperation.TimeSlotDiff(dayPeriods, pmTimes);

                            pmTimes.ForEach(pt =>
                            {
                                notReachable.Add(new PostionWithWarningInfo()
                                {
                                    DayPeriod = pt, WaringMessage = "违反班级课程的下午最大课时规则!"
                                });
                            });
                        }

                        if (x.AmMax > 0 && amNumber > x.AmMax)
                        {
                            //Disable AM
                            var amTimes = cp.Positions.Where(p => p.IsSelected && p.Position == XYKernel.OS.Common.Enums.Position.AM).Select(p => p.DayPeriod).ToList();
                            dayPeriods  = TimeOperation.TimeSlotDiff(dayPeriods, amTimes);

                            amTimes.ForEach(pt =>
                            {
                                notReachable.Add(new PostionWithWarningInfo()
                                {
                                    DayPeriod = pt, WaringMessage = "违反班级课程的上午最大课时规则!"
                                });
                            });
                        }
                    }

                    //If current time slot is PM, And AMMax is full, Disable AM
                    if (timePosition.Position == XYKernel.OS.Common.Enums.Position.PM)
                    {
                        if (x.AmMax > 0 && amNumber >= x.AmMax)
                        {
                            //Disable AM
                            var amTimes = cp.Positions.Where(p => p.IsSelected && p.Position == XYKernel.OS.Common.Enums.Position.AM).Select(p => p.DayPeriod).ToList();
                            dayPeriods  = TimeOperation.TimeSlotDiff(dayPeriods, amTimes);

                            amTimes.ForEach(at =>
                            {
                                notReachable.Add(new PostionWithWarningInfo()
                                {
                                    DayPeriod = at, WaringMessage = "违反班级课程的上午最大课时规则!"
                                });
                            });
                        }

                        if (x.PmMax > 0 && pmNumber > x.PmMax)
                        {
                            //Disable PM
                            var pmTimes = cp.Positions.Where(p => p.IsSelected && p.Position == XYKernel.OS.Common.Enums.Position.PM).Select(p => p.DayPeriod).ToList();
                            dayPeriods  = TimeOperation.TimeSlotDiff(dayPeriods, pmTimes);

                            pmTimes.ForEach(at =>
                            {
                                notReachable.Add(new PostionWithWarningInfo()
                                {
                                    DayPeriod = at, WaringMessage = "违反班级课程的下午最大课时规则!"
                                });
                            });
                        }
                    }
                });

                rule?.AmPmNoContinues.Where(a => a.Weight == 1 && teachers.Contains(a.TeacherID)).ToList()?.ForEach(x =>
                {
                    List <DayPeriodModel> currentTimeSlots = resultModel.ResultClasses?.SelectMany(c => c.ResultDetails)?.Where(c => c.Teachers != null && c.Teachers.Contains(x.TeacherID))?.ToList()?.Select(c => c.DayPeriod)?.ToList() ?? new List <DayPeriodModel>()
                    {
                    };
                    var amLast  = cp.Positions.Where(p => p.Position == XYKernel.OS.Common.Enums.Position.AM && p.DayPeriod.Day == DayOfWeek.Monday).OrderBy(p => p.PositionOrder).LastOrDefault();
                    var pmFirst = cp.Positions.Where(p => p.Position == XYKernel.OS.Common.Enums.Position.PM && p.DayPeriod.Day == DayOfWeek.Monday).OrderBy(p => p.PositionOrder).FirstOrDefault();
                    List <DayPeriodModel> amLasts  = new List <DayPeriodModel>();
                    List <DayPeriodModel> pmFirsts = new List <DayPeriodModel>();

                    if (amLast != null)
                    {
                        amLasts = cp.Positions.Where(p => p.Position == XYKernel.OS.Common.Enums.Position.AM && p.DayPeriod.PeriodName == amLast.DayPeriod.PeriodName).Select(p => p.DayPeriod).ToList();
                    }

                    if (pmFirst != null)
                    {
                        pmFirsts = cp.Positions.Where(p => p.Position == XYKernel.OS.Common.Enums.Position.PM && p.DayPeriod.PeriodName == pmFirst.DayPeriod.PeriodName).Select(p => p.DayPeriod).ToList();
                    }

                    //合并上午最后一节和下午第一节课位
                    List <DayPeriodModel> availableNoonTimes = TimeOperation.TimeSlotUnion(amLasts, pmFirsts);
                    //教师在中午的上课信息
                    List <DayPeriodModel> teacherNoonTimes             = TimeOperation.TimeSlotInterSect(currentTimeSlots, availableNoonTimes);
                    List <DayPeriodModel> teacherNotAvailableNoonTimes = new List <DayPeriodModel>()
                    {
                    };

                    availableNoonTimes.Select(lnt => lnt.Day).Distinct().ToList().ForEach(lnt => {
                        var teacherCurrentDayNoonTimes = teacherNoonTimes.Where(tnt => tnt.Day == lnt);
                        if (teacherCurrentDayNoonTimes.Count() == 2)
                        {
                            var intersectResult = TimeOperation.TimeSlotInterSect(teacherCurrentDayNoonTimes.ToList(), new List <DayPeriodModel>()
                            {
                                it.DayPeriod
                            });
                            if (intersectResult.Count > 0)
                            {
                                var leftTimeSlot = availableNoonTimes.Where(ant => ant.Day == lnt && ant.Period != it.DayPeriod.Period).FirstOrDefault();
                                if (leftTimeSlot != null)
                                {
                                    teacherNotAvailableNoonTimes.Add(leftTimeSlot);
                                }
                            }
                            else
                            {
                                teacherNotAvailableNoonTimes.AddRange(teacherCurrentDayNoonTimes);
                            }
                        }

                        if (teacherCurrentDayNoonTimes.Count() == 1)
                        {
                            var teacherTimeSlot = teacherCurrentDayNoonTimes.First();
                            if (!(teacherTimeSlot.Day == it.DayPeriod.Day && teacherTimeSlot.Period == it.DayPeriod.Period))
                            {
                                var conflitTimeSlot = availableNoonTimes.Where(ant => ant.Day == teacherTimeSlot.Day && ant.Period != teacherTimeSlot.Period).FirstOrDefault();
                                if (conflitTimeSlot != null)
                                {
                                    teacherNotAvailableNoonTimes.Add(conflitTimeSlot);
                                }
                            }
                        }
                    });

                    dayPeriods = TimeOperation.TimeSlotDiff(dayPeriods, teacherNotAvailableNoonTimes);

                    teacherNotAvailableNoonTimes.ForEach(tn =>
                    {
                        notReachable.Add(new PostionWithWarningInfo()
                        {
                            DayPeriod = tn, WaringMessage = "违反教师中午课时不连排规则!"
                        });
                    });
                });

                rule?.MasterApprenttices.Where(m => m.Weight == 1 && m.CourseID == it.CourseID && (teachers.Contains(m.MasterID) || teachers.Intersect(m.ApprenticeIDs).Count() > 0))?.ToList()?.ForEach(x =>
                {
                    //默认处理逻辑为徒弟之间也不允许同时排课, 不然无法保证互听课
                    List <string> tempTeachers = new List <string>();
                    tempTeachers.AddRange(x.ApprenticeIDs);
                    tempTeachers.Add(x.MasterID);
                    tempTeachers = tempTeachers.Distinct().ToList();

                    var classHoursTimes = resultModel.ResultClasses?.SelectMany(c => c.ResultDetails)?.Where(c => c.CourseID == it.CourseID && c.Teachers.Except(it.Teachers).Count() > 0 && c.Teachers.Intersect(tempTeachers).Count() > 0)?.ToList()?.Select(c => c.DayPeriod);

                    classHoursTimes?.ToList()?.ForEach(c =>
                    {
                        dayPeriods.RemoveAll(d => d.Day == c.Day && d.PeriodName == c.PeriodName);
                        notReachable.Add(new PostionWithWarningInfo()
                        {
                            DayPeriod = c, WaringMessage = "违反师徒跟随规则!"
                        });
                    });
                });

                rule?.Mutexes?.Where(m => m.Weight == 1 && m.CourseIDs != null && m.CourseIDs.Contains(it.CourseID))?.ToList()?.ForEach(x =>
                {
                    List <string> tempCourseIds = x.CourseIDs?.Select(xc => xc)?.ToList();
                    tempCourseIds.RemoveAll(t => t == it.CourseID);

                    var classHoursTimes = resultModel.ResultClasses
                                          ?.Where(r => r.ClassID == classID)?.SelectMany(c => c.ResultDetails)
                                          ?.Where(c => tempCourseIds.Contains(c.CourseID))
                                          ?.ToList()?.Select(c => c.DayPeriod.Day);

                    classHoursTimes?.ToList()?.ForEach(c =>
                    {
                        dayPeriods.Where(d => d.Day == c)?.ToList()?.ForEach(dp =>
                        {
                            notReachable.Add(new PostionWithWarningInfo()
                            {
                                DayPeriod = dp, WaringMessage = "违反课程互斥规则!"
                            });
                        });

                        dayPeriods.RemoveAll(d => d.Day == c);
                    });
                });

                #region 合班规则
                List <string> unionClassIDs = new List <string>();
                rule?.ClassUnions?.Where(cu => cu.ClassIDs != null && cu.ClassIDs.Contains(classID) && cu.CourseID == it.CourseID)?.ToList()?.ForEach(x => {
                    //Get All Union ClassID
                    x.ClassIDs.ForEach(cl => {
                        if (!unionClassIDs.Contains(cl))
                        {
                            unionClassIDs.Add(cl);
                        }
                    });
                });

                if (unionClassIDs.Count > 1)
                {
                    bool flag = true;
                    List <DayPeriodModel> timeslots = new List <DayPeriodModel>();

                    foreach (string classId in unionClassIDs)
                    {
                        var courseTimes = resultModel.ResultClasses?
                                          .Where(rc => rc.ClassID == classId)?
                                          .SelectMany(c => c.ResultDetails)?
                                          .Where(c => c.CourseID == it.CourseID)?
                                          .ToList()?.Select(c => c.DayPeriod)?.ToList() ?? new List <DayPeriodModel>();

                        if (timeslots.Count == 0)
                        {
                            timeslots = courseTimes;
                        }
                        else
                        {
                            List <DayPeriodModel> timesUnion = TimeOperation.TimeSlotUnion(timeslots.ToList(), courseTimes);
                            List <DayPeriodModel> timesDiff  = TimeOperation.TimeSlotDiff(timeslots.ToList(), courseTimes);
                            if (timesUnion.Count != timeslots.Count || timesDiff.Count != 0)
                            {
                                flag = false;
                            }
                        }
                    }

                    if (flag)
                    {
                        List <DayPeriodModel> timesInterSect = TimeOperation.TimeSlotInterSect(timeslots.ToList(), dayPeriods.ToList());
                        List <DayPeriodModel> timesDiff      = TimeOperation.TimeSlotDiff(dayPeriods.ToList(), timesInterSect.ToList());

                        timesDiff?.ForEach(c =>
                        {
                            dayPeriods.RemoveAll(d => d.Day == c.Day && d.PeriodName == c.PeriodName);
                            notReachable.Add(new PostionWithWarningInfo()
                            {
                                DayPeriod = c, WaringMessage = "违反合班规则!"
                            });
                        });
                    }
                }
                #endregion
            });

            return(Tuple.Create(dayPeriods, notReachable));
        }
Esempio n. 21
0
        public FilterView()
        {
            InitializeComponent();

            _commonDataManager  = CacheManager.Instance.UnityContainer.Resolve <ICommonDataManager>();
            _patternDataManager = CacheManager.Instance.UnityContainer.Resolve <IPatternDataManager>();

            var local = _commonDataManager.GetLocalCase(_commonDataManager.LocalID);

            CLCase cl;

            if (local.Pattern == Models.Enums.PatternTypeEnum.None)
            {
                cl = _commonDataManager.GetCLCase(_commonDataManager.LocalID);
            }
            else
            {
                cl = _patternDataManager.GetCase(_commonDataManager.LocalID);
            }

            if (cl != null)
            {
                var classList = cl.GetClasses();
                classList.Insert(0, new Models.Mixed.UIClass()
                {
                    ID   = string.Empty,
                    Name = string.Empty,
                });

                FilterHelper.Classes = classList;

                cmb_class.ItemsSource   = classList;
                cmb_class.SelectedIndex = 0;


                var teachers = cl.Teachers.ToList();
                teachers.Insert(0, new XYKernel.OS.Common.Models.Mixed.TeacherModel
                {
                    ID   = string.Empty,
                    Name = string.Empty
                });
                cmb_teacher.ItemsSource   = teachers;
                cmb_teacher.SelectedIndex = 0;

                var courses = cl.Courses.ToList();
                courses.Insert(0, new XYKernel.OS.Common.Models.Mixed.CourseModel()
                {
                    ID   = string.Empty,
                    Name = string.Empty
                });

                cmb_subject.ItemsSource   = courses;
                cmb_subject.SelectedIndex = 0;

                var tagList = cl.Tags?.ToList();
                tagList.Insert(0, new XYKernel.OS.Common.Models.Mixed.TagModel()
                {
                    ID   = string.Empty,
                    Name = string.Empty
                });

                cmb_tag.ItemsSource   = tagList;
                cmb_tag.SelectedIndex = 0;
            }
        }
 public SparkJobTemplateManager([Import] ICommonDataManager storage)
 {
     this.Storage = storage;
 }
Esempio n. 23
0
 public SkillsController(ICommonDataManager commonDataManager)
 {
     this.commonDataManager = commonDataManager;
 }
 public Countries(ICommonDataManager commonDataReadManager)
 {
     this.commonDataReadManager = commonDataReadManager;
 }
        public PlayerModeFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;

            PlayerId = CommonDataManager.PlayerId;
            Turn     = CommonDataManager.Turn;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Turn")
                {
                    Turn = CommonDataManager.Turn;
                }

                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService.MapChanged += (sender, args) =>
            {
                var cellViewModels = new List <CellViewModel>();

                for (int i = 0; i < _mapService.Map.Length; i++)
                {
                    for (int j = 0; j < _mapService.Map[i].Length; j++)
                    {
                        cellViewModels.Add(new CellViewModel {
                            X = j, Y = i, State = Convert.ToString(_mapService.Map[i][j]),
                        });
                    }
                }

                CellCollection   = new ObservableCollection <CellViewModel>(cellViewModels);
                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            };

            _mapService.CellChanged += (sender, args) =>
            {
                int index = args.Y * _mapService.Map.First().Length + args.X;

                CellCollection[index].State = args.State;

                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            };

            if (_mapService.Map != null)
            {
                var cellViewModels = new List <CellViewModel>();

                for (int i = 0; i < _mapService.Map.Length; i++)
                {
                    for (int j = 0; j < _mapService.Map[i].Length; j++)
                    {
                        cellViewModels.Add(new CellViewModel {
                            X = j, Y = i, State = Convert.ToString(_mapService.Map[i][j]),
                        });
                    }
                }

                CellCollection   = new ObservableCollection <CellViewModel>(cellViewModels);
                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            }
            else
            {
                CellCollection   = new ObservableCollection <CellViewModel>();
                PlayerCollection = new ObservableCollection <PlayerViewModel>();
            }

            _isExecuting = false;
        }
 public ConfigFlattenerManager(ICommonDataManager commonData)
 {
     this.CommonData = commonData;
 }
        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));
            }
        }
        public static void CourseChanged(List <Models.Mixed.UICourse> courses, string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetMixedRule(localID);
            var algo = CommonDataManager.GetMixedAlgoRule(localID);
            var cl   = CommonDataManager.GetCLCase(localID);

            if (rule != null)
            {
                courses.ForEach(c =>
                {
                    var classes = cl.Classes.Where(cc => cc.CourseID.Equals(c.ID))?.ToList();
                    classes?.ForEach(tc =>
                    {
                        rule.CourseTimes?.RemoveAll(r => r.ClassID.Equals(tc.ID));
                        rule.ArrangeContinuous?.RemoveAll(r => r.ClassID.Equals(tc.ID));
                        rule.ClassHourAverages?.RemoveAll(r => r.ClassID.Equals(tc.ID));
                        rule.ClassHourSameOpens?.Clear();
                    });

                    rule.AmPmClassHours?.RemoveAll(r => r.CourseID.Equals(c.ID));
                    rule.CourseLimits?.RemoveAll(r => r.CourseID.Equals(c.ID));
                });
            }

            if (algo != null)
            {
                var classHours = cl.ClassHours.Where(ch => courses.Any(c => ch.CourseID.Equals(c.ID)))?.ToList();

                classHours?.ForEach(ch =>
                {
                    algo.ClassHoursSameStartingDays?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingDays?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursSameStartingTimes?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingTimes?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursSameStartingHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingHours?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.MinDaysBetweenClassHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.MinDaysBetweenClassHours?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.MaxDaysBetweenClassHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.MaxDaysBetweenClassHours?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursNotOverlaps?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursNotOverlaps?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursMaxConcurrencyInSelectedTimes?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursMaxConcurrencyInSelectedTimes?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursOccupyMaxTimeFromSelections?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursOccupyMaxTimeFromSelections?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.TwoClassHoursContinuous?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.TwoClassHoursOrdered?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.TwoClassHoursGrouped?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.ThreeClassHoursGrouped?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID) || r.ThirdID.Equals(ch.ID));

                    algo.ClassHourRequiredStartingTimes?.RemoveAll(r => r.ID.Equals(ch.ID));
                    algo.ClassHourRequiredTimes?.RemoveAll(r => r.ID.Equals(ch.ID));
                    algo.ClassHourRequiredStartingTime?.RemoveAll(r => r.ID.Equals(ch.ID));
                });

                algo.Serialize(localID);
            }

            if (cl != null)
            {
                courses.ForEach(c =>
                {
                    cl.Courses.RemoveAll(dc => dc.ID.Equals(c.ID));
                    cl.Classes.RemoveAll(ch => ch.CourseID.Equals(c.ID));


                    cl.ClassHours.RemoveAll(ch => ch.CourseID.Equals(c.ID));

                    cl.Students?.ForEach(st =>
                    {
                        st.Preselections?.RemoveAll(p => p.CourseID.Equals(c.ID));
                    });
                });

                cl.Serialize(localID);
            }
        }
Esempio n. 29
0
 public FlowDataManager(ConfigGenConfiguration configuration, IDesignTimeConfigStorage storage, ICommonDataManager commonsData)
 {
     Storage       = storage;
     Configuration = configuration;
     CommonsData   = commonsData;
 }
        public static void CourseChanged(Models.Base.UICourse course, string localID, ICommonDataManager CommonDataManager)
        {
            var rule = CommonDataManager.GetAminRule(localID);
            var algo = CommonDataManager.GetAminAlgoRule(localID);
            var cp   = CommonDataManager.GetCPCase(localID);

            var classHourIDs = cp.ClassHours.Where(c => c.CourseID.Equals(course.ID))?.ToList();

            if (cp != null)
            {
                cp.ClassHours?.RemoveAll(ch => ch.CourseID.Equals(course.ID));
                cp.Serialize(localID);
            }

            if (rule != null)
            {
                rule.Mutexes?.RemoveAll(r => r.CourseIDs.Contains(course.ID));
                rule.ClassUnions?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.CourseLimits?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.MasterApprenttices?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.PlanFlushes?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.ClassHourAverages?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.ClassHourSameOpens?.Clear();
                //rule.ClassHourSameOpens?.ForEach(s =>
                //{
                //    s.Details?.ForEach(sd =>
                //    {
                //        sd.Classes.RemoveAll(c => c.CourseID.Equals(course.ID));
                //    });
                //    s.Details?.RemoveAll(sd => sd.Classes?.Count == 0);
                //});
                //rule.ClassHourSameOpens?.RemoveAll(s => s.Details?.Count == 0);

                rule.ContinuousPlanFlushes?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.CourseTimes?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.CourseArranges?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.AmPmClassHours?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.ClassHourPriorityBalance?.RemoveAll(r => r.CourseID.Equals(course.ID));
                rule.MinorCourseAvoidTime?.ForEach(r =>
                {
                    r.CourseIDs?.Remove(course.ID);
                });

                rule.MajorCoursePreferredTime?.ForEach(r =>
                {
                    r.CourseIDs?.Remove(course.ID);
                });

                if (rule.TimeTableLockedTimes != null)
                {
                    rule.TimeTableLockedTimes.LockedTimeTable?.RemoveAll(lt => lt.LockedCourseTimeTable.Any(lct => lct.CourseID.Equals(course.ID)));
                }

                rule.Serialize(localID);
            }

            if (algo != null)
            {
                classHourIDs?.ForEach(ch =>
                {
                    algo.ClassHoursSameStartingDays?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingDays?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursSameStartingTimes?.ForEach(a =>
                    {
                        var ids = a.Id?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.Id = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingTimes?.RemoveAll(a => a.Id?.Count() == 0);

                    algo.ClassHoursSameStartingHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursSameStartingHours?.RemoveAll(a => a.ID?.Count() == 0);


                    algo.TwoClassHoursContinuous?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.TwoClassHoursOrdered?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.TwoClassHoursGrouped?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID));
                    algo.ThreeClassHoursGrouped?.RemoveAll(r => r.FirstID.Equals(ch.ID) || r.SecondID.Equals(ch.ID) || r.ThirdID.Equals(ch.ID));

                    algo.MinDaysBetweenClassHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.MinDaysBetweenClassHours?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.MaxDaysBetweenClassHours?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.MaxDaysBetweenClassHours?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursNotOverlaps?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursNotOverlaps?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursMaxConcurrencyInSelectedTimes?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursMaxConcurrencyInSelectedTimes?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHoursOccupyMaxTimeFromSelections?.ForEach(a =>
                    {
                        var ids = a.ID?.ToList();
                        ids?.RemoveAll(ri => ri.Equals(ch.ID));
                        a.ID = ids?.ToArray();
                    });
                    algo.ClassHoursOccupyMaxTimeFromSelections?.RemoveAll(a => a.ID?.Count() == 0);

                    algo.ClassHourRequiredStartingTimes?.RemoveAll(r => r.ID.Equals(ch.ID));
                    algo.ClassHourRequiredTimes?.RemoveAll(r => r.ID.Equals(ch.ID));
                    algo.ClassHourRequiredStartingTime?.RemoveAll(r => r.ID.Equals(ch.ID));
                });

                algo.Serialize(localID);
            }
        }