コード例 #1
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                int RowCount = 0;
                foreach (DAL.UserDefData udd in UDTTransfer.GetDataFromUDT(e.List))
                {
                    RowData row = new RowData();
                    row.ID = udd.RefID;

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "欄位名稱": row.Add(field, udd.FieldName); break;
                                case "值": row.Add(field, udd.Value); break;
                            }
                        }

                    }
                    RowCount++;
                    e.Items.Add(row);
                }
            };
        }
コード例 #2
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                int RowCount = 0;

                List<DAO.UDT_CounselUserDefDataDef> CounselUserDefDataList = _UDTTransfer.GetCounselUserDefineDataByStudentIDList(e.List);

                foreach (DAO.UDT_CounselUserDefDataDef udd in CounselUserDefDataList)
                {
                    RowData row = new RowData();
                    row.ID = udd.StudentID.ToString ();

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "欄位名稱": row.Add(field, udd.FieldName); break;
                                case "值": row.Add(field, udd.Value); break;
                                case "狀態":
                                    row.Add(field, udd.StudentStatus);
                                    break;

                            }
                        }

                    }
                    RowCount++;
                    e.Items.Add(row);
                }
            };
        }
コード例 #3
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(_ExportList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 取得異動代碼
                XElement _UpdateCode=DAL.DALTransfer.GetUpdateCodeList();
                List<string> UpdateCodeList = (from elm in _UpdateCode.Elements("異動") where elm.Element("分類").Value == "新生異動" select elm.Element("代號").Value).ToList();
                // 取得學生新生異動
                List<SHUpdateRecordRecord> updateRecList = (from data in SHUpdateRecord.SelectByStudentIDs(e.List) where UpdateCodeList.Contains(data.UpdateCode) select data).ToList();
            Dictionary<string, string> StudentStatusDict = DAL.FDQuery.GetAllStudentStatus1Dict();

            foreach (SHUpdateRecordRecord rec in updateRecList)
            {
                RowData row = new RowData();
                row.ID = rec.StudentID;
                foreach (string field in e.ExportFields)
                {
                    if (wizard.ExportableFields.Contains(field))
                    {
                        switch(field)
                        {
                            case "學年度":
                                if(rec.SchoolYear.HasValue )
                                    row.Add(field, rec.SchoolYear.Value.ToString ()); break;
                            case "學期":
                                if(rec.Semester.HasValue )
                                    row.Add(field, rec.Semester.Value.ToString ()); break;
                            case "年級": row.Add(field, rec.GradeYear); break;
                            case "異動代碼": row.Add(field, rec.UpdateCode); break;
                            case "原因及事項": row.Add(field, rec.UpdateDescription); break;
                            case "異動日期": row.Add(field, rec.UpdateDate); break;
                            case "備註": row.Add(field, rec.Comment); break;
                            case "班別": row.Add(field, rec.ClassType); break;
                            case "科別": row.Add(field, rec.Department); break;
                            case "特殊身分代碼": row.Add(field, rec.SpecialStatus); break;
                            case "入學資格證明文件": row.Add(field, rec.GraduateDocument); break;
                            case "異動姓名": row.Add(field, rec.StudentName); break;
                            case "異動學號": row.Add(field, rec.StudentNumber); break;
                            case "異動身分證字號": row.Add(field, rec.IDNumber); break;
                            case "異動生日": row.Add(field, rec.Birthdate); break;
                            case "異動身分證註記": row.Add(field, rec.IDNumberComment); break;
                            case "異動性別": row.Add(field, rec.Gender); break;
                            case "畢業國中": row.Add(field, rec.GraduateSchool); break;
                            case "畢業國中所在地代碼": row.Add(field, rec.GraduateSchoolLocationCode); break;
                            case "畢業國中學校代碼": row.Add(field, rec.GraduateSchoolCode); break;
                            case "畢業國中畢業學年度": row.Add(field, rec.GraduateSchoolYear); break;
                            case "畢業國中入學資格註記": row.Add(field, rec.GraduateComment); break;
                            case "核准日期": row.Add(field, rec.ADDate); break;
                            case "核准文號": row.Add(field, rec.ADNumber); break;
                            case "狀態":
                                if(StudentStatusDict.ContainsKey(rec.StudentID))
                                    row.Add(field, StudentStatusDict[rec.StudentID]); break;
                        }
                    }
                }
                e.Items.Add(row);
            }
            };
        }
コード例 #4
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 學生類別組合
                Dictionary<string, StudentTagEntity> StudTagDict = new Dictionary<string, StudentTagEntity>();

                // 取得學生類別
                foreach (StudentTagRecord studTagRec in StudentTag.SelectByStudentIDs(e.List))
                {
                    if (StudTagDict.ContainsKey(studTagRec.RefStudentID))
                        StudTagDict[studTagRec.RefStudentID].AddPrefixName(studTagRec.Prefix, studTagRec.Name);
                    else
                    {
                        StudentTagEntity stn = new StudentTagEntity();
                        stn.StudentID = studTagRec.RefStudentID;
                        stn.AddPrefixName(studTagRec.Prefix, studTagRec.Name);
                        StudTagDict.Add(studTagRec.RefStudentID, stn);
                    }
                }

                // 讀取組合後的學生類別
                foreach (StudentTagEntity ste in StudTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in ste.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = ste.StudentID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("學生.匯出類別", "匯出", "共匯出" + StudTagDict.Values.Count + "筆學生類別資料.");
            };
        }
コード例 #5
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 教師類別組合
                Dictionary<string, TeacherTagEntity> teachTagDict = new Dictionary<string, TeacherTagEntity>();
                // 取得教師類別
                foreach (TeacherTagRecord teachTagRec in TeacherTag.SelectByTeacherIDs(e.List))
                {
                    if (teachTagDict.ContainsKey(teachTagRec.RefTeacherID))
                        teachTagDict[teachTagRec.RefTeacherID].AddPrefixName(teachTagRec.Prefix, teachTagRec.Name);
                    else
                    {
                        TeacherTagEntity stn = new TeacherTagEntity();
                        stn.TeacherID = teachTagRec.RefTeacherID;
                        stn.AddPrefixName(teachTagRec.Prefix, teachTagRec.Name);
                        teachTagDict.Add(teachTagRec.RefTeacherID, stn);
                    }
                }

                // 讀取組合後的教師類別
                foreach (TeacherTagEntity teach in teachTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in teach.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = teach.TeacherID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("教師.匯出類別", "匯出", "共匯出" + teachTagDict.Values.Count + "筆教師類別資料.");
            };
        }
コード例 #6
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 班級類別組合
                Dictionary<string, CourseTagEntity> courTagDict = new Dictionary<string, CourseTagEntity>();
                // 取得班級類別
                foreach (CourseTagRecord courTagRec in CourseTag.SelectByCourseIDs(e.List))
                {
                    if (courTagDict.ContainsKey(courTagRec.RefCourseID))
                        courTagDict[courTagRec.RefCourseID].AddPrefixName(courTagRec.Prefix, courTagRec.Name);
                    else
                    {
                        CourseTagEntity cou = new CourseTagEntity();
                        cou.ClassID = courTagRec.RefCourseID;
                        cou.AddPrefixName(courTagRec.Prefix, courTagRec.Name);
                        courTagDict.Add(courTagRec.RefCourseID, cou);
                    }
                }

                // 讀取組合後的學生類別
                foreach (CourseTagEntity cour in courTagDict.Values)
                {
                    foreach (KeyValuePair<string, List<string>> data in cour.GetPrefixNameDic())
                    {
                        // 當群組空白
                        string key = string.Empty;
                        if (data.Key != " ")
                            key = data.Key;

                        // 類別名稱
                        foreach (string str in data.Value)
                        {
                            RowData row = new RowData();
                            foreach (string field in e.ExportFields)
                            {
                                row.ID = cour.ClassID;

                                if (field == "群組")
                                    row.Add(field, key);

                                if (field == "類別名稱")
                                    row.Add(field, str);
                            }
                            e.Items.Add(row);
                        }
                    }
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("課程.匯出類別", "匯出", "共匯出" + courTagDict.Values.Count + "筆課程類別資料.");
            };
        }
