コード例 #1
0
        private void RefreshPrefixList()
        {
            string origin_selected = cboGroup.Text;

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

            prefixes.Add(AllTagText);
            foreach (JHTagConfigRecord each in JHTagConfig.SelectByCategory(Category))
            {
                if (!prefixes.Contains(each.Prefix))
                {
                    prefixes.Add(each.Prefix);
                }
            }

            cboGroup.Items.Clear();
            prefixes.Sort();
            cboGroup.Items.AddRange(prefixes.ToArray());

            int selIndex = cboGroup.FindString(origin_selected);

            if (selIndex == -1)
            {
                cboGroup.SelectedIndex = (cboGroup.Items.Count > 0 ? 0 : -1);
            }
            else
            {
                cboGroup.SelectedIndex = selIndex;
            }
        }
コード例 #2
0
        /// <summary>
        /// 重新讀取 Tag 資料,會自動呼叫 RefreshPrefixList、RefreshTagNameList。
        /// </summary>
        private void RefreshTagData()
        {
            List <JHTagConfigRecord> records = JHTagConfig.SelectByCategory(Category);

            Editors = new Dictionary <string, JHTagConfigRecord>();
            foreach (JHTagConfigRecord each in records)
            {
                Editors.Add(each.ID, each);
            }

            RefreshPrefixList();
            RefreshTagNameList();
            JHSchool.Tag.Instance.SyncAllBackground();
        }
コード例 #3
0
        private void _writeWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region 寫入離校資訊
            try
            {
                List <JHLeaveInfoRecord> leaveInfoRecordList = new List <JHLeaveInfoRecord>();
                foreach (JHLeaveInfoRecord record in JHLeaveIfno.SelectByStudentIDs(_students.AsKeyList()))
                {
                    if (!_passList.ContainsKey(record.RefStudentID))
                    {
                        continue;
                    }

                    leaveInfoRecordList.Add(record);

                    if (_passList[record.RefStudentID] == true)
                    {
                        record.Reason = "畢業";
                        record.Memo   = string.Empty;
                    }
                    else
                    {
                        record.Reason = "修業";

                        StringBuilder builder = new StringBuilder();
                        _result[record.RefStudentID].Sort();
                        foreach (ResultDetail rd in _result[record.RefStudentID])
                        {
                            string semester = rd.GradeYear + (rd.Semester.Equals("1") ? "上" : "下") + ":";
                            string details  = string.Empty;
                            foreach (string detail in rd.Details)
                            {
                                details += detail + ",";
                            }
                            if (details.EndsWith(","))
                            {
                                details = details.Substring(0, details.Length - 1);
                            }
                            builder.AppendLine(semester + details);
                        }
                        record.Memo = builder.ToString();
                    }

                    // 系統目前預設學年度
                    int SchoolYear;
                    int.TryParse(JHSchool.School.DefaultSchoolYear, out SchoolYear);
                    record.SchoolYear = SchoolYear;
                }
                JHLeaveIfno.Update(leaveInfoRecordList);
            }
            catch (Exception ex)
            {
                BugReporter.ReportException(ex, false);
            }

            #endregion

            #region 寫入類別(Tags)
            string FailurePrefix = "未達畢業標準";
            try
            {
                List <JHTagConfigRecord> tagList            = JHTagConfig.SelectByCategory(K12.Data.TagCategory.Student);
                TagConfigRecordComparer  tagComparer        = new TagConfigRecordComparer();
                StudentTagRecordComparer studentTagComparer = new StudentTagRecordComparer();

                #region 製作各種未達畢業標準的標籤
                List <JHTagConfigRecord> tagConfigRecordList = new List <JHSchool.Data.JHTagConfigRecord>();
                foreach (StudentRecord student in _students)
                {
                    //如果學生通過畢業審查
                    if (_passList[student.ID])
                    {
                        continue;
                    }

                    //如果審查結果沒有該學生編號則跳到下一筆 (這應該不會發生才對)
                    if (!_result.ContainsKey(student.ID))
                    {
                        continue;
                    }

                    List <ResultDetail> rdList = _result[student.ID];
                    foreach (ResultDetail rd in rdList)
                    {
                        foreach (string msg in rd.Messages)
                        {
                            JHTagConfigRecord tagConfigRecord = new JHTagConfigRecord();
                            tagConfigRecord.Prefix   = FailurePrefix;
                            tagConfigRecord.Name     = msg;
                            tagConfigRecord.Category = "Student";
                            if (!tagList.Contains(tagConfigRecord, tagComparer))
                            {
                                tagConfigRecordList.Add(tagConfigRecord);
                                tagList.Add(tagConfigRecord);
                                //foreach (string tag_id in JHSchool.Data.TagConfig.Insert(tagConfigRecord))
                                //{
                                //    if (!tagIDs.ContainsKey(tagConfigRecord.FullName))
                                //        tagIDs.Add(tagConfigRecord.FullName, tag_id);
                                //}
                            }
                        }
                    }
                }

                JHTagConfig.Insert(tagConfigRecordList);
                tagList = JHTagConfig.SelectByCategory(K12.Data.TagCategory.Student);
                #endregion

                #region 貼上標籤
                List <JHStudentTagRecord> studentTagsList = new List <JHStudentTagRecord>();
                List <JHStudentTagRecord> deleteList      = new List <JHStudentTagRecord>();
                foreach (StudentRecord student in _students)
                {
                    //如果學生通過畢業審查,應該把標籤拿下來
                    if (_passList[student.ID])
                    {
                        foreach (JHStudentTagRecord student_tag in JHStudentTag.SelectByStudentID(student.ID))
                        {
                            if (student_tag.Prefix == FailurePrefix)
                            {
                                deleteList.Add(student_tag);
                            }
                        }
                        continue;
                    }

                    if (!_result.ContainsKey(student.ID))
                    {
                        continue;
                    }

                    Dictionary <string, JHStudentTagRecord> studentTags = new Dictionary <string, JHStudentTagRecord>();
                    foreach (JHStudentTagRecord student_tag in JHStudentTag.SelectByStudentID(student.ID))
                    {
                        if (!studentTags.ContainsKey(student_tag.RefTagID))
                        {
                            studentTags.Add(student_tag.RefTagID, student_tag);
                        }
                    }

                    List <ResultDetail> rdList = _result[student.ID];
                    foreach (ResultDetail rd in rdList)
                    {
                        foreach (string msg in rd.Messages)
                        {
                            string fullname = FailurePrefix + ":" + msg;

                            foreach (JHTagConfigRecord record in tagList)
                            {
                                if (record.FullName == fullname && !studentTags.ContainsKey(record.ID))
                                {
                                    JHStudentTagRecord r = new JHStudentTagRecord();
                                    r.RefTagID    = record.ID;
                                    r.RefEntityID = student.ID;
                                    if (!studentTagsList.Contains(r, studentTagComparer))
                                    {
                                        studentTagsList.Add(r);
                                    }
                                }
                            }
                        }
                    }
                }

                JHStudentTag.Insert(studentTagsList);
                JHStudentTag.Delete(deleteList);
                #endregion
            }
            catch (Exception ex)
            {
                BugReporter.ReportException(ex, false);
            }

            #endregion
        }