public DataRationalityMessage Execute()
        {
            RATRecords.Clear();

            DataRationalityMessage Message = new DataRationalityMessage();

            int TotalCount = 0;

            try
            {
                List <JHSemesterScoreRecord> Scores = JHSchool.Data.JHSemesterScore.SelectAll();

                for (int i = 0; i < Scores.Count; i++)
                {
                    foreach (DomainScore score in Scores[i].Domains.Values)
                    {
                        TotalCount++;

                        if (score.Domain.Equals("彈性課程"))
                        {
                            FlexibleDomainRATRecord record = new FlexibleDomainRATRecord();

                            record.學生系統編號 = Scores[i].Student.ID;
                            record.學號     = Scores[i].Student.StudentNumber;
                            record.身分證號   = Scores[i].Student.IDNumber;
                            record.班級     = Scores[i].Student.Class != null?Scores[i].Student.Class.Name:string.Empty;
                            record.座號     = K12.Data.Int.GetString(Scores[i].Student.SeatNo);
                            record.姓名     = Scores[i].Student.Name;
                            record.狀態     = Scores[i].Student.StatusStr;
                            record.學年度    = K12.Data.Int.GetString(Scores[i].SchoolYear);
                            record.學期     = K12.Data.Int.GetString(Scores[i].Semester);
                            record.領域名稱   = score.Domain;
                            record.分數     = K12.Data.Decimal.GetString(score.Score);

                            RATRecords.Add(record);
                        }
                    }
                }
            }
            catch (Exception ve)
            {
                Message.Message = ve.Message;

                return(Message);
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學期領域成績筆數:" + TotalCount);
            strBuilder.AppendLine("學期領域成績包含彈性課程筆數:" + RATRecords.Count);

            var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord;

            Message.Message = strBuilder.ToString();
            Message.Data    = SortedRATRecords.ToList();

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            CanAutoCorrectStudentIDs.Clear();
            LogBuilder = new StringBuilder();
            LogBuilder.AppendLine("學生系統編號,身分證號,學號,班級,座號,姓名,狀態,學年度,學期,異動類別,原因及事項,異動日期,轉出後學校");

            DataRationalityMessage Message = new DataRationalityMessage();

            List <JHStudentRecord> Students = JHStudent.SelectAll().Where(x => x.Status == K12.Data.StudentRecord.StudentStatus.一般).ToList();

            List <JHUpdateRecordRecord> UpdateRecords = JHUpdateRecord.SelectByStudentIDs(Students.Select(x => x.ID)).Where(x => x.UpdateCode.Equals("4")).ToList();

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學生筆數:" + Students.Count);
            strBuilder.AppendLine("問題學生筆數:" + UpdateRecords.Count);

            if (UpdateRecords.Count > 0)
            {
                strBuilder.AppendLine("建議修正方案:");
                strBuilder.AppendLine("1.將學生加入至待處理,手動變更學生的狀態為『畢業或離校』或『刪除』。");
                strBuilder.AppendLine("2.運用本合理性檢查自動修正功能,將學生的狀態批次變更為『刪除』。");
                strBuilder.AppendLine("3.若您運用本合理性檢查自動修正功能,建議先單選1位學生進行嘗試,確認正確變更為『刪除』狀態再進行批次作業。");
            }

            var StudentUpdateRecords = UpdateRecords.Join(Students, UpdateRecord => UpdateRecord.StudentID, Student => Student.ID, (UpdateRecord, Student) =>
                                                          new
            {
                學生系統編號 = Student.ID,
                身分證號   = Student.IDNumber,
                學號     = Student.StudentNumber,
                班級     = Student.Class != null ? Student.Class.Name : string.Empty,
                座號     = K12.Data.Int.GetString(Student.SeatNo),
                姓名     = Student.Name,
                狀態     = Student.StatusStr,
                學年度    = K12.Data.Int.GetString(UpdateRecord.SchoolYear),
                學期     = K12.Data.Int.GetString(UpdateRecord.Semester),
                異動類別   = "轉出",
                原因及事項  = UpdateRecord.UpdateDescription,
                異動日期   = UpdateRecord.UpdateDate,
                轉出後學校  = UpdateRecord.ImportExportSchool,
            });

            foreach (var r in StudentUpdateRecords)
            {
                LogBuilder.AppendLine(r.學生系統編號 + "," + r.身分證號 + "," + r.學號 + "," + r.班級 + "," + r.座號 + "," + r.姓名 + "," + r.狀態 + "," + r.學年度 + "," + r.學期 + "," + r.異動類別 + "," + r.原因及事項 + "," + r.異動日期 + "," + r.轉出後學校);
            }


            Message.Data    = StudentUpdateRecords.ToList();
            Message.Message = strBuilder.ToString();

            CanAutoCorrectStudentIDs.AddRange(UpdateRecords.Select(x => x.StudentID).Distinct());

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            CorrectableUpdateRecords = JHUpdateRecord.SelectAll().Where
                                           (x =>
                                           x.UpdateCode.Equals("1") &&
                                           !string.IsNullOrEmpty(x.ADNumber) &&
                                           !x.ADNumber.Contains("字第")
                                           ).ToList();

            StudentRecords = Student.SelectByIDs(CorrectableUpdateRecords.Select(x => x.StudentID));

            StringBuilder strBuilder = new StringBuilder();

            DataRationalityMessage Message = new DataRationalityMessage();

            var StudentUpdateRecords = CorrectableUpdateRecords.Join(StudentRecords, x => x.StudentID, y => y.ID, (x, y) =>
                                                                     new
            {
                學生系統編號 = y.ID,
                學號     = y.StudentNumber,
                身分證號   = y.IDNumber,
                班級     = y.Class != null ? y.Class.Name : string.Empty,
                座號     = K12.Data.Int.GetString(y.SeatNo),
                姓名     = y.Name,
                狀態     = y.StatusStr,
                學年度    = K12.Data.Int.GetString(x.SchoolYear),
                學期     = K12.Data.Int.GetString(x.Semester),
                異動日期   = x.UpdateDate,
                入學年月   = x.EnrollmentSchoolYear,
                核准文號   = x.ADNumber,
                原核准文號  = x.ADNumber.Replace("字第", "")
            });

            CorrectableUpdateRecords.ForEach(x => x.ADNumber = x.ADNumber.ADNumberCorrect());

            strBuilder.AppendLine("問題筆數:" + CorrectableUpdateRecords.Count());

            if (CorrectableUpdateRecords.Count > 0)
            {
                strBuilder.AppendLine("建議修正方案:");
                strBuilder.AppendLine("1.將資料匯出後於Excel上修改後,再用匯入學生新生異動功能更新。");
                strBuilder.AppendLine("2.運用本合理性檢查自動修正功能,補上『字第』後更新地址。");
                strBuilder.AppendLine("3.自動修正方案僅考慮在核准文號(數字)前加上字號,若您有特殊情況建議使用匯入學生新生異動功能進行更新。");
            }

            var OrderedStudentUpdateRecords = from record in StudentUpdateRecords orderby record.狀態, record.班級, K12.Data.Int.ParseAllowNull(record.座號) select record;

            Message.Data    = OrderedStudentUpdateRecords.ToList();
            Message.Message = strBuilder.ToString();

            return(Message);
        }
Exemplo n.º 4
0
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage Message = new DataRationalityMessage();

            DisplayRecords.Clear();
            StudentIDList.Clear();

            // 取得所有學生沒有新生異動也沒有轉入異動的學生ID
            QueryHelper qh    = new QueryHelper();
            string      query = @"select student.id as sid,student.name as sname,student_number,id_number,class.class_name,student.seat_no,(case student.status when 1 then'一般' when 2 then'延修' when 4 then'休學' when 8 then'輟學' when 16 then'畢業或離校' end ) as stud_status from student left join class on student.ref_class_id=class.id 
where student.status <>256 and student.id not in(select ref_student_id from update_record where update_code in('1','3')) order by student.status,class.class_name,student.seat_no";
            DataTable   dt    = qh.Select(query);

            foreach (DataRow dr in dt.Rows)
            {
                StudentNoRecord1or3RATRecord sdr = new StudentNoRecord1or3RATRecord();
                sdr.學生系統編號 = dr["sid"].ToString();
                sdr.學號     = dr["student_number"].ToString();
                sdr.身分證號   = dr["id_number"].ToString();
                sdr.班級     = dr["class_name"].ToString();
                sdr.座號     = dr["seat_no"].ToString();
                sdr.狀態     = dr["stud_status"].ToString();
                sdr.姓名     = dr["sname"].ToString();
                if (!StudentIDList.Contains(sdr.學生系統編號))
                {
                    StudentIDList.Add(sdr.學生系統編號);
                }

                DisplayRecords.Add(sdr);
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("問題筆數:" + DisplayRecords.Count());
            if (DisplayRecords.Count > 0)
            {
                strBuilder.AppendLine("建議修正方案:");
                strBuilder.AppendLine("1.將學生加入至待處理,使用手動新增新生異動、轉入異動。");
                strBuilder.AppendLine("2.將學生加入至待處理,批次產生新生異動或使用匯入方式匯入新生異動、轉入異動。");
            }

            Message.Data    = DisplayRecords;
            Message.Message = strBuilder.ToString();

            return(Message);
        }
Exemplo n.º 5
0
        public DataRationalityMessage Execute()
        {
            RATRecords.Clear();

            DataRationalityMessage Message = new DataRationalityMessage();

            DateTime StartTime = new DateTime(2010, 12, 13); //起始日期

            FiscaAccessLayer       f1         = new FiscaAccessLayer();
            ActionRecordCollection ActionColl = f1.GetActionByLog(StartTime, DateTime.Now, "資料合理性檢查");

            foreach (ActionRecord each in ActionColl)
            {
                if (each.Action == "懲戒明細不等於自動統計檢查")
                {
                    RepeatTheLogDataScreeningRATRecord Rep = new RepeatTheLogDataScreeningRATRecord();
                    Rep.Log系統編號 = each.ID;
                    Rep.時間      = DateTime.Parse(each.ServerTime).ToString("yyyy/MM/dd HH:mm");
                    Rep.動作      = each.ActionBy;
                    Rep.動作分類    = each.Action;
                    Rep.登入帳號    = each.Actor;
                    Rep.電腦名稱    = each.ClientInfo.HostName;
                    Rep.詳細描述    = each.Description;
                    RATRecords.Add(Rep);
                }
            }

            //錯誤說明
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("共檢查到:" + RATRecords.Count() + "筆資料");
            strBuilder.AppendLine("資料筆數大於2建議您檢查相關資料是否正確!");

            var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.時間 select RATRecord;

            Message.Data    = SortedRATRecords.ToList();
            Message.Message = strBuilder.ToString();

            if (RATRecords.Count == 0)
            {
                MsgBox.Show("未檢查到錯誤資料!!");
            }

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage retMsg = new DataRationalityMessage();

            // 取得所有學生資料
            Dictionary<string,StudentRecord> studIDDict = new Dictionary<string,StudentRecord> ();
            List<StudentRecord> studRecList = Student.SelectAll();
            foreach (StudentRecord stud in studRecList)
                studIDDict.Add(stud.ID, stud);

            // 取得學生自訂欄位資料
            List<UserDefineData.DAL.UserDefData> UserDefDataList = UDTTransfer.GetDataFromUDT(studIDDict.Keys.ToList());

            // 檢查資料並組合
            Dictionary<string, Dictionary<string, List<UserDefineData.DAL.UserDefData>>> dataDict = new Dictionary<string, Dictionary<string, List<DAL.UserDefData>>>();

            foreach (UserDefineData.DAL.UserDefData data in UserDefDataList)
            {
                if (!dataDict.ContainsKey(data.RefID))
                    dataDict.Add(data.RefID, new Dictionary<string,List<DAL.UserDefData>>());

                if (!dataDict[data.RefID].ContainsKey(data.FieldName))
                    dataDict[data.RefID].Add(data.FieldName, new List<DAL.UserDefData>());

                dataDict[data.RefID][data.FieldName].Add(data);
            }

            CorrectableRecs.Clear();
            RATRecs.Clear();
            try
            {
                foreach (string sid in dataDict.Keys)
                {
                    Dictionary<string, List<UserDefineData.DAL.UserDefData>> dataA = dataDict[sid];
                    foreach (List<UserDefineData.DAL.UserDefData> data in dataA.Values)
                    {
                        // 有重複
                        if (data.Count > 1)
                        {
                            foreach (UserDefineData.DAL.UserDefData data1 in data)
                            {
                                DoubleUserDefDataRATRec rec = new DoubleUserDefDataRATRec();
                                rec.UID = data1.UID;
                                rec.學生系統編號 = data1.RefID;
                                rec.欄位名稱 = data1.FieldName;
                                rec.值 = data1.Value;
                                if (studIDDict.ContainsKey(data1.RefID))
                                {
                                    rec.身分證號 = studIDDict[data1.RefID].IDNumber;
                                    rec.姓名 = studIDDict[data1.RefID].Name;
                                    rec.狀態 = studIDDict[data1.RefID].Status.ToString();
                                    rec.學號 = studIDDict[data1.RefID].StudentNumber;
                                    if (studIDDict[data1.RefID].SeatNo.HasValue)
                                        rec.座號 = studIDDict[data1.RefID].SeatNo.Value.ToString();
                                    else
                                        rec.座號 = "";

                                    if (studIDDict[data1.RefID].Class != null)
                                        rec.班級 = studIDDict[data1.RefID].Class.Name;
                                    else
                                        rec.班級 = "";
                                }

                                RATRecs.Add(rec);
                                CorrectableRecs.Add(data1);
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;

                return retMsg;
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學生自訂欄位資料筆數:" + UserDefDataList.Count);
            strBuilder.AppendLine("自訂欄位資料有重複筆數:" + RATRecs.Count);

            var SortedRATRecords = from RATRecord in RATRecs orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.欄位名稱, RATRecord.值 select RATRecord;

            retMsg.Message = strBuilder.ToString();
            retMsg.Data = SortedRATRecords.ToList();

            return retMsg;
        }
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage retMsg = new DataRationalityMessage();

            // 取得所有學生資料
            Dictionary <string, StudentRecord> studIDDict = new Dictionary <string, StudentRecord> ();
            List <StudentRecord> studRecList = Student.SelectAll();

            foreach (StudentRecord stud in studRecList)
            {
                studIDDict.Add(stud.ID, stud);
            }

            // 取得學生自訂欄位資料
            List <UserDefineData.DAL.UserDefData> UserDefDataList = UDTTransfer.GetDataFromUDT(studIDDict.Keys.ToList());

            // 檢查資料並組合
            Dictionary <string, Dictionary <string, List <UserDefineData.DAL.UserDefData> > > dataDict = new Dictionary <string, Dictionary <string, List <DAL.UserDefData> > >();

            foreach (UserDefineData.DAL.UserDefData data in UserDefDataList)
            {
                if (!dataDict.ContainsKey(data.RefID))
                {
                    dataDict.Add(data.RefID, new Dictionary <string, List <DAL.UserDefData> >());
                }

                if (!dataDict[data.RefID].ContainsKey(data.FieldName))
                {
                    dataDict[data.RefID].Add(data.FieldName, new List <DAL.UserDefData>());
                }

                dataDict[data.RefID][data.FieldName].Add(data);
            }

            CorrectableRecs.Clear();
            RATRecs.Clear();
            try
            {
                foreach (string sid in dataDict.Keys)
                {
                    Dictionary <string, List <UserDefineData.DAL.UserDefData> > dataA = dataDict[sid];
                    foreach (List <UserDefineData.DAL.UserDefData> data in dataA.Values)
                    {
                        // 有重複
                        if (data.Count > 1)
                        {
                            foreach (UserDefineData.DAL.UserDefData data1 in data)
                            {
                                DoubleUserDefDataRATRec rec = new DoubleUserDefDataRATRec();
                                rec.UID    = data1.UID;
                                rec.學生系統編號 = data1.RefID;
                                rec.欄位名稱   = data1.FieldName;
                                rec.值      = data1.Value;
                                if (studIDDict.ContainsKey(data1.RefID))
                                {
                                    rec.身分證號 = studIDDict[data1.RefID].IDNumber;
                                    rec.姓名   = studIDDict[data1.RefID].Name;
                                    rec.狀態   = studIDDict[data1.RefID].Status.ToString();
                                    rec.學號   = studIDDict[data1.RefID].StudentNumber;
                                    if (studIDDict[data1.RefID].SeatNo.HasValue)
                                    {
                                        rec.座號 = studIDDict[data1.RefID].SeatNo.Value.ToString();
                                    }
                                    else
                                    {
                                        rec.座號 = "";
                                    }

                                    if (studIDDict[data1.RefID].Class != null)
                                    {
                                        rec.班級 = studIDDict[data1.RefID].Class.Name;
                                    }
                                    else
                                    {
                                        rec.班級 = "";
                                    }
                                }

                                RATRecs.Add(rec);
                                CorrectableRecs.Add(data1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;

                return(retMsg);
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學生自訂欄位資料筆數:" + UserDefDataList.Count);
            strBuilder.AppendLine("自訂欄位資料有重複筆數:" + RATRecs.Count);

            var SortedRATRecords = from RATRecord in RATRecs orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.欄位名稱, RATRecord.值 select RATRecord;

            retMsg.Message = strBuilder.ToString();
            retMsg.Data    = SortedRATRecords.ToList();

            return(retMsg);
        }
        /// <summary>
        /// 開始檢查資料
        /// </summary>
        /// <returns></returns>
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage Message = new DataRationalityMessage();

            return(Message);
        }
Exemplo n.º 9
0
        public DataRationalityMessage Execute()
        {
            QueryHelper Helper = new QueryHelper();

            List <string> StudentIDs = new List <string>();

            DataTable StudentIDTable = Helper.Select("select ref_student_id from sems_entry_score where score_info like'%<SemesterEntryScore><Entry 分項=\"學業\" 成績=\"0.0\"/></SemesterEntryScore>%'  or score_info like'%<SemesterEntryScore><Entry 分項=\"學業\" 成績=\"0\"/></SemesterEntryScore>%' or score_info like'%<SemesterEntryScore><Entry 分項=\"學業\" 成績=\"0.00\"/></SemesterEntryScore>%' or score_info like'%<SemesterEntryScore><Entry 分項=\"學業\" 成績=\"00.00\"/></SemesterEntryScore>%' or score_info like'%<SemesterEntryScore><Entry 分項=\"學業\" 成績=\"00\"/></SemesterEntryScore>%'");

            for (int i = 0; i < StudentIDTable.Rows.Count; i++)
            {
                StudentIDs.Add("" + StudentIDTable.Rows[i][0]);
            }

            List <SHSemesterEntryScoreRecord> SemsScoreList = new List <SHSemesterEntryScoreRecord>();

            if (StudentIDs.Count > 0)
            {
                SemsScoreList = SHSemesterEntryScore.Select(null, StudentIDs, string.Empty, null);
            }

            CorrectableRecs.Clear();
            RATRecs.Clear();
            DataRationalityMessage retMsg = new DataRationalityMessage();

            try
            {
                foreach (SHSemesterEntryScoreRecord SmesRec in SemsScoreList)
                {
                    if (SmesRec.Group == "學習" && SmesRec.GroupMainScore == 0)
                    {
                        EmptySemesterEntryScoreRATRec rec = new EmptySemesterEntryScoreRATRec();
                        rec.學期成績系統編號 = SmesRec.ID;
                        rec.學生系統編號   = SmesRec.RefStudentID;
                        rec.身分證號     = SmesRec.Student.IDNumber;
                        rec.姓名       = SmesRec.Student.Name;
                        rec.狀態       = SmesRec.Student.StatusStr;
                        rec.座號       = K12.Data.Int.GetString(SmesRec.Student.SeatNo);
                        if (SmesRec.Student.Class != null)
                        {
                            rec.班級 = SmesRec.Student.Class.Name;
                        }
                        rec.學年度 = SmesRec.SchoolYear.ToString();
                        rec.學期  = SmesRec.Semester.ToString();
                        rec.學號  = SmesRec.Student.StudentNumber;

                        RATRecs.Add(rec);
                        CorrectableRecs.Add(SmesRec);
                    }
                }
            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;

                return(retMsg);
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("學期分項成績零值筆數:" + RATRecs.Count);

            var SortedRATRecords = from RATRecord in RATRecs orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord;

            retMsg.Message = strBuilder.ToString();
            retMsg.Data    = SortedRATRecords.ToList();

            return(retMsg);
        }
Exemplo n.º 10
0
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage Message = new DataRationalityMessage();

            QueryHelper Helper = new QueryHelper();

            RATRecords.Clear();
            RATRecords = Helper.Select <EmptySCETakeScoreRATRecord>();

            List <DisplayEmptySCETakeScoreRATRecord> DisplayRecords = new List <DisplayEmptySCETakeScoreRATRecord>();

            try
            {
                Dictionary <string, CourseRecord> Courses = Course
                                                            .SelectByIDs(RATRecords.Select(x => x.課程系統編號)
                                                                         .Distinct())
                                                            .ToDictionary(x => x.ID);

                Dictionary <string, StudentRecord> Students = Student
                                                              .SelectByIDs(RATRecords.Select(x => x.學生系統編號)
                                                                           .Distinct())
                                                              .ToDictionary(x => x.ID);
                Dictionary <string, ClassRecord> Classes = Class
                                                           .SelectAll()
                                                           .ToDictionary(x => x.ID);

                foreach (EmptySCETakeScoreRATRecord record in RATRecords)
                {
                    if (Students.ContainsKey(record.學生系統編號))
                    {
                        record.學號 = Students[record.學生系統編號].StudentNumber;
                        record.姓名 = Students[record.學生系統編號].Name;
                        record.狀態 = Students[record.學生系統編號].StatusStr;
                        record.座號 = K12.Data.Int.GetString(Students[record.學生系統編號].SeatNo);
                        record.班級 = Classes[Students[record.學生系統編號].RefClassID].Name;
                    }

                    if (Courses.ContainsKey(record.課程系統編號))
                    {
                        record.學年度  = K12.Data.Int.GetString(Courses[record.課程系統編號].SchoolYear);
                        record.學期   = K12.Data.Int.GetString(Courses[record.課程系統編號].Semester);
                        record.課程名稱 = Courses[record.課程系統編號].Name;
                    }

                    record.自動修正建議 = "刪除此筆平時評量(於定期評量)記錄。";

                    DisplayEmptySCETakeScoreRATRecord DisplayRecord = new DisplayEmptySCETakeScoreRATRecord();

                    DisplayRecord.平時評量成績           = record.平時評量成績;
                    DisplayRecord.平時評量努力程度         = record.平時評量努力程度;
                    DisplayRecord.定期評量設定中含平時評量成績   = record.定期評量設定中含平時評量成績;
                    DisplayRecord.定期評量設定中含平時評量努力程度 = record.定期評量設定中含平時評量努力程度;
                    DisplayRecord.自動修正建議           = record.自動修正建議;
                    DisplayRecord.姓名     = record.姓名;
                    DisplayRecord.狀態     = record.狀態;
                    DisplayRecord.座號     = record.座號;
                    DisplayRecord.班級     = record.班級;
                    DisplayRecord.課程名稱   = record.課程名稱;
                    DisplayRecord.學年度    = record.學年度;
                    DisplayRecord.學期     = record.學期;
                    DisplayRecord.學號     = record.學號;
                    DisplayRecord.評量系統編號 = record.評量系統編號;

                    DisplayRecords.Add(DisplayRecord);
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(e.Message);
            }

            var SortedDisplayRecords = from DisplayRecord in DisplayRecords orderby DisplayRecord.課程名稱, DisplayRecord.狀態, DisplayRecord.班級, K12.Data.Int.ParseAllowNull(DisplayRecord.座號) select DisplayRecord;

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查問題筆數:" + DisplayRecords.Count);
            strBuilder.AppendLine("自動修正建議:刪除平時評量(於定期評量)記錄。");

            Message.Data    = SortedDisplayRecords.ToList();
            Message.Message = strBuilder.ToString();

            return(Message);
        }
        /// <summary>
        /// 檢查
        /// </summary>
        public DataRationalityMessage Execute()
        {
            RATRecords.Clear();
            AssnciationDic.Clear();
            CourseDic.Clear();

            DataRationalityMessage Message = new DataRationalityMessage();

            List <AssnAddress> AssnciationAddressList = _accessHelper.Select <AssnAddress>();

            List <string> CourseIDList = new List <string>();

            foreach (AssnAddress each in AssnciationAddressList)
            {
                if (each.Address == "")
                {
                    //目的是後續要取得該課程
                    if (!CourseIDList.Contains(each.AssociationID))
                    {
                        CourseIDList.Add(each.AssociationID);
                    }

                    //建立對照清單
                    if (!AssnciationDic.ContainsKey(each.UID))
                    {
                        AssnciationDic.Add(each.UID, each);
                    }
                }
            }

            foreach (JHCourseRecord each in JHCourse.SelectByIDs(CourseIDList))
            {
                if (!CourseDic.ContainsKey(each.ID))
                {
                    CourseDic.Add(each.ID, each);
                }
            }

            foreach (AssnAddress each in AssnciationAddressList)
            {
                if (each.Address == "")
                {
                    AssociationAddressRATRecord AArat = new AssociationAddressRATRecord();
                    AArat.社團系統編號 = each.AssociationID;
                    AArat.課學年度   = each.SchoolYear;
                    AArat.課學期    = each.Semester;
                    AArat.課地點    = each.Address;
                    AArat.課地點UID = each.UID;
                    if (CourseDic.ContainsKey(each.AssociationID))
                    {
                        AArat.社團名稱  = CourseDic[each.AssociationID].Name;
                        AArat.社團學年度 = CourseDic[each.AssociationID].SchoolYear.HasValue ? CourseDic[each.AssociationID].SchoolYear.Value.ToString() : "";
                        AArat.社團學期  = CourseDic[each.AssociationID].Semester.HasValue ? CourseDic[each.AssociationID].Semester.Value.ToString() : "";
                    }
                    RATRecords.Add(AArat);
                }
            }

            //錯誤說明
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查(上課地點)筆數:" + _accessHelper.Select <AssnAddress>().Count);
            strBuilder.AppendLine("空值(上課地點)筆數:" + RATRecords.Count);
            strBuilder.AppendLine("(您可以匯出Excel以保存資料,再進行自動修正!!)");

            var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.社團名稱, RATRecord.社團系統編號, RATRecord.課學年度, RATRecord.課學期 select RATRecord;

            Message.Data    = SortedRATRecords.ToList();
            Message.Message = strBuilder.ToString();

            if (RATRecords.Count == 0)
            {
                MsgBox.Show("未檢查到錯誤資料!!");
            }

            return(Message);
        }
        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);
        }
Exemplo n.º 13
0
        public DataRationalityMessage Execute()
        {
            RATList.Clear();
            DataRationalityMessage Message           = new DataRationalityMessage();
            List <string>          Err_StudentIDList = new List <string>();

            try
            {
                // 取得學生基本
                List <SHStudentRecord> StudRecListAll = SHStudent.SelectAll();

                Dictionary <string, SHStudentRecord> StudRecDict = new Dictionary <string, SHStudentRecord>();

                foreach (SHStudentRecord rec in StudRecListAll)
                {
                    if (rec.Status == K12.Data.StudentRecord.StudentStatus.一般 || rec.Status == K12.Data.StudentRecord.StudentStatus.延修)
                    {
                        StudRecDict.Add(rec.ID, rec);
                    }
                }

                Err_StudentIDList = StudRecDict.Keys.ToList();

                // 檢查並取得資料,status 1 一般,2 延俢

                if (Err_StudentIDList.Count > 0)
                {
                    // 取得學生科目成績
                    List <SHSemesterScoreRecord> SHSemScoreList = SHSemesterScore.SelectByStudentIDs(Err_StudentIDList);

                    // 學生科目成績索引,StudentID,
                    Dictionary <string, List <ssSHSubjectScore> > SHSubjScoreDict = new Dictionary <string, List <ssSHSubjectScore> >();

                    foreach (SHSemesterScoreRecord SemsRec in SHSemScoreList)
                    {
                        if (!SHSubjScoreDict.ContainsKey(SemsRec.RefStudentID))
                        {
                            SHSubjScoreDict.Add(SemsRec.RefStudentID, new List <ssSHSubjectScore>());
                        }

                        foreach (SHSubjectScore ss in SemsRec.Subjects.Values)
                        {
                            ssSHSubjectScore sss = new ssSHSubjectScore();
                            sss.ss         = ss;
                            sss.SchoolYear = SemsRec.SchoolYear.ToString();
                            sss.Semester   = SemsRec.Semester.ToString();
                            sss.GradeYear  = SemsRec.GradeYear.ToString();
                            SHSubjScoreDict[SemsRec.RefStudentID].Add(sss);
                        }
                    }

                    Dictionary <string, List <ssSHSubjectScore> > ssSubjDict = new Dictionary <string, List <ssSHSubjectScore> >();
                    // 檢查 科目名稱及級別重覆
                    foreach (string studID in SHSubjScoreDict.Keys)
                    {
                        ssSubjDict.Clear();

                        foreach (ssSHSubjectScore ss1 in SHSubjScoreDict[studID])
                        {
                            string key = ss1.ss.Subject;
                            if (ss1.ss.Level.HasValue)
                            {
                                key += ss1.ss.Subject + ss1.ss.Level.Value;
                            }

                            if (!ssSubjDict.ContainsKey(key))
                            {
                                ssSubjDict.Add(key, new List <ssSHSubjectScore>());
                            }

                            ssSubjDict[key].Add(ss1);
                        }

                        if (StudRecDict.ContainsKey(studID))
                        {
                            foreach (string ssid in ssSubjDict.Keys)
                            {
                                // 有相同2個以上
                                if (ssSubjDict[ssid].Count > 1)
                                {
                                    foreach (ssSHSubjectScore ssScore in ssSubjDict[ssid])
                                    {
                                        SubjectNameDb snb = new SubjectNameDb();
                                        snb.學生系統編號 = studID;
                                        snb.科目名稱   = ssScore.ss.Subject;
                                        snb.科目級別   = "";
                                        if (ssScore.ss.Level.HasValue)
                                        {
                                            snb.科目級別 = ssScore.ss.Level.Value.ToString();
                                        }

                                        snb.座號 = "";
                                        if (StudRecDict[studID].SeatNo.HasValue)
                                        {
                                            snb.座號 = StudRecDict[studID].SeatNo.Value.ToString();
                                        }

                                        if (StudRecDict[studID].Class != null)
                                        {
                                            snb.班級 = StudRecDict[studID].Class.Name;
                                        }

                                        snb.學生姓名 = StudRecDict[studID].Name;
                                        snb.學年度  = ssScore.SchoolYear;
                                        snb.學期   = ssScore.Semester;
                                        snb.年級   = ssScore.GradeYear;
                                        snb.學號   = StudRecDict[studID].StudentNumber;

                                        RATList.Add(snb);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message.Message = ex.Message;
                return(Message);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("(學期科目名稱+科目級別)有重覆紀錄筆數: " + RATList.Count + " 筆");

            Message.Message = sb.ToString();
            // 排序
            var SortedRATRecords = from RATRecord in RATList orderby RATRecord.學號, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.科目名稱, RATRecord.科目級別, RATRecord.學年度, RATRecord.學期 select RATRecord;

            Message.Data = SortedRATRecords.ToList();

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            RATList.Clear();
            DataRationalityMessage Message           = new DataRationalityMessage();
            List <string>          Err_StudentIDList = new List <string>();

            try
            {
                // 檢查並取得資料,status 1 一般,2 延俢
                QueryHelper qh_Err       = new QueryHelper();
                string      strQuery_Err = "select student.id as sid,student.student_number,student.name,course.school_year,course.semester,course.subject,course.subj_level,count(sc_attend.id) as ssid from student inner join sc_attend on student.id = sc_attend.ref_student_id inner join course on course.id=sc_attend.ref_course_id  where student.status in(1,2)  and course.subject <>'' group by sid,student.student_number,student.name,school_year,semester,subject,course.subj_level having count(sc_attend.id)>1";
                DataTable   dt_Err       = qh_Err.Select(strQuery_Err);
                foreach (DataRow dr in dt_Err.Rows)
                {
                    string StudentID = dr["sid"].ToString();
                    if (!Err_StudentIDList.Contains(StudentID))
                    {
                        Err_StudentIDList.Add(StudentID);
                    }
                }

                if (Err_StudentIDList.Count > 0)
                {
                    // 使用找到有疑問StudentID透過Query反查相關呈現資料
                    QueryHelper qh_Data = new QueryHelper();
                    // -- 欄位:學生系統編號、學號、年級、班級、座號、學生姓名、學年度、學期、課程系統編號、課程名稱、科目名稱,科目級別
                    string    strQueryData = "select student.id as sid,student.student_number,class.grade_year,class.class_name,student.seat_no,student.name,course.school_year,course.semester,course.id as coid,course.course_name,course.subject,course.subj_level from student inner join sc_attend on student.id = sc_attend.ref_student_id inner join course on course.id=sc_attend.ref_course_id left join class on student.ref_class_id=class.id where course.subject <>'' and student.id in(" + string.Join(",", Err_StudentIDList.ToArray()) + ")";
                    DataTable dt_Data      = qh_Data.Select(strQueryData);

                    // 比對資料並填入
                    foreach (DataRow drd in dt_Data.Rows)
                    {
                        foreach (DataRow dre in dt_Err.Rows)
                        {
                            // sid,school_year,semester,subject
                            if (dre["sid"].ToString() == drd["sid"].ToString() && dre["school_year"].ToString() == drd["school_year"].ToString() && dre["semester"].ToString() == drd["semester"].ToString() && dre["subject"].ToString() == drd["subject"].ToString() && dre["subj_level"].ToString() == drd["subj_level"].ToString())
                            {
                                CourseSubjectNameDb csnd = new CourseSubjectNameDb();
                                csnd.班級     = drd["class_name"].ToString();
                                csnd.課程系統編號 = drd["coid"].ToString();
                                csnd.課程名稱   = drd["course_name"].ToString();
                                csnd.年級     = drd["grade_year"].ToString();
                                csnd.學年度    = drd["school_year"].ToString();
                                csnd.座號     = drd["seat_no"].ToString();
                                csnd.學期     = drd["semester"].ToString();
                                csnd.學生系統編號 = drd["sid"].ToString();
                                csnd.學生姓名   = drd["name"].ToString();
                                csnd.學號     = drd["student_number"].ToString();
                                csnd.科目名稱   = drd["subject"].ToString();
                                csnd.科目級別   = drd["subj_level"].ToString();
                                RATList.Add(csnd);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message.Message = ex.Message;
                return(Message);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("有重覆俢課紀錄筆數: " + RATList.Count + " 筆");

            Message.Message = sb.ToString();
            // 排序
            var SortedRATRecords = from RATRecord in RATList orderby RATRecord.年級, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期, RATRecord.科目名稱 select RATRecord;

            Message.Data = SortedRATRecords.ToList();

            return(Message);
        }
Exemplo n.º 15
0
        public DataRationalityMessage Execute()
        {
            //初始化

            DataRationalityMessage Message = new DataRationalityMessage();

            CorrectableUpdateRecords.Clear();
            DisplayRecords.Clear();
            StudentRecords.Clear();

            //取得所有異動記錄,並篩選出轉入異動(異動代碼為3)以及新生異動(異動代碼為1)
            IEnumerable <JHUpdateRecordRecord> UpdateRecords = JHUpdateRecord.SelectAll().Where(x => x.UpdateCode.Equals("3") || x.UpdateCode.Equals("1"));

            //取得異動記錄對應的學生資料
            StudentRecords = Student.SelectByIDs(UpdateRecords.Select(x => x.StudentID).Distinct()).ToDictionary(x => x.ID);

            foreach (var StudentUpdateRecords in UpdateRecords.GroupBy(x => x.StudentID))
            {
                //將異動記錄排序
                List <JHUpdateRecordRecord> OrderedStudentUpdateRecords = StudentUpdateRecords.OrderBy(x => x.UpdateCode).ToList();

                //判斷只有2筆異動記錄的情況,其中1筆為『新生異動』,另外1筆為『轉入異動』
                if (OrderedStudentUpdateRecords.Count == 2 && OrderedStudentUpdateRecords[0].UpdateCode.Equals("1") && OrderedStudentUpdateRecords[1].UpdateCode.Equals("3"))
                {
                    CorrectableUpdateRecords.Add(OrderedStudentUpdateRecords[0]);

                    StudentImportNewUpdateRecordMixRATRecord DisplayRecord = new StudentImportNewUpdateRecordMixRATRecord();

                    string StudentID = OrderedStudentUpdateRecords[1].StudentID;

                    if (StudentRecords.ContainsKey(StudentID))
                    {
                        DisplayRecord.學生系統編號 = StudentRecords[StudentID].ID;
                        DisplayRecord.學號     = StudentRecords[StudentID].StudentNumber;
                        DisplayRecord.身分證號   = StudentRecords[StudentID].IDNumber;
                        DisplayRecord.班級     = StudentRecords[StudentID].Class != null ? StudentRecords[StudentID].Class.Name : string.Empty;
                        DisplayRecord.座號     = K12.Data.Int.GetString(StudentRecords[StudentID].SeatNo);
                        DisplayRecord.姓名     = StudentRecords[StudentID].Name;
                        DisplayRecord.狀態     = StudentRecords[StudentID].StatusStr;
                    }

                    DisplayRecord.異動日期  = OrderedStudentUpdateRecords[1].UpdateDate;
                    DisplayRecord.異動類別  = "轉入";
                    DisplayRecord.原因及事項 = OrderedStudentUpdateRecords[1].UpdateDescription;
                    DisplayRecord.轉入前學校 = OrderedStudentUpdateRecords[1].ImportExportSchool;
                    DisplayRecord.說明    = "該生為轉入生也有新生異動";

                    DisplayRecords.Add(DisplayRecord);
                }
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查筆數:" + UpdateRecords.Count());
            strBuilder.AppendLine("問題筆數:" + DisplayRecords.Count());

            if (DisplayRecords.Count > 0)
            {
                strBuilder.AppendLine("建議修正方案:");
                strBuilder.AppendLine("1.將學生加入至待處理,手動刪除學生的新生異動。");
                strBuilder.AppendLine("2.運用本合理性檢查自動修正功能,將學生的新生異動批次刪除。");
                strBuilder.AppendLine("3.若您運用本合理性檢查自動修正功能,建議先單選1位學生進行嘗試,確認正確刪除後並有存入日誌再進行批次作業。");
            }

            var OrderedDisplayRecords = from record in DisplayRecords orderby record.狀態, record.班級, K12.Data.Int.ParseAllowNull(record.座號) select record;

            Message.Data    = OrderedDisplayRecords.ToList();
            Message.Message = strBuilder.ToString();

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            DataRationalityMessage Message = new DataRationalityMessage();

            QueryHelper Helper = new QueryHelper();

            RATRecords.Clear();
            RATRecords = Helper.Select <SCETakeScoreRATRecord>();

            List <DisplaySCETakeScoreRATRecord> DisplayRecords = new List <DisplaySCETakeScoreRATRecord>();

            try
            {
                Dictionary <string, CourseRecord> Courses = Course
                                                            .SelectByIDs(RATRecords.Select(x => x.課程系統編號)
                                                                         .Distinct())
                                                            .ToDictionary(x => x.ID);

                Dictionary <string, StudentRecord> Students = Student
                                                              .SelectByIDs(RATRecords.Select(x => x.學生系統編號)
                                                                           .Distinct())
                                                              .ToDictionary(x => x.ID);
                Dictionary <string, ClassRecord> Classes = Class.SelectAll().ToDictionary(x => x.ID);

                foreach (SCETakeScoreRATRecord record in RATRecords)
                {
                    if (Students.ContainsKey(record.學生系統編號))
                    {
                        record.學號 = Students[record.學生系統編號].StudentNumber;
                        record.姓名 = Students[record.學生系統編號].Name;
                        record.狀態 = Students[record.學生系統編號].StatusStr;
                        record.座號 = K12.Data.Int.GetString(Students[record.學生系統編號].SeatNo);
                        record.班級 = Classes.ContainsKey(Students[record.學生系統編號].RefClassID)?Classes[Students[record.學生系統編號].RefClassID].Name:string.Empty;
                    }

                    if (Courses.ContainsKey(record.課程系統編號))
                    {
                        record.學年度  = K12.Data.Int.GetString(Courses[record.課程系統編號].SchoolYear);
                        record.學期   = K12.Data.Int.GetString(Courses[record.課程系統編號].Semester);
                        record.課程名稱 = Courses[record.課程系統編號].Name;
                    }

                    if (string.IsNullOrEmpty(record.平時評量成績))
                    {
                        record.自動修正建議 = "1.『定期評量設定中含平時評量成績』有資料,而『平時評量成績』無資料,『自動修正』將前者資料複蓋到後者,並將前者資料清空。";
                    }
                    else if (record.定期評量設定中含平時評量成績.Equals(record.平時評量成績))
                    {
                        record.自動修正建議 = "2.『定期評量設定中含平時評量成績』等於『平時評量成績』,『自動修正』將前者資料清空。";
                    }
                    else if (!record.定期評量設定中含平時評量成績.Equals(record.平時評量成績))
                    {
                        record.自動修正建議 = "3.『定期評量設定中含平時評量成績』不等於『平時評量成績』,建議先手動核對後者正確性,再『自動修正』將前者資料清空。";
                    }

                    DisplaySCETakeScoreRATRecord DisplayRecord = new DisplaySCETakeScoreRATRecord();

                    DisplayRecord.平時評量成績           = record.平時評量成績;
                    DisplayRecord.平時評量努力程度         = record.平時評量努力程度;
                    DisplayRecord.自動修正建議           = record.自動修正建議;
                    DisplayRecord.姓名               = record.姓名;
                    DisplayRecord.定期評量設定中含平時評量成績   = record.定期評量設定中含平時評量成績;
                    DisplayRecord.定期評量設定中含平時評量努力程度 = record.定期評量設定中含平時評量努力程度;
                    DisplayRecord.狀態               = record.狀態;
                    DisplayRecord.座號               = record.座號;
                    DisplayRecord.班級               = record.班級;
                    DisplayRecord.評量系統編號           = record.評量系統編號;
                    DisplayRecord.課程名稱             = record.課程名稱;
                    DisplayRecord.學年度              = record.學年度;
                    DisplayRecord.學期               = record.學期;
                    DisplayRecord.學號               = record.學號;

                    DisplayRecords.Add(DisplayRecord);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            var SortedDisplayRecords = from DisplayRecord in DisplayRecords orderby DisplayRecord.課程名稱, DisplayRecord.狀態, DisplayRecord.班級, K12.Data.Int.ParseAllowNull(DisplayRecord.座號) select DisplayRecord;

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查問題筆數:" + RATRecords.Count);
            strBuilder.AppendLine("自動修正建議(狀況3請您務必核對資料後再進行修正):");
            strBuilder.AppendLine("1.『定期評量設定中含平時評量成績』有資料,而『平時評量成績』無資料,『自動修正』將前者資料複蓋到後者,並將前者資料清空。");
            strBuilder.AppendLine("2.『定期評量設定中含平時評量成績』等於『平時評量成績』,『自動修正』將前者資料清空。");
            strBuilder.AppendLine("3.『定期評量設定中含平時評量成績』不等於『平時評量成績』,建議先手動核對後者正確性,再『自動修正』將前者資料清空。");

            Message.Data    = SortedDisplayRecords.ToList();
            Message.Message = strBuilder.ToString();

            return(Message);
        }
        public DataRationalityMessage Execute()
        {
            RATRecs.Clear();

            // 沒成績
            List <CheckStudentSemHistoryScoreRATRec> noScore = new List <CheckStudentSemHistoryScoreRATRec>();
            // 沒學期歷程
            List <CheckStudentSemHistoryScoreRATRec> noHistory = new List <CheckStudentSemHistoryScoreRATRec>();

            // Query: 取得學生有學期成績的學年度、學期
            QueryHelper Helper  = new QueryHelper();
            string      strSQL  = "select ref_student_id,school_year,semester from sems_subj_score where score_info like '%成績%' order by ref_student_id,school_year,semester";
            DataTable   dtScore = Helper.Select(strSQL);
            Dictionary <string, List <string> > studScoreScDict   = new Dictionary <string, List <string> >();
            Dictionary <string, List <string> > studHistoryScDict = new Dictionary <string, List <string> >();

            foreach (DataRow d in dtScore.Rows)
            {
                string ID  = d[0].ToString();
                string val = d[1].ToString() + "," + d[2].ToString();

                if (studScoreScDict.ContainsKey(ID))
                {
                    studScoreScDict[ID].Add(val);
                }
                else
                {
                    List <string> strList = new List <string>();
                    strList.Add(val);
                    studScoreScDict.Add(ID, strList);
                }
            }

            // 取得所有學生
            List <JHStudentRecord> studRecList = JHStudent.SelectAll();

            // 取得學生學習歷程
            Dictionary <string, List <K12.Data.SemesterHistoryItem> > SHistoryDict = new Dictionary <string, List <K12.Data.SemesterHistoryItem> >();

            foreach (JHSemesterHistoryRecord rec in JHSemesterHistory.SelectAll())
            {
                foreach (K12.Data.SemesterHistoryItem shi in rec.SemesterHistoryItems)
                {
                    string val = shi.SchoolYear.ToString() + "," + shi.Semester.ToString();
                    if (studHistoryScDict.ContainsKey(shi.RefStudentID))
                    {
                        studHistoryScDict[shi.RefStudentID].Add(val);
                    }
                    else
                    {
                        List <string> strList = new List <string>();
                        strList.Add(val);
                        studHistoryScDict.Add(shi.RefStudentID, strList);
                    }
                }
            }


            DataRationalityMessage retMsg = new DataRationalityMessage();

            try
            {
                foreach (JHStudentRecord studRec in studRecList)
                {
                    // 依學期歷程為主
                    if (studHistoryScDict.ContainsKey(studRec.ID))
                    {
                        if (studScoreScDict.ContainsKey(studRec.ID))
                        {
                            foreach (string str in studHistoryScDict[studRec.ID])
                            {
                                if (!studScoreScDict[studRec.ID].Contains(str))
                                {
                                    CheckStudentSemHistoryScoreRATRec rec1 = new CheckStudentSemHistoryScoreRATRec();
                                    rec1.身分證號 = studRec.IDNumber;
                                    rec1.姓名   = studRec.Name;
                                    rec1.狀態   = studRec.StatusStr;
                                    if (studRec.SeatNo.HasValue)
                                    {
                                        rec1.座號 = studRec.SeatNo.Value.ToString();
                                    }
                                    if (studRec.Class != null)
                                    {
                                        rec1.班級 = studRec.Class.Name;
                                    }
                                    rec1.說明     = "有學期歷程沒有成績";
                                    rec1.學生系統編號 = studRec.ID;
                                    rec1.學號     = studRec.StudentNumber;
                                    string[] ss = str.Split(',').ToArray();
                                    if (ss.Length > 1)
                                    {
                                        rec1.學年度 = ss[0];
                                        rec1.學期  = ss[1];
                                    }
                                    noScore.Add(rec1);
                                }
                            }
                        }
                    }


                    // 依學期成績為主
                    if (studScoreScDict.ContainsKey(studRec.ID))
                    {
                        if (studHistoryScDict.ContainsKey(studRec.ID))
                        {
                            foreach (string str in studScoreScDict[studRec.ID])
                            {
                                if (!studHistoryScDict[studRec.ID].Contains(str))
                                {
                                    CheckStudentSemHistoryScoreRATRec rec1 = new CheckStudentSemHistoryScoreRATRec();
                                    rec1.身分證號 = studRec.IDNumber;
                                    rec1.姓名   = studRec.Name;
                                    rec1.狀態   = studRec.StatusStr;
                                    if (studRec.SeatNo.HasValue)
                                    {
                                        rec1.座號 = studRec.SeatNo.Value.ToString();
                                    }
                                    if (studRec.Class != null)
                                    {
                                        rec1.班級 = studRec.Class.Name;
                                    }
                                    rec1.說明     = "沒有學期歷程有成績";
                                    rec1.學生系統編號 = studRec.ID;
                                    rec1.學號     = studRec.StudentNumber;
                                    string[] ss = str.Split(',').ToArray();
                                    if (ss.Length > 1)
                                    {
                                        rec1.學年度 = ss[0];
                                        rec1.學期  = ss[1];
                                    }
                                    noHistory.Add(rec1);
                                }
                            }
                        }
                    }
                }
                RATRecs.AddRange(noHistory);
                RATRecs.AddRange(noScore);
                int no;
                var sortedRATRecs = from rec in RATRecs orderby rec.狀態, rec.班級, int.TryParse(rec.座號, out no), rec.學年度, rec.學期 select rec;
                retMsg.Message = "有學期歷程沒有成績共" + noScore.Count + "筆,沒有學期歷程有成績共" + noHistory.Count + "筆。";
                retMsg.Data    = sortedRATRecs.ToList();
            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;
                return(retMsg);
            }

            return(retMsg);
        }
        public DataRationalityMessage Execute()
        {
            QueryHelper Helper = new QueryHelper();

            List <string> StudentIDs = new List <string>();

            DataTable StudentIDTable = Helper.Select("select ref_student_id from sems_subj_score where score_info like'%<SemesterSubjectScoreInfo/>%'  and score_info like'%<Domains/>%' and score_info like'%<LearnDomainScore/>%'");

            for (int i = 0; i < StudentIDTable.Rows.Count; i++)
            {
                StudentIDs.Add("" + StudentIDTable.Rows[i][0]);
            }

            List <JHSemesterScoreRecord> SemsScoreList = JHSemesterScore.SelectByStudentIDs(StudentIDs);

            CorrectableRecs.Clear();
            RATRecs.Clear();
            DataRationalityMessage retMsg = new DataRationalityMessage();

            try
            {
                foreach (JHSemesterScoreRecord SmesRec in SemsScoreList)
                {
                    if (SmesRec.Subjects.Count == 0 && SmesRec.Domains.Count == 0)
                    {
                        EmptySemesterScoreRATRec rec = new EmptySemesterScoreRATRec();
                        rec.學期成績系統編號 = SmesRec.ID;
                        rec.學生系統編號   = SmesRec.RefStudentID;
                        rec.身分證號     = SmesRec.Student.IDNumber;
                        rec.姓名       = SmesRec.Student.Name;
                        rec.狀態       = SmesRec.Student.StatusStr;
                        rec.座號       = K12.Data.Int.GetString(SmesRec.Student.SeatNo);
                        if (SmesRec.Student.Class != null)
                        {
                            rec.班級 = SmesRec.Student.Class.Name;
                        }
                        rec.學年度 = SmesRec.SchoolYear.ToString();
                        rec.學期  = SmesRec.Semester.ToString();
                        rec.學號  = SmesRec.Student.StudentNumber;

                        RATRecs.Add(rec);
                        CorrectableRecs.Add(SmesRec);
                    }
                }
            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;

                return(retMsg);
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學期成績筆數:" + SemsScoreList.Count);
            strBuilder.AppendLine("學期科目與領域成績空值筆數:" + RATRecs.Count);

            var SortedRATRecords = from RATRecord in RATRecs orderby RATRecord.狀態, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord;

            retMsg.Message = strBuilder.ToString();
            retMsg.Data    = SortedRATRecords.ToList();

            return(retMsg);
        }
        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);
        }