コード例 #7
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                RowData row = new RowData();

                foreach (string field in e.ExportFields)
                {
                    if (wizard.ExportableFields.Contains(field))
                    {
                        switch (field)
                        {
                            case "": break;
                        }
                    }
                }
                e.Items.Add(row);

                // 寫 Log
                // ApplicationLog.Log();
            };
        }
コード例 #8
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 取得學生資料
            Dictionary<string, StudentRecord> Students = new Dictionary<string, StudentRecord>();

            // 取得自訂資料欄位資料
            Dictionary<string,List<DAL.UserDefData>> UserDefDataDict = new Dictionary<string,List<UserDefineData.DAL.UserDefData>> ();

            // 取得使用這設定
            Dictionary<string, string> UserSetDataTypeDict = new Dictionary<string, string>();

            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange("欄位名稱","值");
            wizard.RequiredFields.AddRange("欄位名稱");
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                Students.Clear();
                UserDefDataDict.Clear();
                UserSetDataTypeDict.Clear();

                UserSetDataTypeDict = Global.GetUserConfigData();

                // 取得學生資料
                foreach (StudentRecord studRec in Student.SelectByIDs(e.List))
                    if (!Students.ContainsKey(studRec.ID))
                        Students.Add(studRec.ID, studRec);

                // 取得自訂資料欄位
                MultiThreadWorker<string> loader1 = new MultiThreadWorker<string>();
                loader1.MaxThreads = 3;
                loader1.PackageSize = 250;
                loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs<string> e1)
                {
                    foreach (DAL.UserDefData udd in UDTTransfer.GetDataFromUDT(e.List.ToList<string>()))
                    {
                        if(UserDefDataDict.ContainsKey(udd.RefID ))
                            UserDefDataDict[udd.RefID].Add(udd);
                        else
                        {
                            List<DAL.UserDefData> dd = new List<UserDefineData.DAL.UserDefData>();
                            dd.Add(udd);
                            UserDefDataDict.Add(udd.RefID,dd);
                        }
                    }
                };
                loader1.Run(e.List);
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int i = 0;
                // 檢查學生是否存在
                StudentRecord studRec = null;
                if (Students.ContainsKey(e.Data.ID))
                    studRec = Students[e.Data.ID];
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }

                // 驗證格式資料
                // 檢查每位學生欄位是否有重複
                List<string> CheckSameList = new List<string>();
                bool InputFormatPass = true;
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();
                    switch (field)
                    {
                        default:
                            break;

                        case "欄位名稱":
                            if (string.IsNullOrEmpty(value))
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "不允許空白");
                            }
                            string key = e.Data.ID + value;
                            if (CheckSameList.Contains(key))
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "欄位名稱:"+value+" 不允許重複");
                            }
                            CheckSameList.Add(key);
                            break;
                        case "值":
                            decimal dd; DateTime dt;
                            if (!string.IsNullOrEmpty(value))
                            {
                                if (e.Data.ContainsKey("欄位名稱"))
                                {
                                    string str = e.Data["欄位名稱"];

                                    if (UserSetDataTypeDict.ContainsKey(str))
                                    {
                                        if (UserSetDataTypeDict[str] == "Number")
                                        {
                                            if (!decimal.TryParse(value, out dd))
                                            {
                                                e.ErrorFields.Add(field, "非數字型態");
                                                InputFormatPass &= false;
                                                break;
                                            }
                                        }

                                        if (UserSetDataTypeDict[str] == "Date")
                                        {
                                            if (!DateTime.TryParse(value, out dt))
                                            {
                                                e.ErrorFields.Add(field, "非日期型態");
                                                InputFormatPass &= false;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            break;
                    }
                }

            };

            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {

                Dictionary<string, List<RowData>> id_Rows = new Dictionary<string, List<RowData>>();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                        id_Rows.Add(data.ID, new List<RowData>());
                    id_Rows[data.ID].Add(data);
                }

                List<DAL.UserDefData> InsertList = new List<UserDefineData.DAL.UserDefData> ();
                List<DAL.UserDefData> DeleteList = new List<UserDefineData.DAL.UserDefData>();

                foreach (string id in id_Rows.Keys)
                {
                    foreach (RowData data in id_Rows[id])
                    {
                        string FName = string.Empty, Value = string.Empty;
                        if (data.ContainsKey("欄位名稱"))
                            FName = data["欄位名稱"];

                        if (data.ContainsKey("值"))
                            Value = data["值"];

                        // 將需要刪除放入
                        if (UserDefDataDict.ContainsKey(id))
                        foreach (DAL.UserDefData udd in UserDefDataDict[id])
                            if (udd.FieldName == FName)
                            {
                                udd.Deleted = true;
                                DeleteList.Add(udd);
                            }

                        // 新增資料
                        DAL.UserDefData uddNew = new UserDefineData.DAL.UserDefData();
                        uddNew.FieldName = FName;
                        uddNew.RefID = id;
                        uddNew.Value = Value;
                        InsertList.Add(uddNew);
                    }
                }

                try
                {
                    // 先刪除舊的資料在新增新的
                    if(DeleteList.Count >0)
                        UDTTransfer.DeleteDataToUDT(DeleteList);

                    if (InsertList.Count > 0)
                        UDTTransfer.InsertDataToUDT(InsertList );

                    JHSchool.Student.Instance.SyncAllBackground();
                }
                catch (Exception ex) { }

            };
        }
コード例 #9
0
 public void AddWarning(SmartSchool.API.PlugIn.RowData rowData, string message)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #10
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            List<string> SelectedFields = new List<string>() { "學生系統編號", "學號", "班級", "座號", "姓名" };
            List<string> SelectableFields = new List<string>(){"領域","科目","學年度", "學期","權數","節數" , "成績" , "GPA" ,"Level"};

            wizard.SelectedFields.AddRange(SelectedFields);
            wizard.ExportableFields.AddRange(SelectableFields);

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                try
                {
                    List<string> StudentIDs = e.List;

                    string strScoreSQL = "select ref_student_id,school_year,semester,score_info from sems_subj_score where ref_student_id in (" + string.Join(",", StudentIDs.ToArray()) + ")";

                    QueryHelper QueryHelper = Utility.QueryHelper;

                    //學生系統編號 學號 班級 座號 姓名 領域 科目	學年度 學期 權數 節數 成績 GPA Level

                    DataTable tblScore = QueryHelper.Select(strScoreSQL);

                    foreach (DataRow row in tblScore.Rows)
                    {
                        string StudentID = row.Field<string>("ref_student_id");
                        string SchoolYear = row.Field<string>("school_year");
                        string Semester = row.Field<string>("semester");
                        string ScoreInfo = "<root>" + row.Field<string>("score_info") + "</root>";

                        XElement elmScoreInfo = XElement.Load(new StringReader(ScoreInfo));

                        foreach (XElement elmSubject in elmScoreInfo
                            .Element("SemesterSubjectScoreInfo")
                            .Elements("Subject"))
                        {
                            RowData vRow = new RowData();

                            //<Subject GPA=""4.5"" Level=""11"" 努力程度="""" 成績=""100"" 文字描述="""" 權數=""1"" 科目=""物理"" 節數=""1"" 註記="""" 領域=""""/>
                            // "學年度", "學期","領域","科目","權數","節數" , "成績" , "GPA" ,"Level"

                            vRow.ID = StudentID;
                            string Subject = elmSubject.AttributeText("科目");
                            string Score = elmSubject.AttributeText("成績");
                            string Period = elmSubject.AttributeText("節數");
                            string Domain = elmSubject.AttributeText("領域");
                            string Grade = Score;

                            vRow.Add("學年度", SchoolYear);
                            vRow.Add("學期", Semester);
                            vRow.Add("領域", Domain);
                            vRow.Add("科目", Subject);
                            vRow.Add("權數", elmSubject.AttributeText("權數"));
                            vRow.Add("節數", elmSubject.AttributeText("節數"));
                            vRow.Add("成績", elmSubject.AttributeText("成績"));
                            vRow.Add("GPA", elmSubject.AttributeText("GPA"));
                            vRow.Add("Level", elmSubject.AttributeText("Level"));

                            e.Items.Add(vRow);
                        }
                    }
                }
                catch (Exception ve)
                {
                    MessageBox.Show(ve.Message);
                }
            };
        }
