public SemesterDomainScore(DomainScore score) { RawScore = score; Effort = score.Effort; Text = score.Text; Period = score.Period; Value = score.Score; Weight = score.Credit; }
private static DomainScore GetJHDomainScore(string strDomain, SemesterDomainScore scDomain) { DomainScore domain = scDomain.RawScore; if (domain == null) { domain = new DomainScore(); domain.Domain = strDomain; } return(domain); }
public static void FillDomainScore(this List <StudentExcess> students) { //資料表:ischool_student_fitness if (students == null || students.Count <= 0) { return; } string sql = @"select ref_student_id,school_year,semester,score_info from sems_subj_score where ref_student_id in({0}) order by school_year, semester"; sql = string.Format(sql, students.ToPrimaryKeyStringList()); DataTable table = Utility.Q.Select(sql); // Dictionary<string, StudentExcess> StudentLookup = students.ToDictionary(x => x.StudentID); Dictionary <string, StudentExcess> StudentLookup = new Dictionary <string, StudentExcess>(); foreach (StudentExcess data in students) { if (!StudentLookup.ContainsKey(data.StudentID)) { StudentLookup.Add(data.StudentID, data); } } foreach (DataRow row in table.Rows) { string id = row["ref_student_id"] + ""; int school_year = int.Parse(row["school_year"] + ""); int semester = int.Parse(row["semester"] + ""); string score_info = row["score_info"] + ""; if (!StudentLookup.ContainsKey(id)) { continue; } StudentExcess stu = StudentLookup[id]; SemesterData sd = new SemesterData(0, school_year, semester); DomainScore ds = ParseDomainScore(score_info); stu.DomainScore[sd] = ds; } }
private static Dictionary <string, DomainScore> ToDomains(SemesterDomainScoreCollection semesterDomainScoreCollection) { Dictionary <string, DomainScore> dictDomainScore = new Dictionary <string, DomainScore>(); foreach (string key in semesterDomainScoreCollection) { SemesterDomainScore score = semesterDomainScoreCollection[key]; DomainScore domainScore = new DomainScore(); domainScore.Domain = key; domainScore.Period = score.Period; domainScore.Credit = score.Weight; domainScore.Score = score.Value; dictDomainScore.Add(domainScore.Domain, domainScore); } return(dictDomainScore); }
private static DomainScore ParseDomainScore(string rawData) { DomainScore objDS = new DomainScore(); string xmlString = string.Format("<root>{0}</root>", rawData); XElement xmlDom = XElement.Parse(xmlString); foreach (XElement ds in xmlDom.XPathSelectElements("Domains/Domain")) { if (string.IsNullOrWhiteSpace(ds.Attribute("成績").Value)) { continue; } string name = ds.Attribute("領域").Value; decimal score = decimal.Parse(ds.Attribute("成績").Value); objDS[name] = score; } //解析領域成績。 return(objDS); }
/// <summary> /// 取得各領域成績 /// </summary> /// <param name="sem"></param> /// <returns></returns> public List <decimal?> GetScoreList(SemesterData sem) { if (_scores.ContainsKey(sem)) { List <decimal?> scoreList = new List <decimal?>(); foreach (string domain in Global.GetDomains()) { decimal?score = null; if (_scores[sem].Domains.ContainsKey(domain)) { DomainScore domainScore = _scores[sem].Domains[domain]; score = domainScore.Score; } scoreList.Add(score); } return(scoreList); } else { return(new List <decimal?>()); } }
public void Writer(Document doc) { DocumentBuilder builder = new DocumentBuilder(doc); _warned = false; _domainText.Clear(); if (SemesterScoreRecord == null) { builder.MoveToMergeField("成績_start"); builder.MoveToMergeField("成績_end"); builder.MoveToMergeField("文字描述"); return; } builder.MoveToMergeField("成績_start"); Cell startCell = builder.CurrentParagraph.ParentNode as Cell; builder.MoveToMergeField("成績_end"); Cell endCell = builder.CurrentParagraph.ParentNode as Cell; Table table = startCell.ParentRow.ParentTable; int rowCount = table.IndexOf(endCell.ParentRow) - table.IndexOf(startCell.ParentRow) + 1; Font font = builder.Font; #region 填入學習領域總成績 if (_printLearnDomain) { rowCount--; WordHelper.MergeHorizontalCell(endCell, 2); Cell scoreCell = endCell.NextSibling.NextSibling as Cell; WordHelper.MergeHorizontalCell(scoreCell, 2); WordHelper.Write(endCell, font, "學習領域總成績"); WordHelper.Write(scoreCell, font, SemesterScoreRecord.LearnDomainScore.HasValue ? _degreeMapper.GetDegreeByScore(SemesterScoreRecord.LearnDomainScore.Value) : ""); } #endregion #region 整理成 Domain -> List<Subject> Dictionary <string, List <SubjectScore> > domainSubjects = new Dictionary <string, List <SubjectScore> >(); foreach (var subject in SemesterScoreRecord.Subjects.Values) { if (!domainSubjects.ContainsKey(subject.Domain)) { domainSubjects.Add(subject.Domain, new List <SubjectScore>()); } domainSubjects[subject.Domain].Add(subject); } string printsocre = _config.GetString("領域科目設定", "Domain"); if (printsocre == "Domain") { // 沒有科目成績只有領域成績時加入領域名稱(轉學生用到) foreach (DomainScore domin in SemesterScoreRecord.Domains.Values) { if (!domainSubjects.ContainsKey(domin.Domain)) { domainSubjects.Add(domin.Domain, new List <SubjectScore>()); } // 處理新竹語文呈現 if (domin.Domain == "語文") { int co = 0; foreach (SubjectScore ss in SemesterScoreRecord.Subjects.Values) { if (ss.Domain == "語文") { co++; } } if (co == 0) { if (!_domainsWithoutDetail.Contains(domin.Domain)) { _domainsWithoutDetail.Add(domin.Domain); } } } } } foreach (List <SubjectScore> subjectScoreList in domainSubjects.Values) { subjectScoreList.Sort(delegate(SubjectScore x, SubjectScore y) { return(JHSchool.Evaluation.Subject.CompareSubjectOrdinal(x.Subject, y.Subject)); }); } #endregion #region 檢查成績項目是否超出可列印行數 int count = 0; foreach (string domain in Global.GetDomainList()) { if (_domainsWithoutDetail.Contains(domain)) { count++; } else if (domainSubjects.ContainsKey(domain)) { count += domainSubjects[domain].Count; } } if (count > rowCount && _warned == false) { MsgBox.Show("成績項目超出可列印行數,部分成績將不會列在報表上。"); _warned = true; } #endregion #region 填學期成績 Cell currentCell = startCell; List <string> list = new List <string>(domainSubjects.Keys); // 當只有領域成績 if (list.Count == 0) { foreach (var domain in SemesterScoreRecord.Domains.Values) { list.Add(domain.Domain); } } list.Sort(JHSchool.Evaluation.Subject.CompareDomainOrdinal); foreach (string domain in list) { if (_domainsWithoutDetail.Contains(domain)) { #region 只列印領域成績 if (!SemesterScoreRecord.Domains.ContainsKey(domain)) { continue; } rowCount--; DomainScore domainScore = SemesterScoreRecord.Domains[domain]; string group = JHSchool.Evaluation.Subject.GetDomainGroup(domain); if (Global.Params["Mode"] == "KaoHsiung" && !string.IsNullOrEmpty(group)) { currentCell.CellFormat.VerticalMerge = CellMerge.First; WordHelper.Write(currentCell, font, group); WordHelper.Write(currentCell.NextSibling as Cell, font, domain); } else { WordHelper.MergeHorizontalCell(currentCell, 2); WordHelper.Write(currentCell, font, domain); } Cell scoreCell = currentCell.NextSibling.NextSibling as Cell; WordHelper.Write(scoreCell, font, GetPeriodCredit(domainScore.Period, domainScore.Credit)); //scoreCell = scoreCell.NextSibling as Cell; //WordHelper.Write(scoreCell, font, "" + domainScore.Score); scoreCell = scoreCell.NextSibling as Cell; WordHelper.Write(scoreCell, font, (domainScore.Score.HasValue ? _degreeMapper.GetDegreeByScore(domainScore.Score.Value) : "")); if (!_domainText.ContainsKey(domain)) { _domainText.Add(domain, domainScore.Text); } if (rowCount <= 0) { break; } currentCell = WordHelper.GetMoveDownCell(currentCell, 1); #endregion } else { #region 詳列科目成績 if (!domainSubjects.ContainsKey(domain)) { continue; } Cell subjectCell = currentCell; int subjectCount = 0; foreach (SubjectScore subjectScore in domainSubjects[domain]) { rowCount--; subjectCount++; Cell temp = subjectCell.NextSibling as Cell; WordHelper.Write(temp, font, subjectScore.Subject); temp = temp.NextSibling as Cell; WordHelper.Write(temp, font, GetPeriodCredit(subjectScore.Period, subjectScore.Credit)); //temp = temp.NextSibling as Cell; //WordHelper.Write(temp, font, "" + subjectScore.Score); temp = temp.NextSibling as Cell; WordHelper.Write(temp, font, (subjectScore.Score.HasValue ? _degreeMapper.GetDegreeByScore(subjectScore.Score.Value) : "")); if (!_domainText.ContainsKey(subjectScore.Subject)) { _domainText.Add(subjectScore.Subject, subjectScore.Text); } if (rowCount <= 0) { break; } subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1); } if (subjectCount > 1) { WordHelper.MergeVerticalCell(currentCell, subjectCount); } WordHelper.Write(currentCell, font, string.IsNullOrEmpty(domain) ? "彈性課程" : domain); if (rowCount <= 0) { break; } currentCell = WordHelper.GetMoveDownCell(currentCell, subjectCount); #endregion } } currentCell = startCell; string lastGroup = string.Empty; while (currentCell != endCell) { string currentGroup = currentCell.ToTxt().Replace("\r\n", ""); if (currentGroup == lastGroup && !string.IsNullOrEmpty(lastGroup)) { currentCell.CellFormat.VerticalMerge = CellMerge.Previous; } lastGroup = currentGroup; currentCell = WordHelper.GetMoveDownCell(currentCell, 1); if (currentCell == null) { break; } } #endregion #region 填學習領域文字描述 builder.MoveToMergeField("文字描述"); Cell textCell = builder.CurrentParagraph.ParentNode as Cell; Paragraph para = (Paragraph)textCell.GetChild(NodeType.Paragraph, 0, true); font = para.ParagraphBreakFont; textCell.Paragraphs.Clear(); foreach (string header in _domainText.Keys) { if (string.IsNullOrEmpty(_domainText[header])) { continue; } textCell.Paragraphs.Add(new Paragraph(doc)); Run run1 = new Run(doc); run1.Font.Name = font.Name; run1.Font.Size = font.Size; run1.Font.Bold = true; run1.Text = header + ":"; Run run2 = new Run(doc); run2.Font.Name = font.Name; run2.Font.Size = font.Size; run2.Text = _domainText[header]; textCell.LastParagraph.Runs.Add(run1); textCell.LastParagraph.Runs.Add(run2); } #endregion }
public static void SaveSemesterScoreRecordEditor(IEnumerable <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> editors) { Dictionary <string, List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> > grouped = new Dictionary <string, List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> >(); foreach (var editor in editors) { if (!grouped.ContainsKey(editor.RefStudentID)) { grouped.Add(editor.RefStudentID, new List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor>()); } grouped[editor.RefStudentID].Add(editor); } SemesterScore.Instance.SyncData(grouped.Keys); DSXmlHelper insertHelper = new DSXmlHelper("InsertRequest"); DSXmlHelper updateHelper = new DSXmlHelper("UpdateRequest"); DSXmlHelper deleteHelper = new DSXmlHelper("DeleteRequest"); bool do_insert = false, do_update = false, do_delete = false; List <string> synclist = new List <string>(); foreach (var editor in editors) { if (editor.EditorStatus == JHSchool.Editor.EditorStatus.NoChanged) { continue; } if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert) { DSXmlHelper partialInsertHelper = new DSXmlHelper("SemesterSubjectScore"); partialInsertHelper.AddElement(".", "RefStudentId", editor.RefStudentID); partialInsertHelper.AddElement(".", "SchoolYear", "" + editor.SchoolYear); partialInsertHelper.AddElement(".", "Semester", "" + editor.Semester); partialInsertHelper.AddElement(".", "GradeYear", "" + editor.GradeYear); partialInsertHelper.AddElement(".", "ScoreInfo"); partialInsertHelper.AddElement("ScoreInfo", "SemesterSubjectScoreInfo"); foreach (var subjectKey in editor.Subjects.Keys) { SubjectScore subject = editor.Subjects[subjectKey]; XmlElement element = partialInsertHelper.AddElement("ScoreInfo/SemesterSubjectScoreInfo", "Subject"); element.SetAttribute("領域", subject.Domain); element.SetAttribute("科目", subjectKey); element.SetAttribute("節數", "" + subject.Period); element.SetAttribute("權數", "" + subject.Credit); element.SetAttribute("成績", "" + subject.Score); element.SetAttribute("努力程度", "" + subject.Effort); element.SetAttribute("文字描述", "" + subject.Text); element.SetAttribute("註記", "" + subject.Comment); } partialInsertHelper.AddElement("ScoreInfo", "Domains"); foreach (var domainKey in editor.Domains.Keys) { DomainScore domain = editor.Domains[domainKey]; XmlElement element = partialInsertHelper.AddElement("ScoreInfo/Domains", "Domain"); element.SetAttribute("領域", domainKey); element.SetAttribute("節數", "" + domain.Period); element.SetAttribute("權數", "" + domain.Credit); element.SetAttribute("成績", "" + domain.Score); element.SetAttribute("努力程度", "" + domain.Effort); element.SetAttribute("文字描述", "" + domain.Text); element.SetAttribute("註記", "" + domain.Comment); } partialInsertHelper.AddElement("ScoreInfo", "LearnDomainScore", "" + editor.LearnDomainScore); partialInsertHelper.AddElement("ScoreInfo", "CourseLearnScore", "" + editor.CourseLearnScore); insertHelper.AddElement(".", partialInsertHelper.BaseElement); do_insert = true; } else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update) { DSXmlHelper partialUpdateHelper = new DSXmlHelper("SemesterSubjectScore"); partialUpdateHelper.AddElement("Field"); partialUpdateHelper.AddElement("Field", "RefStudentId", editor.RefStudentID); partialUpdateHelper.AddElement("Field", "SchoolYear", "" + editor.SchoolYear); partialUpdateHelper.AddElement("Field", "Semester", "" + editor.Semester); partialUpdateHelper.AddElement("Field", "GradeYear", "" + editor.GradeYear); partialUpdateHelper.AddElement("Field", "ScoreInfo"); partialUpdateHelper.AddElement("Field/ScoreInfo", "SemesterSubjectScoreInfo"); foreach (var subjectKey in editor.Subjects.Keys) { SubjectScore subject = editor.Subjects[subjectKey]; XmlElement element = partialUpdateHelper.AddElement("Field/ScoreInfo/SemesterSubjectScoreInfo", "Subject"); element.SetAttribute("領域", subject.Domain); element.SetAttribute("科目", subjectKey); element.SetAttribute("節數", "" + subject.Period); element.SetAttribute("權數", "" + subject.Credit); element.SetAttribute("成績", "" + subject.Score); element.SetAttribute("努力程度", "" + subject.Effort); element.SetAttribute("文字描述", "" + subject.Text); element.SetAttribute("註記", "" + subject.Comment); } partialUpdateHelper.AddElement("Field/ScoreInfo", "Domains"); foreach (var domainKey in editor.Domains.Keys) { DomainScore domain = editor.Domains[domainKey]; XmlElement element = partialUpdateHelper.AddElement("Field/ScoreInfo/Domains", "Domain"); element.SetAttribute("領域", domainKey); element.SetAttribute("節數", "" + domain.Period); element.SetAttribute("權數", "" + domain.Credit); element.SetAttribute("成績", "" + domain.Score); element.SetAttribute("努力程度", "" + domain.Effort); element.SetAttribute("文字描述", "" + domain.Text); element.SetAttribute("註記", "" + domain.Comment); } partialUpdateHelper.AddElement("Field/ScoreInfo", "LearnDomainScore", "" + editor.LearnDomainScore); partialUpdateHelper.AddElement("Field/ScoreInfo", "CourseLearnScore", "" + editor.CourseLearnScore); partialUpdateHelper.AddElement("Condition"); partialUpdateHelper.AddElement("Condition", "ID", editor.ID); updateHelper.AddElement(".", partialUpdateHelper.BaseElement); do_update = true; synclist.Add(editor.ID); } else { deleteHelper.AddElement("SemesterSubjectScore"); deleteHelper.AddElement("SemesterSubjectScore", "ID", editor.ID); do_delete = true; synclist.Add(editor.ID); } } if (do_insert) { DSXmlHelper response = FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.InsertSemesterSubjectScore", new DSRequest(insertHelper)).GetContent(); foreach (XmlElement each in response.GetElements("NewID")) { synclist.Add(each.InnerText); } } if (do_update) { FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.UpdateSemesterSubjectScore", new DSRequest(updateHelper)); } if (do_delete) { FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.DeleteSemesterSubjectScore", new DSRequest(deleteHelper)); } SemesterScore.Instance.SyncDataBackground(synclist.ToArray()); }
public void Save() { List <JHSemesterScoreRecord> addSemsScore = new List <JHSemesterScoreRecord>(); List <JHSemesterScoreRecord> updateSemsScore = new List <JHSemesterScoreRecord>(); SubjectScoreLogFormater subjLogFormater = new SubjectScoreLogFormater(); DomainScoreLogFormater domainLogFormater = new DomainScoreLogFormater(); foreach (StudentScore student in Students) { #region 決定要新增還是更新。 JHSemesterScoreRecord JHScore = GetJHSemesterScore(student.Id, student.SemestersScore[SemesterData.Empty]); SCSemsScore SCScore = student.SemestersScore[SemesterData.Empty]; if (string.IsNullOrEmpty(JHScore.ID)) { addSemsScore.Add(JHScore); } else { updateSemsScore.Add(JHScore); } #endregion #region 產生科目資料。 JHScore.Subjects.Clear(); foreach (string strSubject in SCScore.Subject) { SemesterSubjectScore objSCSubject = SCScore.Subject[strSubject]; SubjectScore objJHSubject = GetJHSubjectScore(strSubject, objSCSubject); LogData subjLog = new LogData(strSubject); subjLog.Formater = subjLogFormater; decimal?score = objSCSubject.Value.HasValue ? (decimal?)(double)objSCSubject.Value : null; //記錄 Log subjLog.Add(new LogData("成績", objJHSubject.Score + "", score.ToString())); subjLog.Add(new LogData("權重", objJHSubject.Credit + "", objSCSubject.Weight + "")); subjLog.Add(new LogData("節數", objJHSubject.Period + "", objSCSubject.Period + "")); if (Program.Mode == ModuleMode.KaoHsiung) { subjLog.Add(new LogData("努力程度", objJHSubject.Effort + "", objSCSubject.Effort + "")); } subjLog.Add(new LogData("文字評量", objJHSubject.Text + "", objSCSubject.Text)); subjLog.Add(new LogData("領域", objJHSubject.Domain + "", objSCSubject.Domain)); SCScore.Subject.Log.Add(subjLog); objJHSubject.Score = score; objJHSubject.Credit = objSCSubject.Weight; objJHSubject.Period = objSCSubject.Period; objJHSubject.Effort = objSCSubject.Effort; objJHSubject.Text = objSCSubject.Text; objJHSubject.Domain = objSCSubject.Domain; JHScore.Subjects.Add(strSubject, objJHSubject); } //排序科目名稱。 Dictionary <string, SubjectScore> orderSubject = new Dictionary <string, SubjectScore>(JHScore.Subjects); JHScore.Subjects.Clear(); foreach (string subjName in Util.SortSubjectDomain(orderSubject.Keys)) { JHScore.Subjects.Add(subjName, orderSubject[subjName]); } #endregion #region 產生領域資料。 JHScore.Domains.Clear(); foreach (string strDomain in SCScore.Domain) { //彈性課程不記錄領域領域。 if (Util.IsVariableDomain(strDomain)) { continue; } SemesterDomainScore objSCDomain = SCScore.Domain[strDomain]; DomainScore objJHDomain = GetJHDomainScore(strDomain, objSCDomain); LogData domainLog = new LogData(strDomain); domainLog.Formater = subjLogFormater; decimal?score = objSCDomain.Value.HasValue ? (decimal?)(double)objSCDomain.Value : null; //記錄 Log domainLog.Add(new LogData("成績", objJHDomain.Score + "", score + "")); domainLog.Add(new LogData("權重", objJHDomain.Credit + "", objSCDomain.Weight + "")); domainLog.Add(new LogData("節數", objJHDomain.Period + "", objSCDomain.Period + "")); if (Program.Mode == ModuleMode.KaoHsiung) { domainLog.Add(new LogData("努力程度", objJHDomain.Effort + "", objSCDomain.Effort + "")); } domainLog.Add(new LogData("文字評量", objJHDomain.Text + "", objSCDomain.Text)); SCScore.Domain.Log.Add(domainLog); objJHDomain.Score = score; objJHDomain.Credit = objSCDomain.Weight; objJHDomain.Period = objSCDomain.Period; objJHDomain.Effort = objSCDomain.Effort; objJHDomain.Text = objSCDomain.Text; JHScore.Domains.Add(strDomain, objJHDomain); } //記錄 Log SCScore.LearningLog.Formater = domainLogFormater; SCScore.LearningLog.OriginValue = JHScore.CourseLearnScore + ""; SCScore.LearningLog.NewValue = SCScore.LearnDomainScore + ""; SCScore.CourseLog.Formater = domainLogFormater; SCScore.CourseLog.OriginValue = JHScore.CourseLearnScore + ""; SCScore.CourseLog.NewValue = SCScore.CourseLearnScore + ""; JHScore.LearnDomainScore = SCScore.LearnDomainScore; JHScore.CourseLearnScore = SCScore.CourseLearnScore; //排序領域名稱。 Dictionary <string, DomainScore> orderDomain = new Dictionary <string, DomainScore>(JHScore.Domains); JHScore.Domains.Clear(); foreach (string domainName in Util.SortSubjectDomain(orderDomain.Keys)) { JHScore.Domains.Add(domainName, orderDomain[domainName]); } #endregion } #region 新增科目成績 FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord> addSpliter = new FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord>(500, 5); addSpliter.Function = delegate(List <JHSemesterScoreRecord> part) { // 加入檢查當科目與領域成績筆數0不新增 List <JHSemesterScoreRecord> insertPart = new List <JHSemesterScoreRecord> (); foreach (JHSemesterScoreRecord rec in part) { // 沒有任何領域或科目成績 if (rec.Domains.Count == 0 && rec.Subjects.Count == 0) { continue; } insertPart.Add(rec); } if (insertPart.Count > 0) { JHSemesterScore.Insert(insertPart); } return(new List <JHSemesterScoreRecord>()); }; addSpliter.ProgressChange = delegate(int progress) { Reporter.Feedback("新增科目成績...", Util.CalculatePercentage(addSemsScore.Count, progress)); }; addSpliter.Execute(addSemsScore); #endregion #region 更新科目成績 FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord> updateSpliter = new FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord>(500, 5); updateSpliter.Function = delegate(List <JHSemesterScoreRecord> part) { JHSemesterScore.Update(part); return(new List <JHSemesterScoreRecord>()); }; updateSpliter.ProgressChange = delegate(int progress) { Reporter.Feedback("更新科目成績...", Util.CalculatePercentage(updateSemsScore.Count, progress)); }; updateSpliter.Execute(updateSemsScore); #endregion }
/// <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++; } } } }
public static void CalcDomainScore(this List <StudentExcess> students) { //得分項目。 HashSet <string> lookup = new HashSet <string>(new string[] { "健康與體育", "藝術與人文", //藝術與人文 "綜合活動" }); foreach (StudentExcess student in students) //所有學生。 { SemesterDataCollection allSems = student.FiveSemester.ToSemesterOnly(); Dictionary <string, DomainAvgCalculator> calculate = new Dictionary <string, DomainAvgCalculator>(); foreach (SemesterData sems in allSems) //所有學期 { if (!student.DomainScore.ContainsKey(sems)) { continue; } DomainScore ds = student.DomainScore[sems]; foreach (string dn in ds.Keys) //所有領域成績 { string name = dn.Trim(); if (!lookup.Contains(name)) //非需要的領域不處理。 { continue; } if (!calculate.ContainsKey(name)) { calculate[dn] = new DomainAvgCalculator(); } //將指定領域的成績加入到計算機中。 calculate[name].AddScore(ds[name]); } } int passCount = 0; foreach (DomainAvgCalculator avg in calculate.Values) { if (avg.IsPassed) { passCount++; } } decimal score = 0; switch (passCount) { case 1: score = 3; break; case 2: score = 6; break; case 3: score = 10; break; } student.DomainScoreFinal = score; } }
/// <summary> /// 取得五學期領域成績平均 /// </summary> /// <param name="sems"></param> /// <returns></returns> public decimal?GetAverage(SemesterDataCollection sems) { decimal sum, count; Dictionary <SemesterData, decimal?> semScores = new Dictionary <SemesterData, decimal?>(); foreach (SemesterData sem in sems) { sum = count = decimal.Zero; if (!_scores.ContainsKey(sem)) { continue; } foreach (string domain in Global.GetDomains()) { if (!_scores[sem].Domains.ContainsKey(domain)) { continue; } DomainScore domainScore = _scores[sem].Domains[domain]; if (!domainScore.Score.HasValue) { continue; } if (!domainScore.Credit.HasValue) { continue; } sum += domainScore.Score.Value * domainScore.Credit.Value; count += domainScore.Credit.Value; } if (count > 0) { semScores.Add(sem, sum / count); } else { semScores.Add(sem, null); } } sum = count = decimal.Zero; foreach (decimal?score in semScores.Values) { if (!score.HasValue) { continue; } sum += score.Value; count++; } if (count > 0) { return(sum / count); } else { return(null); } }