public void Initilize()
        {
            var cp = CommonDataManager.GetCPCase(base.LocalID);

            if (cp != null)
            {
                _cpcase = cp;

                if (cp.Teachers != null)
                {
                    List <UITeacher> teachers = new List <UITeacher>();
                    cp.Teachers.ForEach(t =>
                    {
                        UITeacher teacher = new UITeacher()
                        {
                            ID   = t.ID,
                            Name = t.Name,
                        };
                        teachers.Add(teacher);
                    });
                    this.Teachers = new ObservableCollection <UITeacher>(teachers);

                    _teacherCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Teachers);
                    _teacherCollectionView.Filter = TeacherContains;
                }
            }
            else
            {
                _cpcase = new CPCase();
            }
        }
        public void GetData(UIClass classModel)
        {
            var cp = CommonDataManager.GetCPCase(base.LocalID);

            if (cp != null)
            {
                _cpcase = cp;

                List <UIStudent> students = new List <UIStudent>();
                _class = cp.Classes.FirstOrDefault(c => c.ID.Equals(classModel.ID));
                _class.Students?.ForEach(s =>
                {
                    UIStudent student = new UIStudent()
                    {
                        ID   = s.ID,
                        Name = s.Name
                    };
                    students.Add(student);
                });

                this.Students = new ObservableCollection <UIStudent>(students);

                _studentCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Students);
                _studentCollectionView.Filter = StudentContains;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据科目,班级 获取教师信息
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="courseID"></param>
        /// <param name="classID"></param>
        /// <returns></returns>
        public static List <UITeacher> GetTeachers(this CPCase cp, string courseID, string classID)
        {
            List <UITeacher> teachers = new List <UITeacher>();

            var classhours = (from c in cp.ClassHours
                              from tid in c.TeacherIDs
                              from t in cp.Teachers
                              where tid.Equals(t.ID)
                              select new
            {
                c.ClassID,
                c.CourseID,
                t
            });

            var results = classhours.Where(c => c.CourseID.Equals(courseID) && c.ClassID.Equals(classID));

            if (results != null)
            {
                var groups = results.GroupBy(r => r.t);
                foreach (var g in groups)
                {
                    UITeacher uiTeacher = new UITeacher()
                    {
                        ID   = g.Key.ID,
                        Name = g.Key.Name
                    };
                    teachers.Add(uiTeacher);
                }
            }
            return(teachers);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取课程
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="teacherIDs"></param>
        /// <returns></returns>
        public static List <UICourse> GetCourses(this CPCase cp, string teacherID)
        {
            List <UICourse> courses = new List <UICourse>();

            var classHours = (from ch in cp.ClassHours where ch.TeacherIDs.Contains(teacherID) select ch);
            var groups     = classHours?.GroupBy(g => g.CourseID);

            if (groups != null)
            {
                foreach (var g in groups)
                {
                    var course = cp.Courses.FirstOrDefault(ch => ch.ID.Equals(g.Key));
                    if (course != null)
                    {
                        UICourse ui = new UICourse()
                        {
                            ID   = course.ID,
                            Name = course.Name
                        };
                        courses.Add(ui);
                    }
                }
            }

            return(courses);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取课时根据课程ID
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="courseID"></param>
        /// <param name="classID"></param>
        /// <returns></returns>
        public static List <UIClassHour> GetClassHours(this CPCase cp, string courseID, string classID)
        {
            List <UIClassHour> results = new List <UIClassHour>();

            var teachers = cp.Teachers;
            var classes  = cp.Classes;
            var courses  = cp.Courses;

            var classHours = cp.ClassHours.Where(c => c.CourseID.Equals(courseID) && c.ClassID.Equals(classID));

            foreach (var ch in classHours)
            {
                UIClassHour uiClassHour = new UIClassHour();
                uiClassHour.ClassID  = ch.ClassID;
                uiClassHour.CourseID = ch.CourseID;
                uiClassHour.ID       = ch.ID;

                if (ch.TeacherIDs == null)
                {
                    uiClassHour.Teachers = new List <TeacherModel>();
                }
                else
                {
                    uiClassHour.Teachers = (from id in ch.TeacherIDs from t in teachers where t.ID == id select t)?.ToList();
                }

                uiClassHour.Class  = classes.FirstOrDefault(c => c.ID.Equals(ch.ClassID))?.Name;
                uiClassHour.Course = courses.FirstOrDefault(c => c.ID.Equals(ch.CourseID))?.Name;

                results.Add(uiClassHour);
            }

            return(results);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取班级,根据课程ID
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="courseID"></param>
        /// <returns></returns>
        public static List <UIClass> GetClasses(this CPCase cp, string courseID)
        {
            List <UIClass> classes = new List <UIClass>();

            var results = cp.Classes.Where(c => c.Settings.Any(s => s.CourseID.Equals(courseID)));

            if (results != null)
            {
                var course = cp.Courses.FirstOrDefault(c => c.ID.Equals(courseID));

                results?.ToList()?.ForEach(r =>
                {
                    UIClass classInfo = new UIClass()
                    {
                        ID       = r.ID,
                        CourseID = courseID,
                        Course   = course.Name,
                        Name     = r.Name
                    };

                    // 课时数
                    var lessons       = cp.ClassHours.Count(ch => ch.ClassID.Equals(r.ID) && ch.CourseID.Equals(course.ID));
                    classInfo.Lessons = lessons;

                    classes.Add(classInfo);
                });
            }
            return(classes);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根据教师ID获取班级
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="teacherID">教师ID</param>
        /// <returns></returns>
        public static List <UIClass> GetClassesByTeacherID(this CPCase cp, string teacherID)
        {
            List <UIClass> classes = new List <UIClass>();

            var classHours = (from ch in cp.ClassHours where ch.TeacherIDs.Contains(teacherID) select ch);

            var groups = classHours?.GroupBy(g => $"{g.CourseID}|{g.ClassID}");

            if (groups != null)
            {
                foreach (var g in groups)
                {
                    var keys = g.Key.Split('|');

                    var classModel = cp.Classes.FirstOrDefault(ch => ch.ID.Equals(keys[1]));
                    if (classModel != null)
                    {
                        var course = cp.Courses.FirstOrDefault(c => c.ID.Equals(keys[0]))?.Name;

                        UIClass ui = new UIClass()
                        {
                            ID       = classModel.ID,
                            Name     = classModel.Name,
                            Course   = course,
                            CourseID = keys[0]
                        };
                        classes.Add(ui);
                    }
                }
            }
            return(classes);
        }
Exemplo n.º 8
0
 public void AddAdminCase(string localID, CPCase model)
 {
     if (CPCases.ContainsKey(localID))
     {
         CPCases[localID] = model;
     }
     else
     {
         CPCases.Add(localID, model);
     }
 }
Exemplo n.º 9
0
        public static string GetCPClassCourseInfo(CPCase cPCase, string classID, string courseID)
        {
            string classCourseInfo = string.Empty;

            if (cPCase != null && !string.IsNullOrEmpty(classID) && !string.IsNullOrEmpty(courseID))
            {
                string className  = cPCase.Classes?.FirstOrDefault(cl => cl.ID == classID).Name ?? string.Empty;
                string courseName = cPCase.Courses?.FirstOrDefault(co => co.ID == courseID)?.Name ?? string.Empty;

                classCourseInfo = $"{className}{courseName}";
            }

            return(classCourseInfo);
        }
Exemplo n.º 10
0
 public CPCase GetCPCase(string localID)
 {
     if (CPCases.ContainsKey(localID))
     {
         return(CPCases[localID]);
     }
     else
     {
         CPCase newCase = new CPCase();
         newCase.IsPEAllowLast         = true;
         newCase.IsTwoClassHourLimit   = true;
         newCase.IsThreeClassHourLimit = true;
         newCase.IsMajorCourseSameDay  = true;
         CPCases.Add(localID, newCase);
         return(newCase);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 获取节次
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public static List <DayPeriodModel> GetDayPeriods(this CPCase cp)
        {
            List <DayPeriodModel> dayPeriods = new List <DayPeriodModel>();

            var positions = cp.Positions.Where(p =>
                                               p.Position != XYKernel.OS.Common.Enums.Position.AB &&
                                               p.Position != XYKernel.OS.Common.Enums.Position.PB &&
                                               p.Position != XYKernel.OS.Common.Enums.Position.Noon);

            if (positions != null)
            {
                var groups = positions.GroupBy(p => p.DayPeriod.PeriodName);
                foreach (var g in groups)
                {
                    dayPeriods.Add(g.First().DayPeriod);
                }
            }
            return(dayPeriods);
        }
Exemplo n.º 12
0
        public void Initilize()
        {
            var cp    = CommonDataManager.GetCPCase(base.LocalID);
            var local = CommonDataManager.GetLocalCase(base.LocalID);

            if (cp != null)
            {
                _cpcase = cp;

                if (cp.Teachers != null)
                {
                    List <UICourse> courses = new List <UICourse>();
                    cp.Courses.ForEach(t =>
                    {
                        UICourse course = new UICourse()
                        {
                            ID   = t.ID,
                            Name = t.Name,
                        };

                        var has = local.CourseColors.ContainsKey(t.ID);
                        if (has)
                        {
                            course.ColorString = local.CourseColors[t.ID];
                        }

                        courses.Add(course);
                    });
                    this.Courses = new ObservableCollection <UICourse>(courses);

                    _courseCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Courses);
                    _courseCollectionView.Filter = CourseContains;
                }
            }
            else
            {
                _cpcase = new CPCase();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获取班级,根据课程ID
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="courseID"></param>
        /// <returns></returns>
        public static List <UIClass> GetClasses(this CPCase cp, string courseID)
        {
            List <UIClass> classes = new List <UIClass>();

            var results = cp.Classes.Where(c => c.Settings.Any(s => s.CourseID.Equals(courseID)));

            if (results != null)
            {
                var course = cp.Courses.FirstOrDefault(c => c.ID.Equals(courseID));

                results?.ToList()?.ForEach(r =>
                {
                    classes.Add(new UIClass()
                    {
                        ID       = r.ID,
                        CourseID = courseID,
                        Course   = course.Name,
                        Name     = r.Name
                    });
                });
            }
            return(classes);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 根据教师ID集合
 /// </summary>
 /// <param name="cp">方案模型</param>
 /// <param name="teacherIDs">教师ID集合</param>
 /// <returns></returns>
 public static List <TeacherModel> GetTeachersByIds(this CPCase cp, List <string> teacherIDs)
 {
     return((from tid in teacherIDs from t in cp.Teachers where t.ID.Equals(tid) select t)?.ToList());
 }
Exemplo n.º 15
0
        /// <summary>
        /// 创建行政班数据
        /// </summary>
        public void CreateAdministratorTime(CPCase cp)
        {
            List <UIPosition> positions = new List <UIPosition>();

            #region  午

            UIPosition am1 = new UIPosition()
            {
                PeriodString = "第一节",
                PositionType = XYKernel.OS.Common.Enums.Position.AM
            };

            UIPosition am2 = new UIPosition()
            {
                PeriodString = "第二节",
                PositionType = XYKernel.OS.Common.Enums.Position.AM
            };

            UIPosition bk = new UIPosition()
            {
                PeriodString = "上午大课间",
                PositionType = XYKernel.OS.Common.Enums.Position.AB
            };

            UIPosition am3 = new UIPosition()
            {
                PeriodString = "第三节",
                PositionType = XYKernel.OS.Common.Enums.Position.AM
            };

            UIPosition am4 = new UIPosition()
            {
                PeriodString = "第四节",
                PositionType = XYKernel.OS.Common.Enums.Position.AM
            };

            positions.Add(am1);
            positions.Add(am2);
            positions.Add(bk);
            positions.Add(am3);
            positions.Add(am4);

            #endregion

            #region  午

            UIPosition noon = new UIPosition()
            {
                PeriodString       = "午休",
                PositionType       = XYKernel.OS.Common.Enums.Position.Noon,
                CanOperation       = false,
                IsFridayChecked    = false,
                IsMondayChecked    = false,
                IsSaturdayChecked  = false,
                IsSundayChecked    = false,
                IsThursdayChecked  = false,
                IsTuesdayChecked   = false,
                IsWednesdayChecked = false
            };

            UIPosition pm1 = new UIPosition()
            {
                PeriodString = "第五节",
                PositionType = XYKernel.OS.Common.Enums.Position.PM
            };

            UIPosition pm2 = new UIPosition()
            {
                PeriodString = "第六节",
                PositionType = XYKernel.OS.Common.Enums.Position.PM
            };

            UIPosition pm3 = new UIPosition()
            {
                PeriodString = "第七节",
                PositionType = XYKernel.OS.Common.Enums.Position.PM
            };

            UIPosition pm4 = new UIPosition()
            {
                PeriodString = "第八节",
                PositionType = XYKernel.OS.Common.Enums.Position.PM
            };

            positions.Add(noon);
            positions.Add(pm1);
            positions.Add(pm2);
            positions.Add(pm3);
            positions.Add(pm4);

            #endregion

            // 遍历课位集合
            for (int i = 0; i < positions.Count; i++)
            {
                var p = positions[i];
                #region 周一至周日

                var monday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Monday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsMondayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(monday);

                var tuesday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Tuesday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsTuesdayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(tuesday);

                var wednesday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Wednesday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsWednesdayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(wednesday);

                var thursday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Thursday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsThursdayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(thursday);

                var Friday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Friday,
                        Period     = i,
                        PeriodName = p.PeriodString,
                    },
                    IsSelected    = p.IsFridayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(Friday);

                var saturday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Saturday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsSaturdayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(saturday);

                var sunday = new CoursePositionModel()
                {
                    DayPeriod = new XYKernel.OS.Common.Models.DayPeriodModel()
                    {
                        Day        = DayOfWeek.Sunday,
                        Period     = i,
                        PeriodName = p.PeriodString
                    },
                    IsSelected    = p.IsSundayChecked,
                    Position      = p.PositionType,
                    PositionOrder = i
                };
                cp.Positions.Add(sunday);

                #endregion
            }
        }