Beispiel #1
0
        private void FillScore()
        {
            _builder.MoveToMergeField("成績");
            _font = _builder.Font;
            Cell indexCell = _builder.CurrentParagraph.ParentNode as Cell;

            try
            {
                //排序
                List <string> domains = new List <string>(_manager.Domains.Keys);
                domains.Sort(JHSchool.Evaluation.Subject.CompareDomainOrdinal);

                foreach (var domainName in domains)
                {
                    DomainRow domain = _manager.Domains[domainName];

                    bool display = false;
                    if (_config.PrintDomains.ContainsKey(domain.DomainName))
                    {
                        display = _config.PrintDomains[domain.DomainName];
                    }
                    else
                    {
                        display = domain.Display;
                    }

                    if (display)
                    {
                        Cell temp = indexCell;
                        indexCell = WordHelper.GetMoveDownCell(indexCell, 1);
                        WriteDomainRowOnly(temp, domain);
                        WordHelper.MergeHorizontalCell(temp, 2);
                        if (indexCell == null)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (domain.Subjects.Count > 0)
                        {
                            int  count = WriteDomainRow(indexCell, domain);
                            Cell temp  = indexCell;
                            indexCell = WordHelper.GetMoveDownCell(indexCell, count);
                            WordHelper.MergeVerticalCell(temp, count);
                            if (indexCell == null)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        internal void SetSubjects(List <string> list)
        {
            List <JHCourseRecord> courseList = new List <JHCourseRecord>();

            foreach (string courseID in list)
            {
                if (!_courseDict.ContainsKey(courseID))
                {
                    continue;
                }
                courseList.Add(_courseDict[courseID]);
            }

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

            foreach (JHCourseRecord course in courseList)
            {
                // 濾過社團
                if (string.IsNullOrEmpty(course.Domain) && string.IsNullOrEmpty(course.Subject))
                {
                    continue;
                }

                string domain  = course.Domain;
                string subject = course.Subject;

                if (!Domains.ContainsKey(domain))
                {
                    Domains.Add(domain, new DomainRow(domain));
                }

                DomainRow domainRow = Domains[domain];

                if (!domainRow.Subjects.ContainsKey(subject))
                {
                    domainRow.AddSubject(subject);
                }
                domainRow.Subjects[subject].SetPeriodCredit(course.Period, course.Credit);
                domainRow.Subjects[subject].Display = true;
            }
        }
Beispiel #3
0
        internal void Add(KH.JHSCETakeRecord sce)
        {
            if (!_courseDict.ContainsKey(sce.RefCourseID))
            {
                return;
            }
            JHCourseRecord course = _courseDict[sce.RefCourseID];

            if (!Domains.ContainsKey(course.Domain))
            {
                Domains.Add(course.Domain, new DomainRow(course.Domain));
            }

            DomainRow row = Domains[course.Domain];

            if (_config.DomainSubjectSetup == DomainSubjectSetup.Subject)
            {
                row.Display = false;
            }
            else
            {
                row.Display = true;
            }
            row.AddExamID(sce.RefExamID);

            if (!row.Subjects.ContainsKey(course.Subject))
            {
                row.Subjects.Add(course.Subject, new SubjectRow(course.Subject));
            }
            SubjectRow subjectRow = row.Subjects[course.Subject];

            subjectRow.SetPeriodCredit(course.Period, course.Credit);
            subjectRow.AddScore(sce.RefExamID, sce.Score, sce.Effort);
            if (_config.DomainSubjectSetup == DomainSubjectSetup.Subject)
            {
                subjectRow.Display = true;
            }
        }
Beispiel #4
0
        private void WriteDomainRowOnly(Cell indexCell, DomainRow domain)
        {
            WordHelper.Write(indexCell, _font, domain.DomainName);
            Cell temp = indexCell.NextSibling as Cell;

            temp = temp.NextSibling as Cell;
            WordHelper.Write(temp, _font, domain.PeriodCredit);

            foreach (var examID in domain.ExamIDs)
            {
                decimal?score      = domain.GetScore(examID);
                string  effortText = string.Empty;
                if (score.HasValue)
                {
                    effortText = _effortMapper.GetTextByDecimal(score.Value);
                }

                temp = WordHelper.GetMoveRightCell(indexCell, _columnMapping[examID]);
                //                WordHelper.Write(temp, _font, (score.HasValue ? "" + _calculator.ParseDomainScore(score.Value) : ""));
                if (score.HasValue)
                {
                    WordHelper.Write(temp, _font, _calculator.ParseDomainScore(score.Value).ToString());
                }
                else
                {
                    WordHelper.Write(temp, _font, "");
                }

                WordHelper.Write(temp.NextSibling as Cell, _font, effortText);
            }


            // 平時
            if (_DomainScoreDict.ContainsKey(domain.DomainName))
            {
                temp = WordHelper.GetMoveRightCell(indexCell, _columnMapping["平時評量"]);
                string effortText1 = string.Empty;
                // 當有值
                if (_DomainScoreDict[domain.DomainName].HasValue)
                {
                    effortText1 = _effortMapper.GetTextByDecimal(_DomainScoreDict[domain.DomainName].Value);
                    WordHelper.Write(temp, _font, _calculator.ParseDomainScore(_DomainScoreDict[domain.DomainName].Value).ToString());
                }
                else
                {
                    WordHelper.Write(temp, _font, ""); // 沒有領域成績填空白
                }
                WordHelper.Write(temp.NextSibling as Cell, _font, effortText1);
            }
            //temp = temp.NextSibling as Cell;
            //temp = temp.NextSibling as Cell;

            //// 總
            //if (_DomainScoreDictTT.ContainsKey(domain.DomainName))
            //{
            //    temp = WordHelper.GetMoveRightCell(indexCell, _columnMapping["課程總成績"]);
            //    string effortText2 = string.Empty;
            //    effortText2 = _effortMapper.GetTextByDecimal(_DomainScoreDictTT[domain.DomainName]);

            //    WordHelper.Write(temp, _font, _calculator.ParseDomainScore(_DomainScoreDictTT[domain.DomainName]).ToString());
            //    WordHelper.Write(temp.NextSibling as Cell, _font, effortText2);
            //}
        }
Beispiel #5
0
        private int WriteDomainRow(Cell indexCell, DomainRow domain)
        {
            WordHelper.Write(indexCell, _font, string.IsNullOrEmpty(domain.DomainName) ? "彈性課程" : domain.DomainName);
            int  col         = 0;
            Cell subjectCell = WordHelper.GetMoveRightCell(indexCell, 1);
            int  count       = 0;

            foreach (var subjectName in domain.Subjects.Keys)
            {
                SubjectRow row = domain.Subjects[subjectName];
                if (row.Display)
                {
                    Cell temp = subjectCell;
                    WordHelper.Write(temp, _font, row.SubjectName);
                    temp = temp.NextSibling as Cell;
                    WordHelper.Write(temp, _font, row.PeriodCredit);

                    foreach (string examID in row.Scores.Keys)
                    {
                        ScoreData data       = row.Scores[examID];
                        string    effortText = string.Empty;
                        if (data.Effort.HasValue)
                        {
                            effortText = _effortMapper.GetTextByInt(data.Effort.Value);
                        }

                        temp = WordHelper.GetMoveRightCell(subjectCell, _columnMapping[examID] - 1);
                        WordHelper.Write(temp, _font, (data.Score.HasValue ? "" + _calculator.ParseSubjectScore(data.Score.Value) : ""));
                        WordHelper.Write(temp.NextSibling as Cell, _font, effortText);
                    }

                    if (_AttendDict.ContainsKey(subjectName))
                    {
                        temp = WordHelper.GetMoveRightCell(subjectCell, _columnMapping["平時評量"] - 1);

                        // 平時
                        if (_AttendDict[subjectName].OrdinarilyScore.HasValue)
                        {
                            WordHelper.Write(temp, _font, _calculator.ParseSubjectScore(_AttendDict[subjectName].OrdinarilyScore.Value).ToString());
                        }
                        else
                        {
                            WordHelper.Write(temp, _font, "");
                        }

                        if (_AttendDict[subjectName].OrdinarilyEffort.HasValue)
                        {
                            WordHelper.Write(temp.NextSibling as Cell, _font, _effortMapper.GetTextByInt(_AttendDict[subjectName].OrdinarilyEffort.Value));
                        }
                        else
                        {
                            WordHelper.Write(temp.NextSibling as Cell, _font, "");
                        }


                        //temp = WordHelper.GetMoveRightCell(indexCell, _columnMapping["課程總成績"]);

                        //// 課程總成績
                        //if (_AttendDict[subjectName].Score.HasValue)
                        //    WordHelper.Write(temp, _font, _calculator.ParseSubjectScore(_AttendDict[subjectName].Score.Value).ToString());
                        //else
                        //    WordHelper.Write(temp, _font, "");

                        //if (_AttendDict[subjectName].Effort.HasValue)
                        //    WordHelper.Write(temp.NextSibling as Cell, _font, _effortMapper.GetTextByInt(_AttendDict[subjectName].Effort.Value));
                        //else
                        //    WordHelper.Write(temp.NextSibling as Cell, _font, "");
                    }

                    subjectCell = WordHelper.GetMoveDownCell(subjectCell, 1);

                    if (subjectCell == null)
                    {
                        break;
                    }
                    count++;
                }
            }
            return(count);
        }
Beispiel #6
0
        private void FillScore()
        {
            // 2018/11/28 穎驊註解, 因應 新版 aspose.Word 修正, 支援學生名字特殊字列印不要錯誤當機問題,
            // 發現,原本寫法 動態畫表,在換了新aspose.Word 有神奇Bug
            // 這裡的 _builder 第一次.MoveToMergeField("成績") 將游標定在 "成績" 功能變數上 
            // 即便回傳值 是 true,但實際上是失敗了, 游標並沒有移到上面,且也沒有刪除該"成績" 功能變數 (可以透過_builder.Document.MailMerge.GetFieldNames() 檢查)
            // 要連續做兩次才會成功, 目前初步判斷,是 _builder 起先還沒有正確定位到Document,導致第一次的失敗
            // 這邊可以先用.MoveToDocumentStart() 讓游標移到文件首後,再移到 "成績" 功能變數,讓往後功能都可以正常運行
            // 如未來有後者有興趣,可以將 _builder.MoveToDocumentStart(); 註解掉後, 將 b1、b2、b3 都開啟,觀察狀況了解。
            _builder.MoveToDocumentStart();
            bool b1 = _builder.MoveToMergeField("成績");

            //bool b2 = _builder.MoveToMergeField("成績");
            //bool b3 = _builder.MoveToMergeField("成績");
            _font = _builder.Font;
            Cell indexCell = _builder.CurrentParagraph.ParentNode as Cell;

            try
            {
                //排序
                List <string> domains = new List <string>(_manager.Domains.Keys);
                domains.Sort(JHSchool.Evaluation.Subject.CompareDomainOrdinal);

                foreach (var domainName in domains)
                {
                    DomainRow domain = _manager.Domains[domainName];

                    bool display = false;
                    if (_config.PrintDomains.ContainsKey(domain.DomainName))
                    {
                        display = _config.PrintDomains[domain.DomainName];
                    }
                    else
                    {
                        display = domain.Display;
                    }

                    if (display)
                    {
                        Cell temp = indexCell;
                        indexCell = WordHelper.GetMoveDownCell(indexCell, 1);
                        WriteDomainRowOnly(temp, domain);
                        WordHelper.MergeHorizontalCell(temp, 2);
                        if (indexCell == null)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (domain.Subjects.Count > 0)
                        {
                            int  count = WriteDomainRow(indexCell, domain);
                            Cell temp  = indexCell;
                            indexCell = WordHelper.GetMoveDownCell(indexCell, count);
                            WordHelper.MergeVerticalCell(temp, count);
                            if (indexCell == null)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }