private void RebuildSemesterMap() { Dictionary <int, SemesterData> indexes = new Dictionary <int, SemesterData>(); foreach (SemesterData sems in _semsMapping.Keys) { if (!indexes.ContainsKey(_semsMapping[sems])) { indexes.Add(_semsMapping[sems], sems); } else { SemesterData orig = indexes[_semsMapping[sems]]; if (int.Parse(sems.SchoolYear) > int.Parse(orig.SchoolYear)) { indexes[_semsMapping[sems]] = sems; } } } _semsMapping.Clear(); _schoolYearMapping.Clear(); foreach (int index in indexes.Keys) { SemesterData sems = indexes[index]; _semsMapping.Add(sems, index); _schoolYearMapping.Add(index, sems.SchoolYear); } }
public bool Add(SemesterData semester, K12.Data.SubjectScore subject) { if (!_scores.ContainsKey(semester)) { _scores.Add(semester, new ScoreData("" + subject.Period, "" + subject.Credit, "" + subject.Score)); return(true); } return(false); }
public bool Add(SemesterData semester, K12.Data.DomainScore domain) { if (!_scores.ContainsKey(semester)) { _scores.Add(semester, new ScoreData("" + domain.Period, "" + domain.Credit, "" + domain.Score)); return(true); } return(false); }
public bool Add(SemesterData semester, int count) { if (!_items.ContainsKey(semester)) { _items.Add(semester, 0); } _items[semester] += count; return(true); }
public bool Add(SemesterData semester, string text) { if (!_items.ContainsKey(semester)) { _items.Add(semester, text); return(true); } else { return(false); } }
public bool Add(SemesterData semester, K12.Data.SubjectScore subject) { if (!_subjectScores.ContainsKey(subject.Subject)) { _subjectScores.Add(subject.Subject, new Dictionary <SemesterData, ScoreData>()); } if (!_subjectScores[subject.Subject].ContainsKey(semester)) { _subjectScores[subject.Subject].Add(semester, new ScoreData("" + subject.Period, "" + subject.Credit, "" + subject.Score)); return(true); } return(false); }
public override bool Equals(object obj) { if (obj is SemesterData) { SemesterData other = obj as SemesterData; if (this.SchoolYear == other.SchoolYear && this.Semester == other.Semester) { return(true); } return(false); } return(false); }
private void Add(K12.Data.SemesterHistoryItem item) { SemesterData semester = new SemesterData("" + item.SchoolYear, "" + item.Semester); if (!_semsMapping.ContainsKey(semester)) { int gradeYear = item.GradeYear; if (gradeYear > 6) { gradeYear -= 6; } int index = (gradeYear - 1) * 2 + item.Semester; _semsMapping.Add(semester, index - 1); } }
internal void Add(SemesterData semester, string text) { if (!_texts.ContainsKey(semester)) { _texts.Add(semester, string.Empty); } if (!string.IsNullOrEmpty(text)) { text = text.Replace('>', ':').Replace('<', ','); if (text.StartsWith(",")) { text = text.Substring(1); } _texts[semester] = text; } }
private void ProcessDemerit(List <AutoSummaryRecord> autoSummaryList) { string postfix = "次數"; Dictionary <string, ValueItemRow> items = new Dictionary <string, ValueItemRow>(); foreach (string name in new string[] { "警告", "小過", "大過" }) { items.Add(name + postfix, new ValueItemRow(name + postfix)); } foreach (var record in autoSummaryList) { SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); items["大過" + postfix].Add(semester, record.DemeritA); items["小過" + postfix].Add(semester, record.DemeritB); items["警告" + postfix].Add(semester, record.DemeritC); } Cell cell = _current; MergeVerticalCell(cell, 3); Write(cell, "懲戒"); Cell itemCell = GetMoveRightCell(cell, 1); foreach (string type in items.Keys) { WriteValueItemRow(itemCell, items[type]); itemCell = GetMoveDownCell(itemCell, 1); if (itemCell == null) { break; } } Cell tempCell = GetMoveDownCell(cell, 3); if (tempCell != null) { cell = tempCell; } _current = cell; }
public void Add(JHSemesterScoreRecord record) { SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); foreach (K12.Data.DomainScore domain in record.Domains.Values) { if (!_domains.ContainsKey(domain.Domain)) { _domains.Add(domain.Domain, new DomainText(domain.Domain)); } DomainText text = _domains[domain.Domain]; text.Add(semester, domain.Text); } // 加入彈性課程文字評量 string strDomainName = "彈性課程"; // 存彈性課程用 List <string> strTextList = new List <string> (); foreach (K12.Data.SubjectScore subj in record.Subjects.Values) { // 科目是彈性課程 if (string.IsNullOrEmpty(subj.Domain)) { strTextList.Add(subj.Text); } } if (!_domains.ContainsKey(strDomainName)) { _domains.Add(strDomainName, new DomainText(strDomainName)); } DomainText text1 = _domains[strDomainName]; text1.Add(semester, string.Join(";", strTextList.ToArray())); }
private void ProcessAttendance(List <AutoSummaryRecord> autoSummaryList) { string postfix = "節數"; Dictionary <string, Dictionary <string, ValueItemRow> > items = new Dictionary <string, Dictionary <string, ValueItemRow> >(); foreach (string type in _types.Keys) { if (!items.ContainsKey(type)) { items.Add(type, new Dictionary <string, ValueItemRow>()); } foreach (string name in _types[type]) { if (!items[type].ContainsKey(name + postfix)) { items[type].Add(name + postfix, new ValueItemRow(name + postfix)); } } } foreach (AutoSummaryRecord record in autoSummaryList) { SemesterData semester = new SemesterData("" + record.SchoolYear, "" + record.Semester); foreach (AbsenceCountRecord absence in record.AbsenceCounts) { if (items.ContainsKey(absence.PeriodType) && items[absence.PeriodType].ContainsKey(absence.Name + postfix)) { items[absence.PeriodType][absence.Name + postfix].Add(semester, absence.Count); } } } Cell cell = _current; foreach (string type in items.Keys) { int count = items[type].Count; MergeVerticalCell(cell, count); Write(cell, type); Cell itemCell = GetMoveRightCell(cell, 1); foreach (ValueItemRow row in items[type].Values) { WriteValueItemRow(itemCell, row); itemCell = GetMoveDownCell(itemCell, 1); if (itemCell == null) { break; } } Cell tempCell = GetMoveDownCell(cell, count); if (tempCell == null) { break; } cell = tempCell; } _current = cell; }
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; }