void createCommand()
        {
            CreateClassHourSameOpenView win = new CreateClassHourSameOpenView();

            win.Closed += (s, arg) =>
            {
                if (win.DialogResult.Value)
                {
                    var last  = this.Rules.LastOrDefault();
                    var index = last == null ? 0 : last.NO;

                    var rule = new UISameOpenTime()
                    {
                        NO      = index + 1,
                        Classes = win.Classes,
                    };

                    var cp = CommonDataManager.GetCPCase(base.LocalID);

                    var details = new XYKernel.OS.Common.Models.Administrative.Rule.SameOpenDetailsModel();
                    rule.Classes.ForEach(c =>
                    {
                        var hours = cp.GetClassHours(c.CourseID, c.ID);
                        if (hours?.Count > 0)
                        {
                            for (int i = 0; i < hours?.Count; i++)
                            {
                                c.HourIndexs.Add(new Models.Administrative.UIClassHourIndex()
                                {
                                    Index     = i,
                                    IsChecked = true
                                });
                            }
                        }
                    });

                    this.Rules.Add(rule);
                }
            };
            win.ShowDialog();
        }
        void save(HostView host)
        {
            var rule = CommonDataManager.GetAminRule(base.LocalID);

            // 1.清除同时开课规则
            rule.ClassHourSameOpens.Clear();

            if (this.Rules != null)
            {
                foreach (var r in this.Rules)
                {
                    var samopenRule = new XYKernel.OS.Common.Models.Administrative.Rule.ClassHourSameOpenRule()
                    {
                        Details = new List <XYKernel.OS.Common.Models.Administrative.Rule.SameOpenDetailsModel>(),
                        Weight  = (int)r.Weight
                    };

                    var maxIndex = r.Classes.Max(c => c.HourIndexs.Count);

                    // 遍历填充详细
                    for (int i = 0; i < maxIndex; i++)
                    {
                        var item = new XYKernel.OS.Common.Models.Administrative.Rule.SameOpenDetailsModel();
                        item.Index   = i;
                        item.Classes = new List <CourseClassModel>();

                        // 过滤选中班级
                        r.Classes.ForEach(c =>
                        {
                            if (c.HourIndexs.Count >= i + 1)
                            {
                                if (c.HourIndexs[i].IsChecked)
                                {
                                    CourseClassModel classModel = new CourseClassModel()
                                    {
                                        ClassID  = c.ID,
                                        CourseID = c.CourseID
                                    };
                                    item.Classes.Add(classModel);
                                }
                            }
                        });

                        if (item.Classes.Count > 1)
                        {
                            samopenRule.Details.Add(item);
                        }
                    }

                    rule.ClassHourSameOpens.Add(samopenRule);
                }
            }

            // 2.序列化
            rule.Serialize(base.LocalID);

            // 3.弹出提示
            this.ShowDialog("提示信息", "保存成功", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);

            // 4.序列化规则
            OSKernel.Presentation.Models.Enums.AdministrativeRuleEnum.ClassHourSameOpen.RuleSerialize(base.LocalID, this.Rules);
        }