public SCETakeCollection LoadData() { int current = 0; SCETakeCollection includes = new SCETakeCollection(); foreach (List <string> each in _packings) { current++; if (_progress.Cancellation) { break; } //_progress.ReportProgress(string.Format("下載成績相關資料({0}%)", Math.Round(((float)current / (float)_packings.Count) * 100, 0)), 0); XmlElement xmlRecords = QueryCourse.GetSECTake(each.ToArray()).GetContent().BaseElement; foreach (XmlElement sce in xmlRecords.SelectNodes("Score")) { SCETake include = new SCETake(sce); includes.Add(include); } } return(includes); }
public void LoadCalculationData(IProgressUI progressUI, IEnumerable <StudentRecord> students, int schoolYear, int semester) { _progress_ui = progressUI; _courses = new CourseCollection(); List <string> courseIds = new List <string>(); //foreach (CourseRecord each in JHSchool.Course.Instance.SelectedList) // courseIds.Add(each.ID); foreach (StudentRecord each in students) { foreach (CourseRecord attend_course in GetAttendCourses(each)) { if (attend_course.SchoolYear != schoolYear) { continue; } if (attend_course.Semester != semester) { continue; } if (!courseIds.Contains(attend_course.ID)) { courseIds.Add(attend_course.ID); } } } CurrentStep = 1; //ReportProgress("下載課程相關資料...", 0); CourseCollection courses = Course.GetCourses(courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } CurrentStep++; //ReportProgress("下載評量相關資料...", 0); ExamTemplateCollection templates = ExamTemplate.GetExamTemplates(); if (_progress_ui.Cancellation) { return; } TEIncludeCollection teincludes = TEInclude.GetTEIncludes(); if (_progress_ui.Cancellation) { return; } CurrentStep++; SCAttendCollection scattends = SCAttend.GetSCAttends(_progress_ui, courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } CurrentStep++; SCETakeCollection scetakes = SCETake.GetSCETakes(_progress_ui, courseIds.ToArray()); if (_progress_ui.Cancellation) { return; } //建立 ExamTemplate 的 TEInclude。 CreateTemplateExamReference(templates, teincludes); //建立 Course 的 ExamTemplate。 CreateCourseTemplateReference(courses, templates); //建立 Course 的 SCAttend。 CreateCourseStudentTwoWayReference(courses, scattends); //建立 SCAttend 的 SCETake。 CreateSCAttendSCETakeReference(scattends, scetakes); _courses = courses; }
private static void CreateSCAttendSCETakeReference(SCAttendCollection scattends, SCETakeCollection scetakes) { foreach (SCETake each in scetakes.Values) { if (scattends.ContainsKey(each.SCAttendId)) { SCAttend scattend = scattends[each.SCAttendId]; scattend.SCETakes.Add(each); } else { Console.WriteLine("SCETake Error:" + each.Identity); } } }