Esempio n. 1
0
        /// <summary>
        /// 使用SQL傳入學年度、學期、學生系統編號,取得學生修課紀錄,目的在處理 K12 無法透過這條件,需要SelectAll學生修課造成記憶體不足。
        /// </summary>
        /// <param name="SchoolYear"></param>
        /// <param name="Semester"></param>
        /// <param name="StudentIDs"></param>
        /// <returns></returns>
        public static List <JHSCAttendRecord> GetSCAttendRecordListBySchoolYearSemsStudentIDs(int SchoolYear, int Semester, List <string> StudentIDs)
        {
            List <JHSCAttendRecord> value = new List <JHSCAttendRecord>();

            string qry = "SELECT " +
                         "sc_attend.id" +
                         " FROM" +
                         " sc_attend" +
                         " INNER JOIN" +
                         " course" +
                         " ON sc_attend.ref_course_id = course.id" +
                         " WHERE sc_attend.ref_student_id IN(" + string.Join(",", StudentIDs.ToArray()) + ") AND course.school_year = " + SchoolYear + " AND course.semester = " + Semester;

            QueryHelper   qh1      = new QueryHelper();
            DataTable     dt       = qh1.Select(qry);
            List <string> scIDList = new List <string>();

            foreach (DataRow dr in dt.Rows)
            {
                scIDList.Add(dr["id"] + "");
            }

            value = JHSCAttend.SelectByIDs(scIDList);

            // 節省記憶體
            dt = null;
            GC.Collect();

            return(value);
        }
        public void ExecuteAutoCorrect(IEnumerable <string> EntityIDs)
        {
            int AutoCorrectCount1 = 0;
            int AutoCorrectCount2 = 0;
            int AutoCorrectCount3 = 0;

            StringBuilder strLogDetail = new StringBuilder();

            List <SCETakeScoreRATRecord> SelectedRATRecords = EntityIDs == null ?
                                                              RATRecords : RATRecords.Where(x => EntityIDs.Contains(x.評量系統編號)).ToList();

            Dictionary <string, JHSCETakeRecord> UpdatedSCETakeRecords = JHSCETake
                                                                         .Select(null, null, null, SelectedRATRecords.Select(x => x.評量系統編號), null)
                                                                         .ToDictionary(x => x.ID);

            List <SCETakeScoreRATRecord> SCRecords = SelectedRATRecords
                                                     .FindAll(x => x.自動修正建議.StartsWith("1"));

            Dictionary <string, JHSCAttendRecord> UpdatedSCAttendRecords = new Dictionary <string, JHSCAttendRecord>();

            if (SCRecords.Count > 0)
            {
                UpdatedSCAttendRecords = JHSCAttend
                                         .SelectByIDs(SCRecords.Select(x => x.學生修課編號))
                                         .ToDictionary(x => x.ID);
            }

            try
            {
                foreach (SCETakeScoreRATRecord record in SelectedRATRecords)
                {
                    if (string.IsNullOrEmpty(record.平時評量成績))
                    {
                        strLogDetail.AppendLine("== SCETakeRecord:" + record.評量系統編號 + "、狀況一 ==");
                        strLogDetail.AppendLine(UpdatedSCETakeRecords[record.評量系統編號].ToString());

                        UpdatedSCAttendRecords[record.學生修課編號].OrdinarilyScore  = UpdatedSCETakeRecords[record.評量系統編號].Score;
                        UpdatedSCAttendRecords[record.學生修課編號].OrdinarilyEffort = UpdatedSCETakeRecords[record.評量系統編號].Effort;

                        UpdatedSCETakeRecords[record.評量系統編號].Score  = null;
                        UpdatedSCETakeRecords[record.評量系統編號].Effort = null;

                        AutoCorrectCount1++;
                    }
                    else if (record.定期評量設定中含平時評量成績.Equals(record.平時評量成績))
                    {
                        strLogDetail.AppendLine("== SCETakeRecord:" + record.評量系統編號 + "、狀況二 ==");
                        strLogDetail.AppendLine(UpdatedSCETakeRecords[record.評量系統編號].ToString());

                        UpdatedSCETakeRecords[record.評量系統編號].Score  = null;
                        UpdatedSCETakeRecords[record.評量系統編號].Effort = null;

                        AutoCorrectCount2++;
                    }
                    else if (!record.定期評量設定中含平時評量成績.Equals(record.平時評量成績))
                    {
                        strLogDetail.AppendLine("== SCETakeRecord:" + record.評量系統編號 + "、狀況三 ==");
                        strLogDetail.AppendLine(UpdatedSCETakeRecords[record.評量系統編號].ToString());

                        UpdatedSCETakeRecords[record.評量系統編號].Score  = null;
                        UpdatedSCETakeRecords[record.評量系統編號].Effort = null;

                        AutoCorrectCount3++;
                    }
                }

                StringBuilder strLog = new StringBuilder();

                strLog.AppendLine("自動修正將依照檢查結果建議值進行修正總共" + SelectedRATRecords.Count + "筆,強烈建議您務必將檢查結果匯出備份,是否進行自動修正?");
                strLog.AppendLine("1.『定期評量設定中含平時評量成績』有資料,而『平時評量成績』無資料,『自動修正』將前者資料複蓋到後者,並將前者資料清空。=>共" + AutoCorrectCount1 + "筆");
                strLog.AppendLine("2.『定期評量設定中含平時評量成績』等於『平時評量成績』,『自動修正』將前者資料清空。=>共" + AutoCorrectCount2 + "筆");
                strLog.AppendLine("3.『定期評量設定中含平時評量成績』不等於『平時評量成績』,建議先手動核對後者正確性,再『自動修正』將前者資料清空。=>共" + AutoCorrectCount3 + "筆");

                if (MsgBox.Show(strLog.ToString(), "您是否要進行自動修正?", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    strLog.AppendLine(strLogDetail.ToString());

                    if (UpdatedSCETakeRecords.Values.Count > 0)
                    {
                        JHSCETake.Update(UpdatedSCETakeRecords.Values);
                    }
                    if (UpdatedSCAttendRecords.Values.Count > 0)
                    {
                        JHSCAttend.Update(UpdatedSCAttendRecords.Values);
                    }

                    MsgBox.Show("已自動修正完成!若要再繼續修正,請重新執行本合理性檢查以確保取得最新資料!");
                    FISCA.LogAgent.ApplicationLog.Log("資料合理性檢查.平時評量成績輸入檢查", "平時評量成績輸入自動修正", strLog.ToString());
                }
            }
            catch (Exception e)
            {
                SmartSchool.ErrorReporting.ReportingService.ReportException(e);
                MsgBox.Show(e.Message);
            }
        }
Esempio n. 3
0
        void _bgWk_DoWork(object sender, DoWorkEventArgs e)
        {
            CourseScoreStatusFormOption Option = e.Argument as CourseScoreStatusFormOption;

            List <CourseScoreCountRecord> CourseScoreCountEntityList              = new List <CourseScoreCountRecord>();
            List <CourseScoreCountRecord> CourseScoreCountEntityListNonInput      = new List <CourseScoreCountRecord>();
            List <CourseScoreCountRecord> CourseScoreCountEntityListNonInputScore = new List <CourseScoreCountRecord>();

            // 處理取得這所選學年學期有課程id,name,修課id
            DAO.QueryData.ProcesstCourseNameStudentBySchoolYearSemester(Option.SchoolYear, Option.Semester);
            Dictionary <string, string> CourseIDNameDict = DAO.QueryData._CourseIDNameDict;
            List <JHSCAttendRecord>     SCAttendList     = JHSCAttend.SelectByIDs(DAO.QueryData._SCAttenndIDList);
            Dictionary <string, List <JHSCAttendRecord> > CourseSCAttendDict = new Dictionary <string, List <JHSCAttendRecord> >();

            foreach (JHSCAttendRecord rec in SCAttendList)
            {
                if (!CourseSCAttendDict.ContainsKey(rec.RefCourseID))
                {
                    CourseSCAttendDict.Add(rec.RefCourseID, new List <JHSCAttendRecord>());
                }

                CourseSCAttendDict[rec.RefCourseID].Add(rec);
            }

            // 取得課程授課教師
            Dictionary <string, string> CourseTeacherNameDict = DAO.QueryData.GetCourseTeacher(Option.SchoolYear, Option.Semester);

            #region 計算人數並組成回傳格式
            foreach (string CourseID in CourseIDNameDict.Keys)
            {
                CourseScoreCountRecord vCourseScoreCountRecord = new CourseScoreCountRecord();

                vCourseScoreCountRecord.CourseID   = CourseID;
                vCourseScoreCountRecord.CourseName = CourseIDNameDict[CourseID];
                if (CourseTeacherNameDict.ContainsKey(CourseID))
                {
                    vCourseScoreCountRecord.TeacherName = CourseTeacherNameDict[CourseID];
                }

                // 計算人數與有成績人數
                if (CourseSCAttendDict.ContainsKey(CourseID))
                {
                    foreach (JHSCAttendRecord rec in CourseSCAttendDict[CourseID])
                    {
                        vCourseScoreCountRecord.OraTotalEffortCount++;
                        vCourseScoreCountRecord.OraTotalScoreCount++;
                        vCourseScoreCountRecord.OraTotalTextCount++;

                        if (rec.OrdinarilyScore.HasValue)
                        {
                            vCourseScoreCountRecord.OraHasScoreCount++;
                        }
                        if (rec.OrdinarilyEffort.HasValue)
                        {
                            vCourseScoreCountRecord.OraHasEffortCount++;
                        }

                        if (Option.CheckText)
                        {
                            if (!string.IsNullOrEmpty(rec.Text))
                            {
                                vCourseScoreCountRecord.OraHasTextCount++;
                            }
                        }
                    }
                }


                if (Option.DisplayNotFinish == true && Option.CheckText == true)
                {
                    // 當勾選未輸入與需要檢查文字描述
                    if (vCourseScoreCountRecord.NonAllInputScore())
                    {
                        CourseScoreCountEntityListNonInput.Add(vCourseScoreCountRecord);
                    }
                }
                else if (Option.DisplayNotFinish == true && Option.CheckText == false)
                {
                    // 當勾選未輸入,不檢查文字描述
                    if (vCourseScoreCountRecord.NonInputScore())
                    {
                        CourseScoreCountEntityListNonInputScore.Add(vCourseScoreCountRecord);
                    }
                }
                else
                {
                    CourseScoreCountEntityList.Add(vCourseScoreCountRecord);
                }
            }

            if (CourseScoreCountEntityListNonInput.Count > 0)
            {
                e.Result = CourseScoreCountEntityListNonInput.OrderBy(x => x.CourseName).ToList();
            }

            if (CourseScoreCountEntityListNonInputScore.Count > 0)
            {
                e.Result = CourseScoreCountEntityListNonInputScore.OrderBy(x => x.CourseName).ToList();
            }

            if (CourseScoreCountEntityList.Count > 0)
            {
                e.Result = CourseScoreCountEntityList.OrderBy(x => x.CourseName).ToList();
            }


            #endregion
        }