コード例 #11
0
        //覆寫
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            List<string> FieldList = new List<string>();
            FieldList.Add("学年度"); //目前字段
            FieldList.Add("学期"); //目前字段
            FieldList.Add("课程名称"); //目前字段
            FieldList.Add("代码");
            FieldList.Add("场地");
            FieldList.Add("类型");

            FieldList.Add("长短课程");
            FieldList.Add("课程领域");
            FieldList.Add("课程属性");
            FieldList.Add("上课形式");

            FieldList.Add("老师1");
            FieldList.Add("老师2");
            FieldList.Add("老师3");

            FieldList.Add("总课时数");
            FieldList.Add("简介");

            FieldList.Add("限制:一年级选课人数限制");
            FieldList.Add("限制:二年级选课人数限制");
            FieldList.Add("限制:三年级选课人数限制");
            FieldList.Add("限制:四年级选课人数限制");
            FieldList.Add("限制:五年级选课人数限制");

            FieldList.Add("限制:一年级选课人数男生限制");
            FieldList.Add("限制:二年级选课人数男生限制");
            FieldList.Add("限制:三年级选课人数男生限制");
            FieldList.Add("限制:四年级选课人数男生限制");
            FieldList.Add("限制:五年级选课人数男生限制");

            FieldList.Add("限制:一年级选课人数女生限制");
            FieldList.Add("限制:二年级选课人数女生限制");
            FieldList.Add("限制:三年级选课人数女生限制");
            FieldList.Add("限制:四年级选课人数女生限制");
            FieldList.Add("限制:五年级选课人数女生限制");


            //取得教師
            TeacherDic = GetTeacher();



            wizard.ExportableFields.AddRange(FieldList);

            wizard.ExportPackage += (sender, e) =>
            {
                //取得學生清單

                AccessHelper helper = new AccessHelper();

                string strCondition = string.Join("','", e.List);
                List<CLUBRecord> records = helper.Select<CLUBRecord>("uid in ('" + strCondition + "')");

                for (int i = 0; i < records.Count; i++)
                {
                    RowData row = new RowData();
                    row.ID = records[i].UID;

                    string teacher1 = "";
                    string teacher2 = "";
                    string teacher3 = "";
                    if (TeacherDic.ContainsKey(records[i].RefTeacherID))
                        teacher1 = TeacherDic[records[i].RefTeacherID];

                    if (TeacherDic.ContainsKey(records[i].RefTeacherID2))
                        teacher2 = TeacherDic[records[i].RefTeacherID2];

                    if (TeacherDic.ContainsKey(records[i].RefTeacherID3))
                        teacher3 = TeacherDic[records[i].RefTeacherID3];

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "学年度": row.Add(field, "" + records[i].SchoolYear); break;
                                case "学期": row.Add(field, "" + records[i].Semester); break;
                                case "课程名称": row.Add(field, records[i].ClubName); break;
                                case "代码": row.Add(field, records[i].ClubNumber); break;
                                case "场地": row.Add(field, records[i].Location); break;
                                case "类型": row.Add(field, records[i].ClubCategory); break;

                                case "长短课程": row.Add(field, records[i].FullPhase.HasValue && records[i].FullPhase.Value ? "长课程" : ""); break;
                                case "课程领域": row.Add(field, records[i].Domain); break;
                                case "课程属性": row.Add(field, records[i].Type); break;
                                case "上课形式": row.Add(field, records[i].Formal); break;


                                case "老师1": row.Add(field, teacher1); break;
                                case "老师2": row.Add(field, teacher2); break;
                                case "老师3": row.Add(field, teacher3); break;
                                case "总课时数": row.Add(field, records[i].TotalNumberHours.HasValue ? records[i].TotalNumberHours.Value.ToString() : ""); break;
                                case "简介": row.Add(field, records[i].About); break;

                                case "限制:一年级选课人数限制": row.Add(field, records[i].Grade1Limit.HasValue ? "" + records[i].Grade1Limit.Value : ""); break;
                                case "限制:二年级选课人数限制": row.Add(field, records[i].Grade2Limit.HasValue ? "" + records[i].Grade2Limit.Value : ""); break;
                                case "限制:三年级选课人数限制": row.Add(field, records[i].Grade3Limit.HasValue ? "" + records[i].Grade3Limit.Value : ""); break;
                                case "限制:四年级选课人数限制": row.Add(field, records[i].Grade4Limit.HasValue ? "" + records[i].Grade4Limit.Value : ""); break;
                                case "限制:五年级选课人数限制": row.Add(field, records[i].Grade5Limit.HasValue ? "" + records[i].Grade5Limit.Value : ""); break;

                                case "限制:一年级选课人数男生限制": row.Add(field, records[i].Grade1BoyLimit.HasValue ? "" + records[i].Grade1BoyLimit.Value : ""); break;
                                case "限制:二年级选课人数男生限制": row.Add(field, records[i].Grade2BoyLimit.HasValue ? "" + records[i].Grade2BoyLimit.Value : ""); break;
                                case "限制:三年级选课人数男生限制": row.Add(field, records[i].Grade3BoyLimit.HasValue ? "" + records[i].Grade3BoyLimit.Value : ""); break;
                                case "限制:四年级选课人数男生限制": row.Add(field, records[i].Grade4BoyLimit.HasValue ? "" + records[i].Grade4BoyLimit.Value : ""); break;
                                case "限制:五年级选课人数男生限制": row.Add(field, records[i].Grade5BoyLimit.HasValue ? "" + records[i].Grade5BoyLimit.Value : ""); break;

                                case "限制:一年级选课人数女生限制": row.Add(field, records[i].Grade1GirlLimit.HasValue ? "" + records[i].Grade1GirlLimit.Value : ""); break;
                                case "限制:二年级选课人数女生限制": row.Add(field, records[i].Grade2GirlLimit.HasValue ? "" + records[i].Grade2GirlLimit.Value : ""); break;
                                case "限制:三年级选课人数女生限制": row.Add(field, records[i].Grade3GirlLimit.HasValue ? "" + records[i].Grade3GirlLimit.Value : ""); break;
                                case "限制:四年级选课人数女生限制": row.Add(field, records[i].Grade4GirlLimit.HasValue ? "" + records[i].Grade4GirlLimit.Value : ""); break;
                                case "限制:五年级选课人数女生限制": row.Add(field, records[i].Grade5GirlLimit.HasValue ? "" + records[i].Grade5GirlLimit.Value : ""); break;

                            }
                        }
                    }
                    e.Items.Add(row);
                }
            };
        }
