private void WriteMoralItemRow(Cell cell, MoralItemRow itemRow) { WriteLines(cell, itemRow.Lines); Row row = cell.ParentRow; int shift = row.IndexOf(cell) + 1; foreach (SemesterData sems in itemRow.Items.Keys) { string text = itemRow.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); } }
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; }