Example #1
0
 public StudentTextProcessor(DocumentBuilder builder, SemesterMap map)
 {
     _builder = builder;
     _builder.MoveToMergeField("學習領域評量");
     _cell    = _builder.CurrentParagraph.ParentNode as Cell;
     _manager = new DomainTextManager();
     _map     = map;
 }
 public StudentTextProcessor(DocumentBuilder builder, SemesterMap map)
 {
     _builder = builder;
     _builder.MoveToMergeField("學習領域評量");
     _cell = _builder.CurrentParagraph.ParentNode as Cell;
     _manager = new DomainTextManager();
     _map = map;
 }
Example #3
0
 public StudentSemesterScoreProcessor(DocumentBuilder builder, SemesterMap map, string type, Dictionary <string, bool> domains, K12.Data.GradScoreRecord StudGradScore)
 {
     builder.MoveToMergeField("成績");
     _builder       = builder;
     _manager       = new DomainRowManager(type);
     _cell          = builder.CurrentParagraph.ParentNode as Cell;
     _map           = map;
     _domains       = domains;
     _StudGradScore = StudGradScore;
 }
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     base.OnModelCreating(modelBuilder);
     _ = new TeacherMap(modelBuilder.Entity <Teacher>());
     _ = new StudentMap(modelBuilder.Entity <Student>());
     _ = new LectureMap(modelBuilder.Entity <Lecture>());
     _ = new CourseMap(modelBuilder.Entity <Course>());
     _ = new EnrollmentMap(modelBuilder.Entity <Enrollment>());
     _ = new SemesterMap(modelBuilder.Entity <Semester>());
 }
 public StudentSemesterScoreProcessor(DocumentBuilder builder, SemesterMap map, string type,Dictionary<string,bool> domains,K12.Data.GradScoreRecord StudGradScore)
 {
     builder.MoveToMergeField("成績");
     _builder = builder;
     _manager = new DomainRowManager( type);
     _cell = builder.CurrentParagraph.ParentNode as Cell;
     _map = map;
     _domains = domains;
     _StudGradScore = StudGradScore;
 }