コード例 #12
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            AccessHelper helper = new AccessHelper();

            Dictionary<string, CLUBRecord> AllClubDic = new Dictionary<string, CLUBRecord>();
            Dictionary<string, List<string>> SemesterClub = new Dictionary<string, List<string>>();
            //社團基本資料
            List<CLUBRecord> ClubList = helper.Select<CLUBRecord>();
            foreach (CLUBRecord each in ClubList)
            {
                if (!AllClubDic.ContainsKey(each.UID))
                {
                    AllClubDic.Add(each.UID, each);
                }

                string SchoolYearSemester = each.SchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + each.Semester.ToString() + "学期";

                if (!SemesterClub.ContainsKey(SchoolYearSemester))
                {
                    //學年度學期名稱/當學期的社團課程ID清單
                    SemesterClub.Add(SchoolYearSemester, new List<string>());
                }

                SemesterClub[SchoolYearSemester].Add(each.UID);
            }

            var FiltedSemester = School.DefaultSchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + School.DefaultSemester + "学期";
            List<string> list = new List<string>();

            foreach (string item in SemesterClub.Keys)
            {
                list.Add(item);
            }
            list.Sort();
            if (list.Count > 0 && !list.Contains(FiltedSemester))
                FiltedSemester = list[0];

            foreach (string item in list)
            {
                SmartSchool.API.PlugIn.VirtualRadioButton radioSem = new VirtualRadioButton(item);
                wizard.Options.Add(radioSem);
                if (item == FiltedSemester)
                    radioSem.Checked = true;
                radioSem.CheckedChanged += delegate(object sender1, EventArgs e1)
                {
                    var target = sender1 as SmartSchool.API.PlugIn.VirtualRadioButton;
                    if (target.Checked)
                        FiltedSemester = target.Text;
                };
                //MenuButton mb = e.VirtualButtons[item];
                //mb.AutoCheckOnClick = true;
                //mb.AutoCollapseOnClick = true;
                //mb.Checked = (item == FiltedSemester);
                //mb.Tag = item;
                //mb.CheckedChanged += delegate(object sender1, EventArgs e1)
                //{
                //    MenuButton mb1 = sender1 as MenuButton;
                //    SetClubList(mb1.Text);
                //    FiltedSemester = FilterMenu.Text = mb1.Text;
                //    mb1.Checked = true;
                //};
            }

            wizard.ExportableFields.AddRange(new string[]{
                "班级",
                "学号",
                "姓名",
                "学籍号",
                "性别",
                "第一阶段",
                "第二阶段"
            });
            wizard.ExportPackage += (sender, e) =>
            {
                Dictionary<string, CLUBRecord> ClubRefIDList = new Dictionary<string, CLUBRecord>();
                //List<CLUBRecord> CLUBRecordList = helper.Select<CLUBRecord>(string.Format("uid in ('{0}')", string.Join("','", e.List)));
                //foreach (CLUBRecord record in CLUBRecordList)
                //{
                //    if (!ClubRefIDList.ContainsKey(record.UID))
                //    {
                //        ClubRefIDList.Add(record.UID, record);
                //    }
                //}
                foreach (CLUBRecord each in ClubList)
                {
                    string SchoolYearSemester = each.SchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + each.Semester.ToString() + "学期";
                    if (FiltedSemester == SchoolYearSemester)
                    {
                        ClubRefIDList.Add(each.UID, each);
                    }
                }

                string ClubIdString = string.Join("','", ClubRefIDList.Keys);
                List<SCJoin> Scjoin = helper.Select<SCJoin>(string.Format("ref_club_id in ('{0}') and ref_student_id in ('{1}')", ClubIdString, string.Join("','", e.List)));

                Dictionary<string, List<SCJoin>> StudentScjoinDic = new Dictionary<string, List<SCJoin>>();
                foreach (SCJoin join in Scjoin)
                {
                    if (!StudentScjoinDic.ContainsKey(join.RefStudentID))
                    {
                        StudentScjoinDic.Add(join.RefStudentID, new List<SCJoin>());
                    }
                    StudentScjoinDic[join.RefStudentID].Add(join);
                }

                var studentList = K12.Data.Student.SelectByIDs(e.List);
                foreach (var stuRec in studentList)
                {
                    RowData row = new RowData();

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "班级":
                                    row.Add(field, stuRec.Class == null ? "" : stuRec.Class.Name);
                                    break;
                                case "学号":
                                    row.Add(field, "" + stuRec.SeatNo);
                                    break;
                                case "姓名":
                                    row.Add(field, "" + stuRec.Name);
                                    break;
                                case "学籍号":
                                    row.Add(field, "" + stuRec.StudentNumber);
                                    break;
                                case "性别":
                                    row.Add(field, "" + stuRec.Gender);
                                    break;
                                case "第一阶段":
                                    if (StudentScjoinDic.ContainsKey(stuRec.ID))
                                    {
                                        foreach (var item in StudentScjoinDic[stuRec.ID])
                                        {
                                            if (item.Phase == 1)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += "," + ClubRefIDList[item.RefClubID].ClubName;
                                                else
                                                    row.Add(field, ClubRefIDList[item.RefClubID].ClubName);
                                            }
                                        }
                                    }
                                    break;
                                case "第二阶段":
                                    if (StudentScjoinDic.ContainsKey(stuRec.ID))
                                    {
                                        foreach (var item in StudentScjoinDic[stuRec.ID])
                                        {
                                            if (item.Phase == 1 && ClubRefIDList[item.RefClubID].FullPhase.HasValue && ClubRefIDList[item.RefClubID].FullPhase.Value == true)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += ",--";
                                                else
                                                    row.Add(field, "--");
                                            }
                                            if (item.Phase == 2)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += "," + ClubRefIDList[item.RefClubID].ClubName;
                                                else
                                                    row.Add(field, ClubRefIDList[item.RefClubID].ClubName);
                                            }
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                    e.Items.Add(row);
                }
            };
        }
