Пример #1
0
        private Dictionary <string, List <SHMoralScoreRecord> > GetMoralScore(List <string> list)
        {
            Dictionary <string, List <SHMoralScoreRecord> > DicMoralScore = new Dictionary <string, List <SHMoralScoreRecord> >();
            //依學生ID取得所有文字評量物件
            List <SHMoralScoreRecord> ListMoralScore = SHMoralScore.SelectByStudentIDs(list);

            foreach (SHMoralScoreRecord Mscore in ListMoralScore)
            {
                if (!DicMoralScore.ContainsKey(Mscore.RefStudentID))
                {
                    DicMoralScore.Add(Mscore.RefStudentID, new List <SHMoralScoreRecord>());
                }
                DicMoralScore[Mscore.RefStudentID].Add(Mscore);
            }

            return(DicMoralScore);
        }
Пример #2
0
        /// <summary>
        /// 依學生學號資料
        /// 取得學生的日常生活表現資料
        /// </summary>
        private List <SHMoralScoreRecord> GetMoralScoreList(List <Campus.DocumentValidator.IRowStream> Rows)
        {
            //學號清單
            List <string> StudentNumberList = new List <string>();

            foreach (IRowStream Row in Rows)
            {
                string StudentNumber = Row.GetValue("學號");
                if (!StudentNumberList.Contains(StudentNumber))
                {
                    StudentNumberList.Add(StudentNumber);
                }
            }
            //比對學號&取得學生Record
            List <SHStudentRecord> importStudRecList = new List <SHStudentRecord>();

            foreach (SHStudentRecord each in SHStudent.SelectAll())
            {
                if (each.Status == StudentRecord.StudentStatus.刪除) //狀態為刪除者排除
                {
                    continue;
                }

                if (StudentNumberList.Contains(each.StudentNumber)) //包含於匯入資料"學號清單之學生
                {
                    importStudRecList.Add(each);

                    //建立學號比對學生Record字典
                    if (!StudentRecordByStudentNumber.ContainsKey(each.StudentNumber))
                    {
                        StudentRecordByStudentNumber.Add(each.StudentNumber, each);
                    }
                }
            }

            //取得學生ID
            List <string> StudentIDList = importStudRecList.Select(x => x.ID).ToList();

            //一次取得學生日常生活表現清單
            return(SHMoralScore.SelectByStudentIDs(StudentIDList));
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //電子報表
            string time = DateTime.Now.Hour.ToString().PadLeft(2) + DateTime.Now.Minute.ToString().PadLeft(2);

            paperForClass = new SmartSchool.ePaper.ElectronicPaper(string.Format("日常表現記錄表(新制_{0})", time), _Schoolyear.ToString(), _Semester.ToString(), SmartSchool.ePaper.ViewerType.Class);

            BGW.ReportProgress(1, "取得紙張設定");
            //取得列印紙張
            int sizeIndex = GetSizeIndex();

            BGW.ReportProgress(4, "取得假別設定");
            //取得列印假別內容
            Dictionary <string, List <string> > UserType = GetUserType();


            #region 取得資料

            //取得使用者選擇班級
            BGW.ReportProgress(8, "取得所選班級");
            List <ClassRecord> allClasses = Class.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource);
            //排序(因為上面沒有照班級排序)
            int displayOrder;
            allClasses = allClasses.OrderBy(i => i.GradeYear).ThenBy(i => displayOrder = Int32.TryParse(i.DisplayOrder, out displayOrder)? displayOrder :0).ThenBy(i => i.Name).ToList();



            #region 取得使用者所選擇的班級學生

            BGW.ReportProgress(12, "取得學生清單");
            string        classidlist = string.Join(",", K12.Presentation.NLDPanels.Class.SelectedSource);
            StringBuilder sb          = new StringBuilder();
            sb.Append("select student.id,student.ref_class_id from student ");
            sb.Append("join class on class.id=student.ref_class_id ");
            sb.Append("where student.status=1 ");
            sb.Append(string.Format("and class.id in ({0})", classidlist));

            List <string> StudentIDList = new List <string>();
            DataTable     dt            = _QueryHelper.Select(sb.ToString());
            foreach (DataRow row in dt.Rows)
            {
                StudentIDList.Add("" + row[0]);
            }

            BGW.ReportProgress(15, "取得學生清單");
            List <StudentRecord> allStudents = Student.SelectByIDs(StudentIDList);

            int maxStudents  = 0;
            int totalStudent = allStudents.Count;

            Dictionary <string, List <StudentRecord> > classStudents = new Dictionary <string, List <StudentRecord> >();
            foreach (StudentRecord each in allStudents)
            {
                if (!classStudents.ContainsKey(each.RefClassID))
                {
                    classStudents.Add(each.RefClassID, new List <StudentRecord>());
                }

                classStudents[each.RefClassID].Add(each);
            }

            foreach (string each in classStudents.Keys)
            {
                if (classStudents[each].Count > maxStudents)
                {
                    maxStudents = classStudents[each].Count;
                }

                classStudents[each].Sort(SortStudent);
            }
            #endregion


            Dictionary <string, RewardRecord> MeritDemeritAttDic   = new Dictionary <string, RewardRecord>();
            Dictionary <string, RewardRecord> TotalMeritDemeritDic = new Dictionary <string, RewardRecord>();

            BGW.ReportProgress(20, "取得獎勵資料");
            #region 獎勵

            foreach (SHMeritRecord each in SHMerit.SelectByStudentIDs(StudentIDList))
            {
                // 2018/1/8 羿均 新增 累計獎勵紀錄資料
                RewardRecord totalMerit = new RewardRecord();
                if (TotalMeritDemeritDic.ContainsKey(each.RefStudentID))
                {
                    totalMerit = TotalMeritDemeritDic[each.RefStudentID];
                }

                totalMerit.MeritACount += each.MeritA.HasValue ? each.MeritA.Value : 0;
                totalMerit.MeritBCount += each.MeritB.HasValue ? each.MeritB.Value : 0;
                totalMerit.MeritCCount += each.MeritC.HasValue ? each.MeritC.Value : 0;

                if (!TotalMeritDemeritDic.ContainsKey(each.RefStudentID))
                {
                    TotalMeritDemeritDic.Add(each.RefStudentID, totalMerit);
                }

                if (each.SchoolYear != _Schoolyear || each.Semester != _Semester)
                {
                    continue;
                }

                RewardRecord rr = new RewardRecord();

                if (MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    rr = MeritDemeritAttDic[each.RefStudentID];
                }

                rr.MeritACount += each.MeritA.HasValue ? each.MeritA.Value : 0;
                rr.MeritBCount += each.MeritB.HasValue ? each.MeritB.Value : 0;
                rr.MeritCCount += each.MeritC.HasValue ? each.MeritC.Value : 0;

                if (!MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    MeritDemeritAttDic.Add(each.RefStudentID, rr);
                }
            }
            #endregion

            BGW.ReportProgress(25, "取得懲戒資料");
            #region 懲戒
            foreach (SHDemeritRecord each in SHDemerit.SelectByStudentIDs(StudentIDList))
            {
                // 2018/1/8 羿均 新增 累計懲戒紀錄資料
                RewardRecord totalDemerit = new RewardRecord();

                if (each.Cleared == "是")
                {
                    continue;
                }

                if (TotalMeritDemeritDic.ContainsKey(each.RefStudentID))
                {
                    totalDemerit = TotalMeritDemeritDic[each.RefStudentID];
                }

                totalDemerit.DemeritACount += each.DemeritA.HasValue ? each.DemeritA.Value : 0;
                totalDemerit.DemeritBCount += each.DemeritB.HasValue ? each.DemeritB.Value : 0;
                totalDemerit.DemeritCCount += each.DemeritC.HasValue ? each.DemeritC.Value : 0;

                if (!TotalMeritDemeritDic.ContainsKey(each.RefStudentID))
                {
                    TotalMeritDemeritDic.Add(each.RefStudentID, totalDemerit);
                }

                if (each.SchoolYear != _Schoolyear || each.Semester != _Semester)
                {
                    continue;
                }

                RewardRecord rr = new RewardRecord();

                if (MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    rr = MeritDemeritAttDic[each.RefStudentID];
                }

                rr.DemeritACount += each.DemeritA.HasValue ? each.DemeritA.Value : 0;
                rr.DemeritBCount += each.DemeritB.HasValue ? each.DemeritB.Value : 0;
                rr.DemeritCCount += each.DemeritC.HasValue ? each.DemeritC.Value : 0;

                if (!MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    MeritDemeritAttDic.Add(each.RefStudentID, rr);
                }
            }
            #endregion

            BGW.ReportProgress(30, "取得節次對照");
            //取得節次對照表
            Dictionary <string, string> periodDic = new Dictionary <string, string>();
            foreach (PeriodMappingInfo var in PeriodMapping.SelectAll())
            {
                string name = var.Type;

                //取得對照表並且對照出節次->類別的清單(99/11/24 by dylan)
                if (!periodDic.ContainsKey(var.Name))
                {
                    periodDic.Add(var.Name, var.Type);
                }
            }

            BGW.ReportProgress(35, "取得缺曠資料");
            #region 缺曠
            foreach (SHAttendanceRecord each in SHAttendance.SelectByStudentIDs(StudentIDList))
            {
                if (each.SchoolYear != _Schoolyear || each.Semester != _Semester)
                {
                    continue;
                }

                RewardRecord rr = new RewardRecord();
                if (MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    rr = MeritDemeritAttDic[each.RefStudentID];
                }

                foreach (AttendancePeriod _Period in each.PeriodDetail)
                {
                    if (periodDic.ContainsKey(_Period.Period))
                    {
                        string typename = periodDic[_Period.Period] + "_" + _Period.AbsenceType;
                        if (rr.Attendance.ContainsKey(typename))
                        {
                            rr.Attendance[typename]++;
                        }
                        else
                        {
                            rr.Attendance.Add(typename, 1);
                        }
                    }
                }

                if (!MeritDemeritAttDic.ContainsKey(each.RefStudentID))
                {
                    MeritDemeritAttDic.Add(each.RefStudentID, rr);
                }
            }
            #endregion

            //日常表現資料
            BGW.ReportProgress(40, "取得日常表現");
            Dictionary <string, SHMoralScoreRecord> SHMoralScoreDic = new Dictionary <string, SHMoralScoreRecord>();
            foreach (SHMoralScoreRecord each in SHMoralScore.Select(null, StudentIDList, _Schoolyear, _Semester))
            {
                if (!SHMoralScoreDic.ContainsKey(each.RefStudentID))
                {
                    SHMoralScoreDic.Add(each.RefStudentID, each);
                }
            }

            //文字評量對照表
            BGW.ReportProgress(45, "取得文字評量");
            List <string> TextScoreList = new List <string>();
            SmartSchool.Customization.Data.SystemInformation.getField("文字評量對照表");
            System.Xml.XmlElement ElmTextScoreList = (System.Xml.XmlElement)SmartSchool.Customization.Data.SystemInformation.Fields["文字評量對照表"];
            foreach (System.Xml.XmlNode Node in ElmTextScoreList.SelectNodes("Content/Morality"))
            {
                TextScoreList.Add(Node.Attributes["Face"].InnerText);
            }

            #endregion

            #region 產生表格

            BGW.ReportProgress(50, "產生報表樣式");

            Workbook template  = new Workbook();
            Workbook prototype = new Workbook();

            //列印尺寸
            if (sizeIndex == 0)
            {
                template.Open(new MemoryStream(Properties.Resources.德行表現總表新制A3), FileFormatType.Excel2003);
            }
            else if (sizeIndex == 1)
            {
                template.Open(new MemoryStream(Properties.Resources.德行表現總表新制A4), FileFormatType.Excel2003);
            }
            else if (sizeIndex == 2)
            {
                template.Open(new MemoryStream(Properties.Resources.德行表現總表新制B4), FileFormatType.Excel2003);
            }

            prototype.Copy(template);

            Worksheet templateSheet  = template.Worksheets[0];
            Worksheet prototypeSheet = prototype.Worksheets[0];

            Range tempAbsence        = templateSheet.Cells.CreateRange(9, 1, true);
            Range tempScoreText      = templateSheet.Cells.CreateRange(10, 1, true);
            Range tempAfterOtherDiff = templateSheet.Cells.CreateRange(11, 1, true);
            Range oder = templateSheet.Cells.CreateRange(12, 1, true);

            Dictionary <string, int> columnIndexTable = new Dictionary <string, int>();

            Dictionary <string, List <string> > periodAbsence = new Dictionary <string, List <string> >();

            //紀錄獎懲的 Column Index
            columnIndexTable.Add("大功", 3);
            columnIndexTable.Add("小功", 4);
            columnIndexTable.Add("嘉獎", 5);
            columnIndexTable.Add("大過", 6);
            columnIndexTable.Add("小過", 7);
            columnIndexTable.Add("警告", 8);

            //缺曠
            int ptColIndex = 9;
            foreach (string var in UserType.Keys)
            {
                foreach (string absence in UserType[var])
                {
                    if (!periodAbsence.ContainsKey(var))
                    {
                        periodAbsence.Add(var, new List <string>());
                    }
                    if (!periodAbsence[var].Contains(absence))
                    {
                        periodAbsence[var].Add(absence);
                    }

                    prototypeSheet.Cells.CreateRange(ptColIndex, 1, true).Copy(tempAbsence);
                    ptColIndex += 1;
                }
            }

            ptColIndex = 9;
            foreach (string period in periodAbsence.Keys)
            {
                prototypeSheet.Cells.CreateRange(2, ptColIndex, 1, periodAbsence[period].Count).Merge();
                prototypeSheet.Cells[2, ptColIndex].PutValue(period);

                foreach (string absence in periodAbsence[period])
                {
                    prototypeSheet.Cells[3, ptColIndex].PutValue(absence);
                    columnIndexTable.Add(period + "_" + absence, ptColIndex);
                    ptColIndex++;
                }
            }

            if (ptColIndex > 9)
            {
                prototypeSheet.Cells.CreateRange(1, 9, 1, ptColIndex - 9).Merge();
                prototypeSheet.Cells[1, 9].PutValue("缺曠");
            }

            //用來調整Column寬度的定位
            int ColumnMax = ptColIndex;

            //文字評量
            foreach (string textscore in TextScoreList)
            {
                columnIndexTable.Add(textscore, ptColIndex);
                prototypeSheet.Cells.CreateRange(ptColIndex, 1, true).Copy(tempScoreText);
                prototypeSheet.Cells[4, ptColIndex].PutValue(textscore);
                ptColIndex++;
            }

            prototypeSheet.Cells[1, ptColIndex - TextScoreList.Count].PutValue("學生綜合表現");

            if ((ptColIndex - TextScoreList.Count > 0) && (TextScoreList.Count > 0))
            {
                prototypeSheet.Cells.CreateRange(1, ptColIndex - TextScoreList.Count, 3, TextScoreList.Count).Merge();
            }

            prototypeSheet.Cells.CreateRange(ptColIndex, 1, true).Copy(tempAfterOtherDiff);
            columnIndexTable.Add("評語", ptColIndex++);
            prototypeSheet.Cells.CreateRange(ptColIndex, 1, true).Copy(oder);
            columnIndexTable.Add("是否留察", ptColIndex++);

            //填入製表日期
            prototypeSheet.Cells[0, 0].PutValue("製表日期:" + DateTime.Today.ToShortDateString());

            //填入標題
            prototypeSheet.Cells.CreateRange(0, 3, 1, ptColIndex - 3).Merge();
            prototypeSheet.Cells[0, 3].PutValue(K12.Data.School.ChineseName + " " + _Schoolyear + " 學年度 " + ((_Semester == 1) ? "上" : "下") + " 學期 日常表現記錄表(新制)");

            Range ptEachRow = prototypeSheet.Cells.CreateRange(5, 1, false);

            for (int i = 5; i < maxStudents + 5; i++)
            {
                prototypeSheet.Cells.CreateRange(i, 1, false).Copy(ptEachRow);
            }

            //加上底線
            prototypeSheet.Cells.CreateRange(maxStudents + 5, 0, 1, ptColIndex).SetOutlineBorder(BorderType.TopBorder, CellBorderType.Medium, System.Drawing.Color.Black);

            for (int i = 12; i >= ptColIndex; i--)
            {
                prototypeSheet.Cells.DeleteColumn(i);
            }

            Range pt = prototypeSheet.Cells.CreateRange(0, maxStudents + 5, false);

            #endregion

            #region 填入表格

            BGW.ReportProgress(53, "填入報表資料");


            Workbook wb = new Workbook();
            wb.Copy(prototype);
            Worksheet ws = wb.Worksheets[0];

            int index         = 0;
            int dataIndex     = 0;
            int classTotalRow = maxStudents + 5;

            BGW.ReportProgress(57, "填入老師姓名");
            #region 取得全校班級,與老師姓名/暱稱(2012/5/24)
            Dictionary <string, string> TeacherDic = new Dictionary <string, string>();
            string st = "SELECT class.id,teacher.teacher_name,teacher.nickname FROM class JOIN teacher ON class.ref_teacher_id = teacher.id";
            dt = _QueryHelper.Select(st);
            foreach (DataRow row in dt.Rows)
            {
                string classID         = "" + row[0];
                string teacherName     = "" + row[1];
                string teacherNickname = "" + row[2];

                if (!TeacherDic.ContainsKey(classID))
                {
                    if (string.IsNullOrEmpty(teacherNickname))
                    {
                        TeacherDic.Add(classID, teacherName);
                    }
                    else
                    {
                        TeacherDic.Add(classID, teacherName + "(" + teacherNickname + ")");
                    }
                }
            }

            #endregion

            BGW.ReportProgress(61, "學生留察資料");
            #region 取得全校本學年度留查之記錄(2012/5/24)
            List <string> MeritFlagIs2 = new List <string>();
            st = string.Format("SELECT ref_student_id from discipline where merit_flag=2 and school_year={0} and semester={1}", _Schoolyear, _Semester);
            dt = _QueryHelper.Select(st);
            foreach (DataRow row in dt.Rows)
            {
                if (!MeritFlagIs2.Contains("" + row[0]))
                {
                    MeritFlagIs2.Add("" + row[0]);
                }
            }

            #endregion

            BGW.ReportProgress(70, "開始列印資料");

            int PeogressNow1 = totalStudent / 30;
            int PeogressNow2 = 0;
            int PeogressNow3 = 70;

            foreach (ClassRecord aClass in allClasses)
            {
                //電子報表用
                #region 電子報表用

                Workbook Paper_wb = new Workbook();
                Paper_wb.Copy(prototype);
                Worksheet Paper_ws = Paper_wb.Worksheets[0];

                int Paper_index         = 0;
                int Paper_dataIndex     = 0;
                int Paper_classTotalRow = maxStudents + 5;

                int Paper_PeogressNow1 = totalStudent / 30;


                #endregion

                if (!classStudents.ContainsKey(aClass.ID))
                {
                    continue;
                }

                string TeacherName = "";
                if (TeacherDic.ContainsKey(aClass.ID))
                {
                    TeacherName = TeacherDic[aClass.ID];
                }

                //複製完成後的樣板
                ws.Cells.CreateRange(index, classTotalRow, false).Copy(pt);
                Paper_ws.Cells.CreateRange(Paper_index, Paper_classTotalRow, false).Copy(pt);

                //填入班級名稱
                ws.Cells[index + 1, 0].PutValue("班級:" + aClass.Name);
                Paper_ws.Cells[Paper_index + 1, 0].PutValue("班級:" + aClass.Name);

                //填入老師名稱
                ws.Cells[index + 3, 0].PutValue("教師:" + TeacherName);
                Paper_ws.Cells[Paper_index + 3, 0].PutValue("教師:" + TeacherName);

                dataIndex       = index + 5;
                Paper_dataIndex = Paper_index + 5;

                foreach (StudentRecord aStudent in classStudents[aClass.ID])
                {
                    PeogressNow2++;

                    if (PeogressNow2 > PeogressNow1 && PeogressNow3 < 101)
                    {
                        PeogressNow3++;
                        PeogressNow2 = 0;
                        BGW.ReportProgress(PeogressNow3, "開始列印資料");
                    }

                    ws.Cells[dataIndex, 0].PutValue(aStudent.SeatNo);
                    ws.Cells[dataIndex, 1].PutValue(aStudent.Name);
                    ws.Cells[dataIndex, 2].PutValue(aStudent.StudentNumber);

                    Paper_ws.Cells[Paper_dataIndex, 0].PutValue(aStudent.SeatNo);
                    Paper_ws.Cells[Paper_dataIndex, 1].PutValue(aStudent.Name);
                    Paper_ws.Cells[Paper_dataIndex, 2].PutValue(aStudent.StudentNumber);
                    // 2018/01/17 羿均
                    // MeritDemeritAttDic 為當學年度學期 缺曠獎懲資料
                    // TotalMeritDemeritDic 為獎懲累計資料
                    if (MeritDemeritAttDic.ContainsKey(aStudent.ID) || TotalMeritDemeritDic.ContainsKey(aStudent.ID))
                    {
                        RewardRecord rr = new RewardRecord();
                        if (MeritDemeritAttDic.ContainsKey(aStudent.ID))
                        {
                            rr = MeritDemeritAttDic[aStudent.ID];
                        }
                        if (TotalMeritDemeritDic.ContainsKey(aStudent.ID))
                        {
                            RewardRecord totalRecord = TotalMeritDemeritDic[aStudent.ID];

                            ws.Cells[dataIndex, columnIndexTable["大功"]].PutValue(rr.MeritACount + " / " + totalRecord.MeritACount);
                            ws.Cells[dataIndex, columnIndexTable["小功"]].PutValue(rr.MeritBCount + " / " + totalRecord.MeritBCount);
                            ws.Cells[dataIndex, columnIndexTable["嘉獎"]].PutValue(rr.MeritCCount + " / " + totalRecord.MeritCCount);
                            ws.Cells[dataIndex, columnIndexTable["大過"]].PutValue(rr.DemeritACount + " / " + totalRecord.DemeritACount);
                            ws.Cells[dataIndex, columnIndexTable["小過"]].PutValue(rr.DemeritBCount + " / " + totalRecord.DemeritBCount);
                            ws.Cells[dataIndex, columnIndexTable["警告"]].PutValue(rr.DemeritCCount + " / " + totalRecord.DemeritCCount);

                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大功"]].PutValue(rr.MeritACount + " / " + totalRecord.MeritACount);
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小功"]].PutValue(rr.MeritBCount + " / " + totalRecord.MeritBCount);
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["嘉獎"]].PutValue(rr.MeritCCount + " / " + totalRecord.MeritCCount);
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大過"]].PutValue(rr.DemeritACount + " / " + totalRecord.DemeritACount);
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小過"]].PutValue(rr.DemeritBCount + " / " + totalRecord.DemeritBCount);
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["警告"]].PutValue(rr.DemeritCCount + " / " + totalRecord.DemeritCCount);
                        }
                        else
                        {
                            //有缺曠沒獎懲,要印獎懲0/0
                            //https://3.basecamp.com/4399967/buckets/15765350/todos/4520462594
                            ws.Cells[dataIndex, columnIndexTable["大功"]].PutValue("0 / 0");
                            ws.Cells[dataIndex, columnIndexTable["小功"]].PutValue("0 / 0");
                            ws.Cells[dataIndex, columnIndexTable["嘉獎"]].PutValue("0 / 0");
                            ws.Cells[dataIndex, columnIndexTable["大過"]].PutValue("0 / 0");
                            ws.Cells[dataIndex, columnIndexTable["小過"]].PutValue("0 / 0");
                            ws.Cells[dataIndex, columnIndexTable["警告"]].PutValue("0 / 0");

                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大功"]].PutValue("0 / 0");
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小功"]].PutValue("0 / 0");
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["嘉獎"]].PutValue("0 / 0");
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大過"]].PutValue("0 / 0");
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小過"]].PutValue("0 / 0");
                            Paper_ws.Cells[Paper_dataIndex, columnIndexTable["警告"]].PutValue("0 / 0");
                        }
                        foreach (string each in rr.Attendance.Keys)
                        {
                            if (columnIndexTable.ContainsKey(each))
                            {
                                ws.Cells[dataIndex, columnIndexTable[each]].PutValue(rr.Attendance[each]);
                                Paper_ws.Cells[Paper_dataIndex, columnIndexTable[each]].PutValue(rr.Attendance[each]);
                            }
                        }
                    }
                    else
                    {
                        //沒缺曠沒獎懲,要印獎懲0/0
                        // https://3.basecamp.com/4399967/buckets/15765350/todos/4520462594
                        ws.Cells[dataIndex, columnIndexTable["大功"]].PutValue("0 / 0");
                        ws.Cells[dataIndex, columnIndexTable["小功"]].PutValue("0 / 0");
                        ws.Cells[dataIndex, columnIndexTable["嘉獎"]].PutValue("0 / 0");
                        ws.Cells[dataIndex, columnIndexTable["大過"]].PutValue("0 / 0");
                        ws.Cells[dataIndex, columnIndexTable["小過"]].PutValue("0 / 0");
                        ws.Cells[dataIndex, columnIndexTable["警告"]].PutValue("0 / 0");

                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大功"]].PutValue("0 / 0");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小功"]].PutValue("0 / 0");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["嘉獎"]].PutValue("0 / 0");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["大過"]].PutValue("0 / 0");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["小過"]].PutValue("0 / 0");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["警告"]].PutValue("0 / 0");
                    }

                    //文字評量部份
                    SHMoralScoreRecord demonScore;
                    if (SHMoralScoreDic.ContainsKey(aStudent.ID))
                    {
                        demonScore = SHMoralScoreDic[aStudent.ID];

                        //文字評量
                        XmlElement xml = demonScore.TextScore;
                        foreach (XmlElement each in xml.SelectNodes("Morality"))
                        {
                            string strFace = each.GetAttribute("Face");
                            if (columnIndexTable.ContainsKey(strFace))
                            {
                                int colIndex = columnIndexTable[strFace];
                                ws.Cells[dataIndex, colIndex].PutValue(each.InnerText);
                                Paper_ws.Cells[Paper_dataIndex, colIndex].PutValue(each.InnerText);
                            }
                        }

                        //導師評語
                        ws.Cells[dataIndex, columnIndexTable["評語"]].PutValue(demonScore.Comment);
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["評語"]].PutValue(demonScore.Comment);
                    }

                    //留察
                    if (MeritFlagIs2.Contains(aStudent.ID))
                    {
                        ws.Cells[dataIndex, columnIndexTable["是否留察"]].PutValue("是");
                        Paper_ws.Cells[Paper_dataIndex, columnIndexTable["是否留察"]].PutValue("是");
                    }

                    foreach (int each in columnIndexTable.Values)
                    {
                        if (each >= ColumnMax)
                        {
                            Paper_ws.AutoFitColumn(each);
                        }
                    }

                    dataIndex++;
                    Paper_dataIndex++;
                }

                //電子報表
                MemoryStream stream = Paper_wb.SaveToStream();
                paperForClass.Append(new PaperItem(PaperFormat.Office2003Xls, stream, aClass.ID));

                index += classTotalRow + 2;
                ws.HPageBreaks.Add(index, ptColIndex);
            }

            foreach (int each in columnIndexTable.Values)
            {
                if (each >= ColumnMax)
                {
                    ws.AutoFitColumn(each);
                }
            }
            #endregion
            if (Carty_paper)
            {
                BGW.ReportProgress(90, "上傳電子報表");
                SmartSchool.ePaper.DispatcherProvider.Dispatch(paperForClass);
            }

            BGW.ReportProgress(100, "資料列印完成");
            e.Result = wb;
        }
