/// <summary> /// 取得所有資料 /// </summary> private void SetStudentBoxs() { List <string> StudentIDList = K12.Presentation.NLDPanels.Student.SelectedSource; ListStudent = Student.SelectByIDs(StudentIDList); //取得學生 ListStudent.Sort(new Comparison <StudentRecord>(ParseStudent)); ListPhone = Phone.SelectByStudentIDs(StudentIDList); //取得電話資料 ListParent = Parent.SelectByStudentIDs(StudentIDList); //取得監護人資料 ListAddress = Address.SelectByStudentIDs(StudentIDList); //取得地址資料 ListMerit = Merit.SelectByStudentIDs(StudentIDList); //取得獎勵資料(一對多) ListDeMerit = Demerit.SelectByStudentIDs(StudentIDList); //取得懲戒資料(一對多) ListMoralScore = SHMoralScore.SelectByStudentIDs(StudentIDList); //取得日常生活表現資料(一對多) ListUpdataRecord = UpdateRecord.SelectByStudentIDs(StudentIDList); //取得異動資料(一對多) ListJHSemesterHistory = SemesterHistory.SelectByStudentIDs(StudentIDList); //取得學生學期歷程 //ListAssnCode = _accessHelper.Select<AssnCode>(); //取得所有社團記錄 ListAutoSummary = AutoSummary.Select(StudentIDList, null); ListAutoSummary.Sort(SortSchoolYearSemester); }
private void MasterWorker_DoWork(object sender, DoWorkEventArgs e) { StudentScore.SetClassMapping(); PrintStudents = StudentIDs.ToReportStudent(); List <ReportStudent> AllStudents = Util.GetAllStudents(); AllStudents.ToSC().ReadSemesterScore(this); AllStudents.ToSC().ReadSemesterHistory(this); if (Preference.PrintRank || Preference.PrintRankPercentage || Preference.FilterRankScope) { #region 如果要排名。 List <ReportStudent> RatingStudents = Util.GetRatingStudents(AllStudents); List <IScoreParser <ReportStudent> > parsers = new List <IScoreParser <ReportStudent> >(); parsers.Add(new LearningDomainParser(Preference.PrintSemesters)); parsers.Add(new SLearningDomainParser(1, 1)); parsers.Add(new SLearningDomainParser(1, 2)); parsers.Add(new SLearningDomainParser(2, 1)); parsers.Add(new SLearningDomainParser(2, 2)); parsers.Add(new SLearningDomainParser(3, 1)); parsers.Add(new SLearningDomainParser(3, 2)); parsers.Add(new SLearningDomainParser(7, 1)); parsers.Add(new SLearningDomainParser(7, 2)); parsers.Add(new SLearningDomainParser(8, 1)); parsers.Add(new SLearningDomainParser(8, 2)); parsers.Add(new SLearningDomainParser(9, 1)); parsers.Add(new SLearningDomainParser(9, 2)); 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 AllStudents) { if (DicPrintStudents.ContainsKey(each.Id)) { DicPrintStudents[each.Id] = each; } } 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 { Dictionary <string, StudentScore> DicPrintStudents = PrintStudents.ToSC().ToDictionary(); foreach (ReportStudent each in AllStudents) { if (DicPrintStudents.ContainsKey(each.Id)) { DicPrintStudents[each.Id] = each; } } PrintStudents = new List <ReportStudent>(DicPrintStudents.Values.ToSS()); } if (PrintStudents.Count <= 0) { Feedback("", -1); //把 Status bar Reset... throw new ArgumentException("沒有任何學生資料可列印。"); } List <StudentScore> 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(); e_For_ConvertToPDF_Worker = e; Feedback("列印完成", -1); }
public DataCache(Options options) { var student_ids = from student in options.Students select student.ID; #region 取得 AutoSummary _autoSummaryCache = new Dictionary <string, AutoSummaryRecord>(); foreach (AutoSummaryRecord record in AutoSummary.Select(student_ids.ToList <string>(), null)) { if (record.SchoolYear == options.SchoolYear && record.Semester == options.Semester) { if (!_autoSummaryCache.ContainsKey(record.RefStudentID)) { _autoSummaryCache.Add(record.RefStudentID, record); } } } #endregion #region 取得 SemesterScore _semesterScoreCache = new Dictionary <string, JHSemesterScoreRecord>(); foreach (var record in JHSemesterScore.SelectByStudentIDs(student_ids.ToList <string>())) { if (record.SchoolYear == options.SchoolYear && record.Semester == options.Semester) { if (!_semesterScoreCache.ContainsKey(record.RefStudentID)) { _semesterScoreCache.Add(record.RefStudentID, record); } } } #endregion #region 取得 SemesterHistoryItem _historyItemCache = new Dictionary <string, K12.Data.SemesterHistoryItem>(); foreach (var record in JHSemesterHistory.SelectByStudentIDs(student_ids)) { foreach (var item in record.SemesterHistoryItems) { if (item.SchoolYear == options.SchoolYear && item.Semester == options.Semester) { if (!_historyItemCache.ContainsKey(item.RefStudentID)) { _historyItemCache.Add(item.RefStudentID, item); } } } } #endregion if (Global.Params["Mode"] == "KaoHsiung") { #region 取得社團成績 _assnScoreCache = new Dictionary <string, AssnScore>(); FISCA.UDT.AccessHelper ah = new FISCA.UDT.AccessHelper(); string condition = string.Format("SchoolYear='{0}' and Semester='{1}'", options.SchoolYear, options.Semester); List <AssnCode> list = ah.Select <AssnCode>(condition); foreach (AssnCode record in list) { if (!_assnScoreCache.ContainsKey(record.StudentID)) { XmlElement scores = K12.Data.XmlHelper.LoadXml(record.Scores); XmlElement itemElement = (XmlElement)scores.SelectSingleNode("Item"); if (itemElement != null) { AssnScore assnScore = new AssnScore() { Score = itemElement.GetAttribute("Score"), Effort = itemElement.GetAttribute("Effort"), Text = itemElement.GetAttribute("Text") }; _assnScoreCache.Add(record.StudentID, assnScore); } } } //<Content> //<Item AssociationName="籃球社" Score="" Effort="" Text=""></Item> //</Content> #endregion } }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { List <JHPeriodMappingInfo> periodList = JHPeriodMapping.SelectAll(); List <JHAbsenceMappingInfo> absenceList = JHAbsenceMapping.SelectAll(); double total = _config.Students.Count; double count = 0; List <string> student_ids = new List <string>(); foreach (JHStudentRecord item in _config.Students) { student_ids.Add(item.ID); } #region 快取資料 Dictionary <string, List <AutoSummaryRecord> > autoSummaryCache = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(student_ids, null)) { if (!autoSummaryCache.ContainsKey(record.RefStudentID)) { autoSummaryCache.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } autoSummaryCache[record.RefStudentID].Add(record); } Dictionary <string, List <JHUpdateRecordRecord> > updateRecordCache = new Dictionary <string, List <JHUpdateRecordRecord> >(); foreach (var record in JHUpdateRecord.SelectByStudentIDs(student_ids)) { if (!updateRecordCache.ContainsKey(record.StudentID)) { updateRecordCache.Add(record.StudentID, new List <JHUpdateRecordRecord>()); } updateRecordCache[record.StudentID].Add(record); } Dictionary <string, List <JHSemesterScoreRecord> > semesterScoreCache = new Dictionary <string, List <JHSemesterScoreRecord> >(); foreach (var record in JHSemesterScore.SelectByStudentIDs(student_ids)) { if (!semesterScoreCache.ContainsKey(record.RefStudentID)) { semesterScoreCache.Add(record.RefStudentID, new List <JHSemesterScoreRecord>()); } semesterScoreCache[record.RefStudentID].Add(record); } Dictionary <string, JHSemesterHistoryRecord> semesterHistoryCache = new Dictionary <string, JHSemesterHistoryRecord>(); foreach (var record in JHSemesterHistory.SelectByStudentIDs(student_ids)) { if (!semesterHistoryCache.ContainsKey(record.RefStudentID)) { semesterHistoryCache.Add(record.RefStudentID, record); } } #endregion #region 取得所有科目 Dictionary <string, SubjectScore> subjectDict = new Dictionary <string, SubjectScore>(); foreach (JHSemesterScoreRecord record in JHSemesterScore.SelectByStudentIDs(student_ids)) { foreach (SubjectScore subject in record.Subjects.Values) { string key = Bind(subject.Domain, subject.Subject); if (!subjectDict.ContainsKey(key)) { subjectDict.Add(key, subject); } } } List <SubjectScore> subjectList = new List <SubjectScore>(subjectDict.Values); subjectList.Sort(delegate(SubjectScore x, SubjectScore y) { List <string> list = new List <string>(new string[] { "國語文", "國文", "英文", "英語", "數學", "歷史", "地理", "公民", "理化", "生物" }); int ix = list.IndexOf(x.Subject); int iy = list.IndexOf(y.Subject); if (ix >= 0 && iy >= 0) { return(ix.CompareTo(iy)); } else if (ix >= 0) { return(-1); } else if (iy >= 0) { return(1); } else { return(x.Subject.CompareTo(y.Subject)); } }); #endregion #region 判斷要列印的領域科目 Dictionary <string, bool> domains = new Dictionary <string, bool>(); Dictionary <string, List <string> > subjects = new Dictionary <string, List <string> >(); if (_config.DomainSubjectSetup == "Domain") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, true); } if (domains.ContainsKey("語文")) { domains["語文"] = false; } if (domains.ContainsKey("彈性課程")) { domains["彈性課程"] = false; } if (!domains.ContainsKey("")) { domains.Add("", false); } } else if (_config.DomainSubjectSetup == "Subject") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, false); } if (!domains.ContainsKey("")) { domains.Add("", false); } } else { throw new Exception("請重新儲存列印設定"); } foreach (var domain in JHSchool.Evaluation.Subject.Domains) { subjects.Add(domain, new List <string>()); } if (!subjects.ContainsKey("")) { subjects.Add("", new List <string>()); } foreach (SubjectScore ss in subjectList) { if (!subjects.ContainsKey(ss.Domain)) { subjects.Add(ss.Domain, new List <string>()); } //很怪 if (domains.ContainsKey(ss.Domain) && domains[ss.Domain] == true) { continue; } if (!subjects[ss.Domain].Contains(ss.Subject)) { subjects[ss.Domain].Add(ss.Subject); } } _config.SetPrintDomains(domains); _config.SetPrintSubjects(subjects); #endregion #region 依節權數設定,在畫面上顯示 DocumentBuilder templateBuilder = new DocumentBuilder(_template); string pcDisplay = string.Empty; if (_config.PrintPeriod && _config.PrintCredit) { pcDisplay = "節/權數"; } else if (_config.PrintPeriod) { pcDisplay = "節數"; } else if (_config.PrintCredit) { pcDisplay = "權數"; } while (templateBuilder.MoveToMergeField("節權數")) { templateBuilder.Write(pcDisplay); } #endregion #region 務學習時數 Config._SLRDict.Clear(); Config._SLRDict = Utility.GetServiceLearningDetail(student_ids); #endregion #region 產生 foreach (JHStudentRecord student in _config.Students) { count++; DocumentBuilder builder = null; #region 建立學期歷程對照 List <SemesterHistoryItem> semesterHistoryList = null; if (semesterHistoryCache.ContainsKey(student.ID)) { semesterHistoryList = semesterHistoryCache[student.ID].SemesterHistoryItems; } else { semesterHistoryList = new List <SemesterHistoryItem>(); } SemesterMap map = new SemesterMap(); map.SetData(semesterHistoryList); #endregion Document each = (Document)_template.Clone(true); builder = new DocumentBuilder(each); #region 基本資料 StudentBasicInfo basic = new StudentBasicInfo(); basic.SetStudent(student, semesterHistoryList); each.MailMerge.MergeField += delegate(object sender1, MergeFieldEventArgs e1) { #region 處理照片 if (e1.FieldName == "照片粘貼處") { DocumentBuilder builder1 = new DocumentBuilder(e1.Document); builder1.MoveToField(e1.Field, true); byte[] photoBytes = null; try { photoBytes = Convert.FromBase64String("" + e1.FieldValue); } catch (Exception ex) { builder1.Write("照片粘貼處"); e1.Field.Remove(); return; } if (photoBytes == null || photoBytes.Length == 0) { builder1.Write("照片粘貼處"); e1.Field.Remove(); return; } e1.Field.Remove(); Shape photoShape = new Shape(e1.Document, ShapeType.Image); photoShape.ImageData.SetImage(photoBytes); photoShape.WrapType = WrapType.Inline; #region AutoResize double origHWRate = photoShape.ImageData.ImageSize.HeightPoints / photoShape.ImageData.ImageSize.WidthPoints; double shapeHeight = (builder1.CurrentParagraph.ParentNode.ParentNode as Row).RowFormat.Height * 6; double shapeWidth = (builder1.CurrentParagraph.ParentNode as Cell).CellFormat.Width; if ((shapeHeight / shapeWidth) < origHWRate) { shapeWidth = shapeHeight / origHWRate; } else { shapeHeight = shapeWidth * origHWRate; } #endregion photoShape.Height = shapeHeight * 0.9; photoShape.Width = shapeWidth * 0.9; builder1.InsertNode(photoShape); } #endregion }; //each.MailMerge.FieldMergingCallback = new InsertDocumentAtMailMergeHandler(); List <string> fieldName = new List <string>(); fieldName.AddRange(basic.GetFieldName()); List <string> fieldValue = new List <string>(); fieldValue.AddRange(basic.GetFieldValue()); each.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray()); #endregion #region 異動資料 List <JHUpdateRecordRecord> updateRecordList = null; if (updateRecordCache.ContainsKey(student.ID)) { updateRecordList = updateRecordCache[student.ID]; } else { updateRecordList = new List <JHUpdateRecordRecord>(); } StudentUpdateRecordProcessor updateRecordProcessor = new StudentUpdateRecordProcessor(each); updateRecordProcessor.SetData(updateRecordList); #endregion #region 成績資料 List <JHSemesterScoreRecord> semesterScoreList = null; if (semesterScoreCache.ContainsKey(student.ID)) { semesterScoreList = semesterScoreCache[student.ID]; } else { semesterScoreList = new List <JHSemesterScoreRecord>(); } StudentSemesterScoreProcessor semesterScoreProcessor = new StudentSemesterScoreProcessor(builder, map, _config); semesterScoreProcessor.SetData(semesterScoreList); #endregion List <AutoSummaryRecord> autoSummaryList = null; if (autoSummaryCache.ContainsKey(student.ID)) { autoSummaryList = autoSummaryCache[student.ID]; } else { autoSummaryList = new List <AutoSummaryRecord>(); } #region 獎懲資料 StudentDisciplineProcessor disciplineProcessor = new StudentDisciplineProcessor(builder, map); disciplineProcessor.SetData(autoSummaryList); #endregion #region 缺曠資料 StudentAttendanceProcessor attendanceProcessor = new StudentAttendanceProcessor(builder, map); attendanceProcessor.SetData(autoSummaryList); #endregion #region 日常行為 StudentTextScoreProcessor textScoreProcessor = new StudentTextScoreProcessor(builder, map); textScoreProcessor.SetData(autoSummaryList); #endregion SemesterHistoryProcessor semesterHistoryProcessor = new SemesterHistoryProcessor(builder, map); foreach (Section sec in each.Sections) { _doc.Sections.Add(_doc.ImportNode(sec, true)); } //回報進度 _worker.ReportProgress((int)(count * 100.0 / total)); } List <string> globalFieldName = new List <string>(); List <object> globalFieldValue = new List <object>(); globalFieldName.Add("學校名稱"); globalFieldValue.Add(School.ChineseName); globalFieldName.Add("列印日期"); globalFieldValue.Add(Common.CDate(DateTime.Now.ToString("yyyy/MM/dd")) + " " + DateTime.Now.ToString("HH:mm:ss")); string chancellor, eduDirector, stuDirector; chancellor = eduDirector = stuDirector = string.Empty; XmlElement info = School.Configuration["學校資訊"].PreviousData; XmlElement chancellorElement = (XmlElement)info.SelectSingleNode("ChancellorChineseName"); XmlElement eduDirectorElement = (XmlElement)info.SelectSingleNode("EduDirectorName"); XmlElement stuDirectorElement = (XmlElement)info.SelectSingleNode("StuDirectorName"); if (chancellorElement != null) { chancellor = chancellorElement.InnerText; } if (eduDirectorElement != null) { eduDirector = eduDirectorElement.InnerText; } if (stuDirectorElement != null) { stuDirector = stuDirectorElement.InnerText; } globalFieldName.Add("教務主任"); globalFieldValue.Add(eduDirector); globalFieldName.Add("學務主任"); globalFieldValue.Add(stuDirector); globalFieldName.Add("校長"); globalFieldValue.Add(chancellor); _doc.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray()); #endregion }
public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } if (!morals.ContainsKey(student.ID)) { continue; } string keyStr = "所有學期"; Dictionary <string, DisTestABC> counter = new Dictionary <string, DisTestABC>(); foreach (AutoSummaryRecord record in morals[student.ID]) { if (!counter.ContainsKey(keyStr)) { counter.Add(keyStr, new DisTestABC()); } if (_balance) { decimal total_merit = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC; decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC; total_demerit -= total_merit; if (total_demerit > 0) { counter[keyStr].ABC = _demeritConverter.Change(total_demerit); } total_demerit = _demeritConverter.BtoA(_demeritConverter.CtoB(total_demerit)); counter[keyStr].demeritINT = total_demerit; } else { decimal total_demerit = record.DemeritA + _demeritConverter.BtoA(record.DemeritB) + _demeritConverter.BtoA(_demeritConverter.CtoB(record.DemeritC)); decimal total_demerit_ABC = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC; if (total_demerit_ABC > 0) { counter[keyStr].ABC = _demeritConverter.Change(total_demerit_ABC); } counter[keyStr].demeritINT = total_demerit; } } List <ResultDetail> resultList = new List <ResultDetail>(); if (counter[keyStr].demeritINT >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("懲戒表現不符合畢業規範"); rd.AddDetail("懲戒表現不符合畢業規範(" + counter[keyStr].ABC + ")"); resultList.Add(rd); } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { List <string> globalFieldName = new List <string>(); List <object> globalFieldValue = new List <object>(); globalFieldName.Add("學校名稱"); globalFieldValue.Add(School.ChineseName); globalFieldName.Add("列印時間"); globalFieldValue.Add(Global.CDate(DateTime.Now.ToString("yyyy/MM/dd")) + " " + DateTime.Now.ToString("HH:mm:ss")); ReportConfiguration _Dylanconfig = new ReportConfiguration(Global.OneFileSave); OneFileSave = _Dylanconfig.GetBoolean("單檔儲存", false); StudentDoc = new Dictionary <string, Document>(); List <JHPeriodMappingInfo> periodList = JHPeriodMapping.SelectAll(); List <JHAbsenceMappingInfo> absenceList = JHAbsenceMapping.SelectAll(); double total = Options.Students.Count; double count = 0; List <string> student_ids = new List <string>(); foreach (JHStudentRecord item in Options.Students) { student_ids.Add(item.ID); } DocumentBuilder templateBuilder = new DocumentBuilder(_template); #region 變更節權數顯示 string pcDisplay = string.Empty; bool printPeriod = Config.GetBoolean("列印節數", false); bool printCredit = Config.GetBoolean("列印權數", false); if (printPeriod && printCredit) { pcDisplay = "節/權數"; } else if (printPeriod) { pcDisplay = "節數"; } else if (printCredit) { pcDisplay = "權數"; } while (templateBuilder.MoveToMergeField("節權數")) { templateBuilder.Write(pcDisplay); } #endregion #region 快取資料 // 取得學生缺曠 Dictionary <string, List <AutoSummaryRecord> > autoSummaryCache = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(student_ids, null)) { if (!autoSummaryCache.ContainsKey(record.RefStudentID)) { autoSummaryCache.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } autoSummaryCache[record.RefStudentID].Add(record); } // 取得學生異動 Dictionary <string, List <JHUpdateRecordRecord> > updateRecordCache = new Dictionary <string, List <JHUpdateRecordRecord> >(); foreach (var record in JHUpdateRecord.SelectByStudentIDs(student_ids)) { if (!updateRecordCache.ContainsKey(record.StudentID)) { updateRecordCache.Add(record.StudentID, new List <JHUpdateRecordRecord>()); } updateRecordCache[record.StudentID].Add(record); } // 取得學生學期成績 Dictionary <string, List <JHSemesterScoreRecord> > semesterScoreCache = new Dictionary <string, List <JHSemesterScoreRecord> >(); foreach (var record in JHSemesterScore.SelectByStudentIDs(student_ids)) { if (!semesterScoreCache.ContainsKey(record.RefStudentID)) { semesterScoreCache.Add(record.RefStudentID, new List <JHSemesterScoreRecord>()); } semesterScoreCache[record.RefStudentID].Add(record); } // 取得學生學期歷程 Dictionary <string, JHSemesterHistoryRecord> semesterHistoryCache = new Dictionary <string, JHSemesterHistoryRecord>(); foreach (var record in JHSemesterHistory.SelectByStudentIDs(student_ids)) { if (!semesterHistoryCache.ContainsKey(record.RefStudentID)) { semesterHistoryCache.Add(record.RefStudentID, record); } } // 取得學生畢業成績 Dictionary <string, K12.Data.GradScoreRecord> StudGradScoreDic = new Dictionary <string, GradScoreRecord>(); foreach (GradScoreRecord score in GradScore.SelectByIDs <GradScoreRecord>(student_ids)) { StudGradScoreDic.Add(score.RefStudentID, score); } #endregion #region 判斷要列印的領域科目 Dictionary <string, bool> domains = new Dictionary <string, bool>(); string domainSubjectSetup = Config.GetString("領域科目設定", "Domain"); if (domainSubjectSetup == "Domain") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, true); } if (domains.ContainsKey("語文")) { domains["語文"] = false; } if (domains.ContainsKey("彈性課程")) { domains["彈性課程"] = false; } if (!domains.ContainsKey("")) { domains.Add("", false); } } else if (domainSubjectSetup == "Subject") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, false); } if (!domains.ContainsKey("")) { domains.Add("", false); } } else { throw new Exception("請重新儲存列印設定"); } //string domainSubjectSetup = Config.GetString("領域科目設定", "Domain"); //if (domainSubjectSetup == "Domain") //{ // foreach (var domain in JHSchool.Evaluation.Subject.Domains) // domains.Add(domain, DomainSubjectExpand.不展開); // if (!domains.ContainsKey("")) domains.Add("", DomainSubjectExpand.展開); //} //else if (domainSubjectSetup == "Subject") //{ // foreach (var domain in JHSchool.Evaluation.Subject.Domains) // domains.Add(domain, DomainSubjectExpand.展開); // if (!domains.ContainsKey("")) domains.Add("", DomainSubjectExpand.展開); //} //else // throw new Exception("請重新儲存一次列印設定"); #endregion #region 務學習時數 Global._SLRDict.Clear(); Global._SLRDict = Utility.GetServiceLearningDetail(student_ids); #endregion #region 產生 foreach (JHStudentRecord student in Options.Students) { count++; DocumentBuilder builder = null; Document each = (Document)_template.Clone(true); #region 建立學期歷程對照 List <SemesterHistoryItem> semesterHistoryList = null; if (semesterHistoryCache.ContainsKey(student.ID)) { semesterHistoryList = semesterHistoryCache[student.ID].SemesterHistoryItems; } else { semesterHistoryList = new List <SemesterHistoryItem>(); } SemesterMap map = new SemesterMap(); map.SetData(semesterHistoryList); #endregion #region Part1 builder = new DocumentBuilder(each); StudentBasicInfo basic = new StudentBasicInfo(); basic.SetStudent(student, semesterHistoryList); StudentSemesterHistory history = new StudentSemesterHistory(); history.SetData(semesterHistoryList); each.MailMerge.MergeField += delegate(object sender1, MergeFieldEventArgs e1) { #region 處理照片 if (e1.FieldName == "照片") { byte[] photoBytes = null; try { photoBytes = Convert.FromBase64String("" + e1.FieldValue); } catch (Exception ex) { e1.Field.Remove(); return; } if (photoBytes == null || photoBytes.Length == 0) { e1.Field.Remove(); return; } DocumentBuilder builder1 = new DocumentBuilder(e1.Document); builder1.MoveToField(e1.Field, true); e1.Field.Remove(); Shape photoShape = new Shape(e1.Document, ShapeType.Image); photoShape.ImageData.SetImage(photoBytes); photoShape.WrapType = WrapType.Inline; #region AutoResize double origHWRate = photoShape.ImageData.ImageSize.HeightPoints / photoShape.ImageData.ImageSize.WidthPoints; double shapeHeight = (builder1.CurrentParagraph.ParentNode.ParentNode as Row).RowFormat.Height * 6; double shapeWidth = (builder1.CurrentParagraph.ParentNode as Cell).CellFormat.Width; if ((shapeHeight / shapeWidth) < origHWRate) { shapeWidth = shapeHeight / origHWRate; } else { shapeHeight = shapeWidth * origHWRate; } #endregion photoShape.Height = shapeHeight; photoShape.Width = shapeWidth; builder1.InsertNode(photoShape); } #endregion }; List <string> fieldName = new List <string>(); fieldName.AddRange(basic.GetFieldName()); fieldName.AddRange(history.GetFieldName()); List <string> fieldValue = new List <string>(); fieldValue.AddRange(basic.GetFieldValue()); fieldValue.AddRange(history.GetFieldValue()); each.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray()); builder.MoveToMergeField("異動"); List <JHUpdateRecordRecord> updateRecordList = null; if (updateRecordCache.ContainsKey(student.ID)) { updateRecordList = updateRecordCache[student.ID]; } else { updateRecordList = new List <JHUpdateRecordRecord>(); } StudentUpdateRecordProcessor updateRecordProcessor = new StudentUpdateRecordProcessor(builder); updateRecordProcessor.SetData(updateRecordList); builder.MoveToMergeField("成績"); List <JHSemesterScoreRecord> semesterScoreList = null; if (semesterScoreCache.ContainsKey(student.ID)) { semesterScoreList = semesterScoreCache[student.ID]; } else { semesterScoreList = new List <JHSemesterScoreRecord>(); } // 學生畢業成績 K12.Data.GradScoreRecord studGradScore = new GradScoreRecord(); if (StudGradScoreDic.ContainsKey(student.ID)) { studGradScore = StudGradScoreDic[student.ID]; } StudentSemesterScoreProcessor semesterScoreProcessor = new StudentSemesterScoreProcessor(builder, map, domainSubjectSetup, domains, studGradScore); semesterScoreProcessor.DegreeMapper = _degreeMapper; semesterScoreProcessor.PrintPeriod = printPeriod; semesterScoreProcessor.PrintCredit = printCredit; semesterScoreProcessor.SetData(semesterScoreList); #endregion #region Part2 //builder = new DocumentBuilder(each); builder.MoveToMergeField("領域文字描述"); if (Config.GetBoolean("列印文字評語", true)) { StudentDomainTextProcessor domainTextProcessor = new StudentDomainTextProcessor(builder, map); domainTextProcessor.SetData(semesterScoreList); } else { Section deleteSection = builder.CurrentSection; each.Sections.Remove(deleteSection); } #endregion #region Part3 //Document part3 = (Document)_template_part3.Clone(true); //builder = new DocumentBuilder(each); builder.MoveToMergeField("日常行為"); StudentMoralProcessor moralProcessor = new StudentMoralProcessor(builder, map, periodList, absenceList); List <AutoSummaryRecord> autoSummaryList = null; if (autoSummaryCache.ContainsKey(student.ID)) { autoSummaryList = autoSummaryCache[student.ID]; } else { autoSummaryList = new List <AutoSummaryRecord>(); } moralProcessor.SetData(autoSummaryList); // 處理多出來 table row Cell cel = moralProcessor.GetCurrentCell(); Table table = cel.ParentRow.ParentTable; for (int i = 47; i >= 20; i--) { bool rm = true; foreach (Aspose.Words.Cell cell in table.Rows[i].Cells) { if (cell.GetText() != "\a") { rm = false; break; } } if (rm) { table.Rows[i].Remove(); } } #endregion if (OneFileSave) { each.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray()); string fileName = ""; fileName = student.StudentNumber; fileName += "_" + student.IDNumber; if (!string.IsNullOrEmpty(student.RefClassID)) { fileName += "_" + student.Class.Name; } else { fileName += "_"; } fileName += "_" + (student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : ""); fileName += "_" + student.Name; if (!StudentDoc.ContainsKey(fileName)) { StudentDoc.Add(fileName, each); } } else { foreach (Section sec in each.Sections) { _doc.Sections.Add(_doc.ImportNode(sec, true)); } } //回報進度 _worker.ReportProgress((int)(count * 100.0 / total)); } if (!OneFileSave) { _doc.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray()); } #endregion }
Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); //Dictionary<string, List<Data.JHMoralScoreRecord>> morals = new Dictionary<string, List<JHSchool.Data.JHMoralScoreRecord>>(); //foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) //{ // if (!morals.ContainsKey(moral.RefStudentID)) // morals.Add(moral.RefStudentID, new List<JHSchool.Data.JHMoralScoreRecord>()); // morals[moral.RefStudentID].Add(moral); //} Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studHisRecDic = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studHisRecDic.Add(rec.RefStudentID, rec); //} foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } //foreach (SemesterHistoryRecord record in student.GetSemesterHistories()) //{ // SemesterInfo info = new SemesterInfo(); // info.SchoolYear = record.SchoolYear; // info.Semester = record.Semester; // if (!gyMapping.ContainsKey(info)) // gyMapping.Add(info, record.GradeYear); //} if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, DisTestABC> counter = new Dictionary <SemesterInfo, DisTestABC>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; if (!counter.ContainsKey(info)) { counter.Add(info, new DisTestABC()); } //decimal meritA = 0, meritB = 0, meritC = 0; //decimal demeritA = 0, demeritB = 0, demeritC = 0; //foreach (XmlElement itemElement in record.Summary.SelectNodes("DisciplineStatistics/Merit")) //{ // decimal merit; // if (decimal.TryParse(itemElement.GetAttribute("A"), out merit)) // meritA = merit; // if (decimal.TryParse(itemElement.GetAttribute("B"), out merit)) // meritB = merit; // if (decimal.TryParse(itemElement.GetAttribute("C"), out merit)) // meritC = merit; //} //foreach (XmlElement itemElement in record.Summary.SelectNodes("DisciplineStatistics/Demerit")) //{ // decimal demerit; // if (decimal.TryParse(itemElement.GetAttribute("A"), out demerit)) // demeritA = demerit; // if (decimal.TryParse(itemElement.GetAttribute("B"), out demerit)) // demeritB = demerit; // if (decimal.TryParse(itemElement.GetAttribute("C"), out demerit)) // demeritC = demerit; //} if (_balance) { decimal total_merit = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC; decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC; total_demerit -= total_merit; if (total_demerit > 0) { counter[info].ABC = _demeritConverter.Change(total_demerit); } total_demerit = _demeritConverter.BtoA(_demeritConverter.CtoB(total_demerit)); counter[info].demeritINT = total_demerit; } else { decimal total_demerit = record.DemeritA + _demeritConverter.BtoA(record.DemeritB) + _demeritConverter.BtoA(_demeritConverter.CtoB(record.DemeritC)); decimal total_demerit_ABC = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC; if (total_demerit_ABC > 0) { counter[info].ABC = _demeritConverter.Change(total_demerit_ABC); } counter[info].demeritINT = total_demerit; } } List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { if (gyMapping.ContainsKey(info) && counter[info].demeritINT >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("懲戒表現不符合畢業規範"); rd.AddDetail("懲戒表現不符合畢業規範(" + counter[info].ABC + ")"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
//private static List<string> 新生異動代碼 = new List<string>() { "001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "099" }; //private static List<string> 轉入代碼 = new List<string>() { "111", "112", "113", "114", "115", "121", "122", "123", "124" }; //private static List<string> 轉出代碼 = new List<string>() { "311", "312", "313", "314", "315", "316", "321", "322", "323", "325", "326", "327", "341", "342", "343", "344", "345", "346", "347", "348", "349", "350", "351", "361", "362", "371", "371", "373", "374", "375", "376", "377", "378", "379", "380"}; //private static List<string> 畢業代碼 = new List<string>() { "501" }; public static Dictionary <string, StudentObj> Get(List <string> studentIDs) { try { //入學及離校日期對照 Dictionary <string, EnLvDateObj> dateDic = new Dictionary <string, EnLvDateObj>(); string str_ids = string.Join("','", studentIDs); str_ids = "'" + str_ids + "'"; string sql = "select ref_student_id,entrance_date,leaving_date from $jhcore_bilingual.studentrecordext where ref_student_id in (" + str_ids + ")"; DataTable dt = tool._Q.Select(sql); foreach (DataRow row in dt.Rows) { string id = row["ref_student_id"] + ""; string ed = row["entrance_date"] + ""; string ld = row["leaving_date"] + ""; dateDic.Add(id, new EnLvDateObj(ed, ld)); } Dictionary <string, StudentObj> StudentDic = new Dictionary <string, StudentObj>(); //學生基本資料 foreach (StudentRecord sr in K12.Data.Student.SelectByIDs(studentIDs)) { if (!StudentDic.ContainsKey(sr.ID)) { StudentDic.Add(sr.ID, new StudentObj(sr)); } } //設定入學及離校日期 foreach (string id in StudentDic.Keys) { if (dateDic.ContainsKey(id)) { StudentDic[id].Entrance = dateDic[id].EntranceDate; StudentDic[id].Leaving = dateDic[id].LeavingDate; } } //學生異動資料 //foreach (UpdateRecordRecord urr in K12.Data.UpdateRecord.SelectByStudentIDs(studentIDs)) //{ // if (新生異動代碼.Contains(urr.UpdateCode)) // StudentDic[urr.StudentID].SetEntrance(urr); // if (轉入代碼.Contains(urr.UpdateCode)) // StudentDic[urr.StudentID].SetEntrance(urr); // if (轉出代碼.Contains(urr.UpdateCode)) // StudentDic[urr.StudentID].SetLeaving(urr); // if (畢業代碼.Contains(urr.UpdateCode)) // StudentDic[urr.StudentID].SetLeaving(urr); //} //學生地址 foreach (AddressRecord ar in K12.Data.Address.SelectByStudentIDs(studentIDs)) { StudentDic[ar.RefStudentID].AddressRecord = ar; } //學生監護人 foreach (ParentRecord pr in K12.Data.Parent.SelectByStudentIDs(studentIDs)) { StudentDic[pr.RefStudentID].ParentRecord = pr; } //前級畢業資訊 foreach (BeforeEnrollmentRecord ber in K12.Data.BeforeEnrollment.SelectByStudentIDs(studentIDs)) { StudentDic[ber.RefStudentID].BeforeEnrollmentRecord = ber; } //學生學期歷程 foreach (SemesterHistoryRecord shr in K12.Data.SemesterHistory.SelectByStudentIDs(studentIDs)) { foreach (SemesterHistoryItem item in shr.SemesterHistoryItems) { StudentDic[item.RefStudentID].SetHistory(item); } } //取得學期成績 foreach (SemesterScoreRecord ssr in K12.Data.SemesterScore.SelectByStudentIDs(studentIDs)) { StudentDic[ssr.RefStudentID].SetSubjects(ssr); } //假別設定初始化(在SetAttendance之前執行) Global.AbsenceSetDicInit(); //取得缺曠 foreach (AutoSummaryRecord asr in AutoSummary.Select(studentIDs, null)) { StudentDic[asr.RefStudentID].SetAttendance(asr); } return(StudentDic); } catch (Exception e) { MessageBox.Show("取得資料過程發生錯誤:" + e); return(null); } }
/// <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++; } } } }
/// <summary> /// 根據學生判斷是否符合條件 /// </summary> /// <param name="list"></param> /// <returns></returns> public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); //學生通過或不通過列表 Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); //取得學生的自動缺曠獎懲統計 foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { //先假設每位學生通過判斷 passList.Add(student.ID, true); #region 針對每位學生產生學年度學期對學年度對照 Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { //針對學生的每筆學期歷程 foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { //建立學年度學期物件,並將學期歷程的學年度及學期複製過去 SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; //將學年度學期對年級加入到集合中 if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } #endregion if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); #region 針對學生的每筆自動缺曠獎懲統計,統計缺曠節數 foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; //針對每筆缺曠名稱的統計 foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //要缺曠類別在成績計算規則中才統計 if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } //將自動獎懲缺曠統計放入到變數中 if (!counter.ContainsKey(info)) { counter.Add(info, 0); } //加總缺曠節次 counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } #endregion List <ResultDetail> resultList = new List <ResultDetail>(); decimal count = 0; foreach (SemesterInfo info in counter.Keys) { count += counter[info]; } if (count >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("缺課節數超次"); rd.AddDetail("缺課節數超次(累計" + count + "節)"); resultList.Add(rd); } //若ResultDetail的列表項目大於0 if (resultList.Count > 0) { //將ResultDetail加入到回傳結果中 _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); TempData.tmpStudentAbsenceAmountAllDict.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { //核准假別的累積次數須歸零 _AvoidDic.Clear(); foreach (string key in _AvoidList) { if (!_AvoidDic.ContainsKey(key)) { _AvoidDic.Add(key, 0); } } passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); Dictionary <SemesterInfo, decimal> schoolDayMapping = new Dictionary <SemesterInfo, decimal>(); foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = item.SchoolYear; info.Semester = item.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, item.GradeYear); if (item.SchoolDayCount.HasValue) { decimal num = (decimal)item.SchoolDayCount.Value; //設定臨界值 decimal newNum = 0; newNum += num * _dayPeriod; //foreach (string type in _periodMapping.Keys) //{ // newNum += num * _periodMapping[type]; //} schoolDayMapping.Add(info, newNum); } } } if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //加總各項核定假別 if (_AvoidDic.ContainsKey(acRecord.Name)) { _AvoidDic[acRecord.Name] += acRecord.Count; } if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } if (!counter.ContainsKey(info)) { counter.Add(info, 0); } counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; // 累積缺曠明細 if (!TempData.tmpStudentAbsenceAmountAllDict.ContainsKey(student.ID)) { TempData.tmpStudentAbsenceAmountAllDict.Add(student.ID, new Dictionary <string, Dictionary <string, int> >()); } string scStr = info.SchoolYear + "學年度第" + info.Semester + "學期"; if (!TempData.tmpStudentAbsenceAmountAllDict[student.ID].ContainsKey(scStr)) { TempData.tmpStudentAbsenceAmountAllDict[student.ID].Add(scStr, new Dictionary <string, int>()); } string strType = acRecord.PeriodType + ":" + acRecord.Name; if (!TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr].ContainsKey(strType)) { TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr].Add(strType, 0); } TempData.tmpStudentAbsenceAmountAllDict[student.ID][scStr][strType] += acRecord.Count; } } List <ResultDetail> resultList = new List <ResultDetail>(); decimal count = 0; decimal schoolDay = 0; foreach (SemesterInfo info in counter.Keys) { count += counter[info]; } foreach (KeyValuePair <SemesterInfo, decimal> kvp in schoolDayMapping) { schoolDay += kvp.Value; } //循環要扣除的假別數 foreach (string elem in _AvoidDic.Keys) { schoolDay -= _AvoidDic[elem]; } //總節數乘上設定比例 if (schoolDay < 0) { schoolDay = 0; } schoolDay *= _amount / 100; if (count > schoolDay) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("上課天數不足"); rd.AddDetail("上課天數不足(累計" + count + "節)"); resultList.Add(rd); } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { passList.Add(student.ID, true); decimal schoolDay = 0; // 取得學生上課日期 foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { if (item.SchoolDayCount.HasValue) { decimal num = (decimal)item.SchoolDayCount.Value; num *= _dayPeriod; num = num * _amount / 100; schoolDay += num; } } if (!morals.ContainsKey(student.ID)) { continue; } decimal counter = 0; foreach (AutoSummaryRecord record in morals[student.ID]) { foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } counter += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } List <ResultDetail> resultList = new List <ResultDetail>(); if (counter >= schoolDay) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("上課天數不足"); rd.AddDetail("上課天數不足(累計" + counter + "節)"); resultList.Add(rd); } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
public DataRationalityMessage Execute() { RATRecords.Clear(); DataRationalityMessage Message = new DataRationalityMessage(); int UpdateRecordCount = 0; //取得學生資料及建立資料物件 foreach (JHStudentRecord student in JHStudent.SelectAll()) { if (!Dic.ContainsKey(student.ID)) { Dic.Add(student.ID, new SuperObj_new(student)); } } foreach (JHUpdateRecordRecord each in JHUpdateRecord.SelectByStudentIDs(Dic.Keys)) { if (each.UpdateCode == "3") //轉入異動代碼為"3" { if (Dic.ContainsKey(each.StudentID)) //包含於清單內 { Dic.Remove(each.StudentID); //將其移除 UpdateRecordCount++; } } } //取得所有懲戒明細,並加入學生資料物件內 foreach (JHDemeritRecord demerit in JHDemerit.SelectAll()) { if (Dic.ContainsKey(demerit.RefStudentID)) { Dic[demerit.RefStudentID].DemeritList.Add(demerit); } } //取得(971,972,981,982)自動統計,排除目前學年度/學期 List <SchoolYearSemester> SysList = new List <SchoolYearSemester>(); SysList.Add(new SchoolYearSemester(97, 1)); SysList.Add(new SchoolYearSemester(97, 2)); SysList.Add(new SchoolYearSemester(98, 1)); SysList.Add(new SchoolYearSemester(98, 2)); SysList.Add(new SchoolYearSemester(99, 1)); SysList.Add(new SchoolYearSemester(99, 2)); List <AutoSummaryRecord> AutoSummaryList = AutoSummary.Select(Dic.Keys, SysList, SummaryType.Discipline, true); foreach (AutoSummaryRecord autoSummary in AutoSummaryList) { if (!Dic[autoSummary.RefStudentID].AutoSummaryDic.Contains(autoSummary)) { Dic[autoSummary.RefStudentID].AutoSummaryDic.Add(autoSummary); } } foreach (string each in Dic.Keys) { //if (Dic[each].IsCleadDmmerit()) //{ if (Dic[each].DetailAndSummary(97, 1)) { SetValue(Dic[each], 97, 1); } if (Dic[each].DetailAndSummary(97, 2)) { SetValue(Dic[each], 97, 2); } if (Dic[each].DetailAndSummary(98, 1)) { SetValue(Dic[each], 98, 1); } if (Dic[each].DetailAndSummary(98, 2)) { SetValue(Dic[each], 98, 2); } if (Dic[each].DetailAndSummary(99, 1)) { SetValue(Dic[each], 99, 1); } if (Dic[each].DetailAndSummary(99, 2)) { SetValue(Dic[each], 99, 2); } //} } //錯誤說明 StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine("檢查(非明細統計)筆數:" + AutoSummaryList.Count()); strBuilder.AppendLine("檢查(非明細統計)不為0筆數:" + RATRecords.Count); strBuilder.AppendLine("具有(轉入異動)記錄之學生共" + UpdateRecordCount + "名,未列入檢查範圍!"); strBuilder.AppendLine("(非明細定義於:僅轉入生可以有值)"); var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord; Message.Data = SortedRATRecords.ToList(); Message.Message = strBuilder.ToString(); if (RATRecords.Count == 0) { MsgBox.Show("未檢查到錯誤資料!!"); } return(Message); }
Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); //Dictionary<string, List<Data.JHMoralScoreRecord>> morals = new Dictionary<string, List<JHSchool.Data.JHMoralScoreRecord>>(); //foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) //{ // if (!morals.ContainsKey(moral.RefStudentID)) // morals.Add(moral.RefStudentID, new List<JHSchool.Data.JHMoralScoreRecord>()); // morals[moral.RefStudentID].Add(moral); //} Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studHisRecDic = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studHisRecDic.Add(rec.RefStudentID, rec); //} // 獎懲明細統計 TempData.tmpStudentDemeritAmountAllDict.Clear(); foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } //foreach (SemesterHistoryRecord record in student.GetSemesterHistories()) //{ // SemesterInfo info = new SemesterInfo(); // info.SchoolYear = record.SchoolYear; // info.Semester = record.Semester; // if (!gyMapping.ContainsKey(info)) // gyMapping.Add(info, record.GradeYear); //} if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, DisTestABC> counter = new Dictionary <SemesterInfo, DisTestABC>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; if (!counter.ContainsKey(info)) { counter.Add(info, new DisTestABC()); } string scStr = info.SchoolYear + "學年度第" + info.Semester + "學期"; if (!TempData.tmpStudentDemeritAmountAllDict.ContainsKey(student.ID)) { TempData.tmpStudentDemeritAmountAllDict.Add(student.ID, new Dictionary <string, Dictionary <string, int> >()); } if (!TempData.tmpStudentDemeritAmountAllDict[student.ID].ContainsKey(scStr)) { Dictionary <string, int> value = new Dictionary <string, int>(); value.Add("大功", 0); value.Add("小功", 0); value.Add("嘉獎", 0); value.Add("大過", 0); value.Add("小過", 0); value.Add("警告", 0); TempData.tmpStudentDemeritAmountAllDict[student.ID].Add(scStr, value); } TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["大功"] += record.MeritA; TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["小功"] += record.MeritB; TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["嘉獎"] += record.MeritC; TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["大過"] += record.DemeritA; TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["小過"] += record.DemeritB; TempData.tmpStudentDemeritAmountAllDict[student.ID][scStr]["警告"] += record.DemeritC; decimal total_merit = _meritConverter.BtoC(_meritConverter.AtoB(record.MeritA) + record.MeritB) + record.MeritC; decimal total_demerit = _demeritConverter.BtoC(_demeritConverter.AtoB(record.DemeritA) + record.DemeritB) + record.DemeritC; //獎懲加總 counter[info].Merit = total_merit; counter[info].Demerit = total_demerit; } List <ResultDetail> resultList = new List <ResultDetail>(); decimal merit = 0; decimal demerit = 0; decimal demeritINT = 0; //存放懲戒詳細數量 Dictionary <string, int> ABC = new Dictionary <string, int>(); ABC.Add("大過", 0); ABC.Add("小過", 0); ABC.Add("警告", 0); //加總總懲戒及各項懲戒 foreach (SemesterInfo info in counter.Keys) { merit += counter[info].Merit; demerit += counter[info].Demerit; } if (_balance) {//功過相抵 demerit -= merit; if (demerit > 0) { Dictionary <string, int> dic = _demeritConverter.Change(demerit); ABC["大過"] += dic["大過"]; ABC["小過"] += dic["小過"]; ABC["警告"] += dic["警告"]; } demeritINT = _demeritConverter.BtoA(_demeritConverter.CtoB(demerit)); } else { if (demerit > 0) { Dictionary <string, int> dic = _demeritConverter.Change(demerit); ABC["大過"] += dic["大過"]; ABC["小過"] += dic["小過"]; ABC["警告"] += dic["警告"]; } demeritINT = _demeritConverter.BtoA(_demeritConverter.CtoB(demerit)); } if (demeritINT >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "0", "0"); rd.AddMessage("懲戒表現不符合畢業規範"); string str = ""; //取得懲戒詳細數量 foreach (KeyValuePair <string, int> kvp in ABC) { str += kvp.Key + kvp.Value; } //2017/12/19,羿均根據高雄小組會議[09-11][02] 所做之修改 rd.AddDetail("懲戒表現不符合畢業規範(說明:所有學期之獎懲累計,經功過相抵換算後相當於" + str + ",已滿三大過)"); resultList.Add(rd); } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
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); } }
public Dictionary <string, bool> Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); list.SyncSemesterHistoryCache(); Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } //foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) //{ // if (!morals.ContainsKey(moral.RefStudentID)) // morals.Add(moral.RefStudentID, new List<JHSchool.Data.JHMoralScoreRecord>()); // morals[moral.RefStudentID].Add(moral); //} //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studHisRecDic = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studHisRecDic.Add(rec.RefStudentID, rec); //} foreach (StudentRecord student in list) { passList.Add(student.ID, true); // 產生學期歷程對照 Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); if (UIConfig._StudentSHistoryRecDict.ContainsKey(student.ID)) { foreach (K12.Data.SemesterHistoryItem shi in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = shi.SchoolYear; info.Semester = shi.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, shi.GradeYear); } else { FISCA.Presentation.Controls.MsgBox.Show("學生:" + UIConfig._StudentSHistoryRecDict[student.ID].Student.Name + " 學期歷程重覆"); } } } //foreach (SemesterHistoryRecord record in student.GetSemesterHistories()) //{ // SemesterInfo info = new SemesterInfo(); // info.SchoolYear = record.SchoolYear; // info.Semester = record.Semester; // if (!gyMapping.ContainsKey(info)) // gyMapping.Add(info, record.GradeYear); //} if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; if (gyMapping.ContainsKey(info) && !((gyMapping[info] == 3 || gyMapping[info] == 9) && info.Semester == 2)) { continue; } //foreach (XmlElement itemElement in record.Summary.SelectNodes("AttendanceStatistics/Absence")) foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //string name = itemElement.GetAttribute("Name"); //string periodType = itemElement.GetAttribute("PeriodType"); if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } //decimal count; //if (!decimal.TryParse(itemElement.GetAttribute("Count"), out count)) // count = 0; //else // count *= _types[periodType + ":" + name]; if (!counter.ContainsKey(info)) { counter.Add(info, 0); } counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { if (gyMapping.ContainsKey(info) && counter[info] >= _amount) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("缺課節數超次"); rd.AddDetail("缺課節數超次(累計" + counter[info] + "節)"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { List <string> globalFieldName = new List <string>(); List <object> globalFieldValue = new List <object>(); globalFieldName.Add("學校名稱"); globalFieldValue.Add(K12.Data.School.ChineseName); globalFieldName.Add("列印日期"); globalFieldValue.Add(DateConvert.CDate(DateTime.Now.ToString("yyyy/MM/dd"))); globalFieldName.Add("列印時間"); globalFieldValue.Add(DateTime.Now.ToString("HH:mm:ss")); ReportConfiguration _Dylanconfig = new ReportConfiguration(Global.OneFileSave); OneFileSave = _Dylanconfig.GetBoolean("單檔儲存", false); StudentDoc = new Dictionary <string, Document>(); double total = _students.Count; double count = 0; List <string> student_ids = new List <string>(); foreach (JHStudentRecord item in _students) { student_ids.Add(item.ID); } #region 快取資料 //取得異動資料 Dictionary <string, List <JHUpdateRecordRecord> > updateRecordCache = new Dictionary <string, List <JHUpdateRecordRecord> >(); foreach (var record in JHUpdateRecord.SelectByStudentIDs(student_ids)) { if (!updateRecordCache.ContainsKey(record.StudentID)) { updateRecordCache.Add(record.StudentID, new List <JHUpdateRecordRecord>()); } updateRecordCache[record.StudentID].Add(record); } //取得缺曠獎懲資料 Dictionary <string, List <AutoSummaryRecord> > autoSummaryCache = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(student_ids, null)) { if (!autoSummaryCache.ContainsKey(record.RefStudentID)) { autoSummaryCache.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } autoSummaryCache[record.RefStudentID].Add(record); } //取得學期歷程 Dictionary <string, JHSemesterHistoryRecord> semesterHistoryCache = new Dictionary <string, JHSemesterHistoryRecord>(); foreach (var record in JHSemesterHistory.SelectByStudentIDs(student_ids)) { if (!semesterHistoryCache.ContainsKey(record.RefStudentID)) { semesterHistoryCache.Add(record.RefStudentID, record); } } //取得學期成績 Dictionary <string, List <JHSemesterScoreRecord> > semesterScoreCache = new Dictionary <string, List <JHSemesterScoreRecord> >(); foreach (var record in JHSemesterScore.SelectByStudentIDs(student_ids)) { if (!semesterScoreCache.ContainsKey(record.RefStudentID)) { semesterScoreCache.Add(record.RefStudentID, new List <JHSemesterScoreRecord>()); } semesterScoreCache[record.RefStudentID].Add(record); } // 取得畢業成績 Dictionary <string, K12.Data.GradScoreRecord> StudGradScoreDic = new Dictionary <string, GradScoreRecord>(); foreach (GradScoreRecord score in GradScore.SelectByIDs <GradScoreRecord>(student_ids)) { StudGradScoreDic.Add(score.RefStudentID, score); } ////課程 //JHCourse.RemoveAll(); //Dictionary<string, JHCourseRecord> courseCache = new Dictionary<string, JHCourseRecord>(); //foreach (JHCourseRecord record in JHCourse.SelectAll()) //{ // if (!courseCache.ContainsKey(record.ID)) // courseCache.Add(record.ID, record); //} #endregion #region 判斷要列印的領域科目 Dictionary <string, bool> domains = new Dictionary <string, bool>(); //Dictionary<string, List<string>> subjects = new Dictionary<string, List<string>>(); //List<JHCourseRecord> courseList = new List<JHCourseRecord>(courseCache.Values); //courseList.Sort(delegate(JHCourseRecord x, JHCourseRecord y) //{ // return JHSchool.Evaluation.Subject.CompareSubjectOrdinal(x.Subject, y.Subject); //}); string domainSubjectSetup = Config.GetString("領域科目設定", "Domain"); if (domainSubjectSetup == "Domain") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, DomainSubjectExpand.展開); } if (!domains.ContainsKey("")) { domains.Add("", DomainSubjectExpand.展開); } } else if (domainSubjectSetup == "Subject") { foreach (var domain in JHSchool.Evaluation.Subject.Domains) { domains.Add(domain, DomainSubjectExpand.展開); } if (!domains.ContainsKey("")) { domains.Add("", DomainSubjectExpand.展開); } } else { throw new Exception("請重新儲存一次列印設定"); } //foreach (var domain in JHSchool.Evaluation.Subject.Domains) // subjects.Add(domain, new List<string>()); //if (!subjects.ContainsKey("")) subjects.Add("", new List<string>()); //foreach (var course in courseList) //{ // if (!subjects.ContainsKey(course.Domain)) // subjects.Add(course.Domain, new List<string>()); // if (!subjects[course.Domain].Contains(course.Subject) && // domains.ContainsKey(course.Domain) && // domains[course.Domain] == false) // { // subjects[course.Domain].Add(course.Subject); // } //} #endregion DocumentBuilder templateBuilder = new DocumentBuilder(_template); #region 節權數顯示 string pcDisplay = string.Empty; bool printPeriod = Config.GetBoolean("列印節數", true); bool printCredit = Config.GetBoolean("列印權數", false); if (printPeriod && printCredit) { pcDisplay = "節" + Environment.NewLine + "權" + Environment.NewLine + "數"; } else if (printPeriod) { pcDisplay = "節" + Environment.NewLine + "數"; } else if (printCredit) { pcDisplay = "權" + Environment.NewLine + "數"; } while (templateBuilder.MoveToMergeField("節權數")) { templateBuilder.Write(pcDisplay); } #endregion #region 文字評語是否列印 bool printText = Config.GetBoolean("列印文字評語", true); if (printText == false) { templateBuilder.MoveToMergeField("學習領域評量"); (templateBuilder.CurrentParagraph.ParentNode as Cell).ParentRow.ParentTable.Remove(); } #endregion #region 務學習時數 Global._SLRDict.Clear(); Global._SLRDict = Utility.GetServiceLearningDetail(student_ids); #endregion #region 產生 foreach (JHStudentRecord student in _students) { count++; Document each = (Document)_template.Clone(true); DocumentBuilder builder = new DocumentBuilder(each); #region 建立學期歷程對照 List <SemesterHistoryItem> semesterHistoryList = null; if (semesterHistoryCache.ContainsKey(student.ID)) { semesterHistoryList = semesterHistoryCache[student.ID].SemesterHistoryItems; } else { semesterHistoryList = new List <SemesterHistoryItem>(); } SemesterMap map = new SemesterMap(); map.SetData(semesterHistoryList); #endregion #region 學生基本資料 StudentBasicInfo basicInfo = new StudentBasicInfo(builder); basicInfo.SetStudent(student, semesterHistoryList); #endregion #region 異動資料 List <JHUpdateRecordRecord> updateRecordList = null; if (updateRecordCache.ContainsKey(student.ID)) { updateRecordList = updateRecordCache[student.ID]; } else { updateRecordList = new List <JHUpdateRecordRecord>(); } StudentUpdateRecordProcessor updateRecordProcessor = new StudentUpdateRecordProcessor(builder); updateRecordProcessor.SetData(updateRecordList); #endregion #region 日常表現 List <AutoSummaryRecord> autoSummaryList = null; if (autoSummaryCache.ContainsKey(student.ID)) { autoSummaryList = autoSummaryCache[student.ID]; } else { autoSummaryList = new List <AutoSummaryRecord>(); } StudentMoralProcessor moralProcessor = new StudentMoralProcessor(builder, map); moralProcessor.SetData(autoSummaryList); #endregion #region 學期歷程 StudentHistoryProcessor history = new StudentHistoryProcessor(builder, map, (semesterHistoryCache.ContainsKey(student.ID) ? semesterHistoryCache[student.ID] : null)); #endregion #region 學期成績 List <JHSemesterScoreRecord> semesterScoreList = null; if (semesterScoreCache.ContainsKey(student.ID)) { semesterScoreList = semesterScoreCache[student.ID]; } else { semesterScoreList = new List <JHSemesterScoreRecord>(); } // 畢業成績 K12.Data.GradScoreRecord StudGradScore = new GradScoreRecord(); if (StudGradScoreDic.ContainsKey(student.ID)) { StudGradScore = StudGradScoreDic[student.ID]; } StudentSemesterScoreProcessor semesterScoreProcessor = new StudentSemesterScoreProcessor(builder, map, domainSubjectSetup, domains, StudGradScore); semesterScoreProcessor.DegreeMapper = _degreeMapper; semesterScoreProcessor.PrintPeriod = printPeriod; semesterScoreProcessor.PrintCredit = printCredit; semesterScoreProcessor.SetData(semesterScoreList); #endregion #region 學習領域評量 if (printText == true) { StudentTextProcessor text = new StudentTextProcessor(builder, map); text.SetData(semesterScoreList); } #endregion if (OneFileSave) { each.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray()); string fileName = ""; fileName = student.StudentNumber; fileName += "_" + student.IDNumber; if (!string.IsNullOrEmpty(student.RefClassID)) { fileName += "_" + student.Class.Name; } else { fileName += "_"; } fileName += "_" + (student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : ""); fileName += "_" + student.Name; if (!StudentDoc.ContainsKey(fileName)) { StudentDoc.Add(fileName, each); } } else { foreach (Section sec in each.Sections) { _doc.Sections.Add(_doc.ImportNode(sec, true)); } } //回報進度 _worker.ReportProgress((int)(count * 100.0 / total)); } if (!OneFileSave) { _doc.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray()); } #endregion }
Dictionary <string, bool> IEvaluative.Evaluate(IEnumerable <StudentRecord> list) { _result.Clear(); Dictionary <string, bool> passList = new Dictionary <string, bool>(); //// 取得學生目前班級年級 //Dictionary<string, int> studGrYearDic = new Dictionary<string, int>(); //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(list.AsKeyList())) //{ // if (stud.Class != null) // if (stud.Class.GradeYear.HasValue) // studGrYearDic.Add(stud.ID, stud.Class.GradeYear.Value); //} //bool checkInsShi = false; //// 取得學生學期歷程 //Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord> studentHistories = new Dictionary<string, JHSchool.Data.JHSemesterHistoryRecord>(); //foreach (JHSchool.Data.JHSemesterHistoryRecord rec in JHSchool.Data.JHSemesterHistory.SelectByStudentIDs(list.AsKeyList())) //{ // checkInsShi = true; // K12.Data.SemesterHistoryItem shi = new K12.Data.SemesterHistoryItem(); // shi.SchoolYear = UIConfig._UserSetSHSchoolYear; // shi.Semester = UIConfig._UserSetSHSemester; // if (studGrYearDic.ContainsKey(rec.RefStudentID)) // shi.GradeYear = studGrYearDic[rec.RefStudentID]; // foreach (K12.Data.SemesterHistoryItem shiItem in rec.SemesterHistoryItems) // if (shiItem.SchoolYear == shi.SchoolYear && shiItem.Semester == shi.Semester) // checkInsShi = false; // if (checkInsShi) // rec.SemesterHistoryItems.Add(shi); // studentHistories.Add(rec.RefStudentID, rec); //} //Dictionary<string, List<Data.JHMoralScoreRecord>> morals = new Dictionary<string, List<JHSchool.Data.JHMoralScoreRecord>>(); //foreach (Data.JHMoralScoreRecord moral in Data.JHMoralScore.SelectByStudentIDs(list.AsKeyList())) //{ // if (!morals.ContainsKey(moral.RefStudentID)) // morals.Add(moral.RefStudentID, new List<JHSchool.Data.JHMoralScoreRecord>()); // morals[moral.RefStudentID].Add(moral); //} Dictionary <string, List <AutoSummaryRecord> > morals = new Dictionary <string, List <AutoSummaryRecord> >(); foreach (AutoSummaryRecord record in AutoSummary.Select(list.AsKeyList(), null)) { if (!morals.ContainsKey(record.RefStudentID)) { morals.Add(record.RefStudentID, new List <AutoSummaryRecord>()); } morals[record.RefStudentID].Add(record); } foreach (StudentRecord student in list) { passList.Add(student.ID, true); Dictionary <SemesterInfo, int> gyMapping = new Dictionary <SemesterInfo, int>(); Dictionary <SemesterInfo, decimal> schoolDayMapping = new Dictionary <SemesterInfo, decimal>(); foreach (K12.Data.SemesterHistoryItem item in UIConfig._StudentSHistoryRecDict[student.ID].SemesterHistoryItems) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = item.SchoolYear; info.Semester = item.Semester; if (!gyMapping.ContainsKey(info)) { gyMapping.Add(info, item.GradeYear); if (item.SchoolDayCount.HasValue) { decimal num = (decimal)item.SchoolDayCount.Value; //設定臨界值 decimal count = 0; count += num * _dayPeriod; //foreach (string type in _SelectedType) //{ // count += num * _periodMapping[type] * _typeWeight[type]; //} count = count * _amount / 100; schoolDayMapping.Add(info, count); //num *= _dayPeriod; //num = num * _amount / 100; //schoolDayMapping.Add(info, num); } } } if (!morals.ContainsKey(student.ID)) { continue; } Dictionary <SemesterInfo, decimal> counter = new Dictionary <SemesterInfo, decimal>(); foreach (AutoSummaryRecord record in morals[student.ID]) { SemesterInfo info = new SemesterInfo(); info.SchoolYear = record.SchoolYear; info.Semester = record.Semester; if (gyMapping.ContainsKey(info) && !((gyMapping[info] == 3 || gyMapping[info] == 9) && info.Semester == 2)) { continue; } //foreach (XmlElement itemElement in record.Summary.SelectNodes("AttendanceStatistics/Absence")) foreach (AbsenceCountRecord acRecord in record.AbsenceCounts) { //string name = itemElement.GetAttribute("Name"); //string periodType = itemElement.GetAttribute("PeriodType"); if (!_types.ContainsKey(acRecord.PeriodType + ":" + acRecord.Name)) { continue; } //decimal count; //if (!decimal.TryParse(itemElement.GetAttribute("Count"), out count)) // count = 0; //else // count *= _types[periodType + ":" + name]; if (!counter.ContainsKey(info)) { counter.Add(info, 0); } counter[info] += acRecord.Count * _types[acRecord.PeriodType + ":" + acRecord.Name]; } } List <ResultDetail> resultList = new List <ResultDetail>(); foreach (SemesterInfo info in counter.Keys) { if (!gyMapping.ContainsKey(info)) { continue; } if (!schoolDayMapping.ContainsKey(info)) { continue; } if (counter[info] > schoolDayMapping[info]) { ResultDetail rd = new ResultDetail(student.ID, "" + gyMapping[info], "" + info.Semester); rd.AddMessage("上課天數不足"); rd.AddDetail("上課天數不足(累計" + counter[info] + "節)"); resultList.Add(rd); } } if (resultList.Count > 0) { _result.Add(student.ID, resultList); passList[student.ID] = false; } } return(passList); }
public DataRationalityMessage Execute() { RATRecords.Clear(); StringBuilder strBuilder = new StringBuilder(); DataRationalityMessage Message = new DataRationalityMessage(); List <JHMoralScoreRecord> moralscorerecords = JHMoralScore.Select(null, StudentIDs, null, null); List <AutoSummaryRecord> autosummaryrecords = AutoSummary.Select(StudentIDs, null); //取得預設學年度及學期 int SchoolYear = K12.Data.Int.Parse(K12.Data.School.DefaultSchoolYear); int Semester = K12.Data.Int.Parse(K12.Data.School.DefaultSemester); try { foreach (JHMoralScoreRecord moralscorerecord in moralscorerecords.Where(x => !(x.SchoolYear == SchoolYear && x.Semester == Semester))) { List <AutoSummaryRecord> filterrecords = autosummaryrecords.Where(x => x.RefStudentID.Equals(moralscorerecord.RefStudentID) && x.SchoolYear == moralscorerecord.SchoolYear && x.Semester == moralscorerecord.Semester).ToList(); if (filterrecords.Count != 1) { throw new Exception("學號" + moralscorerecord.Student.StudentNumber + "對於" + moralscorerecord.SchoolYear + "學年度" + moralscorerecord.Semester + "學期應有對應的自動缺曠獎懲統計物件!!筆數為" + filterrecords.Count); } if (moralscorerecord.Summary != null) { foreach (XmlNode Node in moralscorerecord.Summary.SelectNodes("AttendanceStatistics/Absence")) { XmlElement Elm = Node as XmlElement; if (Elm != null) { int Count = 0; List <AbsenceCountRecord> absencecountrecords = filterrecords[0].AbsenceCounts.Where(x => x.Name.Equals(Elm.GetAttribute("Name")) && x.PeriodType.Equals(Elm.GetAttribute("PeriodType"))).ToList(); if (absencecountrecords.Count == 1) { Count = absencecountrecords[0].Count; } if (Count != K12.Data.Int.Parse(Elm.GetAttribute("Count"))) { AttendanceSummaryRATRecord record = new AttendanceSummaryRATRecord(); record.學生系統編號 = moralscorerecord.Student.ID; record.學號 = moralscorerecord.Student.StudentNumber; record.身分證號 = moralscorerecord.Student.IDNumber; record.班級 = moralscorerecord.Student.Class != null ? moralscorerecord.Student.Class.Name : string.Empty; record.座號 = K12.Data.Int.GetString(moralscorerecord.Student.SeatNo); record.姓名 = moralscorerecord.Student.Name; record.狀態 = moralscorerecord.Student.StatusStr; record.學年度 = K12.Data.Int.GetString(moralscorerecord.SchoolYear); record.學期 = K12.Data.Int.GetString(moralscorerecord.Semester); record.節次類型 = Elm.GetAttribute("PeriodType"); record.缺曠假別 = Elm.GetAttribute("Name"); record.缺曠統計值 = Elm.GetAttribute("Count"); record.缺曠自動統計值 = K12.Data.Int.GetString(Count); RATRecords.Add(record); } } } } } } catch (Exception e) { Message.Message = e.Message; Message.Data = RATRecords; return(Message); } strBuilder.AppendLine("檢查缺曠統計筆數:" + moralscorerecords.Count); strBuilder.AppendLine("問題缺曠統計筆數:" + RATRecords.Count); strBuilder.AppendLine(RATRecords.Count > 0 ? "系統中有學生日常生活表現缺曠統計值與自動缺曠統計值不一致,建議您運用本檢查匯出功能將自動結算值刪除後,再運用系統匯入功能將缺曠統計值匯入做調整。" : string.Empty); var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord; Message.Data = SortedRATRecords.ToList(); Message.Message = strBuilder.ToString(); return(Message); }