コード例 #13
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 取得學生資料
            Dictionary<string, SHStudentRecord> Students = new Dictionary<string, SHStudentRecord>();

            // 取得異動資料
            Dictionary<string, List<SHUpdateRecordRecord>> UpdateRecs = new Dictionary<string, List<SHUpdateRecordRecord>>();
            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange("班別", "特殊身份代碼", "異動科別", "年級", "異動學號", "異動姓名", "身分證號", "註1", "異動代碼", "異動日期", "原因及事項", "新學號", "更正後資料", "舊班別", "舊科別代碼", "備查日期", "備查文號", "核准日期", "核准文號", "備註");
            wizard.RequiredFields.AddRange("異動代碼", "異動日期");
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                Students.Clear();
                UpdateRecs.Clear();

                // 取得學生資料
                foreach (SHStudentRecord studRec in SHStudent.SelectByIDs(e.List))
                    if (!Students.ContainsKey(studRec.ID))
                        Students.Add(studRec.ID, studRec);
                foreach (string str in Students.Keys)
                {
                    List<SHUpdateRecordRecord> UpdRecList = new List<SHUpdateRecordRecord>();
                    UpdateRecs.Add(str, UpdRecList);
                }

                // 取得異動
                MultiThreadWorker<string> loader1 = new MultiThreadWorker<string>();
                loader1.MaxThreads = 3;
                loader1.PackageSize = 250;
                loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs<string> e1)
                {
                    foreach (SHUpdateRecordRecord UpdRec in SHUpdateRecord.SelectByStudentIDs(e.List))
                    {

                        // 過濾非符合標準的異動(目前是學籍)
                        if(!_UpdateCodeList.Contains(UpdRec.UpdateCode))
                            continue;

                            if (UpdateRecs.ContainsKey(UpdRec.StudentID))
                                UpdateRecs[UpdRec.StudentID].Add(UpdRec);
                    }
                };
                loader1.Run(e.List);
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int i = 0;
                DateTime dt;
                // 檢查學生是否存在
                SHStudentRecord studRec = null;
                if (Students.ContainsKey(e.Data.ID))
                    studRec = Students[e.Data.ID];
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }

                // 驗證格式資料
                bool InputFormatPass = true;
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();
                    //// 驗證$無法匯入
                    //if (value.IndexOf('$') > -1)
                    //{
                    //    e.ErrorFields.Add(field, "儲存格有$無法匯入.");
                    //    break;
                    //}
                    switch (field)
                    {
                        default:
                            break;

                        //// 班別
                        //case "班別": break;
                        //// 特殊身份代碼
                        //case "特殊身份代碼": break;
                        //// 異動科別
                        //case "異動科別": break;
                        //// 年級
                        //case "年級": break;
                        //// 異動學號
                        //case "異動學號": break;
                        //// 異動姓名
                        //case "異動姓名": break;
                        //// 身分證號
                        //case "身分證號": break;
                        //// 註1
                        //case "註1": break;
                        //// 異動種類
                        //case "異動種類": break;
                        // 異動代碼
                        case "異動代碼":
                            if (!_UpdateCodeList.Contains(value))
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "非學籍異動代碼!");
                            }
                            break;
                        // 異動日期(必填)
                        case "異動日期":
                            DateTime dtC1;
                            if (DateTime.TryParse(value, out dtC1))
                            { }
                            else
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "日期錯誤!");
                            }

                            break;

                        case "備查日期":
                        case "核准日期":
                            DateTime dtC2;
                            if (value.Trim() != "")
                            {
                                if (DateTime.TryParse(value, out dtC2))
                                { }
                                else
                                {
                                    InputFormatPass &= false;
                                    e.ErrorFields.Add(field, "日期錯誤!");
                                }
                            }
                            break;
                        //// 原因及事項
                        //case "原因及事項": break;
                        //// 新學號
                        //case "新學號": break;
                        //// 更正後資料
                        //case "更正後資料": break;
                        //// 舊班別
                        //case "舊班別": break;
                        //// 舊科別代碼
                        //case "舊科別代碼": break;
                        //// 備查日期
                        //case "備查日期":
                        //    break;
                        //// 備查文號
                        //case "備查文號": break;
                        //// 核准日期
                        //case "核准日期": break;
                        //// 核准文號
                        //case "核准文號": break;
                        //// 備註
                        //case "備註": break;
                    }
                }

            };

            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                Dictionary<string, List<RowData>> id_Rows = new Dictionary<string, List<RowData>>();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                        id_Rows.Add(data.ID, new List<RowData>());
                    id_Rows[data.ID].Add(data);
                }

                List<SHUpdateRecordRecord> InsertList = new List<SHUpdateRecordRecord>();
                List<SHUpdateRecordRecord> UpdateList = new List<SHUpdateRecordRecord>();

                // 檢查新增或更新方式:
                // 每筆 Key 為:異動日期+異動代碼+原因及事項,如果三者內容相同更新,如果不同就新增。
                foreach (string id in id_Rows.Keys)
                {
                    DateTime dt;

                    // 讀取工作表內資料
                    foreach (RowData data in id_Rows[id])
                    {
                        // 當異動記錄內沒有工作表讀取轉換後學生ID,就跳過。
                        if (!UpdateRecs.ContainsKey(id))
                            continue;

                        DateTime.TryParse(data["異動日期"], out dt);

                        // 異動代碼
                        string UpdateCode = string.Empty;
                        if (data.ContainsKey("異動代碼"))
                            UpdateCode = data["異動代碼"];

                        // 取得原因及事項
                        string UpdateDesc = string.Empty;
                        if (data.ContainsKey("原因及事項"))
                            UpdateDesc = data["原因及事項"];

                        SHUpdateRecordRecord updateRec = null;
                        // 異動日期+異動代碼 (如果相同有當更新,不同就新增)
                        foreach (SHUpdateRecordRecord urr in UpdateRecs[id])
                        {
                            if (UpdateCode == urr.UpdateCode)
                            {
                                DateTime dt1;
                                DateTime.TryParse(urr.UpdateDate, out dt1);
                                if (dt == dt1)
                                {
                                    // 使用原因及事項當作Key
                                    if(UpdateDesc == urr.UpdateDescription )
                                        updateRec = urr;
                                }
                            }
                        }
                        bool isInsert = true;

                        if (updateRec == null)
                        {
                            updateRec = new SHUpdateRecordRecord();
                            updateRec.StudentID = id;
                        }
                        else
                            isInsert = false;

                        // 這段在做資料填入異動紀錄
                        foreach (string field in e.ImportFields)
                        {
                            string value = data[field].Trim();
                            switch (field)
                            {
                                // 班別
                                case "班別":
                                    updateRec.ClassType = value;
                                    break;
                                // 特殊身份代碼
                                case "特殊身份代碼":
                                    updateRec.SpecialStatus = value;
                                    break;
                                // 異動科別
                                case "異動科別":
                                    updateRec.Department = value;
                                    break;
                                // 年級
                                case "年級":
                                    updateRec.GradeYear = value;
                                    break;
                                // 異動學號
                                case "異動學號":
                                    updateRec.StudentNumber = value;
                                    break;
                                // 異動姓名
                                case "異動姓名":
                                    updateRec.StudentName = value;
                                    break;
                                // 身分證號
                                case "身分證號":
                                    updateRec.IDNumber = value;
                                    break;
                                // 註1
                                case "註1":
                                    updateRec.IDNumberComment = value;
                                    break;
                                //// 異動種類
                                //case "異動種類":
                                //    break;
                                // 異動代碼
                                case "異動代碼":
                                    updateRec.UpdateCode = value;
                                    break;
                                // 異動日期
                                case "異動日期":
                                    DateTime dt1;
                                    if (DateTime.TryParse(value, out dt1))
                                        updateRec.UpdateDate = dt1.ToShortDateString();
                                    break;
                                // 原因及事項
                                case "原因及事項":
                                    updateRec.UpdateDescription = value;
                                    break;
                                // 新學號
                                case "新學號":
                                    updateRec.NewStudentNumber = value;
                                    break;
                                // 更正後資料
                                case "更正後資料":
                                    updateRec.NewData = value;
                                    break;
                                // 舊班別
                                case "舊班別":
                                    updateRec.OldClassType = value;
                                    break;
                                // 舊科別代碼
                                case "舊科別代碼":
                                    updateRec.OldDepartmentCode = value;
                                    break;
                                // 備查日期
                                case "備查日期":
                                    DateTime dt2;
                                    if (DateTime.TryParse(value,out dt2))
                                        updateRec.LastADDate = dt2.ToShortDateString ();
                                    break;
                                // 備查文號
                                case "備查文號":
                                    updateRec.LastADNumber = value;
                                    break;
                                // 核准日期
                                case "核准日期":
                                    DateTime dt3;
                                    if(DateTime.TryParse(value, out dt3))
                                        updateRec.ADDate = dt3.ToShortDateString();
                                    break;
                                // 核准文號
                                case "核准文號":
                                    updateRec.ADNumber = value;
                                    break;
                                // 備註
                                case "備註":
                                    updateRec.GraduateComment = value;
                                    break;
                            }
                        }

                        if (string.IsNullOrEmpty(updateRec.StudentID) || string.IsNullOrEmpty(updateRec.UpdateDate) || string.IsNullOrEmpty(updateRec.UpdateCode))
                            continue;
                        else
                        {
                            if (isInsert)
                                InsertList.Add(updateRec);
                            else
                                UpdateList.Add(updateRec);
                        }
                    }

                }

                try
                {
                    if (InsertList.Count > 0)
                        Insert(InsertList);

                    if (UpdateList.Count > 0)
                        Update(UpdateList);

                    PermRecLogProcess prlp = new PermRecLogProcess();
                    prlp.SaveLog("學生.匯入異動", "匯入學籍異動", "匯入學籍異動:共新增" + InsertList.Count + "筆資料,共更新:" + UpdateList.Count + "筆資料");
                    SmartSchool.StudentRelated.Student.Instance.SyncAllBackground();
                }
                catch (Exception ex) { }
            };
        }