Example #6
0
        public StudentMoralProcessor(DocumentBuilder builder, SemesterMap map)
        {
            _builder = builder;

            _map   = map;
            _types = new Dictionary <string, List <string> >();

            _run = WordHelper.CreateRun(_builder);

            #region 取得假別設定
            ConfigData cd = K12.Data.School.Configuration["學籍表"];
            if (cd.Contains("假別設定"))
            {
                XmlElement config = Framework.XmlHelper.LoadXml(cd["假別設定"]);

                foreach (XmlElement type in config.SelectNodes("Type"))
                {
                    string typeName = type.GetAttribute("Text");
                    if (!_types.ContainsKey(typeName))
                    {
                        _types.Add(typeName, new List <string>());
                    }

                    foreach (XmlElement absence in type.SelectNodes("Absence"))
                    {
                        string absenceName = absence.GetAttribute("Text");
                        if (!_types[typeName].Contains(absenceName))
                        {
                            _types[typeName].Add(absenceName);
                        }
                    }
                }
            }
            #endregion

            #region 取得社團成績
            _assnScoreCache = new Dictionary <string, List <AssnScore> >();

            FISCA.UDT.AccessHelper ah = new FISCA.UDT.AccessHelper();
//            string condition = string.Format("SchoolYear='{0}' and Semester='{1}'", options.SchoolYear, options.Semester);
//            List<AssnCode> list = ah.Select<AssnCode>(condition);

            if (AssociationUDTCache == null)
            {
                AssociationUDTCache = ah.Select <AssnCode>();
            }

            List <AssnCode> list = AssociationUDTCache;
            foreach (AssnCode record in list)
            {
                //if (!_assnScoreCache.ContainsKey(record.StudentID))
                //{
                XmlElement scores      = K12.Data.XmlHelper.LoadXml(record.Scores);
                XmlElement itemElement = (XmlElement)scores.SelectSingleNode("Item");
                if (itemElement != null)
                {
                    AssnScore assnScore = new AssnScore()
                    {
                        Score      = itemElement.GetAttribute("Score"),
                        Effort     = itemElement.GetAttribute("Effort"),
                        Text       = itemElement.GetAttribute("Text"),
                        SchoolYear = record.SchoolYear,
                        Semester   = record.Semester
                    };
                    if (_assnScoreCache.ContainsKey(record.StudentID))
                    {
                        _assnScoreCache[record.StudentID].Add(assnScore);
                    }
                    else
                    {
                        List <AssnScore> lis = new List <AssnScore>();
                        lis.Add(assnScore);
                        _assnScoreCache.Add(record.StudentID, lis);
                    }
                }
                //}
            }

            //<Content>
            //<Item AssociationName="籃球社" Score="" Effort="" Text=""></Item>
            //</Content>
            #endregion
        }
        public StudentMoralProcessor(DocumentBuilder builder, SemesterMap map)
        {
            _builder = builder;

            _map = map;
            _types = new Dictionary<string, List<string>>();

            _run = WordHelper.CreateRun(_builder);

            #region 取得假別設定
            ConfigData cd = K12.Data.School.Configuration["學籍表"];
            if (cd.Contains("假別設定"))
            {
                XmlElement config = Framework.XmlHelper.LoadXml(cd["假別設定"]);

                foreach (XmlElement type in config.SelectNodes("Type"))
                {
                    string typeName = type.GetAttribute("Text");
                    if (!_types.ContainsKey(typeName))
                        _types.Add(typeName, new List<string>());

                    foreach (XmlElement absence in type.SelectNodes("Absence"))
                    {
                        string absenceName = absence.GetAttribute("Text");
                        if (!_types[typeName].Contains(absenceName))
                            _types[typeName].Add(absenceName);
                    }
                }
            }
            #endregion

            #region 取得社團成績
            _assnScoreCache = new Dictionary<string, List<AssnScore>>();

            FISCA.UDT.AccessHelper ah = new FISCA.UDT.AccessHelper();
//            string condition = string.Format("SchoolYear='{0}' and Semester='{1}'", options.SchoolYear, options.Semester);
//            List<AssnCode> list = ah.Select<AssnCode>(condition);

            if (AssociationUDTCache == null)
                AssociationUDTCache = ah.Select<AssnCode>();

            List<AssnCode> list = AssociationUDTCache;
            foreach (AssnCode record in list)
            {
                //if (!_assnScoreCache.ContainsKey(record.StudentID))
                //{
                    XmlElement scores = K12.Data.XmlHelper.LoadXml(record.Scores);
                    XmlElement itemElement = (XmlElement)scores.SelectSingleNode("Item");
                    if (itemElement != null)
                    {
                        AssnScore assnScore = new AssnScore()
                        {
                            Score = itemElement.GetAttribute("Score"),
                            Effort = itemElement.GetAttribute("Effort"),
                            Text = itemElement.GetAttribute("Text"),
                            SchoolYear = record.SchoolYear,
                            Semester = record.Semester
                        };
                        if (_assnScoreCache.ContainsKey(record.StudentID))
                            _assnScoreCache[record.StudentID].Add(assnScore);
                        else
                        {
                            List<AssnScore> lis = new List<AssnScore>();
                            lis.Add(assnScore);
                            _assnScoreCache.Add(record.StudentID, lis);
                        }
                    }
                //}
            }

            //<Content>
            //<Item AssociationName="籃球社" Score="" Effort="" Text=""></Item>
            //</Content>
            #endregion
        }
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            List<string> globalFieldName = new List<string>();
            List<object> globalFieldValue = new List<object>();

            globalFieldName.Add("學校名稱");
            globalFieldValue.Add(K12.Data.School.ChineseName);

            globalFieldName.Add("列印日期");
            globalFieldValue.Add(DateConvert.CDate(DateTime.Now.ToString("yyyy/MM/dd")));

            globalFieldName.Add("列印時間");
            globalFieldValue.Add(DateTime.Now.ToString("HH:mm:ss"));

            ReportConfiguration _Dylanconfig = new ReportConfiguration(Global.OneFileSave);
            OneFileSave = _Dylanconfig.GetBoolean("單檔儲存", false);
            StudentDoc = new Dictionary<string, Document>();

            double total = _students.Count;
            double count = 0;

            List<string> student_ids = new List<string>();
            foreach (JHStudentRecord item in _students)
                student_ids.Add(item.ID);

            #region 快取資料
            //取得異動資料
            Dictionary<string, List<JHUpdateRecordRecord>> updateRecordCache = new Dictionary<string, List<JHUpdateRecordRecord>>();
            foreach (var record in JHUpdateRecord.SelectByStudentIDs(student_ids))
            {
                if (!updateRecordCache.ContainsKey(record.StudentID))
                    updateRecordCache.Add(record.StudentID, new List<JHUpdateRecordRecord>());
                updateRecordCache[record.StudentID].Add(record);
            }

            //取得缺曠獎懲資料
            Dictionary<string, List<AutoSummaryRecord>> autoSummaryCache = new Dictionary<string, List<AutoSummaryRecord>>();
            foreach (AutoSummaryRecord record in AutoSummary.Select(student_ids, null))
            {
                if (!autoSummaryCache.ContainsKey(record.RefStudentID))
                    autoSummaryCache.Add(record.RefStudentID, new List<AutoSummaryRecord>());
                autoSummaryCache[record.RefStudentID].Add(record);
            }

            //取得學期歷程
            Dictionary<string, JHSemesterHistoryRecord> semesterHistoryCache = new Dictionary<string, JHSemesterHistoryRecord>();
            foreach (var record in JHSemesterHistory.SelectByStudentIDs(student_ids))
            {
                if (!semesterHistoryCache.ContainsKey(record.RefStudentID))
                    semesterHistoryCache.Add(record.RefStudentID, record);
            }

            //取得學期成績
            Dictionary<string, List<JHSemesterScoreRecord>> semesterScoreCache = new Dictionary<string, List<JHSemesterScoreRecord>>();
            foreach (var record in JHSemesterScore.SelectByStudentIDs(student_ids))
            {
                if (!semesterScoreCache.ContainsKey(record.RefStudentID))
                    semesterScoreCache.Add(record.RefStudentID, new List<JHSemesterScoreRecord>());
                semesterScoreCache[record.RefStudentID].Add(record);
            }

            // 取得畢業成績
            Dictionary<string, K12.Data.GradScoreRecord> StudGradScoreDic = new Dictionary<string, GradScoreRecord>();
            foreach (GradScoreRecord score in GradScore.SelectByIDs<GradScoreRecord>(student_ids))
                StudGradScoreDic.Add(score.RefStudentID, score);

            ////課程
            //JHCourse.RemoveAll();
            //Dictionary<string, JHCourseRecord> courseCache = new Dictionary<string, JHCourseRecord>();
            //foreach (JHCourseRecord record in JHCourse.SelectAll())
            //{
            //    if (!courseCache.ContainsKey(record.ID))
            //        courseCache.Add(record.ID, record);
            //}
            #endregion

            #region 判斷要列印的領域科目
            Dictionary<string, bool> domains = new Dictionary<string, bool>();
            //Dictionary<string, List<string>> subjects = new Dictionary<string, List<string>>();

            //List<JHCourseRecord> courseList = new List<JHCourseRecord>(courseCache.Values);

            //courseList.Sort(delegate(JHCourseRecord x, JHCourseRecord y)
            //{
            //    return JHSchool.Evaluation.Subject.CompareSubjectOrdinal(x.Subject, y.Subject);
            //});

            string domainSubjectSetup = Config.GetString("領域科目設定", "Domain");
            if (domainSubjectSetup == "Domain")
            {
                foreach (var domain in JHSchool.Evaluation.Subject.Domains)
                    domains.Add(domain, DomainSubjectExpand.不展開);

                if (!domains.ContainsKey("")) domains.Add("", DomainSubjectExpand.展開);
            }
            else if (domainSubjectSetup == "Subject")
            {
                foreach (var domain in JHSchool.Evaluation.Subject.Domains)
                    domains.Add(domain, DomainSubjectExpand.展開);
                if (!domains.ContainsKey("")) domains.Add("", DomainSubjectExpand.展開);
            }
            else
                throw new Exception("請重新儲存一次列印設定");

            //foreach (var domain in JHSchool.Evaluation.Subject.Domains)
            //    subjects.Add(domain, new List<string>());
            //if (!subjects.ContainsKey("")) subjects.Add("", new List<string>());

            //foreach (var course in courseList)
            //{
            //    if (!subjects.ContainsKey(course.Domain))
            //        subjects.Add(course.Domain, new List<string>());
            //    if (!subjects[course.Domain].Contains(course.Subject) &&
            //        domains.ContainsKey(course.Domain) &&
            //        domains[course.Domain] == false)
            //    {
            //        subjects[course.Domain].Add(course.Subject);
            //    }
            //}
            #endregion

            DocumentBuilder templateBuilder = new DocumentBuilder(_template);

            #region 節權數顯示
            string pcDisplay = string.Empty;
            bool printPeriod = Config.GetBoolean("列印節數", true);
            bool printCredit = Config.GetBoolean("列印權數", false);
            if (printPeriod && printCredit)
                pcDisplay = "節權數";
            else if (printPeriod)
                pcDisplay = "節數";
            else if (printCredit)
                pcDisplay = "權數";

            while (templateBuilder.MoveToMergeField("節權數"))
                templateBuilder.Write(pcDisplay);
            #endregion

            #region 文字評語是否列印
            bool printText = Config.GetBoolean("列印文字評語", true);
            if (printText == false)
            {
                templateBuilder.MoveToMergeField("學習領域評量");
                (templateBuilder.CurrentParagraph.ParentNode as Cell).ParentRow.ParentTable.Remove();
            }
            #endregion

            #region 服務學習時數
            Global._SLRDict.Clear();
            Global._SLRDict = Utility.GetServiceLearningDetail(student_ids);
            #endregion

            #region 產生
            foreach (JHStudentRecord student in _students)
            {
                count++;

                Document each = (Document)_template.Clone(true);
                DocumentBuilder builder = new DocumentBuilder(each);

                #region 建立學期歷程對照
                List<SemesterHistoryItem> semesterHistoryList = null;
                if (semesterHistoryCache.ContainsKey(student.ID))
                    semesterHistoryList = semesterHistoryCache[student.ID].SemesterHistoryItems;
                else
                    semesterHistoryList = new List<SemesterHistoryItem>();

                SemesterMap map = new SemesterMap();
                map.SetData(semesterHistoryList);
                #endregion

                #region 學生基本資料
                StudentBasicInfo basicInfo = new StudentBasicInfo(builder);
                basicInfo.SetStudent(student, semesterHistoryList);
                #endregion

                #region 異動資料
                List<JHUpdateRecordRecord> updateRecordList = null;
                if (updateRecordCache.ContainsKey(student.ID))
                    updateRecordList = updateRecordCache[student.ID];
                else
                    updateRecordList = new List<JHUpdateRecordRecord>();

                StudentUpdateRecordProcessor updateRecordProcessor = new StudentUpdateRecordProcessor(builder);
                updateRecordProcessor.SetData(updateRecordList);
                #endregion

                #region 日常表現
                List<AutoSummaryRecord> autoSummaryList = null;
                if (autoSummaryCache.ContainsKey(student.ID))
                    autoSummaryList = autoSummaryCache[student.ID];
                else
                    autoSummaryList = new List<AutoSummaryRecord>();

                StudentMoralProcessor moralProcessor = new StudentMoralProcessor(builder, map);
                moralProcessor.SetData(autoSummaryList);
                #endregion

                #region 學期歷程
                StudentHistoryProcessor history = new StudentHistoryProcessor(builder, map, (semesterHistoryCache.ContainsKey(student.ID) ? semesterHistoryCache[student.ID] : null));
                #endregion

                #region 學期成績
                List<JHSemesterScoreRecord> semesterScoreList = null;
                if (semesterScoreCache.ContainsKey(student.ID))
                    semesterScoreList = semesterScoreCache[student.ID];
                else
                    semesterScoreList = new List<JHSemesterScoreRecord>();

                // 畢業成績
                K12.Data.GradScoreRecord StudGradScore = new GradScoreRecord();
                if (StudGradScoreDic.ContainsKey(student.ID))
                    StudGradScore = StudGradScoreDic[student.ID];

                StudentSemesterScoreProcessor semesterScoreProcessor = new StudentSemesterScoreProcessor(builder, map, domainSubjectSetup, domains, StudGradScore);
                semesterScoreProcessor.DegreeMapper = _degreeMapper;
                semesterScoreProcessor.PrintPeriod = printPeriod;
                semesterScoreProcessor.PrintCredit = printCredit;
                semesterScoreProcessor.SetData(semesterScoreList);
                #endregion

                #region 學習領域評量
                if (printText == true)
                {
                    StudentTextProcessor text = new StudentTextProcessor(builder, map);
                    text.SetData(semesterScoreList);
                }
                #endregion

                if (OneFileSave)
                {
                    each.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray());

                    string fileName = "";
                    fileName = student.StudentNumber;

                    if (!string.IsNullOrEmpty(student.RefClassID))
                        fileName += "_" + student.Class.Name;
                    else
                        fileName += "_";

                    fileName += "_" + (student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "");
                    fileName += "_" + student.Name;

                    if (!StudentDoc.ContainsKey(fileName))
                    {
                        StudentDoc.Add(fileName, each);
                    }

                }
                else
                {
                    foreach (Section sec in each.Sections)
                        _doc.Sections.Add(_doc.ImportNode(sec, true));
                }

                //回報進度
                _worker.ReportProgress((int)(count * 100.0 / total));
            }

            if (!OneFileSave)
            {
                _doc.MailMerge.Execute(globalFieldName.ToArray(), globalFieldValue.ToArray());
            }

            #endregion
        }
