private void InitializeData(IEnumerable<string> pStudentIDs) { if (pStudentIDs.Count() == 0) throw new Exception("未傳入學生資料。"); _PersonalReReadSchoolYear = new Dictionary<string, List<int>>(); _PersonalSemesterEntryReReadSchoolYear = new Dictionary<string, List<int>>(); _PersonalYearEntryReReadSchoolYear = new Dictionary<string, List<int>>(); // 學年科目成績 _SHYearSubjectScoreInfo = new SHYearSubjectScoreInfo(_Students); // 學期科目成績 _SHSemesterSubjectScoreInfo = new SHSemesterSubjectScoreInfo(_Students); // 畢業及離校資訊 _PersonalSHLeaveInfo = SHSchool.Data.SHLeaveInfo.SelectByStudentIDs(pStudentIDs).ToDictionary(x=>x.RefStudentID); // 學生 _StudentRecord = new Dictionary<string, SHSchool.Data.SHStudentRecord>(); foreach(SHSchool.Data.SHStudentRecord student in _Students) { _StudentRecord.Add(student.ID, student); } // 班級 IEnumerable<string> classiDs = _Students.Select(x => x.RefClassID); Dictionary<string, SHSchool.Data.SHClassRecord> _SHClass = new Dictionary<string,SHSchool.Data.SHClassRecord>(); _Class = new Dictionary<string, SHSchool.Data.SHClassRecord>(); foreach(SHSchool.Data.SHClassRecord clazz in SHSchool.Data.SHClass.SelectByIDs(classiDs)) { if (!_SHClass.ContainsKey(clazz.ID)) _SHClass.Add(clazz.ID, clazz); } foreach (SHSchool.Data.SHStudentRecord pStudent in _Students) { if (_SHClass.ContainsKey(pStudent.RefClassID)) if (!_Class.ContainsKey(pStudent.ID)) _Class.Add(pStudent.ID, _SHClass[pStudent.RefClassID]); } classiDs = null; // 科別 List<string> _DepartmentIDs = new List<string>(); Dictionary<string, string> _StudentDepartmentIDs = new Dictionary<string, string>(); _Department = new Dictionary<string,SHSchool.Data.SHDepartmentRecord>(); foreach (SHSchool.Data.SHStudentRecord pStudent in _Students) { if (pStudent.DepartmentID != "") { _StudentDepartmentIDs.Add(pStudent.ID, pStudent.DepartmentID); if (!_DepartmentIDs.Contains(pStudent.DepartmentID)) _DepartmentIDs.Add(pStudent.DepartmentID); } else { if (pStudent.RefClassID == "") continue; if (_SHClass[pStudent.RefClassID] == null) continue; if (_SHClass[pStudent.RefClassID].RefDepartmentID != "") { _StudentDepartmentIDs.Add(pStudent.ID, _SHClass[pStudent.RefClassID].RefDepartmentID); if (!_DepartmentIDs.Contains(pStudent.DepartmentID)) _DepartmentIDs.Add(pStudent.DepartmentID); } } } Dictionary<string, SHSchool.Data.SHDepartmentRecord> _DepartmentRecords = new Dictionary<string, SHDepartmentRecord>(); List<SHSchool.Data.SHDepartmentRecord> allDepartmentRecords = SHSchool.Data.SHDepartment.SelectAll(); foreach (SHSchool.Data.SHDepartmentRecord record in allDepartmentRecords) { if (_DepartmentIDs.Contains(record.ID)) _DepartmentRecords.Add(record.ID, record); } //SHSchool.Data.SHDepartment.SelectByIDs(_DepartmentIDs).ToDictionary(x=>x.ID); foreach (SHSchool.Data.SHStudentRecord pStudent in _Students) { if (pStudent.DepartmentID != "") { if (_StudentDepartmentIDs.ContainsKey(pStudent.ID)) _Department.Add(pStudent.ID, _DepartmentRecords[_StudentDepartmentIDs[pStudent.ID]]); } else { if (pStudent.RefClassID == "") continue; if (_SHClass[pStudent.RefClassID] == null) continue; if (_SHClass[pStudent.RefClassID].RefDepartmentID != "") _Department.Add(pStudent.ID, _DepartmentRecords[_SHClass[pStudent.RefClassID].RefDepartmentID]); } } _SHClass = null; _DepartmentIDs = null; _StudentDepartmentIDs = null; // 畢業照 _GraduatePhoto = K12.Data.Photo.SelectGraduatePhoto(pStudentIDs); // 入學照 _FreshmanPhoto = K12.Data.Photo.SelectFreshmanPhoto(pStudentIDs); // 監護人 List<SHSchool.Data.SHParentRecord> _Parents = SHSchool.Data.SHParent.SelectByStudentIDs(pStudentIDs); _SHParentRecord = new Dictionary<string,SHSchool.Data.SHParentRecord>(); foreach(SHSchool.Data.SHParentRecord pr in _Parents) { _SHParentRecord.Add(pr.RefStudentID, pr); } _Parents = null; // 電話 List<SHSchool.Data.SHPhoneRecord> _Phone = SHSchool.Data.SHPhone.SelectByStudentIDs(pStudentIDs); _SHPhoneRecord = new Dictionary<string,SHSchool.Data.SHPhoneRecord>(); foreach (SHSchool.Data.SHPhoneRecord pr in _Phone) { _SHPhoneRecord.Add(pr.RefStudentID, pr); } _Phone = null; // 地址 List<SHSchool.Data.SHAddressRecord> _Address = SHSchool.Data.SHAddress.SelectByStudentIDs(pStudentIDs); _SHAddressRecord = new Dictionary<string,SHSchool.Data.SHAddressRecord>(); foreach (SHSchool.Data.SHAddressRecord pr in _Address) { _SHAddressRecord.Add(pr.RefStudentID, pr); } _Address = null; // 學業成績 List<SHSchool.Data.SHSemesterEntryScoreRecord> _SHSemesterEntryScores = SHSchool.Data.SHSemesterEntryScore.Select(null, pStudentIDs, "學習", null, false); _SHSemesterEntryScore = new Dictionary<string,List<SHSchool.Data.SHSemesterEntryScoreRecord>>(); foreach (SHSchool.Data.SHSemesterEntryScoreRecord sr in _SHSemesterEntryScores) { if (!_SHSemesterEntryScore.ContainsKey(sr.RefStudentID)) _SHSemesterEntryScore.Add(sr.RefStudentID, new List<SHSchool.Data.SHSemesterEntryScoreRecord>()); _SHSemesterEntryScore[sr.RefStudentID].Add(sr); } _SHSemesterEntryScores = null; // 學年學業成績 List<SHSchool.Data.SHSchoolYearEntryScoreRecord> _SHYearEntryScores = SHSchool.Data.SHSchoolYearEntryScore.Select(null, pStudentIDs, "學習", null); _SHYearEntryScore = new Dictionary<string, List<SHSchool.Data.SHSchoolYearEntryScoreRecord>>(); foreach (SHSchool.Data.SHSchoolYearEntryScoreRecord sr in _SHYearEntryScores) { if (!_SHYearEntryScore.ContainsKey(sr.RefStudentID)) _SHYearEntryScore.Add(sr.RefStudentID, new List<SHSchool.Data.SHSchoolYearEntryScoreRecord>()); _SHYearEntryScore[sr.RefStudentID].Add(sr); } _SHYearEntryScores = null; // 德行評量 List<SHSchool.Data.SHMoralScoreRecord> _SHMoralScoreRecords = SHSchool.Data.SHMoralScore.SelectByStudentIDs(pStudentIDs); Dictionary<string, List<SHSchool.Data.SHMoralScoreRecord>> sHMoralScoreRecord = new Dictionary<string, List<SHSchool.Data.SHMoralScoreRecord>>(); _SHMoralScoreRecord = new Dictionary<string,List<SHSchool.Data.SHMoralScoreRecord>>(); foreach (SHSchool.Data.SHMoralScoreRecord sr in _SHMoralScoreRecords) { if (!_SHMoralScoreRecord.ContainsKey(sr.RefStudentID)) _SHMoralScoreRecord.Add(sr.RefStudentID, new List<SHSchool.Data.SHMoralScoreRecord>()); _SHMoralScoreRecord[sr.RefStudentID].Add(sr); } _SHMoralScoreRecords = null; // 畢業成績 List<SHSchool.Data.SHGradScoreRecord> _SHGradScoreRecords = SHSchool.Data.SHGradScore.SelectByIDs(pStudentIDs); _SHGradScoreRecord = new Dictionary<string,SHSchool.Data.SHGradScoreRecord>(); foreach (SHSchool.Data.SHGradScoreRecord sr in _SHGradScoreRecords) { _SHGradScoreRecord.Add(sr.RefStudentID, sr); } _SHGradScoreRecords = null; // 獎懲 _MeritDeMeritInfo = new MeritDeMeritInfo(_Students); // 異動 List<SHSchool.Data.SHUpdateRecordRecord> _Shurr = SHSchool.Data.SHUpdateRecord.SelectByStudentIDs(pStudentIDs); _SHUpdateRecord = new Dictionary<string, List<SHSchool.Data.SHUpdateRecordRecord>>(); foreach (SHSchool.Data.SHUpdateRecordRecord sr in _Shurr) { if (!_SHUpdateRecord.ContainsKey(sr.StudentID)) _SHUpdateRecord.Add(sr.StudentID, new List<SHSchool.Data.SHUpdateRecordRecord>()); _SHUpdateRecord[sr.StudentID].Add(sr); } _Shurr = null; // 成績計算規則 _PersonalSHScoreCalcRuleRecordInfo = new Dictionary<string, SHSchool.Data.SHScoreCalcRuleRecord>(); Dictionary<string, SHSchool.Data.SHScoreCalcRuleRecord> _SHScoreCalcRule = SHSchool.Data.SHScoreCalcRule.SelectAll().ToDictionary(x => x.ID); foreach (SHSchool.Data.SHStudentRecord student in _Students) { string _ScoreCalcRuleID = string.Empty; if (!string.IsNullOrEmpty(student.OverrideScoreCalcRuleID)) { _ScoreCalcRuleID = student.OverrideScoreCalcRuleID; } else { SHSchool.Data.SHClassRecord clazz = this.GetClass(student.ID); if (clazz == null) continue; else { if (string.IsNullOrEmpty(clazz.RefScoreCalcRuleID)) continue; else _ScoreCalcRuleID = clazz.RefScoreCalcRuleID; } } if (_SHScoreCalcRule.ContainsKey(_ScoreCalcRuleID)) _PersonalSHScoreCalcRuleRecordInfo.Add(student.ID, _SHScoreCalcRule[_ScoreCalcRuleID]); } // 身份類別 _StudentTag = new Dictionary<string, List<SHSchool.Data.SHStudentTagRecord>>(); List<SHSchool.Data.SHStudentTagRecord> _StudentTags = SHSchool.Data.SHStudentTag.SelectByStudentIDs(pStudentIDs); foreach (SHSchool.Data.SHStudentTagRecord st in _StudentTags) { if (!_StudentTag.ContainsKey(st.RefStudentID)) _StudentTag.Add(st.RefStudentID, new List<SHSchool.Data.SHStudentTagRecord>()); _StudentTag[st.RefStudentID].Add(st); } _StudentTags = null; // 學籍身份對照表 _PersonalStatusMappingInfo = new Dictionary<string, List<string>>(); List<SHSchool.Data.SHPermrecStatusMappingInfo> _StatusMappingInfo = SHSchool.Data.SHPermrecStatusMapping.SelectAll(); foreach (SHSchool.Data.SHPermrecStatusMappingInfo sm in _StatusMappingInfo) _PersonalStatusMappingInfo.Add(sm.Name, sm.TagFullNames); _StatusMappingInfo = null; // 綜合高中學程核心課程標示 _CoreCourseTable = new List<string>(); List<SHSubjectTableRecord> _CourseTable = SHSubjectTable.Select(null, null, null); foreach (SHSubjectTableRecord sr in _CourseTable) { foreach (SHSubjectTableSubject ss in sr.Subjects) { if (ss.IsCore.HasValue) { if (ss.IsCore.Value == false) continue; } else continue; string key = string.Empty; if (ss.Levels.Count == 0) { key = sr.Name + "_" + ss.Name; if (!_CoreCourseTable.Contains(key)) _CoreCourseTable.Add(key); } else { foreach (int a in ss.Levels) { key = sr.Name + "_" + ss.Name + "_" + a.ToString(); if (!_CoreCourseTable.Contains(key)) _CoreCourseTable.Add(key); } } } } _CourseTable = null; }
public List<SHSubjectSemesterScoreInfo> GetPersonalSemesterSubjectScoreInfo(string pStudentID, int pSchoolYear1, int pSemester1, SHSemesterSubjectScoreInfo.SubjectSemesterScoreType pSubjectSemesterScoreType, int pSchoolYear2, int pSemester2) { return _SHSemesterSubjectScoreInfo.GetPersonalSemesterSubjectScoreInfo(pStudentID, pSchoolYear1, pSemester1, pSubjectSemesterScoreType, pSchoolYear2, pSemester2); }