コード例 #14
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender,SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                // 依學生ID取得優先關懷
                List<DAO.UDT_CounselCareRecordDef> _CounselCareRecordList = _UDTTransfer.GetCareRecordsByStudentIDList(e.List);

                // 學生ID List
                List<int> studIdList = (from data in _CounselCareRecordList select data.StudentID).ToList();

                // 取得學生名稱log 用
                Dictionary<string, string> StudentNameDict = new Dictionary<string, string>();
                foreach (KeyValuePair<int, string> data in Utility.GetConvertStringDict1fromDB(studIdList))
                    StudentNameDict.Add(data.Key.ToString(), data.Value);

                // 記錄匯出 log 細項用
                Dictionary<string, StringBuilder> logData = new Dictionary<string, StringBuilder>();

                // 匯出總筆數
                int totalCount = 0;

                foreach (DAO.UDT_CounselCareRecordDef ccrd in _CounselCareRecordList)
                {
                    RowData row = new RowData();
                    totalCount++;

                    row.ID = ccrd.StudentID.ToString();
                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch(field)
                            {
                                case "代號":
                                    row.Add(field, ccrd.CodeName);
                                    break;
                                case "立案日期":
                                    if(ccrd.FileDate.HasValue)
                                        row.Add(field, ccrd.FileDate.Value.ToShortDateString());
                                    break;
                                case "個案類別":
                                    row.Add(field, ccrd.CaseCategory);
                                    break;
                                case "個案類別備註":
                                    row.Add(field, ccrd.CaseCategoryRemark);
                                    break;
                                case "個案來源":
                                    row.Add(field, ccrd.CaseOrigin);
                                    break;
                                case "個案來源備註":
                                    row.Add(field, ccrd.CaseOriginRemark);
                                    break;
                                case "優勢能力及財力":
                                    row.Add(field, ccrd.Superiority);
                                    break;
                                case "弱勢能力及財力":
                                    row.Add(field, ccrd.Weakness);
                                    break;
                                case "輔導人員輔導目標":
                                    row.Add(field, ccrd.CounselGoal);
                                    break;
                                case "校外協輔機構":
                                    row.Add(field, ccrd.OtherInstitute);
                                    break;
                                case "輔導人員輔導方式":
                                    row.Add(field, ccrd.CounselType);
                                    break;
                                case "協同輔導人員協助導師事項":
                                    row.Add(field, ccrd.AssistedMatter);
                                    break;
                                case "記錄者":
                                    row.Add(field, ccrd.AuthorID);
                                    break;
                                case "記錄者姓名":
                                    row.Add(field, ccrd.AuthorName);
                                    break;
                                case "狀態":
                                    row.Add(field, ccrd.StudentStatus);
                                    break;
                            }
                        }
                    }
                    e.Items.Add(row);
                }
                // 處理 log 細項
                foreach (RowData rd in e.Items)
                {
                    // 收集 log
                    StringBuilder sb = new StringBuilder();
                    if (StudentNameDict.ContainsKey(rd.ID))
                        sb.AppendLine(StudentNameDict[rd.ID]);
                    sb.AppendLine(this.Text);
                    foreach (KeyValuePair<string, string> data in rd)
                        sb.AppendLine(data.Key + ":" + data.Value);

                    // 加入 log
                    if (logData.ContainsKey(rd.ID))
                    {
                        sb.AppendLine();
                        logData[rd.ID].AppendLine(sb.ToString());
                    }
                    else
                        logData.Add(rd.ID, sb);
                }

                // 寫入 log
                DAO.LogTransfer log = new DAO.LogTransfer();
                foreach (KeyValuePair<string, StringBuilder> data in logData)
                    log.SaveLog("輔導系統." + this.Text, "匯出", "student", data.Key, data.Value);

                StringBuilder sbT= new StringBuilder ();
                sbT.AppendLine(this.Text);
                sbT.AppendLine("總共匯出"+logData.Keys.Count+"位學生 , 共"+totalCount+"筆");
                sbT.AppendLine("匯出學生名單..");
                foreach (KeyValuePair<string, string> data in StudentNameDict)
                    if (logData.ContainsKey(data.Key))
                        sbT.AppendLine(data.Value);

                log.SaveLog("輔導系統." + this.Text, "匯出","student","",sbT);

            };
        }
