void save(HostView host) { var rule = base.GetClRule(base.LocalID); // 1.清除同时开课规则 rule.ClassHourSameOpens.Clear(); if (this.Rules != null) { foreach (var r in this.Rules) { var samopenRule = new XYKernel.OS.Common.Models.Mixed.Rule.ClassHourSameOpenRule() { Details = new List <XYKernel.OS.Common.Models.Mixed.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.Mixed.Rule.SameOpenDetailsModel(); item.Index = i; item.Classes = new List <string>(); if (r.Classes.Count > 1) { // 过滤选中班级 r.Classes.ForEach(c => { if (c.HourIndexs.Count >= i + 1) { if (c.HourIndexs[i].IsChecked) { item.Classes.Add(c.ID); } } }); if (item.Classes.Count > 1) { samopenRule.Details.Add(item); } } } rule.ClassHourSameOpens.Add(samopenRule); } } // 2.序列化 base.SerializePatternRule(rule, base.LocalID); // 4.序列化规则 OSKernel.Presentation.Models.Enums.MixedRuleEnum.ClassHourSameOpen.RuleSerialize(base.LocalID, this.Rules); // 3.弹出提示 this.ShowDialog("提示信息", "保存成功", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None); }
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, Display = win.Classes?.Select(c => { return(c.Display); })?.Parse() }; var cl = base.GetClCase(base.LocalID); var details = new XYKernel.OS.Common.Models.Mixed.Rule.SameOpenDetailsModel(); rule.Classes.ForEach(c => { var hours = cl.GetClassHours(c.CourseID, c.ID, c.LevelID); if (hours?.Count > 0) { for (int i = 0; i < hours?.Count; i++) { c.HourIndexs.Add(new Models.Mixed.UIClassHourIndex() { Index = i, IsChecked = true }); } } }); this.Rules.Add(rule); } }; win.ShowDialog(); }