Exemple #1
0
        private void MasterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1.Goup By 可選擇的科目清單。
            //2.寫入成績資料到 ReportStudent 上。



            int schoolYear = Semester.SelectedSchoolYear;
            int semester   = Semester.SelectedSemester;
            FunctionSpliter <string, JHSemesterScoreRecord> selectData = new FunctionSpliter <string, JHSemesterScoreRecord>(1000, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSemesterScore.SelectBySchoolYearAndSemester(ps, schoolYear, semester));
            };
            List <JHSemesterScoreRecord> semsScores = selectData.Execute(AllStudents.ToKeys());

            GroupBySubjects(semsScores);

            //先把學生身上的成績、排名相關資料清掉。
            foreach (ReportStudent each in AllStudents)
            {
                each.Clear();
                each.Scores.Add(Utilities.SubjectToken, new ScoreCollection()); //科目成績。
                each.Scores.Add(Utilities.DomainToken, new ScoreCollection());  //領域成績。
                each.Scores.Add(Utilities.SummaryToken, new ScoreCollection()); //運算後的成績。
            }

            //將成績填到學生身上。
            Dictionary <string, ReportStudent> dicAllStudent = AllStudents.ToDictionary();

            foreach (JHSemesterScoreRecord eachScore in semsScores)
            {
                //如果找不到該學生,跳到下一筆。
                if (!dicAllStudent.ContainsKey(eachScore.RefStudentID))
                {
                    continue;
                }

                ReportStudent student = dicAllStudent[eachScore.RefStudentID];

                //科目成績。
                foreach (SubjectScore each in eachScore.Subjects.Values)
                {
                    // 初始執
                    decimal ss = -1;

                    if (Perference.UserSelScoreType == "原始成績")
                    {
                        if (each.ScoreOrigin.HasValue)
                        {
                            ss = each.ScoreOrigin.Value;
                        }
                    }

                    if (Perference.UserSelScoreType == "原始補考擇優")
                    {
                        // 成績
                        if (each.Score.HasValue && each.Score.Value > ss)
                        {
                            ss = each.Score.Value;
                        }
                    }

                    //                    if (!each.Score.HasValue) continue; //沒有分數不處理。

                    if (ss == -1)
                    {
                        continue;
                    }

                    if (!each.Credit.HasValue || each.Credit.Value < 0)
                    {
                        continue;                                                  //沒有節數不處理。 //2021-07 要求權重0也要印出
                    }
                    if (!student.Scores[Utilities.SubjectToken].Contains(each.Subject))
                    {
                        student.Scores[Utilities.SubjectToken].Add(each.Subject, ss, each.Credit.Value);

                        if (Perference.UserSelScoreType == "原始補考擇優" && each.ScoreMakeup.HasValue)
                        {
                            student.Scores[Utilities.DomainToken].AddReExam(each.Subject, each.ScoreMakeup.Value);
                        }
                    }
                }

                //領域成績。
                foreach (DomainScore each in eachScore.Domains.Values)
                {
                    decimal dd = -1;
                    if (Perference.UserSelScoreType == "原始成績")
                    {
                        if (each.ScoreOrigin.HasValue)
                        {
                            dd = each.ScoreOrigin.Value;
                        }
                    }

                    if (Perference.UserSelScoreType == "原始補考擇優")
                    {
                        if (each.Score.HasValue && each.Score.Value > dd)
                        {
                            dd = each.Score.Value;
                        }
                    }

                    //if (!each.Score.HasValue) continue;
                    if (dd == -1)
                    {
                        continue;
                    }

                    if (!each.Credit.HasValue || each.Credit.Value < 0)
                    {
                        continue;                                                 //2021-07 要求權重0也要印出
                    }
                    if (!student.Scores[Utilities.DomainToken].Contains(each.Domain))
                    {
                        student.Scores[Utilities.DomainToken].Add(each.Domain, dd, each.Credit.Value);

                        if (Perference.UserSelScoreType == "原始補考擇優" && each.ScoreMakeup.HasValue)
                        {
                            student.Scores[Utilities.DomainToken].AddReExam(each.Domain, each.ScoreMakeup.Value);
                        }
                    }
                }

                //運算後成績是在使用者按下列印時才計算。
                //因為需要依據使用者選擇的科目進行計算。
            }
        }
Exemple #2
0
        private void MasterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1.Goup By 可選擇的科目清單。
            //2.寫入成績資料到 ReportStudent 上。

            int schoolYear = Semester.SelectedSchoolYear;
            int semester   = Semester.SelectedSemester;
            FunctionSpliter <string, JHSemesterScoreRecord> selectData = new FunctionSpliter <string, JHSemesterScoreRecord>(1000, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSemesterScore.SelectBySchoolYearAndSemester(ps, schoolYear, semester));
            };
            List <JHSemesterScoreRecord> semsScores = selectData.Execute(AllStudents.ToKeys());

            GroupBySubjects(semsScores);

            //先把學生身上的成績、排名相關資料清掉。
            foreach (ReportStudent each in AllStudents)
            {
                each.Clear();
                each.Scores.Add(Utilities.SubjectToken, new ScoreCollection()); //科目成績。
                each.Scores.Add(Utilities.DomainToken, new ScoreCollection());  //領域成績。
                each.Scores.Add(Utilities.SummaryToken, new ScoreCollection()); //運算後的成績。
            }

            //將成績填到學生身上。
            Dictionary <string, ReportStudent> dicAllStudent = AllStudents.ToDictionary();

            foreach (JHSemesterScoreRecord eachScore in semsScores)
            {
                //如果找不到該學生,跳到下一筆。
                if (!dicAllStudent.ContainsKey(eachScore.RefStudentID))
                {
                    continue;
                }

                ReportStudent student = dicAllStudent[eachScore.RefStudentID];

                //科目成績。
                foreach (SubjectScore each in eachScore.Subjects.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;                       //沒有分數不處理。
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;                                                   //沒有節數不處理。
                    }
                    if (!student.Scores[Utilities.SubjectToken].Contains(each.Subject))
                    {
                        student.Scores[Utilities.SubjectToken].Add(each.Subject, each.Score.Value, each.Credit.Value);
                    }
                }

                //領域成績。
                foreach (DomainScore each in eachScore.Domains.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;
                    }

                    student.Scores[Utilities.DomainToken].Add(each.Domain, each.Score.Value, each.Credit.Value);
                }

                //運算後成績是在使用者按下列印時才計算。
                //因為需要依據使用者選擇的科目進行計算。
            }
        }