Exemple #1
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (textBoxX1.Text != "")
            {
                string ruleName = (iiSchoolYear.Value > 0 ? "" + iiSchoolYear.Value : "") + textBoxX1.Text;

                _CopyElement = ReviseXmlContent(_CopyElement, iiSchoolYear.Value);

                try
                {
                    SmartSchool.Feature.SubjectTable.AddSubejctTable.Insert(ruleName, _Catalog, _CopyElement);
                }
                catch (Exception ex)
                {
                    CurrentUser user = CurrentUser.Instance;
                    BugReporter.ReportException("SmartSchool", user.SystemVersion, ex, false);
                    MsgBox.Show("新增" + _Catalog + "時發生未預期之錯誤。\n系統已回報此錯誤內容。");
                }
                SubjectTable.Items[_Catalog].Reflash();
                FrmSubjectTableConfiguration.SetAdvTreeExpandStatus(iiSchoolYear.Value.ToString(), true);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                MsgBox.Show("必需輸入" + _Catalog + "名稱。");
            }
        }
 private void _historyWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         _errorList.AddRange(Graduation.Instance.CheckSemesterHistories(_students));
     }
     catch (Exception ex)
     {
         MsgBox.Show("檢查學期歷程時發生錯誤。" + ex.Message);
         BugReporter.ReportException(ex, true);
     }
 }
        void bkwDataLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            Dictionary <List <string>, ManualResetEvent>   handle = (Dictionary <List <string>, ManualResetEvent>)((object[])e.Argument)[0];
            Dictionary <ManualResetEvent, List <RowData> > Filler = (Dictionary <ManualResetEvent, List <RowData> >)((object[])e.Argument)[1];
            List <string> exportFieldList = (List <string>)((object[])e.Argument)[2];

            foreach (List <string> splitList in handle.Keys)
            {
                try
                {
                    if (ExportPackage != null)
                    {
                        ExportPackageEventArgs args = new ExportPackageEventArgs();
                        foreach (string var in splitList)
                        {
                            args.List.Add(var);
                        }
                        foreach (string var in exportFieldList)
                        {
                            if (_ExportableFields.Contains(var))
                            {
                                args.ExportFields.Add(var);
                            }
                        }
                        ExportPackage.Invoke(this, args);
                        Filler[handle[splitList]].AddRange(args.Items);
                    }
                }
                catch (Exception ex)
                {
                    BugReporter.ReportException(ex, false);
                }
                finally
                {
                    handle[splitList].Set();
                }
            }
        }
        public bool Validate(GraduationPlanInfo info, IErrorViewer responseViewer)
        {
            _OneTimeOneCheck.WaitOne();
            bool pass = true;

            try
            {
                if (!_PassedList.Contains(info))
                {
                    _Editor.SetSource(info.GraduationPlanElement);
                    pass &= _Editor.IsValidated;
                    pass &= _Editor.GetSource().SelectNodes("Subject").Count == info.GraduationPlanElement.SelectNodes("Subject").Count;
                    if (pass)
                    {
                        foreach (XmlNode var in _Editor.GetSource().SelectNodes("Subject"))
                        {
                            XmlElement subject1 = (XmlElement)var;
                            XmlElement subject2 = (XmlElement)info.GraduationPlanElement.SelectSingleNode("Subject[@SubjectName='" + subject1.GetAttribute("SubjectName") + "' and @Level='" + subject1.GetAttribute("Level") + "']");
                            if (subject2 != null)
                            {
                                foreach (XmlAttribute attributeInfo in subject1.Attributes)
                                {
                                    if (subject1.GetAttribute(attributeInfo.Name) != subject2.GetAttribute(attributeInfo.Name))
                                    {
                                        pass = false;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                pass = false;
                                break;
                            }
                        }
                    }
                    if (pass)
                    {
                        _PassedList.Add(info);
                    }
                }
                if (pass)
                {
                    foreach (IValidater <GraduationPlanInfo> extendValidater in _ExtendValidater)
                    {
                        pass &= extendValidater.Validate(info, responseViewer);
                    }
                }
                else
                {
                    if (responseViewer != null)
                    {
                        responseViewer.SetMessage("課程規畫表:\"" + info.Name + "\"驗證失敗");
                    }
                    pass = false;
                }
                _OneTimeOneCheck.Set();
            }
            catch (Exception ex)
            {
                if (responseViewer != null)
                {
                    responseViewer.SetMessage("課程規畫表:\"" + info.Name + "\"在驗證過程中發生未預期錯誤");
                }
                BugReporter.ReportException("SmartSchool", CurrentUser.Instance.SystemVersion, ex, false);
                _OneTimeOneCheck.Set();
                return(false);
            }
            return(pass);
        }
Exemple #5
0
        public static void Main()
        {
            if (System.IO.File.Exists(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "阿寶萬歲萬歲萬萬歲")))
            {
                return;
            }

            //毛毛蟲
            List <Customization.PlugIn.ExtendedContent.IContentItem> _items = new List <Customization.PlugIn.ExtendedContent.IContentItem>();

            List <Type> _type_list = new List <Type>(new Type[] {
                //// 異動資料項目(舊)先註
                //typeof(Content.UpdatePalmerwormItem)
            });

            foreach (Type type in _type_list)
            {
                if (!Attribute.IsDefined(type, typeof(SmartSchool.AccessControl.FeatureCodeAttribute)) || CurrentUser.Acl[type].Viewable)
                {
                    try
                    {
                        IContentItem item = type.GetConstructor(Type.EmptyTypes).Invoke(null) as IContentItem;
                        _items.Add(item);
                    }
                    catch (Exception ex) { BugReporter.ReportException(ex, false); }
                }
            }
            foreach (Customization.PlugIn.ExtendedContent.IContentItem var in _items)
            {
                K12.Presentation.NLDPanels.Student.AddDetailBulider(new ContentItemBulider(var));
            }

            //UserControl1 updateRecord = new UserControl1();
            //BaseItem item = c.ProcessRibbon.Items[0];

            //SmartSchool.Customization.PlugIn.GeneralizationPluhgInManager<BaseItem>.Instance[@"學生\指定"].Add(item);
            //SmartSchool.Customization.PlugIn.GeneralizationPluhgInManager<BaseItem>.Instance.Add(@"學生\學籍作業", updateRecord);

            // 舊功能
            //名冊Ribbon
            //new Process.NameList();

            // 批次畢業異動功能
            new Process.BatchUpdateRecord();

            RibbonBarButton rbItemExport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯出"];

            #region 匯出(1000708)

            //rbItemExport["異動相關匯出"]["匯出新生異動"].Enable = CurrentUser.Acl["Button0200"].Executable;
            //rbItemExport["異動相關匯出"]["匯出新生異動"].Click += delegate
            //{
            //    new ExportStudent(new ExportNewStudentsUpdateRecord()).ShowDialog();
            //};

            //rbItemExport["異動相關匯出"]["匯出轉入異動"].Enable = CurrentUser.Acl["Button0200"].Executable;
            //rbItemExport["異動相關匯出"]["匯出轉入異動"].Click += delegate
            //{
            //    new ExportStudent(new ExportTransferSchoolStudentsUpdateRecord()).ShowDialog();
            //};

            //rbItemExport["異動相關匯出"]["匯出學籍異動"].Enable = CurrentUser.Acl["Button0200"].Executable;
            //rbItemExport["異動相關匯出"]["匯出學籍異動"].Click += delegate
            //{
            //    new ExportStudent(new ExprotStudentsUpdateRecord()).ShowDialog();
            //};

            //rbItemExport["異動相關匯出"]["匯出畢業異動"].Enable = CurrentUser.Acl["Button0200"].Executable;
            //rbItemExport["異動相關匯出"]["匯出畢業異動"].Click += delegate
            //{
            //    new ExportStudent(new ExportStudentGraduateUpdateRecord()).ShowDialog();
            //};
            #endregion


            RibbonBarButton rbItemImport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯入"];

            #region 匯入(1000708)
            //rbItemImport["異動相關匯入"]["匯入新生異動"].Enable = CurrentUser.Acl["Button0280"].Executable;
            //rbItemImport["異動相關匯入"]["匯入新生異動"].Click += delegate
            //{
            //    new ImportStudent(new ImportNewStudentsUpdateRecord()).ShowDialog();
            //};

            //rbItemImport["異動相關匯入"]["匯入轉入異動"].Enable = CurrentUser.Acl["Button0280"].Executable;
            //rbItemImport["異動相關匯入"]["匯入轉入異動"].Click += delegate
            //{
            //    new ImportStudent(new ImportTransferSchoolStudentsUpdateRecord()).ShowDialog();
            //};

            //rbItemImport["異動相關匯入"]["匯入畢業異動"].Enable = CurrentUser.Acl["Button0280"].Executable;
            //rbItemImport["異動相關匯入"]["匯入畢業異動"].Click += delegate
            //{
            //    new ImportStudent(new ImportStudentGraduateUpdateRecord()).ShowDialog();
            //};
            #endregion

            //匯出異動紀錄(1000708註解)
            //SmartSchool.Customization.PlugIn.ImportExport.ExportStudent.AddProcess(new ImportExport.ExportNewStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ExportStudent.AddProcess(new ImportExport.ExportTransferSchoolStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ExportStudent.AddProcess(new ImportExport.ExprotStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ExportStudent.AddProcess(new ImportExport.ExportStudentGraduateUpdateRecord());

            //匯入異動紀錄(1000708註解)
            //SmartSchool.Customization.PlugIn.ImportExport.ImportStudent.AddProcess(new ImportExport.ImportNewStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ImportStudent.AddProcess(new ImportExport.ImportTransferSchoolStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ImportStudent.AddProcess(new ImportExport.ImportStudentGraduateUpdateRecord());

            //??被註解
            //SmartSchool.Customization.PlugIn.ImportExport.ImportStudent.AddProcess(new ImportExport.ImportStudentsUpdateRecord());
            //SmartSchool.Customization.PlugIn.ImportExport.ImportStudent.AddProcess(new ImportExport.ImportStudentGraduateUpdateRecord());
            SmartSchool.Customization.Data.StudentHelper.FillingUpdateRecord += new EventHandler <SmartSchool.Customization.Data.FillEventArgs <SmartSchool.Customization.Data.StudentRecord> >(StudentHelper_FillingUpdateRecord);
        }
        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
        }