Beispiel #1
0
        /// <summary>
        /// 讀取評量成績
        /// </summary>
        /// <param name="reporter"></param>
        internal void ReadScores(IReporter reporter)
        {
            List <string> subjects = new List <string>(Config.TargetSubjects);

            subjects.Add(Config.SourceSubject);

            List <string> attendIDs = GetAttendIDs(subjects);

            FunctionSpliter <string, JHSCETakeRecord> spliter = new FunctionSpliter <string, JHSCETakeRecord>(200, Util.MaxThread);

            spliter.Function = delegate(List <string> part)
            {
                return(JHSCETake.Select(null, null, new string[] { Config.Exam.ID }, null, part));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                reporter.Feedback("讀取評量成績中...", Util.CalculatePercentage(attendIDs.Count, progress));
            };

            foreach (JHSCETakeRecord score in spliter.Execute(attendIDs))
            {
                if (Data.ContainsKey(score.RefStudentID))
                {
                    Data[score.RefStudentID].Scores.Add(score);
                }
            }
        }
Beispiel #2
0
        private void ScoreSaver_DoWork(object sender, DoWorkEventArgs e)
        {
            List <JHSCETakeRecord> sceList = new List <JHSCETakeRecord>();

            List <StudentData> sdList = AttendManager.Instance.GetStudentDataList();
            int count = 0;

            foreach (StudentData sd in sdList)
            {
                count++;
                sceList.AddRange(sd.GetCopiedScores(Config.SourceSubject, Config.TargetSubjects));
                ScoreSaver.ReportProgress(Util.CalculatePercentage(sdList.Count, count), "複製評量成績中...");
            }

            List <JHSCETakeRecord> insertList = new List <JHSCETakeRecord>();
            List <JHSCETakeRecord> updateList = new List <JHSCETakeRecord>();

            foreach (JHSCETakeRecord sce in sceList)
            {
                if (string.IsNullOrEmpty(sce.ID))
                {
                    insertList.Add(sce);
                }
                else
                {
                    updateList.Add(sce);
                }
            }

            if (insertList.Count > 0)
            {
                FunctionSpliter <JHSCETakeRecord, string> spliterInsert = new FunctionSpliter <JHSCETakeRecord, string>(100, Util.MaxThread);
                spliterInsert.Function = delegate(List <JHSCETakeRecord> part)
                {
                    JHSCETake.Insert(part);
                    return(null);
                };
                spliterInsert.ProgressChange = delegate(int progress)
                {
                    ScoreSaver.ReportProgress(Util.CalculatePercentage(insertList.Count, progress), "儲存評量成績中...");
                };
                spliterInsert.Execute(insertList);
            }
            if (updateList.Count > 0)
            {
                FunctionSpliter <JHSCETakeRecord, string> spliterUpdate = new FunctionSpliter <JHSCETakeRecord, string>(100, Util.MaxThread);
                spliterUpdate.Function = delegate(List <JHSCETakeRecord> part)
                {
                    JHSCETake.Update(part);
                    return(null);
                };
                spliterUpdate.ProgressChange = delegate(int progress)
                {
                    ScoreSaver.ReportProgress(Util.CalculatePercentage(updateList.Count, progress), "儲存評量成績中...");
                };
                spliterUpdate.Execute(updateList);
            }
        }
Beispiel #3
0
        private void CourseWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            CourseWorker.ReportProgress(0, "讀取學生資料...");
            Event.WaitOne();
            CourseWorker.ReportProgress(100, "讀取學生資料...");

            List <string> studentIDs = Students.AsKeyList();
            FunctionSpliter <string, JHSCAttendRecord> spliter = new FunctionSpliter <string, JHSCAttendRecord>(100, Util.MaxThread);

            spliter.Function = delegate(List <string> part)
            {
                return(JHSCAttend.Select(part, null, null, "" + RunningSchoolYear, "" + RunningSemester));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                CourseWorker.ReportProgress(Util.CalculatePercentage(studentIDs.Count, progress), "讀取修課記錄...");
            };
            List <JHSCAttendRecord> AllAttends = spliter.Execute(studentIDs);

            AttendManager.Instance.Set(Students, AllAttends);

            List <string> validCourseIDs = new List <string>();

            foreach (JHSCAttendRecord sca in AllAttends)
            {
                if (!validCourseIDs.Contains(sca.RefCourseID))
                {
                    validCourseIDs.Add(sca.RefCourseID);
                }
            }

            //CourseWorker.ReportProgress(0, "讀取課程...");

            JHCourse.RemoveAll();

            FunctionSpliter <string, JHCourseRecord> spliter2 = new FunctionSpliter <string, JHCourseRecord>(100, Util.MaxThread);

            spliter2.Function = delegate(List <string> part)
            {
                return(JHCourse.SelectByIDs(part));
            };
            spliter2.ProgressChange = delegate(int progress)
            {
                CourseWorker.ReportProgress(Util.CalculatePercentage(validCourseIDs.Count, progress), "讀取課程...");
            };
            Courses = spliter2.Execute(validCourseIDs);
        }