コード例 #15
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            Dictionary<string, TeacherRecord> Teachers = new Dictionary<string, TeacherRecord>();
            Dictionary<string, List<TeacherTagRecord>> TeacherTagRecDic = new Dictionary<string, List<TeacherTagRecord>>();

            Dictionary<string, Dictionary<string, string>> TeachTagNameDic = DATeacherTransfer.GetTeacherTagNameDic();

            // 取得可加入學生 TagName
            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange(ImportItemList);
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                // 取得學生資料
                foreach (TeacherRecord TeacherRec in Teacher.SelectByIDs(e.List))
                    if (!Teachers.ContainsKey(TeacherRec.ID))
                    {
                        Teachers.Add(TeacherRec.ID, TeacherRec);
                        TeacherTagRecDic.Add(TeacherRec.ID, new List<TeacherTagRecord>());
                    }

                // 取得學生類別
                foreach (TeacherTagRecord teachTag in TeacherTag.SelectByTeacherIDs(Teachers.Keys))
                {
                    //if (!StudTagRecDic.ContainsKey(studTag.RefStudentID))
                    //{
                    //    List<JHStudentTagRecord> rec = new List<JHStudentTagRecord> ();
                    //    rec.Add(studTag );
                    //    StudTagRecDic.Add(studTag.RefStudentID,rec);
                    //}
                    //else
                    if (TeacherTagRecDic.ContainsKey(teachTag.RefTeacherID))
                        TeacherTagRecDic[teachTag.RefTeacherID].Add(teachTag);
                }
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int i = 0;

                // 檢查學生是否存在
                TeacherRecord teachRec = null;
                if (Teachers.ContainsKey(e.Data.ID))
                    teachRec = Teachers[e.Data.ID];
                else
                {
                    e.ErrorMessage = "沒有這位老師" + e.Data.ID;
                    return;
                }

                // 驗證資料
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();

                    // 驗證$無法匯入
                    if (value.IndexOf('$') > -1)
                    {
                        e.ErrorFields.Add(field, "儲存格有$無法匯入.");
                        break;
                    }

                    if (field == "類別名稱")
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            e.ErrorFields.Add(field, "不允許空白");
                        }
                    }
                }

            };

            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                // 目前學生類別管理,沒有新增標示類別,有的就不更動跳過。

                Dictionary<string, List<RowData>> id_Rows = new Dictionary<string, List<RowData>>();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                        id_Rows.Add(data.ID, new List<RowData>());
                    id_Rows[data.ID].Add(data);
                }

                List<TeacherTagRecord> InsertList = new List<TeacherTagRecord>();
                //                List<JHStudentTagRecord> UpdateList = new List<JHStudentTagRecord>();

                // 放需要新增的教師類別
                Dictionary<string, List<string>> NeedAddPrefixName = new Dictionary<string, List<string>>();

                // 檢查用 List
                List<string> CheckStudTagName = new List<string>();

                foreach (KeyValuePair<string, Dictionary<string, string>> data in TeachTagNameDic)
                {
                    foreach (KeyValuePair<string, string> data1 in data.Value)
                        CheckStudTagName.Add(data.Key + data1.Key);
                }

                // 檢查類別是否已經存在
                foreach (string id in id_Rows.Keys)
                {
                    if (!TeacherTagRecDic.ContainsKey(id))
                        continue;
                    foreach (RowData data in id_Rows[id])
                    {
                        string strPrefix = string.Empty, strName = string.Empty;

                        if (data.ContainsKey("群組"))
                            strPrefix = data["群組"];

                        if (data.ContainsKey("類別名稱"))
                            strName = data["類別名稱"];

                        string FullName = strPrefix + strName;

                        // 需要新增的,
                        if (!CheckStudTagName.Contains(FullName))
                        {
                            CheckStudTagName.Add(FullName);
                            if ((NeedAddPrefixName.ContainsKey(strPrefix)))
                                NeedAddPrefixName[strPrefix].Add(strName);
                            else
                            {
                                List<string> Names = new List<string>();
                                Names.Add(strName);
                                NeedAddPrefixName.Add(strPrefix, Names);
                            }
                        }
                    }
                }

                // 新增至學生類別管理
                List<TagConfigRecord> Recs = new List<TagConfigRecord>();
                foreach (KeyValuePair<string, List<string>> data in NeedAddPrefixName)
                {
                    foreach (string data1 in data.Value)
                    {
                        TagConfigRecord rec = new TagConfigRecord();
                        rec.Category = "Teacher";
                        rec.Prefix = data.Key;
                        rec.Name = data1;
                        rec.Color = System.Drawing.Color.White;
                        Recs.Add(rec);
                    }
                }
                TagConfig.Insert(Recs);

                TeachTagNameDic.Clear();

                // 重新取得
                TeachTagNameDic = DATeacherTransfer.GetTeacherTagNameDic();

                foreach (string id in id_Rows.Keys)
                {
                    if (!TeacherTagRecDic.ContainsKey(id))
                        continue;
                    foreach (RowData data in id_Rows[id])
                    {
                        string strPrefix = string.Empty, strName = string.Empty;

                        if (data.ContainsKey("群組"))
                            strPrefix = data["群組"];

                        if (data.ContainsKey("類別名稱"))
                            strName = data["類別名稱"];

                        // 欄位有在 Tag Prefix 內
                        bool isInsert = true;

                        foreach (TeacherTagRecord rec in TeacherTagRecDic[id])
                        {
                            if (rec.Prefix == strPrefix && rec.Name == strName)
                            {
                                isInsert = false;
                                break;
                            }
                        }

                        if (isInsert)
                        {
                            // 學生類別管理名稱對照
                            if (TeachTagNameDic.ContainsKey(strPrefix))
                            {
                                if (TeachTagNameDic[strPrefix].ContainsKey(strName))
                                {
                                    TeacherTagRecord TeachTag = new TeacherTagRecord();
                                    TeachTag.RefEntityID = id;
                                    TeachTag.RefTagID = TeachTagNameDic[strPrefix][strName];
                                    InsertList.Add(TeachTag);
                                }
                            }
                        }
                    }
                }

                try
                {
                    if (InsertList.Count > 0)
                        Insert(InsertList);

                    //if (UpdateList.Count > 0)
                    //    Update(UpdateList);

                    Tagging.PermRecLogProcess prlp = new Tagging.PermRecLogProcess();
                    prlp.SaveLog("教師.匯入類別", "匯入教師類別", "共新增" + InsertList.Count + "筆資料");
                    K12.Data.Teacher.RemoveAll();
                    K12.Data.Teacher.SelectAll();

                }
                catch (Exception ex) { }

            };
        }
コード例 #16
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
               {
               // 依學生ID取得晤談紀錄
                List<DAO.UDT_CounselStudentInterviewRecordDef> _StudentInterviewRecordList = _UDTTransfer.GetCounselStudentInterviewRecordByStudentIDList(e.List);

                // 取得教師ID與名稱對照
                Dictionary<int, string> TeacherNameDict = Utility.GetTeacherIDNameDict();

               Dictionary<string, string> item_AttendessDict = new Dictionary<string, string>();
                Dictionary<string, string> item_CounselTypeDict = new Dictionary<string, string>();
                Dictionary<string, string> item_CounselTypeKindDict = new Dictionary<string, string>();

                // 學生ID List
                List<int> studIdList = (from data in _StudentInterviewRecordList select data.StudentID).ToList();

                // 取得學生名稱log 用
                Dictionary<string, string> StudentNameDict = new Dictionary<string, string>();
                foreach (KeyValuePair<int, string> data in Utility.GetConvertStringDict1fromDB(studIdList))
                    StudentNameDict.Add(data.Key.ToString(), data.Value);

                // 記錄匯出 log 細項用
                Dictionary<string, StringBuilder> logData = new Dictionary<string, StringBuilder>();

                // 匯出總筆數
                int totalCount = 0;

                foreach (DAO.UDT_CounselStudentInterviewRecordDef csir in _StudentInterviewRecordList)
                {

                    // 取得 XML 解析後
                    item_AttendessDict = Utility.GetConvertCounselXMLVal_Attendees(csir.Attendees);
                    item_CounselTypeDict = Utility.GetConvertCounselXMLVal_CounselType(csir.CounselType);
                    item_CounselTypeKindDict = Utility.GetConvertCounselXMLVal_CounselTypeKind(csir.CounselTypeKind);

                    RowData row = new RowData();
                    row.ID = csir.StudentID.ToString();
                     foreach (string field in e.ExportFields)
                     {
                         if (wizard.ExportableFields.Contains(field))
                         {
                             // 參與人員
                             if (item_AttendessDict.ContainsKey(field))
                                 row.Add(field, item_AttendessDict[field]);

                             // 輔導方式
                             if (item_CounselTypeDict.ContainsKey(field))
                                 row.Add(field, item_CounselTypeDict[field]);

                             // 輔導歸類
                             if (item_CounselTypeKindDict.ContainsKey(field))
                                 row.Add(field, item_CounselTypeKindDict[field]);

                             switch (field)
                             {
                                 case "晤談編號":
                                     row.Add(field, csir.InterviewNo);
                                     break;
                                 case "晤談老師":
                                     // 需轉換
                                   if(TeacherNameDict.ContainsKey(csir.TeacherID))
                                       row.Add(field, TeacherNameDict[csir.TeacherID]);
                                     break;
                                 case "晤談方式":
                                     row.Add(field, csir.InterviewType);
                                     break;
                                 case "晤談對象":
                                     row.Add(field, csir.IntervieweeType);
                                     break;
                                 case "日期":
                                     if(csir.InterviewDate.HasValue )
                                        row.Add(field, csir.InterviewDate.Value.ToShortDateString());
                                     break;
                                 case "時間":
                                     row.Add(field, csir.InterviewTime);
                                     break;
                                 case "地點":
                                     row.Add(field, csir.Place);
                                     break;
                                 case "晤談事由":
                                     row.Add(field, csir.Cause);
                                     break;
                                 case "參與人員":
                                     // 解析 XML
                                     row.Add(field,Utility.AttendeesXMLToString(csir.Attendees));
                                     break;
                                 case "輔導方式":
                                     // 解析 XML
                                     row.Add(field, Utility.CounselTypeXMLToString(csir.CounselType));
                                     break;
                                 case "輔導歸類":
                                     // 解析 XML
                                     row.Add(field, Utility.CounselTypeKindXMLToString(csir.CounselTypeKind));
                                     break;
                                 case "內容要點":
                                     row.Add(field, csir.ContentDigest);
                                     break;

                                 case "記錄者":
                                     row.Add(field, csir.AuthorID);
                                     break;

                                 case "記錄者姓名":
                                     row.Add(field, csir.AuthorName);
                                     break;

                                 case "狀態":
                                     row.Add(field, csir.StudentStatus);
                                     break;

                             }
                         }
                     }
                     e.Items.Add(row);
                }
                // 處理 log 細項
                foreach (RowData rd in e.Items)
                {
                    // 收集 log
                    StringBuilder sb = new StringBuilder();
                    if (StudentNameDict.ContainsKey(rd.ID))
                        sb.AppendLine(StudentNameDict[rd.ID]);
                    sb.AppendLine(this.Text);
                    foreach (KeyValuePair<string, string> data in rd)
                        sb.AppendLine(data.Key + ":" + data.Value);

                    // 加入 log
                    if (logData.ContainsKey(rd.ID))
                    {
                        sb.AppendLine();
                        logData[rd.ID].AppendLine(sb.ToString());
                    }
                    else
                        logData.Add(rd.ID, sb);
                }

                // 寫入 log
                DAO.LogTransfer log = new DAO.LogTransfer();
                foreach (KeyValuePair<string, StringBuilder> data in logData)
                    log.SaveLog("輔導系統." + this.Text, "匯出", "student", data.Key, data.Value);

                StringBuilder sbT = new StringBuilder();
                sbT.AppendLine(this.Text);
                sbT.AppendLine("總共匯出" + logData.Keys.Count + "位學生 , 共" + totalCount + "筆");
                sbT.AppendLine("匯出學生名單..");
                foreach (KeyValuePair<string, string> data in StudentNameDict)
                    if (logData.ContainsKey(data.Key))
                        sbT.AppendLine(data.Value);

                log.SaveLog("輔導系統." + this.Text, "匯出", "student", "", sbT);
               };
        }
