private void MasterWorker_DoWork(object sender, DoWorkEventArgs e) { StudentScore.SetClassMapping(); // 取得學生類別List // List<K12.Data.StudentTagRecord> StudTagRecList = K12.Data.StudentTag.SelectByStudentIDs(StudentIDs); List <K12.Data.StudentTagRecord> StudTagRecList = K12.Data.StudentTag.SelectAll(); // 過濾不排學生ID List <string> NonStudentIDList = DAL.DALTransfer.GetNonRankStudentIDFromUDTByStudentTag(StudTagRecList, JointAdmissionModule.DAL.DALTransfer.SchoolType.高中); foreach (string id in NonStudentIDList) { if (StudentIDs.Contains(id)) { StudentIDs.Remove(id); } } List <ReportStudent> PrintStudents = StudentIDs.ToReportStudent(); if (Preference.PrintRank || Preference.PrintRankPercentage || Preference.FilterRankScope) { #region 如果要排名。 //List<ReportStudent> RatingStudents = Util.GetAllStudents(); List <ReportStudent> RatingStudents = Util.GetStudentsDef(NonStudentIDList); RatingStudents.ToSC().ReadSemesterScore(this); RatingStudents.ToSC().ReadSemesterHistory(this); List <IScoreParser <ReportStudent> > parsers = new List <IScoreParser <ReportStudent> >(); List <SLearningDomainParser> allsems = new List <SLearningDomainParser>(); parsers.Add(new LearningDomainParser(Preference.PrintSemesters)); allsems.Add(new SLearningDomainParser(1, 1)); allsems.Add(new SLearningDomainParser(1, 2)); allsems.Add(new SLearningDomainParser(2, 1)); allsems.Add(new SLearningDomainParser(2, 2)); allsems.Add(new SLearningDomainParser(3, 1)); allsems.Add(new SLearningDomainParser(3, 2)); allsems.Add(new SLearningDomainParser(7, 1)); allsems.Add(new SLearningDomainParser(7, 2)); allsems.Add(new SLearningDomainParser(8, 1)); allsems.Add(new SLearningDomainParser(8, 2)); allsems.Add(new SLearningDomainParser(9, 1)); allsems.Add(new SLearningDomainParser(9, 2)); foreach (SLearningDomainParser each in allsems) { parsers.Add(each); } // 將學生加入年排名 List <RatingScope <ReportStudent> > scopes = RatingStudents.ToGradeYearScopes(); foreach (RatingScope <ReportStudent> each in scopes) { foreach (IScoreParser <ReportStudent> parser in parsers) { each.Rank(parser, PlaceOptions.Unsequence); } } Dictionary <string, StudentScore> DicPrintStudents = PrintStudents.ToSC().ToDictionary(); foreach (ReportStudent each in RatingStudents) { if (DicPrintStudents.ContainsKey(each.Id)) { DicPrintStudents[each.Id] = each; } //each.Places["學習領域"].Percentage //each.Places["學習領域"].GetPercentage(); //each.Places["學習領域"].Score } // 整理全部學生年排名 DAL.DALTransfer.StudRankScoreDict.Clear(); // 建立Key foreach (RatingScope <ReportStudent> scope in scopes) { DAL.DALTransfer.StudRankScoreDict.Add(scope.Name, new Dictionary <string, List <JointAdmissionModule.DAL.StudRankScore> >()); DAL.DALTransfer.StudRankScoreDict[scope.Name].Add("學期總平均", new List <JointAdmissionModule.DAL.StudRankScore>()); foreach (SLearningDomainParser semsIndex in allsems) { DAL.DALTransfer.StudRankScoreDict[scope.Name].Add(semsIndex.Name, new List <JointAdmissionModule.DAL.StudRankScore>()); } } foreach (RatingScope <ReportStudent> scope in scopes) { // 學習領域 foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains("學習領域") select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")["學習領域"]; DAL.DALTransfer.StudRankScoreDict[scope.Name]["學期總平均"].Add(srs); } foreach (SLearningDomainParser semsIndex in allsems) { foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains(semsIndex.Name) select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")[semsIndex.Name]; DAL.DALTransfer.StudRankScoreDict[scope.Name][semsIndex.Name].Add(srs); } } } //foreach (ReportStudent stud in RatingStudents) //{ //----------------- //foreach (RatingScope<ReportStudent> scope in scopes) //{ // if (!DAL.DALTransfer.StudRankScoreDict.ContainsKey(scope.Name)) // DAL.DALTransfer.StudRankScoreDict.Add(scope.Name, new Dictionary<string, List<DAL.StudRankScore>>()); // foreach (ReportStudent stud in scope) // { // // 學期總平均 // if (stud.Places.NS("年排名").Contains("學習領域")) // { // DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); // srs.StudentID = stud.StudentID; // srs.Place = stud.Places.NS("年排名")["學習領域"]; // if (DAL.DALTransfer.StudRankScoreDict[scope.Name].ContainsKey("學期總平均")) // { // DAL.DALTransfer.StudRankScoreDict[scope.Name]["學期總平均"].Add(srs); // } // else // { // List<DAL.StudRankScore> srsList = new List<JointAdmissionModule.DAL.StudRankScore>(); // srsList.Add(srs); // DAL.DALTransfer.StudRankScoreDict[scope.Name].Add("學期總平均", srsList); // } // } // foreach (SLearningDomainParser semsIndex in allsems) // { // if (stud.Places.NS("年排名").Contains(semsIndex.Name)) // { // DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); // srs.StudentID = stud.StudentID; // srs.Place = stud.Places.NS("年排名")[semsIndex.Name]; // if (DAL.DALTransfer.StudRankScoreDict[scope.Name].ContainsKey(semsIndex.Name)) // { // DAL.DALTransfer.StudRankScoreDict[scope.Name][semsIndex.Name].Add(srs); // } // else // { // List<DAL.StudRankScore> srsList = new List<JointAdmissionModule.DAL.StudRankScore>(); // srsList.Add(srs); // DAL.DALTransfer.StudRankScoreDict[scope.Name].Add(semsIndex.Name, srsList); // } // } // } // } //} //------------------------------------ //} //// 排序對照年排名資料 debug 用 //for (int i = 1; i <= 9; i++) //{ // if (DAL.DALTransfer.StudRankScoreDict.ContainsKey(i.ToString())) // { // string idx = i.ToString(); // foreach (SLearningDomainParser semsIndex in allsems) // { // if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(semsIndex.Name)) // { // var x = from xx in DAL.DALTransfer.StudRankScoreDict[idx][semsIndex.Name] orderby xx.Place.Score descending select xx; // DAL.DALTransfer.StudRankScoreDict[idx][semsIndex.Name] = x.ToList(); // } // } // } //} Workbook wb = new Workbook(); Dictionary <string, ReportStudent> students = RatingStudents.ToDictionary(x => x.Id); int wstCot = 0; // 排序對照年排名資料 debug 用 foreach (RatingScope <ReportStudent> scope in scopes) { if (DAL.DALTransfer.StudRankScoreDict.ContainsKey(scope.Name)) { string idx = scope.Name; string AvggName = "學期總平均"; if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(AvggName)) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + AvggName; wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][AvggName].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(AvggName); wb.Worksheets[wstCot].Cells[row, 3].PutValue(idx); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } wstCot++; } foreach (SLearningDomainParser semsIndex in allsems) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + semsIndex.Name.Replace(":", "-"); wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(semsIndex.Name)) { foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][semsIndex.Name].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(semsIndex.Name); wb.Worksheets[wstCot].Cells[row, 3].PutValue(semsIndex.Grade); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } } wstCot++; } } } for (int i = 0; i < wb.Worksheets.Count; i++) { if (wb.Worksheets[i].Cells.MaxDataRow < 2) { wb.Worksheets.RemoveAt(i); } } try { wb.Save(Application.StartupPath + "\\樂學成績debug.xls", FileFormatType.Excel2003); // System.Diagnostics.Process.Start(Application.StartupPath + "\\樂學成績debug.xls"); } catch (Exception ex) { } if (Preference.FilterRankScope) { List <ReportStudent> filteredStudent = new List <ReportStudent>(); foreach (ReportStudent each in DicPrintStudents.Values.ToSS()) { //看是否有「學習領域」的年排名。 if (each.Places.NS("年排名").Contains(LearningDomainParser.PlaceName)) { Place place = each.Places.NS("年排名")[LearningDomainParser.PlaceName]; if (place.Level >= Preference.RankStart && place.Level <= Preference.RankEnd) { filteredStudent.Add(each); } } PrintStudents = filteredStudent; } } else { PrintStudents = new List <ReportStudent>(DicPrintStudents.Values.ToSS()); } #endregion } else { PrintStudents.ToSC().ReadSemesterScore(this); PrintStudents.ToSC().ReadSemesterHistory(this); } List <StudentScore> CalcStudents; if (PrintStudents.Count <= 0) { Feedback("", -1); //把 Status bar Reset... throw new ArgumentException("沒有任何學生資料可列印。"); } else { CalcStudents = PrintStudents.ToSC(); CalcStudents.ReadCalculationRule(this); //讀取成績計算規則。 #region 讀取缺曠獎懲。 //List<JHMoralScoreRecord> jhmorals = JHSchool.Data.JHMoralScore.SelectByStudentIDs(StudentIDs); List <AutoSummaryRecord> jhsummary = AutoSummary.Select(StudentIDs, null); Dictionary <string, ReportStudent> DicStudents = PrintStudents.ToDictionary(); //foreach (JHMoralScoreRecord each in jhmorals) foreach (AutoSummaryRecord each in jhsummary) { if (!DicStudents.ContainsKey(each.RefStudentID)) { continue; } SemesterData semester = new SemesterData(0, each.SchoolYear, each.Semester); ReportStudent student = DicStudents[each.RefStudentID]; if (!student.Summaries.ContainsKey(semester)) { student.Summaries.Add(semester, each.AutoSummary); } } #endregion PrintStudents.ReadUpdateRecordDate(this); e.Result = new Report(PrintStudents, Preference).Print(); Feedback("列印完成", -1); } }
void _BGWorker_DoWork(object sender, DoWorkEventArgs e) { StudentScore.SetClassMapping(); // 取得學生類別List List <K12.Data.StudentTagRecord> StudTagRecList = K12.Data.StudentTag.SelectAll(); // 過濾不排學生ID List <string> NonStudentIDList = DAL.DALTransfer.GetNonRankStudentIDFromUDTByStudentTag(StudTagRecList, JointAdmissionModule.DAL.DALTransfer.SchoolType.高中); foreach (string id in NonStudentIDList) { if (StudentIDs.Contains(id)) { StudentIDs.Remove(id); } } List <ReportStudent> PrintStudents = StudentIDs.ToReportStudent(); List <ReportStudent> RatingStudents = Util.GetStudentsDef(NonStudentIDList); RatingStudents.ToSC().ReadSemesterScore(this); RatingStudents.ToSC().ReadSemesterHistory(this); #region 讀取三學期學期領域成績(LearnDomainScore),填入ReportStudent foreach (ReportStudent stud in RatingStudents) { // 取得2,3年級學期歷程 List <SemesterData> semtList = (from xx in stud.SHistory where xx.GradeYear == 2 || xx.GradeYear == 8 || xx.GradeYear == 3 || xx.GradeYear == 9 select xx).ToList(); foreach (SemesterData sd in semtList) { foreach (SemesterScore ss in stud.SemestersScore) { // 二年級 if (sd.GradeYear == 2 || sd.GradeYear == 8) { if (sd.SchoolYear == ss.SchoolYear) { if (ss.Semester == 1) { if (ss.LearnDomainScore.HasValue) { stud.LearnDomainScore81 = ss.LearnDomainScore.Value; } else { stud.LearnDomainScore81 = 0; } //取得核心學習領域成績 if (CurrentMode == ModuleMode.Tainan) { stud.CoreLearnDomainScore81 = ss.GetCoreDomainLearningScore(); } } if (ss.Semester == 2) { if (ss.LearnDomainScore.HasValue) { stud.LearnDomainScore82 = ss.LearnDomainScore.Value; } else { stud.LearnDomainScore82 = 0; } //取得核心學習領域成績 if (CurrentMode == ModuleMode.Tainan) { stud.CoreLearnDomainScore82 = ss.GetCoreDomainLearningScore(); } } } } // 三上 if ((sd.GradeYear == 3 || sd.GradeYear == 9) && sd.Semester == 1) { if (sd.SchoolYear == ss.SchoolYear && ss.Semester == 1) { if (ss.LearnDomainScore.HasValue) { stud.LearnDomainScore91 = ss.LearnDomainScore.Value; } else { stud.LearnDomainScore91 = 0; } //取得核心學習領域成績 if (CurrentMode == ModuleMode.Tainan) { stud.CoreLearnDomainScore91 = ss.GetCoreDomainLearningScore(); } } } } } } #endregion List <IScoreParser <ReportStudent> > parsers = new List <IScoreParser <ReportStudent> >(); List <SLearningDomainParser> allsems = new List <SLearningDomainParser>(); List <int> semInt = new List <int>(); semInt.Add(3); semInt.Add(4); semInt.Add(5); parsers.Add(new LearningDomainParser(semInt)); allsems.Add(new SLearningDomainParser(1, 1)); allsems.Add(new SLearningDomainParser(1, 2)); allsems.Add(new SLearningDomainParser(2, 1)); allsems.Add(new SLearningDomainParser(2, 2)); allsems.Add(new SLearningDomainParser(3, 1)); allsems.Add(new SLearningDomainParser(3, 2)); allsems.Add(new SLearningDomainParser(7, 1)); allsems.Add(new SLearningDomainParser(7, 2)); allsems.Add(new SLearningDomainParser(8, 1)); allsems.Add(new SLearningDomainParser(8, 2)); allsems.Add(new SLearningDomainParser(9, 1)); allsems.Add(new SLearningDomainParser(9, 2)); //加入核心學習領域解析 if (CurrentMode == ModuleMode.Tainan) { parsers.Add(new CoreLearningDomainParser()); } foreach (SLearningDomainParser each in allsems) { parsers.Add(each); } #region 3學期8科目 List <string> DomainNameList = DAL.DALTransfer.GetDomainNameList(); // 放領域排名 List <DomainParser> AllDomainSems = new List <DomainParser>(); //取得各領域三學期平均排名 foreach (string name in DomainNameList) { DomainParser dp = new DomainParser(name, 100); AllDomainSems.Add(dp); } foreach (DomainParser each in AllDomainSems) { parsers.Add(each); } #endregion //將學生依年級分類 List <RatingScope <ReportStudent> > scopes = RatingStudents.ToGradeYearScopes(); #region 針對每個年級的學生進行排名 foreach (RatingScope <ReportStudent> each in scopes) { foreach (IScoreParser <ReportStudent> parser in parsers) { each.Rank(parser, PlaceOptions.Unsequence); } } Dictionary <string, StudentScore> DicPrintStudents = PrintStudents.ToSC().ToDictionary(); foreach (ReportStudent each in RatingStudents) { if (DicPrintStudents.ContainsKey(each.Id)) { DicPrintStudents[each.Id] = each; } } #endregion // 整理全部學生年排名 DAL.DALTransfer.StudRankScoreDict.Clear(); // 建立Key foreach (RatingScope <ReportStudent> scope in scopes) { DAL.DALTransfer.StudRankScoreDict.Add(scope.Name, new Dictionary <string, List <JointAdmissionModule.DAL.StudRankScore> >()); //學期總平均 DAL.DALTransfer.StudRankScoreDict[scope.Name].Add("學期總平均", new List <JointAdmissionModule.DAL.StudRankScore>()); //核心學期總平均 DAL.DALTransfer.StudRankScoreDict[scope.Name].Add("核心學期總平均", new List <DAL.StudRankScore>()); // 領域平均 foreach (SLearningDomainParser semsIndex in allsems) { DAL.DALTransfer.StudRankScoreDict[scope.Name].Add(semsIndex.Name, new List <JointAdmissionModule.DAL.StudRankScore>()); } // 各領域 foreach (DomainParser semsIdx in AllDomainSems) { DAL.DALTransfer.StudRankScoreDict[scope.Name].Add(semsIdx.Name, new List <JointAdmissionModule.DAL.StudRankScore>()); } } foreach (RatingScope <ReportStudent> scope in scopes) { // 學習領域 foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains("學習領域") select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")["學習領域"]; DAL.DALTransfer.StudRankScoreDict[scope.Name]["學期總平均"].Add(srs); } //核心學習領域 foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains("核心學習領域") select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")["核心學習領域"]; DAL.DALTransfer.StudRankScoreDict[scope.Name]["核心學期總平均"].Add(srs); } // 領域平均 foreach (SLearningDomainParser semsIndex in allsems) { foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains(semsIndex.Name) select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")[semsIndex.Name]; DAL.DALTransfer.StudRankScoreDict[scope.Name][semsIndex.Name].Add(srs); } } // 各領域 foreach (DomainParser semsIndex in AllDomainSems) { foreach (ReportStudent stud in (from xx in scope where xx.Places.NS("年排名").Contains(semsIndex.Name) select xx).ToList()) { DAL.StudRankScore srs = new JointAdmissionModule.DAL.StudRankScore(); srs.StudentID = stud.StudentID; srs.Place = stud.Places.NS("年排名")[semsIndex.Name]; DAL.DALTransfer.StudRankScoreDict[scope.Name][semsIndex.Name].Add(srs); } } } // 排序對照年排名資料 debug 用 Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); Dictionary <string, ReportStudent> students = RatingStudents.ToDictionary(x => x.Id); int wstCot = 0; foreach (RatingScope <ReportStudent> scope in scopes) { if (DAL.DALTransfer.StudRankScoreDict.ContainsKey(scope.Name)) { string idx = scope.Name; string AvggName = "學期總平均"; if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(AvggName)) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + AvggName; wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][AvggName].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(AvggName); wb.Worksheets[wstCot].Cells[row, 3].PutValue(idx); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } wstCot++; } string CoreAvggName = "核心學期總平均"; if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(CoreAvggName)) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + CoreAvggName; wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][CoreAvggName].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(AvggName); wb.Worksheets[wstCot].Cells[row, 3].PutValue(idx); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } wstCot++; } foreach (SLearningDomainParser semsIndex in allsems) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + semsIndex.Name.Replace(":", "-"); wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(semsIndex.Name)) { foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][semsIndex.Name].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(semsIndex.Name); wb.Worksheets[wstCot].Cells[row, 3].PutValue(semsIndex.Grade); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } } wstCot++; } foreach (DomainParser semsIndex in AllDomainSems) { int row = 1; wb.Worksheets.Add(); wb.Worksheets[wstCot].Name = idx + semsIndex.Name.Replace(":", "-"); wb.Worksheets[wstCot].Cells[0, 0].PutValue("成績"); wb.Worksheets[wstCot].Cells[0, 1].PutValue("年排名"); wb.Worksheets[wstCot].Cells[0, 2].PutValue("分類"); wb.Worksheets[wstCot].Cells[0, 3].PutValue("年級"); wb.Worksheets[wstCot].Cells[0, 4].PutValue("SID"); wb.Worksheets[wstCot].Cells[0, 5].PutValue("StudCount"); if (DAL.DALTransfer.StudRankScoreDict[idx].ContainsKey(semsIndex.Name)) { foreach (JointAdmissionModule.DAL.StudRankScore xx in DAL.DALTransfer.StudRankScoreDict[idx][semsIndex.Name].OrderByDescending(x => x.Place.Score)) { wb.Worksheets[wstCot].Cells[row, 0].PutValue(xx.Place.Score); wb.Worksheets[wstCot].Cells[row, 1].PutValue(xx.Place.Percentage); wb.Worksheets[wstCot].Cells[row, 2].PutValue(semsIndex.Name); wb.Worksheets[wstCot].Cells[row, 3].PutValue(semsIndex.Grade); wb.Worksheets[wstCot].Cells[row, 4].PutValue(xx.StudentID); wb.Worksheets[wstCot].Cells[row, 5].PutValue(xx.Place.Radix); wb.Worksheets[wstCot].Cells[row, 6].PutValue(students[xx.StudentID].GradeYear); row++; } } wstCot++; } } } for (int i = 0; i < wb.Worksheets.Count; i++) { if (wb.Worksheets[i].Cells.MaxDataRow < 2) { wb.Worksheets.RemoveAt(i); } } try { wb.Save(Application.StartupPath + "\\竹苗成績debug.xls", Aspose.Cells.FileFormatType.Excel2003); //System.Diagnostics.Process.Start(Application.StartupPath + "\\五專成績debug.xls"); } catch (Exception ex) { } if (true) { List <ReportStudent> filteredStudent = new List <ReportStudent>(); foreach (ReportStudent each in DicPrintStudents.Values.ToSS()) { //看是否有「學習領域」的年排名。 if (each.Places.NS("年排名").Contains(LearningDomainParser.PlaceName)) { Place place = each.Places.NS("年排名")[LearningDomainParser.PlaceName]; filteredStudent.Add(each); } PrintStudents = filteredStudent; } } else { PrintStudents = new List <ReportStudent>(DicPrintStudents.Values.ToSS()); } PrintStudents.ToSC().ReadSemesterScore(this); PrintStudents.ToSC().ReadSemesterHistory(this); List <StudentScore> CalcStudents; if (PrintStudents.Count <= 0) { Feedback("", -1); //把 Status bar Reset... throw new ArgumentException("沒有任何學生資料可列印。"); } else { CalcStudents = PrintStudents.ToSC(); CalcStudents.ReadCalculationRule(this); //讀取成績計算規則。 PrintStudents.ReadUpdateRecordDate(this); e.Result = new Report(PrintStudents, txtReportTitle.Text, CurrentMode); Feedback("列印完成", -1); } }