Example #9
0
        public StudentHistoryProcessor(DocumentBuilder builder, SemesterMap map, JHSemesterHistoryRecord record)
        {
            _data = new Dictionary <string, string>();
            _data.Add("一上班級", "");
            _data.Add("一下班級", "");
            _data.Add("二上班級", "");
            _data.Add("二下班級", "");
            _data.Add("三上班級", "");
            _data.Add("三下班級", "");
            _data.Add("一上導師", "");
            _data.Add("一下導師", "");
            _data.Add("二上導師", "");
            _data.Add("二下導師", "");
            _data.Add("三上導師", "");
            _data.Add("三下導師", "");

            _gradeMap = new Dictionary <int, string>();
            _gradeMap.Add(1, "一上");
            _gradeMap.Add(2, "一下");
            _gradeMap.Add(3, "二上");
            _gradeMap.Add(4, "二下");
            _gradeMap.Add(5, "三上");
            _gradeMap.Add(6, "三下");

            List <string> fieldName  = new List <string>();
            List <string> fieldValue = new List <string>();

            int index = 0;

            //foreach (string name in new string[] { "一上", "一下", "二上", "二下", "三上", "三下" })
            foreach (string name in new string[] { "一年級學年度", "二年級學年度", "三年級學年度" })
            {
                fieldName.Add(name);
                if (map.SchoolYearMapping.ContainsKey(index))
                {
                    fieldValue.Add(map.SchoolYearMapping[index] + "學年度");
                }
                else
                {
                    fieldValue.Add("");
                }
                index += 2;
            }

            foreach (var item in record.SemesterHistoryItems)
            {
                int gradeYear = item.GradeYear;
                if (gradeYear > 6)
                {
                    gradeYear -= 6;
                }

                index = (gradeYear - 1) * 2 + item.Semester;
                if (_gradeMap.ContainsKey(index))
                {
                    string key = _gradeMap[index];

                    string classSeatNo = string.Empty;
                    if (!string.IsNullOrEmpty(item.ClassName))
                    {
                        classSeatNo += item.ClassName + "班";
                    }
                    if (!string.IsNullOrEmpty("" + item.SeatNo))
                    {
                        classSeatNo += item.SeatNo + "號";
                    }

                    _data[key + "導師"] = item.Teacher;
                    _data[key + "班級"] = classSeatNo;
                }
            }

            fieldName.AddRange(_data.Keys);
            fieldValue.AddRange(_data.Values);

            builder.Document.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray());
        }
        public StudentHistoryProcessor(DocumentBuilder builder, SemesterMap map, JHSemesterHistoryRecord record)
        {
            _data = new Dictionary<string, string>();
            _data.Add("一上班級", "");
            _data.Add("一下班級", "");
            _data.Add("二上班級", "");
            _data.Add("二下班級", "");
            _data.Add("三上班級", "");
            _data.Add("三下班級", "");
            _data.Add("一上導師", "");
            _data.Add("一下導師", "");
            _data.Add("二上導師", "");
            _data.Add("二下導師", "");
            _data.Add("三上導師", "");
            _data.Add("三下導師", "");

            _gradeMap = new Dictionary<int, string>();
            _gradeMap.Add(1, "一上");
            _gradeMap.Add(2, "一下");
            _gradeMap.Add(3, "二上");
            _gradeMap.Add(4, "二下");
            _gradeMap.Add(5, "三上");
            _gradeMap.Add(6, "三下");

            List<string> fieldName = new List<string>();
            List<string> fieldValue = new List<string>();

            int index = 0;
            //foreach (string name in new string[] { "一上", "一下", "二上", "二下", "三上", "三下" })
            foreach (string name in new string[] { "一年級學年度", "二年級學年度", "三年級學年度" })
            {
                fieldName.Add(name);
                if (map.SchoolYearMapping.ContainsKey(index))
                    fieldValue.Add(map.SchoolYearMapping[index] + "學年度");
                else
                    fieldValue.Add("");
                index += 2;
            }

            foreach (var item in record.SemesterHistoryItems)
            {
                int gradeYear = item.GradeYear;
                if (gradeYear > 6) gradeYear -= 6;

                index = (gradeYear - 1) * 2 + item.Semester;
                if (_gradeMap.ContainsKey(index))
                {
                    string key = _gradeMap[index];

                    string classSeatNo = string.Empty;
                    if (!string.IsNullOrEmpty(item.ClassName))
                        classSeatNo += item.ClassName + "班";
                    if (!string.IsNullOrEmpty("" + item.SeatNo))
                        classSeatNo += item.SeatNo + "號";

                    _data[key + "導師"] = item.Teacher;
                    _data[key + "班級"] = classSeatNo;
                }
            }

            fieldName.AddRange(_data.Keys);
            fieldValue.AddRange(_data.Values);

            builder.Document.MailMerge.Execute(fieldName.ToArray(), fieldValue.ToArray());
        }