示例#1
0
        /// <summary>
        /// 從單一資料來源取得教師不排課時段資料
        /// </summary>
        /// <param name="Connection">連線物件</param>
        /// <param name="SQL">SQL指令</param>
        /// <returns></returns>
        private static List<STeacherBusy> Select(Connection Connection)
        {
            #region 取得教師不排課時段原始資料
            XElement Element = ContractService.GetTeacherExBusy(Connection);

            List<STeacherBusy> TeacherBusys = new List<STeacherBusy>();
            #endregion

            #region 將原始資料轉換成教師不排課時段物件
            foreach (XElement SubElement in Element.Elements("TeacherBusy"))
            {
                STeacherBusy TeacherBusy = new STeacherBusy();
                TeacherBusy.Load(SubElement,Connection.AccessPoint.Name);

                TeacherBusys.Add(TeacherBusy);
            }
            #endregion

            return TeacherBusys;
        }
示例#2
0
        private void SetElement(XElement Element, Action<int> Progress)
        {
            try
            {
                this.SchoolYear = Element.AttributeText("SchoolYear");
                this.Semester = Element.AttributeText("Semester");

                ClassResult = new SIntegrationResult<SClass>();
                ClassResult.Data = new List<SClass>();

                XElement elmClasses = Element.Element("Classes");

                if (elmClasses != null)
                {
                    foreach (XElement SubElement in elmClasses.Elements("Class"))
                    {
                        SClass Class = new SClass();
                        Class.Load(SubElement);
                        ClassResult.Data.Add(Class);
                    }
                }

                ClassBusysResult = new SIntegrationResult<SClassBusy>();
                ClassBusysResult.Data = new List<SClassBusy>();

                XElement elmClassBuys = Element.Element("ClassBusys");

                if (elmClassBuys != null)
                {
                    foreach (XElement SubElement in elmClassBuys.Elements("ClassBusy"))
                    {
                        SClassBusy ClassBusy = new SClassBusy();
                        ClassBusy.Load(SubElement);
                        ClassBusysResult.Data.Add(ClassBusy);
                    }
                }

                Progress.Invoke(10);

                TeacherResult = new SIntegrationResult<STeacher>();
                TeacherResult.Data = new List<STeacher>();

                XElement elmTeachers = Element.Element("Teachers");

                if (elmTeachers != null)
                {
                    foreach (XElement SubElement in elmTeachers.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        TeacherResult.Data.Add(Teacher);
                    }
                }

                FullTeacherResult = new SIntegrationResult<STeacher>();
                FullTeacherResult.Data = new List<STeacher>();

                XElement elmFullTeacher = Element.Element("FullTeachers");

                if (elmFullTeacher != null)
                {
                    foreach (XElement SubElement in elmFullTeacher.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        FullTeacherResult.Data.Add(Teacher);
                    }
                }

                Progress.Invoke(20);

                TeacherBusysResult = new SIntegrationResult<STeacherBusy>();
                TeacherBusysResult.Data = new List<STeacherBusy>();

                XElement elmTeacherBusy = Element.Element("TeacherBusys");

                if (elmTeacherBusy != null)
                {
                    foreach (XElement SubElement in  elmTeacherBusy.Elements("TeacherBusy"))
                    {
                        STeacherBusy TeacherBusy = new STeacherBusy();
                        TeacherBusy.Load(SubElement);
                        TeacherBusysResult.Data.Add(TeacherBusy);
                    }
                }

                Progress.Invoke(30);

                CourseSectionResult = new SIntegrationResult<SCourseSection>();
                CourseSectionResult.Data = new List<SCourseSection>();

                XElement elmCourseSections = Element.Element("CourseSections");

                if (elmCourseSections != null)
                {
                    foreach (XElement SubElement in elmCourseSections.Elements("CourseSection"))
                    {
                        SCourseSection CourseSection = new SCourseSection();
                        CourseSection.Load(SubElement);
                        CourseSectionResult.Data.Add(CourseSection);
                    }
                }

                Progress.Invoke(40);

                ClassroomResult = new SIntegrationResult<SClassroom>();
                ClassroomResult.Data = new List<SClassroom>();

                XElement elmClassrooms = Element.Element("Classrooms");

                if (elmClassrooms!=null)
                {
                    foreach (XElement SubElement in elmClassrooms.Elements("Classroom"))
                    {
                        SClassroom Classroom = new SClassroom();

                        Classroom.Load(SubElement);

                        ClassroomResult.Data.Add(Classroom);
                    }
                }

                Progress.Invoke(50);

                ClassroomBusysResult = new SIntegrationResult<SClassroomBusy>();
                ClassroomBusysResult.Data = new List<SClassroomBusy>();

                XElement elmClassroomBusys = Element.Element("ClassroomBusys");

                if (elmClassroomBusys != null)
                {
                    foreach (XElement SubElement in elmClassroomBusys.Elements("ClassroomBusy"))
                    {
                        SClassroomBusy ClassroomBusy = new SClassroomBusy();
                        ClassroomBusy.Load(SubElement);
                        ClassroomBusysResult.Data.Add(ClassroomBusy);
                    }
                }

                Progress.Invoke(60);

                LocationResult = new SIntegrationResult<SLocation>();
                LocationResult.Data = new List<SLocation>();

                XElement elmLocations = Element.Element("Locations");

                if (elmLocations != null)
                {
                    foreach (XElement SubElement in elmLocations.Elements("Location"))
                    {
                        SLocation Location = new SLocation();

                        Location.Load(SubElement);

                        LocationResult.Data.Add(Location);
                    }
                }

                Progress.Invoke(70);

                TimeTableResult = new SIntegrationResult<STimeTable>();
                TimeTableResult.Data = new List<STimeTable>();

                XElement elmTimeTables = Element.Element("TimeTables");

                if (elmTimeTables != null)
                {
                    foreach (XElement SubElement in elmTimeTables.Elements("TimeTable"))
                    {
                        STimeTable TimeTable = new STimeTable();

                        TimeTable.Load(SubElement);

                        TimeTableResult.Data.Add(TimeTable);
                    }
                }

                Progress.Invoke(80);

                TimeTableSecsResult = new SIntegrationResult<STimeTableSec>();
                TimeTableSecsResult.Data = new List<STimeTableSec>();

                XElement elmTimeTableSecs = Element.Element("TimeTableSecs");

                if (elmTimeTableSecs != null)
                {
                    foreach (XElement SubElement in elmTimeTableSecs.Elements("TimeTableSec"))
                    {
                        STimeTableSec TimeTableSec = new STimeTableSec();

                        TimeTableSec.Load(SubElement);

                        TimeTableSecsResult.Data.Add(TimeTableSec);
                    }
                }

                Progress.Invoke(90);

                Subjects = CourseSectionResult.Data.Select(x => x.Subject).Distinct().ToList();

                Progress.Invoke(100);

                IsSuccess = true;
            }
            catch (Exception e)
            {
                IsSuccess = false;

                throw e;
            }
        }