コード例 #17
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 學生資料, 準備用來判斷學生是否存在
            // key: 學生系統ID ; value: 學生資料
            Dictionary<string, StudentRecord> studentDic = new Dictionary<string, StudentRecord>();
            // key: 學生系統ID ; Value: 離校資訊
            Dictionary<string, SHLeaveInfoRecord> leaveInfoDic = new Dictionary<string, SHLeaveInfoRecord>();
            // 用來檢查是否有重複的資料
            List<string> checkSameList = new List<string>();

            wizard.PackageLimit = 300;
            // 離校學年度, 離校類別, 離校科別, 離校班級, 畢業證書字號
            wizard.ImportableFields.AddRange(new string[] { Global._ColLeaveScholYear,
                                                            Global._ColLeaveReason,
                                                            Global._ColLeaveDept,
                                                            Global._ColLeaveClassName,
                                                            Global._ColDiplomaNumber
                                                            });
            //wizard.RequiredFields.AddRange("欄位名稱");
            
            //#region 說明按鈕的內容
            //wizard.HelpButtonVisible = true;
            //wizard.HelpButtonClick += delegate(object sender, EventArgs e)
            //{
            //    new FrmHelp(new List<string>(),
            //                wizard.ImportableFields.ToList<string>()).ShowDialog();
            //};
            //#endregion 說明按鈕的內容

            #region "準備驗證資料"的事件
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                // 初始資料
                studentDic.Clear();
                leaveInfoDic.Clear();
                checkSameList.Clear();
                _LogHelper = new LogHelper();
                _UpdateRecList = new List<SHLeaveInfoRecord>();

                #region 取得需要的資料
                // 取得學生資料
                foreach (StudentRecord studRec in Student.SelectByIDs(e.List))
                    if (!studentDic.ContainsKey(studRec.ID))
                        studentDic.Add(studRec.ID, studRec);

                // 取得學生的離校資訊
                List<SHLeaveInfoRecord> leaveInfoList = SHLeaveInfo.SelectByStudentIDs(e.List);
                foreach (SHLeaveInfoRecord rec in leaveInfoList)
                {
                    if (!leaveInfoDic.ContainsKey(rec.RefStudentID))
                        leaveInfoDic.Add(rec.RefStudentID, rec);
                }
                #endregion
            };
            #endregion

            #region "開始驗證每一條row"的事件
            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                #region 檢查學生是否存在
                if (!studentDic.ContainsKey(e.Data.ID))
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }
                #endregion

                #region 檢查是否有重複的學生系統編號
                if (checkSameList.Contains(e.Data.ID))
                {
                    e.ErrorFields.Add(Global._ColStudentId, e.Data.ID + " 不允許重複");
                }
                else
	              {
                    checkSameList.Add(e.Data.ID);
	              }
                #endregion

                #region 檢查是否有這個學生的離校資訊
                if (!leaveInfoDic.ContainsKey(e.Data.ID))
                {
                    e.ErrorMessage = "無法取得這位學生" + e.Data.ID + "離校資訊";
                    return;
                }
                #endregion

                #region 驗證格式資料
                
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();
                    switch (field)
                    {
                        case Global._ColLeaveScholYear:
                            if (!string.IsNullOrEmpty(value) &&     // 非空字串
                                (Utility.ConvertStringToInt(value) == null) )   // 轉數字失敗
                            {
                                e.ErrorFields.Add(field, "非數字型態");
                            }
                            
                            break;
                        default:
                            break;
                    }
                }
                #endregion
            };
            #endregion

            #region "開始匯入資料"的事件
            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                #region 處理每一筆row
                foreach (RowData row in e.Items)
                {
                    string studentId = row.ID;

                    // 取得該位學生的離校資訊
                    SHLeaveInfoRecord rec = leaveInfoDic[studentId];
                    
                    // [Log]儲存學生資料
                    _LogHelper.SaveStudentRecForLog(studentDic[studentId]);
                    // [Log]先儲存原本的資料
                    _LogHelper.SaveOldRecForLog(rec);

                    #region 處理需要更新資料
                    foreach (string field in e.ImportFields)
                    {
                        string value = row[field];
                        // 假如內容為空, 不處理
                        if (string.IsNullOrEmpty(value)) continue;

                        switch (field)
                        {
                            // 離校學年度
                            case Global._ColLeaveScholYear:
                                int? tmp = Utility.ConvertStringToInt(value);
                                rec.SchoolYear = tmp;
                                break;
                            // 離校類別
                            case Global._ColLeaveReason:
                                rec.Reason = value;
                                break;
                            // 離校科別
                            case Global._ColLeaveDept:
                                rec.DepartmentName = value;
                                break;
                            // 離校班級
                            case Global._ColLeaveClassName:
                                rec.ClassName = value;
                                break;
                            // 畢業證書字號
                            case Global._ColDiplomaNumber:
                                rec.DiplomaNumber = value;
                                break;
                            default:
                                break;
                        }

                    }
                    #endregion 處理需要更新資料

                    // [Log]儲存更新後的資料
                    _LogHelper.SaveNewRecForLog(rec);

                    // 加入更新名單
                    _UpdateRecList.Add(rec);
                }
                #endregion 處理每一筆row

                #region 更新DB資料
                if (_UpdateRecList.Count > 0)
                {
                    // 更新DB資料
                    SHLeaveInfo.Update(_UpdateRecList);

                    #region 處理Log
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("更新" + Global._Title + ":");
                    foreach (SHLeaveInfoRecord rec in _UpdateRecList)
                    {
                        if (_LogHelper.LeaveInfoPairDic.ContainsKey(rec.RefStudentID))
                            sb.AppendLine(_LogHelper.ComposeUpdateLogString(_LogHelper.LeaveInfoPairDic[rec.RefStudentID]));
                    }

                    FISCA.LogAgent.ApplicationLog.Log("學生." + Global._Title + "-匯入", "更新匯入", sb.ToString());
                    #endregion 處理Log
                }
                #endregion 更新DB資料
            };
            #endregion "開始匯入資料"的事件

            #region "匯入結束"的事件
            wizard.ImportComplete += delegate(object sender, EventArgs e)
            {
                // 更新系統暫存資料
                SmartSchool.Broadcaster.Events.Items["學生/資料變更"].Invoke(studentDic.Keys.ToList<string>());
            };
            #endregion "匯入結束"的事件
        }