private void ProcessDailyLifeRecommend() { _builder.MoveToMergeField("綜合評語"); _cell = _builder.CurrentParagraph.ParentNode as Cell; TextScoreItemRow itemRow = new TextScoreItemRow(""); foreach (AutoSummaryRecord asRecord in _list) { if (asRecord.MoralScore == null) { continue; } JHMoralScoreRecord record = asRecord.MoralScore; SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); XmlElement textscore = record.TextScore; if (textscore != null) { XmlElement item = (XmlElement)textscore.SelectSingleNode("DailyLifeRecommend"); if (item != null) { itemRow.Add(semester, item.GetAttribute("Description")); } } } WriteTextScoreItemRow(_cell, itemRow); }
private void ProcessDailyBehavior() { _builder.MoveToMergeField("日常行為"); _cell = _builder.CurrentParagraph.ParentNode as Cell; Dictionary <string, TextScoreItemRow> items = new Dictionary <string, TextScoreItemRow>(); foreach (AutoSummaryRecord asRecord in _list) { if (asRecord.MoralScore == null) { continue; } JHMoralScoreRecord record = asRecord.MoralScore; SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); XmlElement textscore = record.TextScore; if (textscore != null) { foreach (string name in _sortOrder) { XmlElement item = (XmlElement)textscore.SelectSingleNode("DailyBehavior/Item[@Name='" + name + "']"); if (item != null) { if (!items.ContainsKey(name)) { items.Add(name, new TextScoreItemRow(name)); } items[name].Add(semester, item.GetAttribute("Degree")); } } } } Cell itemCell = _cell; foreach (string name in _sortOrder) { if (items.ContainsKey(name)) { WriteTextScoreItemRow(itemCell, items[name]); } itemCell = WordHelper.GetMoveDownCell(itemCell, 1); if (itemCell == null) { break; } } }
private void ProcessMoralScore(List <AutoSummaryRecord> autoSummaryList) { Dictionary <string, MoralItemRow> items = new Dictionary <string, MoralItemRow>(); //團體活動 MoralItemRow groupActivityRow = null; //公共服務 MoralItemRow publicServiceRow = null; //校內外特殊表現 MoralItemRow schoolSpecialRow = null; //具體建議 MoralItemRow recommendRow = null; #region 建立適合列印的資料結構 foreach (AutoSummaryRecord asRecord in autoSummaryList) { if (asRecord.MoralScore == null) { continue; } JHMoralScoreRecord record = asRecord.MoralScore; SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); XmlElement dailyBehavior = (XmlElement)record.TextScore.SelectSingleNode("DailyBehavior"); if (dailyBehavior != null) { foreach (XmlElement item in dailyBehavior.SelectNodes("Item")) { string name = item.GetAttribute("Name"); string index = item.GetAttribute("Index"); string degree = item.GetAttribute("Degree"); string[] lines = index.Split(new string[] { ";", ";" }, StringSplitOptions.RemoveEmptyEntries); if (!items.ContainsKey(name)) { items.Add(name, new MoralItemRow(lines)); } items[name].Add(semester, degree); } } XmlElement dailyLifeRecommend = (XmlElement)record.TextScore.SelectSingleNode("DailyLifeRecommend"); if (dailyLifeRecommend != null) { string GroupName = ""; if (Utility.MorItemDict.ContainsKey("DailyLifeRecommend")) { GroupName = Utility.MorItemDict["DailyLifeRecommend"]; } if (recommendRow == null) { recommendRow = new MoralItemRow(new string[] { GroupName }); } recommendRow.Add(semester, dailyLifeRecommend.GetAttribute("Description")); } // 團體活動 XmlElement groupActivity = (XmlElement)record.TextScore.SelectSingleNode("GroupActivity"); if (groupActivity != null) { string GroupName = ""; if (Utility.MorItemDict.ContainsKey("GroupActivity")) { GroupName = Utility.MorItemDict["GroupActivity"]; } if (groupActivityRow == null) { groupActivityRow = new MoralItemRow(new string[] { GroupName }); } string text = string.Empty; foreach (XmlElement item in groupActivity.SelectNodes("Item")) { string degree = item.GetAttribute("Degree"); string desc = item.GetAttribute("Description"); string name = item.GetAttribute("Name"); if (string.IsNullOrEmpty(degree) && string.IsNullOrEmpty(desc)) { continue; } string line = name + ":" + (string.IsNullOrEmpty(degree) ? "" : degree + "/") + (string.IsNullOrEmpty(desc) ? "" : desc); if (line.EndsWith("/")) { line = line.Substring(0, line.Length - 1); } text += line; } // 加入社團 if (_assnScoreCache.ContainsKey(record.RefStudentID)) { string sc = record.SchoolYear.ToString(); string ss = record.Semester.ToString(); foreach (AssnScore asc in _assnScoreCache[record.RefStudentID]) { if (asc.SchoolYear == sc && asc.Semester == ss) { text += "社團活動:" + asc.Score + "," + asc.Effort + "/" + asc.Text; } } } groupActivityRow.Add(semester, text); } XmlElement publicService = (XmlElement)record.TextScore.SelectSingleNode("PublicService"); if (publicService != null) { string GroupName = ""; if (Utility.MorItemDict.ContainsKey("PublicService")) { GroupName = Utility.MorItemDict["PublicService"]; } if (publicServiceRow == null) { publicServiceRow = new MoralItemRow(new string[] { GroupName }); } string text = string.Empty; foreach (XmlElement item in publicService.SelectNodes("Item")) { string degree = item.GetAttribute("Degree"); string desc = item.GetAttribute("Description"); string name = item.GetAttribute("Name"); if (string.IsNullOrEmpty(degree) && string.IsNullOrEmpty(desc)) { continue; } string line = name + ":" + (string.IsNullOrEmpty(degree) ? "" : degree + "/") + (string.IsNullOrEmpty(desc) ? "" : desc); if (line.EndsWith("/")) { line = line.Substring(0, line.Length - 1); } text += line; } publicServiceRow.Add(semester, text); } XmlElement schoolSpecial = (XmlElement)record.TextScore.SelectSingleNode("SchoolSpecial"); if (schoolSpecial != null) { string GroupName = ""; if (Utility.MorItemDict.ContainsKey("SchoolSpecial")) { GroupName = Utility.MorItemDict["SchoolSpecial"]; } if (schoolSpecialRow == null) { schoolSpecialRow = new MoralItemRow(new string[] { GroupName }); } string text = string.Empty; foreach (XmlElement item in schoolSpecial.SelectNodes("Item")) { string degree = item.GetAttribute("Degree"); string desc = item.GetAttribute("Description"); string name = item.GetAttribute("Name"); if (string.IsNullOrEmpty(degree) && string.IsNullOrEmpty(desc)) { continue; } string line = name + ":" + (string.IsNullOrEmpty(degree) ? "" : degree + "/") + (string.IsNullOrEmpty(desc) ? "" : desc); if (line.EndsWith("/")) { line = line.Substring(0, line.Length - 1); } text += line; } schoolSpecialRow.Add(semester, text); } } #endregion #region 定位,產生Row _builder.MoveToMergeField("日常行為表現"); Cell currentCell = _builder.CurrentParagraph.ParentNode as Cell; Row currentRow = currentCell.ParentRow; Table table = currentRow.ParentTable; int rowCount = items.Count; int insertIndex = table.Rows.IndexOf(currentRow) + 1; for (int i = 1; i < rowCount; i++) { table.Rows.Insert(insertIndex, currentRow.Clone(true)); } #endregion #region 寫入日常行為表現 Cell cell = currentCell; foreach (string key in items.Keys) { WordHelper.Write(cell, key, _builder); Cell indexCell = WordHelper.GetMoveRightCell(cell, 1); WriteMoralItemRow(indexCell, items[key]); cell = WordHelper.GetMoveDownCell(cell, 1); } #endregion #region 寫入團體活動表現 _builder.MoveToMergeField("團體活動"); if (groupActivityRow != null && groupActivityRow.Items.Count > 0) { currentCell = _builder.CurrentParagraph.ParentNode as Cell; WriteMoralItemRow(currentCell, groupActivityRow); if (currentCell.Paragraphs.Count > 0) { currentCell.Paragraphs[0].ParagraphFormat.Alignment = ParagraphAlignment.Center; } } else { (_builder.CurrentParagraph.ParentNode as Cell).ParentRow.Remove(); } #endregion #region 寫入公共服務表現 _builder.MoveToMergeField("公共服務"); if (publicServiceRow != null && publicServiceRow.Items.Count > 0) { currentCell = _builder.CurrentParagraph.ParentNode as Cell; WriteMoralItemRow(currentCell, publicServiceRow); if (currentCell.Paragraphs.Count > 0) { currentCell.Paragraphs[0].ParagraphFormat.Alignment = ParagraphAlignment.Center; } } else { (_builder.CurrentParagraph.ParentNode as Cell).ParentRow.Remove(); } #endregion #region 寫入校內外特殊表現 _builder.MoveToMergeField("校內外特殊"); if (schoolSpecialRow != null && schoolSpecialRow.Items.Count > 0) { currentCell = _builder.CurrentParagraph.ParentNode as Cell; WriteMoralItemRow(currentCell, schoolSpecialRow); if (currentCell.Paragraphs.Count > 0) { currentCell.Paragraphs[0].ParagraphFormat.Alignment = ParagraphAlignment.Center; } } else { (_builder.CurrentParagraph.ParentNode as Cell).ParentRow.Remove(); } #endregion #region 寫入具體建議 _builder.MoveToMergeField("具體建議"); if (recommendRow != null && recommendRow.Items.Count > 0) { currentCell = _builder.CurrentParagraph.ParentNode as Cell; WriteMoralItemRow(currentCell, recommendRow); if (currentCell.Paragraphs.Count > 0) { currentCell.Paragraphs[0].ParagraphFormat.Alignment = ParagraphAlignment.Center; } } else { (_builder.CurrentParagraph.ParentNode as Cell).ParentRow.Remove(); } #endregion }
private void ProcessMoralScore(List <AutoSummaryRecord> autoSummaryList) { Dictionary <string, MoralItemRow> items = new Dictionary <string, MoralItemRow>(); string recommendName = string.Empty, OtherRecommendName = string.Empty; // 綜合評語使用 MoralItemRow recommendRow = new MoralItemRow(new string[] { }); // 其他評語使用 MoralItemRow OtherrecommendRow = new MoralItemRow(new string[] { }); foreach (AutoSummaryRecord asRecord in autoSummaryList) { if (asRecord.MoralScore == null) { continue; } JHMoralScoreRecord record = asRecord.MoralScore; SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); XmlElement dailyBehavior = (XmlElement)record.TextScore.SelectSingleNode("DailyBehavior"); if (dailyBehavior != null) { foreach (XmlElement item in dailyBehavior.SelectNodes("Item")) { string name = item.GetAttribute("Name"); string index = item.GetAttribute("Index"); string degree = item.GetAttribute("Degree"); string[] lines = index.Split(new string[] { ";", ";" }, StringSplitOptions.RemoveEmptyEntries); if (!items.ContainsKey(name)) { items.Add(name, new MoralItemRow(lines)); } items[name].Add(semester, degree); } } // 綜和評語 XmlElement dailyLifeRecommend = (XmlElement)record.TextScore.SelectSingleNode("DailyLifeRecommend"); // 使用系統設定 recommendName = GetDLString("綜合評語"); if (dailyLifeRecommend != null) { if (string.IsNullOrEmpty(recommendName)) { recommendName = dailyLifeRecommend.GetAttribute("Name"); } recommendRow.Add(semester, dailyLifeRecommend.GetAttribute("Description")); } // 其他 XmlElement OtherRecommend = (XmlElement)record.TextScore.SelectSingleNode("OtherRecommend"); // 使用系統設定 OtherRecommendName = GetDLString("其它表現"); if (OtherRecommend != null) { if (string.IsNullOrEmpty(OtherRecommendName)) { OtherRecommendName = OtherRecommend.GetAttribute("Name"); } OtherrecommendRow.Add(semester, OtherRecommend.GetAttribute("Description")); } } Cell cell = _current; int totalCount = 0; foreach (string key in items.Keys) { Write(cell, key); int lineCount = items[key].LineCount; if (lineCount > 0) { MergeVerticalCell(cell, lineCount); Cell otherCell = GetMoveRightCell(cell, 1); MergeVerticalCell(otherCell, lineCount); for (int i = 0; i < 6; i++) { otherCell = GetMoveRightCell(otherCell, 1); if (otherCell == null) { break; } MergeVerticalCell(otherCell, lineCount); } } else { lineCount = 1; } totalCount += lineCount; Cell indexCell = GetMoveRightCell(cell, 1); WriteMoralItemRow(indexCell, items[key]); cell = GetMoveDownCell(cell, lineCount); } cell.CellFormat.HorizontalMerge = CellMerge.First; GetMoveRightCell(cell, 1).CellFormat.HorizontalMerge = CellMerge.Previous; // 綜合評語 Write(cell, recommendName); if (cell != null) { Row row = cell.ParentRow; int shift = row.IndexOf(cell) + 2; foreach (SemesterData sems in recommendRow.Items.Keys) { string text = recommendRow.Items[sems]; int index = -1; if (_map.SemesterMapping.ContainsKey(sems)) { index = _map.SemesterMapping[sems]; } if (index < 0) { continue; } index = index + shift; Write(row.Cells[index], text); } } // 往下走一格 cell = GetMoveDownCell(cell, 1); int current_row_index = _current.ParentRow.ParentTable.IndexOf(_current.ParentRow); current_row_index += totalCount; int count = TotalRow + FirstRowIndex - current_row_index; Cell tempCell = cell; //MergeVerticalCell(tempCell, count); //tempCell = GetMoveRightCell(tempCell, 1); //MergeVerticalCell(tempCell, count); //for (int i = 0; i < 6; i++) //{ // tempCell = GetMoveRightCell(tempCell, 1); // MergeVerticalCell(tempCell, count); //} tempCell = cell; for (int i = 0; i < count; i++) { tempCell.CellFormat.HorizontalMerge = CellMerge.First; GetMoveRightCell(tempCell, 1).CellFormat.HorizontalMerge = CellMerge.Previous; tempCell = GetMoveDownCell(tempCell, 1); if (tempCell == null) { break; } } // 其他 Write(cell, OtherRecommendName); if (cell != null) { Row row = cell.ParentRow; int shift = row.IndexOf(cell) + 2; foreach (SemesterData sems in OtherrecommendRow.Items.Keys) { string text = OtherrecommendRow.Items[sems]; int index = -1; if (_map.SemesterMapping.ContainsKey(sems)) { index = _map.SemesterMapping[sems]; } if (index < 0) { continue; } index = index + shift; Write(row.Cells[index], text); } } //int current_row_index = _current.ParentRow.ParentTable.IndexOf(_current.ParentRow); //current_row_index += totalCount; //int count = TotalRow + FirstRowIndex - current_row_index; //Cell tempCell = cell; //MergeVerticalCell(tempCell, count); //tempCell = GetMoveRightCell(tempCell, 1); //MergeVerticalCell(tempCell, count); //for (int i = 0; i < 6; i++) //{ // tempCell = GetMoveRightCell(tempCell, 1); // MergeVerticalCell(tempCell, count); //} //tempCell = cell; //for (int i = 0; i < count; i++) //{ // tempCell.CellFormat.HorizontalMerge = CellMerge.First; // GetMoveRightCell(tempCell, 1).CellFormat.HorizontalMerge = CellMerge.Previous; // tempCell = GetMoveDownCell(tempCell, 1); // if (tempCell == null) break; //} _current = cell; }
/// <summary> /// 填寫DataTable的資料 /// </summary> /// <param name="dt"></param> private static void FillData(DataTable dt) { string printDateTime = SelectTime(); string schoolName = K12.Data.School.ChineseName; string 校長 = K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName").InnerText; string 教務主任 = K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("EduDirectorName").InnerText; //假別設定 Dictionary <string, List <string> > allowAbsentDic = new Dictionary <string, List <string> >(); foreach (AbsentSetting abs in _A.Select <AbsentSetting>()) { string target = abs.Target; string source = abs.Source; if (!allowAbsentDic.ContainsKey(target)) { allowAbsentDic.Add(target, new List <string>()); } allowAbsentDic[target].Add(source); } List <string> classIDs = _students.Select(x => x.RefClassID).Distinct().ToList(); List <string> studentIDs = _students.Select(x => x.ID).ToList(); //學生ID字串 string id_str = string.Join("','", studentIDs); id_str = "'" + id_str + "'"; //班級 catch Dictionary <string, ClassRecord> classDic = new Dictionary <string, ClassRecord>(); foreach (ClassRecord cr in K12.Data.Class.SelectByIDs(classIDs)) { if (!classDic.ContainsKey(cr.ID)) { classDic.Add(cr.ID, cr); } } //基本資料 foreach (StudentRecord student in _students) { DataRow row = dt.NewRow(); ClassRecord myClass = classDic.ContainsKey(student.RefClassID) ? classDic[student.RefClassID] : new ClassRecord(); TeacherRecord myTeacher = myClass.Teacher != null ? myClass.Teacher : new TeacherRecord(); row["列印日期"] = printDateTime; row["學校名稱"] = schoolName; row["學年度"] = _schoolYear; row["學期"] = _semester; row["姓名"] = student.Name; row["班級"] = myClass.Name + ""; row["班導師"] = myTeacher.Name + ""; row["座號"] = student.SeatNo + ""; row["學號"] = student.StudentNumber; row["校長"] = 校長; row["教務主任"] = 教務主任; //filedName是 "列印假別1~20" foreach (string filedName in allowAbsentDic.Keys) { row[filedName] = 0; } dt.Rows.Add(row); _RowCatchs.Add(student.ID, row); } //上課天數 foreach (SemesterHistoryRecord shr in K12.Data.SemesterHistory.SelectByStudents(_students)) { DataRow row = _RowCatchs[shr.RefStudentID]; foreach (SemesterHistoryItem shi in shr.SemesterHistoryItems) { if (shi.SchoolYear == _schoolYear && shi.Semester == _semester) { row["上課天數"] = shi.SchoolDayCount + ""; } } } //學期科目及領域成績 foreach (JHSemesterScoreRecord jsr in JHSchool.Data.JHSemesterScore.SelectBySchoolYearAndSemester(studentIDs, _schoolYear, _semester)) { DataRow row = _RowCatchs[jsr.RefStudentID]; _文字描述.Clear(); //學習領域成績 if (_UserSelScoreType == "原始成績") { row["學習領域成績"] = jsr.LearnDomainScoreOrigin.HasValue ? jsr.LearnDomainScoreOrigin.Value + "" : string.Empty; row["課程學習成績"] = jsr.CourseLearnScoreOrigin.HasValue ? jsr.CourseLearnScoreOrigin.Value + "" : string.Empty; } else { row["學習領域成績"] = jsr.LearnDomainScore.HasValue ? jsr.LearnDomainScore.Value + "" : string.Empty; row["課程學習成績"] = jsr.CourseLearnScore.HasValue ? jsr.CourseLearnScore.Value + "" : string.Empty; } row["學習領域原始成績"] = jsr.LearnDomainScoreOrigin.HasValue ? jsr.LearnDomainScoreOrigin.Value + "" : string.Empty; row["課程學習原始成績"] = jsr.CourseLearnScoreOrigin.HasValue ? jsr.CourseLearnScoreOrigin.Value + "" : string.Empty; // 收集領域科目成績給領域科目對照時使用 Dictionary <string, DomainScore> DomainScoreDict = new Dictionary <string, DomainScore>(); Dictionary <string, List <SubjectScore> > DomainSubjScoreDict = new Dictionary <string, List <SubjectScore> >(); #region 科目成績照領域排序 var jsSubjects = new List <SubjectScore>(jsr.Subjects.Values); var domainList = new Dictionary <string, int>(); domainList.Add("語文", 9000); domainList.Add("國語文", 8000); domainList.Add("英語", 7000); domainList.Add("數學", 6000); domainList.Add("社會", 5000); domainList.Add("自然科學", 4500); domainList.Add("自然與生活科技", 4000); domainList.Add("藝術", 3500); domainList.Add("藝術與人文", 3000); domainList.Add("健康與體育", 2000); domainList.Add("綜合活動", 1000); domainList.Add("彈性課程", 0900); jsSubjects.Sort(delegate(SubjectScore r1, SubjectScore r2) { decimal rank1 = 0; decimal rank2 = 0; if (r1.Credit != null) { rank1 += r1.Credit.Value; } if (r2.Credit != null) { rank2 += r2.Credit.Value; } if (domainList.ContainsKey(r1.Domain)) { rank1 += domainList[r1.Domain]; } if (domainList.ContainsKey(r2.Domain)) { rank2 += domainList[r2.Domain]; } if (rank1 == rank2) { return(r2.Subject.CompareTo(r1.Subject)); } else { return(rank2.CompareTo(rank1)); } }); #endregion //科目成績 int count = 0; foreach (SubjectScore subj in jsSubjects) { string ssNmae = subj.Domain; if (string.IsNullOrEmpty(ssNmae)) { ssNmae = "彈性課程"; } if (!DomainSubjScoreDict.ContainsKey(ssNmae)) { DomainSubjScoreDict.Add(ssNmae, new List <SubjectScore>()); } DomainSubjScoreDict[ssNmae].Add(subj); count++; //超過就讓它爆炸 if (count > Global.SupportSubjectCount) { throw new Exception("超過支援列印科目數量: " + Global.SupportSubjectCount); } row["S科目" + count] = subj.Subject; row["S領域" + count] = string.IsNullOrWhiteSpace(subj.Domain) ? "彈性課程" : subj.Domain; row["S節數" + count] = subj.Period + ""; row["S權數" + count] = subj.Credit + ""; row["S成績" + count] = GetScoreString(subj.Score, subj.ScoreOrigin, subj.ScoreMakeup); row["S等第" + count] = GetScoreDegreeString(subj.Score, subj.ScoreOrigin);//subj.Score.HasValue ? _degreeMapper.GetDegreeByScore(subj.Score.Value) : string.Empty; row["S原始成績" + count] = subj.ScoreOrigin.HasValue ? subj.ScoreOrigin.Value + "" : string.Empty; row["S補考成績" + count] = subj.ScoreMakeup.HasValue ? subj.ScoreMakeup.Value + "" : string.Empty; } // 處理領域科目並列 foreach (string dName in Global.PriDomainNameList()) { if (DomainSubjScoreDict.ContainsKey(dName)) { int si = 1; foreach (SubjectScore ss in DomainSubjScoreDict[dName]) { row[dName + "科目" + si] = ss.Subject; row[dName + "領域" + si] = ss.Domain; row[dName + "節數" + si] = ss.Period + ""; row[dName + "權數" + si] = ss.Credit + ""; row[dName + "等第" + si] = GetScoreDegreeString(ss.Score, ss.ScoreOrigin);//ss.Score.HasValue ? _degreeMapper.GetDegreeByScore(ss.Score.Value) : string.Empty; row[dName + "成績" + si] = GetScoreString(ss.Score, ss.ScoreOrigin, ss.ScoreMakeup); row[dName + "原始成績" + si] = ss.ScoreOrigin.HasValue ? ss.ScoreOrigin.Value + "" : string.Empty; row[dName + "補考成績" + si] = ss.ScoreMakeup.HasValue ? ss.ScoreMakeup.Value + "" : string.Empty; si++; } } } count = 0; foreach (DomainScore domain in jsr.Domains.Values) { if (!DomainScoreDict.ContainsKey(domain.Domain)) { DomainScoreDict.Add(domain.Domain, domain); } count++; //超過就讓它爆炸 if (count > Global.SupportDomainCount) { throw new Exception("超過支援列印領域數量: " + Global.SupportDomainCount); } row["D領域" + count] = domain.Domain; row["D節數" + count] = domain.Period + ""; row["D權數" + count] = domain.Credit + ""; //row["D成績" + count] = domain.Score.HasValue ? domain.Score.Value + "" : string.Empty; row["D成績" + count] = GetScoreString(domain.Score, domain.ScoreOrigin, domain.ScoreMakeup); row["D等第" + count] = GetScoreDegreeString(domain.Score, domain.ScoreOrigin);//domain.Score.HasValue ? _degreeMapper.GetDegreeByScore(domain.Score.Value) : string.Empty; row["D原始成績" + count] = domain.ScoreOrigin.HasValue ? domain.ScoreOrigin.Value + "" : string.Empty; row["D補考成績" + count] = domain.ScoreMakeup.HasValue ? domain.ScoreMakeup.Value + "" : string.Empty; if (!string.IsNullOrWhiteSpace(domain.Text)) { _文字描述.Add(domain.Domain + " : " + domain.Text); } } // 處理指定領域 foreach (string dName in Global.PriDomainNameList()) { if (DomainScoreDict.ContainsKey(dName)) { DomainScore domain = DomainScoreDict[dName]; row[dName + "領域"] = domain.Domain; row[dName + "節數"] = domain.Period + ""; row[dName + "權數"] = domain.Credit + ""; row[dName + "成績"] = GetScoreString(domain.Score, domain.ScoreOrigin, domain.ScoreMakeup); row[dName + "等第"] = GetScoreDegreeString(domain.Score, domain.ScoreOrigin);//domain.Score.HasValue ? _degreeMapper.GetDegreeByScore(domain.Score.Value) : string.Empty; row[dName + "原始成績"] = domain.ScoreOrigin.HasValue ? domain.ScoreOrigin.Value + "" : string.Empty; row[dName + "補考成績"] = domain.ScoreMakeup.HasValue ? domain.ScoreMakeup.Value + "" : string.Empty; } } row["文字描述"] = string.Join(Environment.NewLine, _文字描述); } //預設學年度學期物件 JHSchool.Behavior.BusinessLogic.SchoolYearSemester sysm = new JHSchool.Behavior.BusinessLogic.SchoolYearSemester(_schoolYear, _semester); //AutoSummary foreach (AutoSummaryRecord asr in AutoSummary.Select(_students.Select(x => x.ID), new JHSchool.Behavior.BusinessLogic.SchoolYearSemester[] { sysm })) { DataRow row = _RowCatchs[asr.RefStudentID]; //缺曠 foreach (AbsenceCountRecord acr in asr.AbsenceCounts) { string key = Global.GetKey(acr.PeriodType, acr.Name); //filedName是 "列印假別1~20" foreach (string filedName in allowAbsentDic.Keys) { foreach (string item in allowAbsentDic[filedName]) { if (key == item) { int count = 0; int.TryParse(row[filedName] + "", out count); count += acr.Count; row[filedName] = count; } } } } //獎懲 row["大功"] = asr.MeritA; row["小功"] = asr.MeritB; row["嘉獎"] = asr.MeritC; row["大過"] = asr.DemeritA; row["小過"] = asr.DemeritB; row["警告"] = asr.DemeritC; //日常生活表現 JHMoralScoreRecord msr = asr.MoralScore; XmlElement textScore = (msr != null && msr.TextScore != null) ? msr.TextScore : K12.Data.XmlHelper.LoadXml("<TextScore/>"); foreach (string key in Global.DLBehaviorRef.Keys) { SetDLBehaviorData(key, Global.DLBehaviorRef[key], textScore, row); } } //社團成績 string condition = string.Format("SchoolYear='{0}' and Semester='{1}' and studentid in ({2})", _schoolYear, _semester, id_str); List <AssnCode> list = _A.Select <AssnCode>(condition); foreach (string id in studentIDs) { int count = 0; DataRow row = _RowCatchs[id]; foreach (AssnCode ac in list.FindAll(x => x.StudentID == id)) { XmlElement scores = K12.Data.XmlHelper.LoadXml(ac.Scores); foreach (XmlElement item in scores.SelectNodes("Item")) { count++; //超過就讓它爆炸 if (count > Global.SupportClubCount) { throw new Exception("超過支援列印社團數量: " + Global.SupportClubCount); } string name = item.GetAttribute("AssociationName"); string score = item.GetAttribute("Score"); string effort = item.GetAttribute("Effort"); string text = item.GetAttribute("Text"); row["社團Name" + count] = name; row["社團Score" + count] = score; row["社團Effort" + count] = effort; row["社團Text" + count] = text; } } } //服務學習時數 string query = string.Format("select ref_student_id,occur_date,reason,hours from $k12.service.learning.record where school_year={0} and semester={1} and ref_student_id in ({2})", _schoolYear, _semester, id_str); DataTable table = _Q.Select(query); foreach (DataRow dr in table.Rows) { string sid = dr["ref_student_id"] + ""; DataRow row = _RowCatchs[sid]; decimal new_hr = 0; decimal.TryParse(dr["hours"] + "", out new_hr); decimal old_hr = 0; decimal.TryParse(row["服務學習時數"] + "", out old_hr); decimal hr = old_hr + new_hr; row["服務學習時數"] = hr; } // 取得體適能資料 Dictionary <string, List <StudentFitnessRecord_C> > StudentFitnessRecord_CDict = new Dictionary <string, List <StudentFitnessRecord_C> >(); string qry = "ref_student_id in('" + string.Join("','", studentIDs.ToArray()) + "') and school_year=" + _schoolYear; AccessHelper accHelper = new AccessHelper(); List <StudentFitnessRecord_C> StudentFitnessRecord_CList = accHelper.Select <StudentFitnessRecord_C>(qry); // 依測驗日期排序 StudentFitnessRecord_CList = (from data in StudentFitnessRecord_CList orderby data.TestDate ascending select data).ToList(); foreach (StudentFitnessRecord_C rec in StudentFitnessRecord_CList) { if (!StudentFitnessRecord_CDict.ContainsKey(rec.StudentID)) { StudentFitnessRecord_CDict.Add(rec.StudentID, new List <StudentFitnessRecord_C>()); } StudentFitnessRecord_CDict[rec.StudentID].Add(rec); } foreach (string sid in StudentFitnessRecord_CDict.Keys) { if (_RowCatchs.ContainsKey(sid)) { DataRow row = _RowCatchs[sid]; int cot = 1; foreach (StudentFitnessRecord_C rec in StudentFitnessRecord_CDict[sid]) { row["身高" + cot] = rec.Height; row["體重" + cot] = rec.Weight; row["坐姿體前彎" + cot] = rec.SitAndReach; row["坐姿體前彎常模" + cot] = rec.SitAndReachDegree; row["立定跳遠" + cot] = rec.StandingLongJump; row["立定跳遠常模" + cot] = rec.StandingLongJumpDegree; row["仰臥起坐" + cot] = rec.SitUp; row["仰臥起坐常模" + cot] = rec.SitUpDegree; row["心肺適能" + cot] = rec.Cardiorespiratory; row["心肺適能常模" + cot] = rec.CardiorespiratoryDegree; cot++; } } } }