Пример #5
0
        /// <summary>
        /// 每1000筆資料,分批執行匯入
        /// Return是Log資訊
        /// </summary>
        public override string Import(List <Campus.DocumentValidator.IRowStream> Rows)
        {
            List <MoralScoreLogRobot> LogList = new List <MoralScoreLogRobot>();

            //取得匯入資料中,所有學生編號下的的日常生活表現資料
            List <SHMoralScoreRecord> MoralScoreList = GetMoralScoreList(Rows);

            List <SHMoralScoreRecord> InsertList = new List <SHMoralScoreRecord>();
            List <SHMoralScoreRecord> UpdateList = new List <SHMoralScoreRecord>();
            int NochangeCount = 0; //未處理資料記數

            if (mOption.Action == ImportAction.InsertOrUpdate)
            {
                foreach (IRowStream Row in Rows)
                {
                    int             SchoolYear    = int.Parse(Row.GetValue("學年度"));
                    int             Semester      = int.Parse(Row.GetValue("學期"));
                    string          StudentNumber = Row.GetValue("學號");
                    SHStudentRecord student       = StudentRecordByStudentNumber[StudentNumber];

                    SHMoralScoreRecord SSR = GetMoralScoreRecord(MoralScoreList, StudentNumber, SchoolYear, Semester);

                    //Log機器人
                    MoralScoreLogRobot log = new MoralScoreLogRobot(student, faceDic.Keys.ToList());

                    if (SSR == null) //新增SHMoralScoreRecord
                    {
                        SHMoralScoreRecord newRecord = new SHMoralScoreRecord();
                        newRecord.RefStudentID = student.ID;
                        newRecord.SchoolYear   = SchoolYear;
                        newRecord.Semester     = Semester;
                        newRecord.TextScore    = GetInsertTextScore(Row);
                        //Log
                        log.SetOldLost();
                        log.SetNew(newRecord);

                        InsertList.Add(newRecord);
                    }
                    else //已存在資料需要修改 or 覆蓋
                    {
                        //Log(old)
                        log.SetOld(SSR);

                        //取得新的Xml結構
                        SSR.TextScore = GetUpdateTextScore(SSR, Row);

                        //Log(New)
                        log.SetNew(SSR);
                        if (!string.IsNullOrEmpty(log.LogToString()))
                        {
                            UpdateList.Add(SSR);
                        }
                    }
                    LogList.Add(log);
                }
            }
            if (InsertList.Count > 0)
            {
                try
                {
                    SHMoralScore.Insert(InsertList);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("於新增資料時發生錯誤!!\n" + ex.Message);
                }
            }
            if (UpdateList.Count > 0)
            {
                try
                {
                    SHMoralScore.Update(UpdateList);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("於更新資料時發生錯誤!!\n" + ex.Message);
                }
            }
            //批次記錄Log
            LogSaver Batch = FISCA.LogAgent.ApplicationLog.CreateLogSaverInstance();

            foreach (MoralScoreLogRobot each in LogList)
            {
                if (!string.IsNullOrEmpty(each.LogToString()))
                {
                    Batch.AddBatch("學務系統.匯入文字評量", "student", each._student.ID, each.LogToString());
                }
                else
                {
                    NochangeCount++;
                }
            }
            Batch.LogBatch(true);
            //Summary Log
            StringBuilder sbSummary = new StringBuilder();

            sbSummary.AppendLine("匯入文字評量操作:");
            sbSummary.AppendLine("新增:" + InsertList.Count + "筆資料");
            sbSummary.AppendLine("更新:" + UpdateList.Count + "筆資料");
            sbSummary.AppendLine("未更動:" + NochangeCount + "筆資料");
            FISCA.LogAgent.ApplicationLog.Log("學務系統.匯入文字評量", "匯入", sbSummary.ToString());

            //StringBuilder sbSummary2 = new StringBuilder();
            //sbSummary2.AppendLine("匯入文字評量操作:");
            //sbSummary2.AppendLine("新增:" + InsertList.Count + "筆資料");
            //sbSummary2.AppendLine("更新:" + UpdateList.Count + "筆資料");
            //sbSummary2.AppendLine("未更動:" + NochangeCount + "筆資料");

            return("");
        }