Ejemplo n.º 1
0
 public static void Delete(string id)
 {
     DSXmlHelper dsreq = new DSXmlHelper("Request");
     dsreq.AddElement("ElectronicPaper");
     dsreq.AddElement("ElectronicPaper", "ID", id);
     FeatureBase.CallService("SmartSchool.ElectronicPaper.Delete", new DSRequest(dsreq));
 }
Ejemplo n.º 2
0
 public static void RemoveUpdateRecord(string updateID)
 {
     DSXmlHelper helper = new DSXmlHelper("DeleteRequest");
     helper.AddElement("UpdateRecord");
     helper.AddElement("UpdateRecord","ID",updateID);
     DSAServices.CallService("SmartSchool.Student.UpdateRecord.Delete", new DSRequest(helper));
 }
Ejemplo n.º 3
0
 public static DSResponse GetDepartment()
 {
     DSXmlHelper helper = new DSXmlHelper("GetDepartmentListRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "All");
     return DSAServices.CallService("SmartSchool.Config.GetDepartment", new DSRequest(helper));
 }
 public static DSResponse GetPaperItemContentById(string id)
 {
     DSXmlHelper helper = new DSXmlHelper("Request");
     helper.AddElement("Content");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "ID", id);
     return FeatureBase.CallService("SmartSchool.ElectronicPaper.GetPaperItem", new DSRequest(helper));
 }
Ejemplo n.º 5
0
        public static void RemoveCourseTeachers(string courseId)
        {
            DSXmlHelper helper = new DSXmlHelper("Request");
            helper.AddElement("Course");
            helper.AddElement("Course", "CourseID", courseId);

            DSAServices.CallService("SmartSchool.Course.RemoveCourseTeacher", new DSRequest(helper));
        }
        public static XmlElement GetShiftCheckList(string key, string value)
        {
            DSXmlHelper request = new DSXmlHelper("GetShiftCheckList");
            request.AddElement(key);
            request.AddElement(value);

            return DSAServices.CallService("SmartSchool.Student.BulkProcessJH.GetShiftCheckList", new DSRequest(request)).GetContent().BaseElement;
        }
Ejemplo n.º 7
0
 public static void DeletePaperItem(params string[] item_ids)
 {
     DSXmlHelper helper = new DSXmlHelper("Request");
     helper.AddElement("Paper");
     foreach (string each_id in item_ids)
         helper.AddElement("Paper", "PaperItemID", each_id);
     FeatureBase.CallService("SmartSchool.ElectronicPaper.DeletePaperItem", new DSRequest(helper));
 }
Ejemplo n.º 8
0
 public static DSResponse GetClassDetail(string classid)
 {
     DSXmlHelper helper = new DSXmlHelper("GetClassListRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "All");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "ID", classid);
     return DSAServices.CallService("SmartSchool.Class.GetDetailList", new DSRequest(helper));
 }
Ejemplo n.º 9
0
 public static void UpdatePaperName(string new_name, string id)
 {
     DSXmlHelper dsreq = new DSXmlHelper("Request");
     dsreq.AddElement("ElectronicPaper");
     dsreq.AddElement("ElectronicPaper", "Name", new_name);
     dsreq.AddElement("ElectronicPaper", "Condition");
     dsreq.AddElement("ElectronicPaper/Condition", "ID", id);
     FeatureBase.CallService("SmartSchool.ElectronicPaper.Update", new DSRequest(dsreq));
 }
 public static DSResponse GetDetailList(string schoolyear, string semester)
 {
     DSXmlHelper helper = new DSXmlHelper("Request");
     helper.AddElement("All");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "SchoolYear", schoolyear);
     helper.AddElement("Condition", "Semester", semester);
     return FeatureBase.CallService("SmartSchool.ElectronicPaper.GetDetailList", new DSRequest(helper));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 取得現有年級
 /// </summary>
 /// <returns></returns>
 public static DSResponse GetGradeYearList()
 {
     DSXmlHelper helper = new DSXmlHelper("GetGradeYearRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "ClassCount");
     helper.AddElement("Field", "GradeYear");
     //helper.AddElement("Field", "Status");
     DSRequest dsreq = new DSRequest(helper);
     return DSAServices.CallService("SmartSchool.Class.GetGradeYearList", dsreq);
 }
Ejemplo n.º 12
0
 public void ChangePassword(string newPassword)
 {
     DSXmlHelper helper = new DSXmlHelper("ChangePassword");
     helper.AddElement("CurrentUser");
     helper.AddElement("CurrentUser", "NewPassword", newPassword);
     helper.AddElement("CurrentUser", "Condition");
     //helper.AddElement("CurrentUser/Condition", "UserName", CurrentUser.Instance.UserName.ToUpper());
     helper.AddElement("CurrentUser/Condition", "UserName", FISCA.Authentication.DSAServices.UserAccount.ToUpper());
     FISCA.Authentication.DSAServices.CallService("SmartSchool.Personal.ChangePassword", new DSRequest(helper));
 }
        public void SaveConfiguration(IEnumerable<ConfigurationRecord> configurations)
        {
            MultiThreadWorker<ConfigurationRecord> worker = new MultiThreadWorker<ConfigurationRecord>();
            worker.MaxThreads = 3;
            worker.PackageSize = 20;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs<ConfigurationRecord> e)
            {
                DSXmlHelper insert = new DSXmlHelper("Request");
                DSXmlHelper update = new DSXmlHelper("Request");
                DSXmlHelper delete = new DSXmlHelper("Request");
                bool insert_exec = false, update_exec = false, delete_exec = false;

                foreach (ConfigurationRecord eachConf in e.List)
                {
                    if (eachConf.EditAction == 1) //新增
                    {
                        insert.AddElement("Configuration");
                        insert.AddElement("Configuration", "Name", eachConf.Namespace);
                        insert.AddElement("Configuration", "Content", eachConf.GetXml(), true);
                        insert_exec = true;
                    }
                    else if (eachConf.EditAction == 2) //修改
                    {
                        update.AddElement("Configuration");
                        update.AddElement("Configuration", "Content", eachConf.GetXml(), true);
                        update.AddElement("Configuration", "Condition");
                        update.AddElement("Configuration/Condition", "Name", eachConf.Namespace);
                        update_exec = true;
                    }
                    else if (eachConf.EditAction == 3) //刪除
                    {
                        delete.AddElement("Configuration");
                        delete.AddElement("Configuration", "Name", eachConf.Namespace);
                        delete_exec = true;
                    }
                    else
                        throw new ArgumentException("沒有這一種的啦。");
                }

                if (insert_exec)
                    DSAServices.CallService("SmartSchool.Configuration.Insert", new DSRequest(insert));

                if (update_exec)
                    DSAServices.CallService("SmartSchool.Configuration.Update", new DSRequest(update));

                if (delete_exec)
                    DSAServices.CallService("SmartSchool.Configuration.Delete", new DSRequest(delete));
            };

            List<PackageWorkEventArgs<ConfigurationRecord>> results = worker.Run(configurations);

            foreach (PackageWorkEventArgs<ConfigurationRecord> each in results)
                if (each.HasException) throw each.Exception;
        }
Ejemplo n.º 14
0
 public static void UpdateGraduatePhoto(string picBase64String, string StudentID)
 {
     DSRequest dsreq = new DSRequest();
     DSXmlHelper helper = new DSXmlHelper("UpdateStudentList");
     helper.AddElement("Student");
     helper.AddElement("Student", "Field");
     helper.AddElement("Student/Field", "GraduatePhoto");
     helper.AddCDataSection("Student/Field/GraduatePhoto", picBase64String);
     helper.AddElement("Student", "Condition");
     helper.AddElement("Student/Condition", "ID", StudentID);
     dsreq.SetContent(helper);
     DSResponse dsrsp = DSAServices.CallService(UPDATE_SERVICENAME, dsreq);
 }
Ejemplo n.º 15
0
 public static DSResponse GetAbsenceList()
 {
     string serviceName = "GetAbsenceList";
     if (DataCacheManager.Get(serviceName) == null)
     {
         DSRequest request = new DSRequest();
         DSXmlHelper helper = new DSXmlHelper("GetAbsenceListRequest");
         helper.AddElement("Field");
         helper.AddElement("Field", "All");
         request.SetContent(helper);
         DSResponse dsrsp = DSAServices.CallService("SmartSchool.Others.GetAbsenceList", request);
         DataCacheManager.Add(serviceName, dsrsp);
     }
     return DataCacheManager.Get(serviceName);
 }
Ejemplo n.º 16
0
 private static DSXmlHelper CreateBriefFieldHelper()
 {
     DSXmlHelper helper = new DSXmlHelper("GetTeacherListRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "ID");
     helper.AddElement("Field", "TeacherName");
     helper.AddElement("Field", "Nickname");
     helper.AddElement("Field", "Status");
     helper.AddElement("Field", "Gender");
     helper.AddElement("Field", "IDNumber");
     helper.AddElement("Field", "Category");
     helper.AddElement("Field", "ContactPhone");
     helper.AddElement("Field", "TALoginName");
     return helper;
 }
Ejemplo n.º 17
0
        public static string Insert(string name, string schoolYear, string semester, string viewerType, Dictionary<string, string> metadata)
        {
            DSXmlHelper dsreq = new DSXmlHelper("Request");
            dsreq.AddElement("ElectronicPaper");
            dsreq.AddElement("ElectronicPaper", "Name", name);
            dsreq.AddElement("ElectronicPaper", "SchoolYear", schoolYear);
            dsreq.AddElement("ElectronicPaper", "Semester", semester);
            dsreq.AddElement("ElectronicPaper", "ViewerType", viewerType);

            if (metadata != null)
            {
                DSXmlHelper hlpmd = new DSXmlHelper("Metadata");
                foreach (KeyValuePair<string, string> each in metadata)
                {
                    XmlElement item = hlpmd.AddElement("Item");
                    item.SetAttribute("Name", each.Key);
                    item.SetAttribute("Value", each.Value);
                }
                dsreq.AddElement("ElectronicPaper", hlpmd.BaseElement);
            }

            DSResponse dsrsp = FeatureBase.CallService("SmartSchool.ElectronicPaper.Insert", new DSRequest(dsreq));
            if (dsrsp.HasContent)
            {
                DSXmlHelper helper = dsrsp.GetContent();
                string newid = helper.GetText("NewID");
                return newid;
            }
            return "";
        }
Ejemplo n.º 18
0
        public Dictionary<string, ConfigurationRecord> GetAllConfiguration()
        {
            DSXmlHelper request = new DSXmlHelper("Request");
            request.AddElement("Content");

            return SendRequest(request);
        }
Ejemplo n.º 19
0
 public static DSResponse GetTeacherListWithSupervisedByClassInfo(params string[] teacherIdList)
 {
     DSXmlHelper helper = new DSXmlHelper("GetDetailListRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "ID");
     helper.AddElement("Field", "TeacherName");
     helper.AddElement("Field", "Nickname");
     helper.AddElement("Field", "Gender");
     helper.AddElement("Field", "IDNumber");
     helper.AddElement("Field", "ContactPhone");
     helper.AddElement("Field", "Category");
     helper.AddElement("Field", "SupervisedByClassID");
     helper.AddElement("Field", "SupervisedByClassName");
     helper.AddElement("Field", "SupervisedByGradeYear");
     helper.AddElement("Field", "Status");
     helper.AddElement("Condition");
     if ( teacherIdList.Length > 0 )
     {
         helper.AddElement("Condition", "IDList");
         foreach ( string id in teacherIdList )
         {
             helper.AddElement("Condition/IDList", "ID", id);
         }
     }
     helper.AddElement("Order");
     helper.AddElement("Order", "TeacherName");
     return DSAServices.CallService("SmartSchool.Teacher.GetDetailListWithSupervisedByClassInfo", new DSRequest(helper));
 }
Ejemplo n.º 20
0
        public static DSXmlHelper GetAbstractList(params string[] gradeYear)
        {
            DSRequest dsreq = new DSRequest();
            DSXmlHelper helper = new DSXmlHelper("Request");
            helper.AddElement(".", "Field", "<ID/><Name/><RefClassID/><ClassName/><SeatNo/><RefDepartmentID/><DepartmentName/><GradeYear/>", true);
            helper.AddElement("Condition");
            helper.AddElement("Condition", "Status", "�@��");

            foreach (string each in gradeYear)
                helper.AddElement("Condition", "GradeYear", each);

            helper.AddElement(".", "Order", "<GradeYear/><RefClassID/><SeatNo/>", true);
            dsreq.SetContent(helper);
            DSResponse dsrsp = DSAServices.CallService("SmartSchool.Student.GetAbstractList", dsreq);
            return dsrsp.GetContent();
        }
        public Dictionary<string, ConfigurationRecord> GetConfiguration(IEnumerable<string> namespaces)
        {
            DSXmlHelper request = new DSXmlHelper("Request");
            bool execute_required = false;
            request.AddElement("Content");
            request.AddElement("Condition");
            foreach (string each in namespaces)
            {
                request.AddElement("Condition", "Name", each);
                execute_required = true;
            }

            if (execute_required)
                return SendRequest(request);
            else
                return new Dictionary<string, ConfigurationRecord>();
        }
Ejemplo n.º 22
0
        public static XmlElement GetShiftCheckList(params string[] fieldList)
        {
            DSXmlHelper request = new DSXmlHelper("Request");
            foreach (string each in fieldList)
                request.AddElement(".", each);

            string sn = "SmartSchool.Class.BulkProcessJH.GetShiftCheckList";
            return DSAServices.CallService(sn, new DSRequest(request)).GetContent().BaseElement;
        }
Ejemplo n.º 23
0
        public static XmlElement GetCourseTeachers(IEnumerable<string> fieldList)
        {
            DSXmlHelper request = new DSXmlHelper("Request");
            foreach (string each in fieldList)
                request.AddElement(".", each);

            string sn = "SmartSchool.Course.BulkProcessJH.GetCourseTeachers";
            return DSAServices.CallService(sn, new DSRequest(request)).GetContent().BaseElement;
        }
Ejemplo n.º 24
0
        public static List<string> GetCountyList()
        {
            DSRequest request = new DSRequest();
            DSXmlHelper helper = new DSXmlHelper("Request");
            helper.AddElement("Fields");
            helper.AddElement("Fields", "All");
            request.SetContent(helper);
            DSResponse dsrsp = DSAServices.CallService("SmartSchool.Config.GetCountyTownList", request);

            List<string> countyList = new List<string>();
            foreach (XmlNode node in dsrsp.GetContent().GetElements("Town"))
            {
                string county = node.Attributes["County"].Value;
                if (!countyList.Contains(county))
                    countyList.Add(county);
            }
            return countyList;
        }
Ejemplo n.º 25
0
 public static DSResponse GetTeacherList()
 {
     DSXmlHelper helper = new DSXmlHelper("GetAbstractList");
     helper.AddElement("Field");
     helper.AddElement("Field", "ID");
     helper.AddElement("Field", "TeacherName");
     helper.AddElement("Field", "Nickname");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "Status", "�@��");
     helper.AddElement("Order");
     helper.AddElement("Order", "TeacherName");
     return DSAServices.CallService("SmartSchool.Teacher.GetAbstractList", new DSRequest(helper));
 }
 public static DSResponse GetPaperItemByViewer(string viewer_type, string viewer_id)
 {
     DSXmlHelper helper = new DSXmlHelper("Request");
     helper.AddElement("ID");
     helper.AddElement("Format");
     //helper.AddElement("Content");
     helper.AddElement("PaperID");
     helper.AddElement("PaperName");
     helper.AddElement("Timestamp");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "ViewerType", viewer_type);
     helper.AddElement("Condition", "ViewerID", viewer_id);
     return FeatureBase.CallService("SmartSchool.ElectronicPaper.GetPaperItem", new DSRequest(helper));
 }
Ejemplo n.º 27
0
 public static DSResponse GetCourseList(string teacherid)
 {
     DSXmlHelper helper = new DSXmlHelper("SelectRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "All");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "TeacherID", teacherid);
     helper.AddElement("Order");
     helper.AddElement("Order", "SchoolYear");
     helper.AddElement("Order", "Semester");
     return DSAServices.CallService("SmartSchool.Teacher.GetCourseList", new DSRequest(helper));
 }
Ejemplo n.º 28
0
 public static DSResponse GetAddress(string RunningID)
 {
     DSXmlHelper helper = new DSXmlHelper("GetStudentListRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "PermanentAddress");
     helper.AddElement("Field", "MailingAddress");
     helper.AddElement("Field", "OtherAddresses");
     helper.AddElement("Condition");
     helper.AddElement("Condition", "ID", RunningID);
     DSRequest dsreq = new DSRequest(helper);
     return DSAServices.CallService("SmartSchool.Student.GetDetailList", dsreq);
 }
Ejemplo n.º 29
0
 public static DSResponse GetClassList()
 {
     DSXmlHelper helper = new DSXmlHelper("GetGradeYearRequest");
     helper.AddElement("Field");
     helper.AddElement("Field", "ClassID");
     helper.AddElement("Field", "ClassName");
     helper.AddElement("Order");
     helper.AddElement("Order", "DisplayOrder");
     helper.AddElement("Order", "ClassName");
     DSRequest dsreq = new DSRequest(helper);
     return DSAServices.CallService("SmartSchool.Class.GetAbstractList", dsreq);
 }
Ejemplo n.º 30
0
 public static void SetExtend(string nameSpace, string field, IDictionary<string, string> list)
 {
     if ( list.Count == 0 ) return;
     foreach ( string var in new string[]{"0","1","2","3","4","5","6","7","8","9"} )
     {
         if ( field.StartsWith(var) )
             throw new Exception("���W�ٶ}�Y���i���Ʀr");
     }
     DSRequest dsreq = new DSRequest();
     DSXmlHelper helper = new DSXmlHelper("Request");
     helper.SetAttribute(".", "Namespace", nameSpace);
     foreach ( string id in list.Keys )
     {
         helper.AddElement("Student");
         helper.SetAttribute("Student", "ID", id);
         if(string.IsNullOrEmpty(list[id]))
             helper.AddElement("Student", field);
         else
         helper.AddElement("Student", field,list[id]);
     }
     dsreq.SetContent(helper);
     DSAServices.CallService("SmartSchool.Student.SetExtend", dsreq);
 }
Ejemplo n.º 31
0
        public static void SaveSCETakeRecordEditor(IEnumerable <SCETakeRecordEditor> editors)
        {
            MultiThreadWorker <SCETakeRecordEditor> worker = new MultiThreadWorker <SCETakeRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <SCETakeRecordEditor> e)
            {
                DSXmlHelper   insertHelper = new DSXmlHelper("Request");
                DSXmlHelper   updateHelper = new DSXmlHelper("Request");
                DSXmlHelper   deleteHelper = new DSXmlHelper("Request");
                List <string> synclist     = new List <string>();

                bool do_insert = false, do_update = false, do_delete = false;

                foreach (var editor in editors)
                {
                    if (editor.EditorStatus != JHSchool.Editor.EditorStatus.NoChanged)
                    {
                        if (!string.IsNullOrEmpty(editor.ID))
                        {
                            synclist.Add(editor.ID);
                        }
                    }

                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                    {
                        insertHelper.AddElement("ScoreSheetList");
                        insertHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", "" + editor.Score.Value);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "ExamID", editor.RefExamID);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "AttendID", editor.RefSCAttendID);

                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "Extension");
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet/Extension", "Extension");
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet/Extension/Extension", "Effort", "" + editor.Effort);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet/Extension/Extension", "Text", editor.Text);

                        do_insert = true;
                    }
                    else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                    {
                        updateHelper.AddElement("ScoreSheetList");
                        updateHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", "" + editor.Score.Value);
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "ExamID", editor.RefExamID);
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "AttendID", editor.RefSCAttendID);

                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "Extension");
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet/Extension", "Extension");
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet/Extension/Extension", "Effort", "" + editor.Effort);
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet/Extension/Extension", "Text", editor.Text);

                        //這個 Element 是 Condition。這支 Service 寫法比較怪一點。
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "ID", editor.ID);

                        do_update = true;
                    }
                    else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Delete)
                    {
                        deleteHelper.AddElement("ScoreSheet");
                        deleteHelper.AddElement("ScoreSheet", "ID", editor.ID);

                        do_delete = true;
                    }
                }

                //新增、修改、刪除的三個 Services 名字不太一致
                //Insert : SmartSchool.Course.InsertSECScore
                //Update : SmartSchool.Course.UpdateSCEScore
                //Delete : SmartSchool.Course.DeleteSCEScore
                if (do_insert)
                {
                    DSResponse resp = FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.InsertSECScore", new DSRequest(insertHelper.BaseElement));
                    foreach (var item in resp.GetContent().GetElements("NewID"))
                    {
                        synclist.Add(item.InnerText);
                    }
                }
                if (do_update)
                {
                    FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.UpdateSCEScore", new DSRequest(updateHelper.BaseElement));
                }
                if (do_delete)
                {
                    FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.DeleteSCEScore", new DSRequest(deleteHelper.BaseElement));
                }

                //SCETake 不做 CacheManager 了
                //SCETake.Instance.SyncDataBackground(synclist);
            };
            List <PackageWorkEventArgs <SCETakeRecordEditor> > packages = worker.Run(editors);

            foreach (PackageWorkEventArgs <SCETakeRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Ejemplo n.º 32
0
        public void UpdateToServer()
        {
            int  progress       = 0;
            bool updateRequired = false;

            foreach (List <Course> each in _packings)
            {
                DSXmlHelper request = new DSXmlHelper("Request");

                foreach (Course course in each)
                {
                    if (course.ExamTemplate == null)
                    {
                        continue;
                    }

                    if (!course.ExamRequired)
                    {
                        continue;
                    }

                    //AllowUpload 為 True 時,略過成績計算,因為成績是由老師提供。
                    //if (course.ExamTemplate.AllowUpload)
                    //    continue;

                    foreach (SCAttend attend in course.SCAttends.Values)
                    {
                        XmlElement  xmlAttend = request.AddElement("Attend");
                        DSXmlHelper hlpAttend = new DSXmlHelper(xmlAttend);
                        hlpAttend.AddElement(".", "ID", attend.Identity);

                        if (_clear_data)
                        {
                            hlpAttend.AddElement(".", "Score", "");
                            hlpAttend.AddElement(".", "Extension");
                            hlpAttend.AddElement("Extension", "Extension");
                            hlpAttend.AddElement("Extension/Extension", "Effort", "");
                            attend.PreviousScore  = string.Empty;
                            attend.PreviousEffort = string.Empty;
                        }
                        else
                        {
                            hlpAttend.AddElement(".", "Score", attend.Score);
                            hlpAttend.AddElement(".", "Extension");
                            hlpAttend.AddElement("Extension", "Extension");
                            hlpAttend.AddElement("Extension/Extension", "Effort", attend.Effort);
                            attend.SaveScore();
                            attend.SaveEffort();
                        }

                        updateRequired = true; //指示是否要執行呼叫 Service 的動作。

                        progress++;
                    }
                }

                if (updateRequired && request.PathExist("Attend"))
                {
                    EditCourse.UpdateAttend(request);
                }

                //Progress.ReportProgress("", progress);
            }
        }
Ejemplo n.º 33
0
        private static DSXmlHelper CreateBriefFieldHelper()
        {
            DSXmlHelper helper = new DSXmlHelper("GetStudentListRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "Status");
            helper.AddElement("Field", "SeatNo");
            helper.AddElement("Field", "Name");
            helper.AddElement("Field", "StudentNumber");
            helper.AddElement("Field", "Gender");
            helper.AddElement("Field", "IDNumber");
            helper.AddElement("Field", "PermanentPhone");
            helper.AddElement("Field", "ContactPhone");
            helper.AddElement("Field", "Birthdate");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "RefClassID");
            helper.AddElement("Field", "SeatNo");
            helper.AddElement("Field", "TagPrefix");
            helper.AddElement("Field", "TagName");
            helper.AddElement("Field", "TagID");
            helper.AddElement("Field", "TagColor");
            helper.AddElement("Field", "OverrideDeptName");
            helper.AddElement("Field", "LeaveInfo");
            return(helper);
        }
Ejemplo n.º 34
0
        //┤·╕╒е╬
        public static DSResponse GetTeacherDetailTest(params string[] idList)
        {
            DSXmlHelper helper = new DSXmlHelper("GetDetailListRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "TeacherName");
            helper.AddElement("Field", "Nickname");
            helper.AddElement("Field", "Gender");
            helper.AddElement("Field", "IDNumber");
            helper.AddElement("Field", "ContactPhone");
            //helper.AddElement("Field", "Email");
            //helper.AddElement("Field", "Photo");
            helper.AddElement("Field", "Category");
            //helper.AddElement("Field", "SmartTeacherLoginName");
            //helper.AddElement("Field", "SmartTeacherPassword");
            //helper.AddElement("Field", "RemoteAccount");
            helper.AddElement("Field", "Status");
            if (idList.Length > 0)
            {
                helper.AddElement("Condition");
                foreach (string var in idList)
                {
                    helper.AddElement("Condition", "TeacherID", var);
                }
            }
            helper.AddElement("Order");
            helper.AddElement("Order", "TeacherName");
            return(DSAServices.CallService("SmartSchool.Teacher.GetDetailList", new DSRequest(helper)));
        }
Ejemplo n.º 35
0
        public override void Save()
        {
            if (!ValidAll())
            {
                FISCA.Presentation.Controls.MsgBox.Show("資料內容有誤, 請先修正後再行儲存!", "內容錯誤", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }



            string studentName = "";

            foreach (StudentRecord student in Student.Instance.SelectedList)
            {
                if (student.ID == RunningID)
                {
                    studentName = student.Name;
                }
            }

            StringBuilder isb = new StringBuilder("");
            StringBuilder usb = new StringBuilder("");
            StringBuilder dsb = new StringBuilder("");

            int         uc = 0, ic = 0;
            DSXmlHelper uh = new DSXmlHelper("Request");
            DSXmlHelper ih = new DSXmlHelper("Request");

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                RecordInfo rinfo = row.Tag as RecordInfo;
                if (!rinfo.IsAddedRow)
                {
                    string id         = rinfo.ID;
                    bool   changed    = false;
                    string schoolYear = row.Cells[colSchoolYear.Name].Value.ToString();
                    string semester   = row.Cells[colSemester.Name].Value.ToString();
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        string columnText = dataGridViewX1.Columns[cell.ColumnIndex].HeaderText;
                        string key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", columnText);
                        string newValue   = GetValue(cell);
                        if (!_valueManager.GetValues().ContainsKey(key))
                        {
                            if (newValue != "")
                            {
                                usb.Append(key).Append(":「").Append(newValue).Append("」\n");
                                changed = true;
                            }
                        }
                        else if (_valueManager.IsDirtyItem(key))
                        {
                            string oldValue = _valueManager.GetOldValue(key);
                            usb.Append(key).Append(":由「").Append(oldValue).Append("」變更值為「").Append(newValue).Append("」\n");
                            changed = true;
                        }
                    }
                    if (changed)
                    {
                        uc++;
                        uh.AddElement("SemesterMoralScore");
                        uh.AddElement("SemesterMoralScore", "Condition");
                        uh.AddElement("SemesterMoralScore/Condition", "ID", id);
                        uh.AddElement("SemesterMoralScore", "SupervisedByDiff", GetValue(row.Cells[colTB.Name]));
                        uh.AddElement("SemesterMoralScore", "SupervisedByComment", GetValue(row.Cells[colTT.Name]));
                        uh.AddElement("SemesterMoralScore", "OtherDiff");

                        bool hasRoot = false;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            DataGridViewColumn column = dataGridViewX1.Columns[cell.ColumnIndex];
                            if (column.Name.StartsWith("colItem"))
                            {
                                if (!hasRoot)
                                {
                                    uh.AddElement("SemesterMoralScore/OtherDiff", "OtherDiffList");
                                    hasRoot = true;
                                }
                                XmlElement element = uh.AddElement("SemesterMoralScore/OtherDiff/OtherDiffList", "OtherDiff", GetValue(cell));
                                element.SetAttribute("Name", column.HeaderText);
                            }
                        }
                    }
                }

                // 處理 insert
                else
                {
                    isb.Append("新增【").Append(studentName).Append("-").Append(GetValue(row.Cells[colSchoolYear.Name]))
                    .Append("學年度").Append(GetValue(row.Cells[colSemester.Name])).Append("學期】資料:\n");

                    isb.Append("\t").Append(colTB.HeaderText).Append(":").Append(GetValue(row.Cells[colTB.Name])).Append("\n");
                    isb.Append("\t").Append(colTT.HeaderText).Append(":").Append(GetValue(row.Cells[colTT.Name])).Append("\n");

                    ih.AddElement("SemesterMoralScore");
                    ih.AddElement("SemesterMoralScore", "RefStudentID", RunningID);
                    ih.AddElement("SemesterMoralScore", "SchoolYear", GetValue(row.Cells[colSchoolYear.Name]));
                    ih.AddElement("SemesterMoralScore", "Semester", GetValue(row.Cells[colSemester.Name]));
                    ih.AddElement("SemesterMoralScore", "SupervisedByDiff", GetValue(row.Cells[colTB.Name]));
                    ih.AddElement("SemesterMoralScore", "SupervisedByComment", GetValue(row.Cells[colTT.Name]));
                    ih.AddElement("SemesterMoralScore", "OtherDiff");
                    bool hasRoot = false;
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        DataGridViewColumn column = dataGridViewX1.Columns[cell.ColumnIndex];
                        if (column.Name.StartsWith("colItem"))
                        {
                            if (!hasRoot)
                            {
                                ih.AddElement("SemesterMoralScore/OtherDiff", "OtherDiffList");
                                hasRoot = true;
                            }
                            XmlElement element = ih.AddElement("SemesterMoralScore/OtherDiff/OtherDiffList", "OtherDiff", GetValue(cell));
                            element.SetAttribute("Name", column.HeaderText);
                            isb.Append("\t").Append(column.HeaderText).Append(":").Append(GetValue(row.Cells[column.Name])).Append("\n");
                        }
                    }
                    ic++;
                }
            }

            try
            {
                if (_deletedRowID.Count > 0)
                {
                    DSXmlHelper dh = new DSXmlHelper("Request");
                    dh.AddElement("SemesterMoralScore");
                    foreach (string id in _deletedRowID.Keys)
                    {
                        dsb.Append("刪除【").Append(studentName).Append("-").Append(_deletedRowID[id]).Append("】\n");
                        dh.AddElement("SemesterMoralScore", "ID", id);
                    }
                    JHSchool.Feature.Legacy.RemoveScore.DeleteSemesterMoralScore(new DSRequest(dh));
                    //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Delete, RunningID, dsb.ToString(), Title, dh.GetRawXml());
                }
                if (ic > 0)
                {
                    JHSchool.Feature.Legacy.AddScore.InsertSemesterMoralScore(new DSRequest(ih));
                    //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Insert, RunningID, isb.ToString(), Title, ih.GetRawXml());
                }
                if (uc > 0)
                {
                    JHSchool.Feature.Legacy.EditScore.UpdateSemesterMoralScore(new DSRequest(uh));
                    //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Update, RunningID, usb.ToString(), Title, uh.GetRawXml());
                }
            }
            catch (Exception ex)
            {
                FISCA.Presentation.Controls.MsgBox.Show("儲存失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SaveButtonVisible = false;
            LoadContent(RunningID);
        }
Ejemplo n.º 36
0
        public static void SaveSemesterScoreRecordEditor(IEnumerable <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> editors)
        {
            Dictionary <string, List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> > grouped = new Dictionary <string, List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor> >();

            foreach (var editor in editors)
            {
                if (!grouped.ContainsKey(editor.RefStudentID))
                {
                    grouped.Add(editor.RefStudentID, new List <JHSchool.Evaluation.Editor.SemesterScoreRecordEditor>());
                }
                grouped[editor.RefStudentID].Add(editor);
            }
            SemesterScore.Instance.SyncData(grouped.Keys);

            DSXmlHelper insertHelper = new DSXmlHelper("InsertRequest");
            DSXmlHelper updateHelper = new DSXmlHelper("UpdateRequest");
            DSXmlHelper deleteHelper = new DSXmlHelper("DeleteRequest");

            bool          do_insert = false, do_update = false, do_delete = false;
            List <string> synclist = new List <string>();

            foreach (var editor in editors)
            {
                if (editor.EditorStatus == JHSchool.Editor.EditorStatus.NoChanged)
                {
                    continue;
                }

                if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                {
                    DSXmlHelper partialInsertHelper = new DSXmlHelper("SemesterSubjectScore");
                    partialInsertHelper.AddElement(".", "RefStudentId", editor.RefStudentID);
                    partialInsertHelper.AddElement(".", "SchoolYear", "" + editor.SchoolYear);
                    partialInsertHelper.AddElement(".", "Semester", "" + editor.Semester);
                    partialInsertHelper.AddElement(".", "GradeYear", "" + editor.GradeYear);
                    partialInsertHelper.AddElement(".", "ScoreInfo");

                    partialInsertHelper.AddElement("ScoreInfo", "SemesterSubjectScoreInfo");
                    foreach (var subjectKey in editor.Subjects.Keys)
                    {
                        SubjectScore subject = editor.Subjects[subjectKey];
                        XmlElement   element = partialInsertHelper.AddElement("ScoreInfo/SemesterSubjectScoreInfo", "Subject");
                        element.SetAttribute("領域", subject.Domain);
                        element.SetAttribute("科目", subjectKey);
                        element.SetAttribute("節數", "" + subject.Period);
                        element.SetAttribute("權數", "" + subject.Credit);
                        element.SetAttribute("成績", "" + subject.Score);
                        element.SetAttribute("努力程度", "" + subject.Effort);
                        element.SetAttribute("文字描述", "" + subject.Text);
                        element.SetAttribute("註記", "" + subject.Comment);
                    }

                    partialInsertHelper.AddElement("ScoreInfo", "Domains");
                    foreach (var domainKey in editor.Domains.Keys)
                    {
                        DomainScore domain  = editor.Domains[domainKey];
                        XmlElement  element = partialInsertHelper.AddElement("ScoreInfo/Domains", "Domain");
                        element.SetAttribute("領域", domainKey);
                        element.SetAttribute("節數", "" + domain.Period);
                        element.SetAttribute("權數", "" + domain.Credit);
                        element.SetAttribute("成績", "" + domain.Score);
                        element.SetAttribute("努力程度", "" + domain.Effort);
                        element.SetAttribute("文字描述", "" + domain.Text);
                        element.SetAttribute("註記", "" + domain.Comment);
                    }

                    partialInsertHelper.AddElement("ScoreInfo", "LearnDomainScore", "" + editor.LearnDomainScore);
                    partialInsertHelper.AddElement("ScoreInfo", "CourseLearnScore", "" + editor.CourseLearnScore);

                    insertHelper.AddElement(".", partialInsertHelper.BaseElement);

                    do_insert = true;
                }
                else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                {
                    DSXmlHelper partialUpdateHelper = new DSXmlHelper("SemesterSubjectScore");
                    partialUpdateHelper.AddElement("Field");
                    partialUpdateHelper.AddElement("Field", "RefStudentId", editor.RefStudentID);
                    partialUpdateHelper.AddElement("Field", "SchoolYear", "" + editor.SchoolYear);
                    partialUpdateHelper.AddElement("Field", "Semester", "" + editor.Semester);
                    partialUpdateHelper.AddElement("Field", "GradeYear", "" + editor.GradeYear);
                    partialUpdateHelper.AddElement("Field", "ScoreInfo");

                    partialUpdateHelper.AddElement("Field/ScoreInfo", "SemesterSubjectScoreInfo");
                    foreach (var subjectKey in editor.Subjects.Keys)
                    {
                        SubjectScore subject = editor.Subjects[subjectKey];
                        XmlElement   element = partialUpdateHelper.AddElement("Field/ScoreInfo/SemesterSubjectScoreInfo", "Subject");
                        element.SetAttribute("領域", subject.Domain);
                        element.SetAttribute("科目", subjectKey);
                        element.SetAttribute("節數", "" + subject.Period);
                        element.SetAttribute("權數", "" + subject.Credit);
                        element.SetAttribute("成績", "" + subject.Score);
                        element.SetAttribute("努力程度", "" + subject.Effort);
                        element.SetAttribute("文字描述", "" + subject.Text);
                        element.SetAttribute("註記", "" + subject.Comment);
                    }

                    partialUpdateHelper.AddElement("Field/ScoreInfo", "Domains");
                    foreach (var domainKey in editor.Domains.Keys)
                    {
                        DomainScore domain  = editor.Domains[domainKey];
                        XmlElement  element = partialUpdateHelper.AddElement("Field/ScoreInfo/Domains", "Domain");
                        element.SetAttribute("領域", domainKey);
                        element.SetAttribute("節數", "" + domain.Period);
                        element.SetAttribute("權數", "" + domain.Credit);
                        element.SetAttribute("成績", "" + domain.Score);
                        element.SetAttribute("努力程度", "" + domain.Effort);
                        element.SetAttribute("文字描述", "" + domain.Text);
                        element.SetAttribute("註記", "" + domain.Comment);
                    }

                    partialUpdateHelper.AddElement("Field/ScoreInfo", "LearnDomainScore", "" + editor.LearnDomainScore);
                    partialUpdateHelper.AddElement("Field/ScoreInfo", "CourseLearnScore", "" + editor.CourseLearnScore);

                    partialUpdateHelper.AddElement("Condition");
                    partialUpdateHelper.AddElement("Condition", "ID", editor.ID);

                    updateHelper.AddElement(".", partialUpdateHelper.BaseElement);

                    do_update = true;
                    synclist.Add(editor.ID);
                }
                else
                {
                    deleteHelper.AddElement("SemesterSubjectScore");
                    deleteHelper.AddElement("SemesterSubjectScore", "ID", editor.ID);

                    do_delete = true;
                    synclist.Add(editor.ID);
                }
            }

            if (do_insert)
            {
                DSXmlHelper response = FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.InsertSemesterSubjectScore", new DSRequest(insertHelper)).GetContent();
                foreach (XmlElement each in response.GetElements("NewID"))
                {
                    synclist.Add(each.InnerText);
                }
            }

            if (do_update)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.UpdateSemesterSubjectScore", new DSRequest(updateHelper));
            }

            if (do_delete)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.DeleteSemesterSubjectScore", new DSRequest(deleteHelper));
            }

            SemesterScore.Instance.SyncDataBackground(synclist.ToArray());
        }
Ejemplo n.º 37
0
        internal static void SaveClassTagRecordEditor(IEnumerable <JHSchool.Editor.ClassTagRecordEditor> editors)
        {
            MultiThreadWorker <JHSchool.Editor.ClassTagRecordEditor> worker = new MultiThreadWorker <JHSchool.Editor.ClassTagRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <JHSchool.Editor.ClassTagRecordEditor> e)
            {
                DSXmlHelper   updateHelper = new DSXmlHelper("Request");
                DSXmlHelper   insertHelper = new DSXmlHelper("Request");
                DSXmlHelper   deleteHelper = new DSXmlHelper("Request");
                List <string> synclist = new List <string>(); //這個目前沒作用
                bool          hasInsert = false, hasDelete = false;

                foreach (var editor in e.List)
                {
                    #region 更新
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                    {
                        deleteHelper.AddElement("Tag");
                        deleteHelper.AddElement("Tag", "RefClassID", editor.RefEntityID);
                        deleteHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

                        hasDelete = true;
                        synclist.Add(editor.RefEntityID);

                        insertHelper.AddElement("Tag");
                        insertHelper.AddElement("Tag", "RefClassID", editor.RefEntityID);
                        insertHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

                        hasInsert = true;
                    }
                    #endregion

                    #region 新增
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                    {
                        insertHelper.AddElement("Tag");
                        insertHelper.AddElement("Tag", "RefClassID", editor.RefEntityID);
                        insertHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

                        hasInsert = true;
                    }
                    #endregion

                    #region 刪除
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Delete)
                    {
                        deleteHelper.AddElement("Tag");
                        deleteHelper.AddElement("Tag", "RefClassID", editor.RefEntityID);
                        deleteHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

                        hasDelete = true;
                        synclist.Add(editor.RefEntityID);
                    }
                    #endregion
                }

                if (hasInsert)
                {
                    DSXmlHelper response = DSAServices.CallService("SmartSchool.Tag.AddClassTag", new DSRequest(insertHelper.BaseElement)).GetContent();
                    foreach (XmlElement each in response.GetElements("NewID"))
                    {
                        synclist.Add(each.InnerText);
                    }
                }

                if (hasDelete)
                {
                    DSAServices.CallService("SmartSchool.Tag.RemoveClassTag", new DSRequest(deleteHelper.BaseElement));
                }
            };
            List <PackageWorkEventArgs <JHSchool.Editor.ClassTagRecordEditor> > packages = worker.Run(editors);
            foreach (PackageWorkEventArgs <JHSchool.Editor.ClassTagRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Ejemplo n.º 38
0
        public static List <SCAttendRecord> GetSCAttendRecords(IEnumerable <string> primaryKeys)
        {
            bool        hasKey   = false;
            var         students = Student.Instance.Items;
            var         courses  = Course.Instance.Items;
            DSXmlHelper helper   = new DSXmlHelper("SelectRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "RefStudentID");
            helper.AddElement("Field", "RefCourseID");
            helper.AddElement("Field", "IsRequired");
            helper.AddElement("Field", "RequiredBy");
            helper.AddElement("Field", "Score");
            helper.AddElement("Field", "Extension");
            helper.AddElement("Condition");
            foreach (var item in primaryKeys)
            {
                helper.AddElement("Condition", "ID", item);
                hasKey = true;
            }
            helper.AddElement("Order");
            List <SCAttendRecord> result = new List <SCAttendRecord>();

            if (hasKey)
            {
                DSRequest dsreq = new DSRequest(helper);
                foreach (var item in FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.GetSCAttend", dsreq).GetContent().GetElements("Student"))
                {
                    helper = new DSXmlHelper(item);
                    var    studentid  = helper.GetText("RefStudentID");
                    var    courseid   = helper.GetText("RefCourseID");
                    var    score      = helper.GetText("Score");
                    var    effort     = helper.GetText("Extension/Extension/Effort");
                    var    text       = helper.GetText("Extension/Extension/Text");
                    var    id         = item.GetAttribute("ID");
                    bool?  required   = null;
                    string requiredby = null;
                    switch (helper.GetText("IsRequired"))
                    {
                    case "必":
                        required = true;
                        break;

                    case "選":
                        required = false;
                        break;

                    default:
                        required = null;
                        break;
                    }
                    switch (helper.GetText("RequiredBy"))
                    {
                    case "部訂":
                    case "校訂":
                        requiredby = helper.GetText("RequiredBy");
                        break;

                    default:
                        requiredby = null;
                        break;
                    }
                    //if ( students.ContainsKey(studentid) && courses.ContainsKey(courseid) )
                    result.Add(new SCAttendRecord(studentid, courseid, id, score, effort, text));
                }
            }
            return(result);
        }
Ejemplo n.º 39
0
        public static DSResponse GetSCAttendBrief(params string[] courseid)
        {
            DSXmlHelper helper = new DSXmlHelper("SelectRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "RefStudentID");
            helper.AddElement("Field", "RefCourseID");
            helper.AddElement("Field", "ClassName");
            helper.AddElement("Field", "StudentNumber");
            helper.AddElement("Field", "SeatNumber");
            helper.AddElement("Field", "Name");
            helper.AddElement("Field", "Score");
            helper.AddElement("Field", "Extension");
            helper.AddElement("Condition");
            foreach (string var in courseid)
            {
                helper.AddElement("Condition", "CourseID", var);
            }
            helper.AddElement("Order");
            helper.AddElement("Order", "ClassName", "ASC");
            helper.AddElement("Order", "SeatNumber", "ASC");
            DSRequest  dsreq = new DSRequest(helper);
            DSResponse rsp   = FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.GetSCAttend", dsreq);

            return(rsp);
        }
Ejemplo n.º 40
0
        internal static void SaveProgramPlanRecordEditor(IEnumerable <ProgramPlanRecordEditor> editors)
        {
            DSXmlHelper insertReq = new DSXmlHelper("Request");
            DSXmlHelper updateReq = new DSXmlHelper("Request");
            DSXmlHelper deleteReq = new DSXmlHelper("Request");

            deleteReq.AddElement(".", "GraduationPlan");

            //同步清單,裡面包含了 graduation plan 的系統編號。
            List <string> synclist = new List <string>();

            bool do_insert = false, do_update = false, do_delete = false;

            foreach (ProgramPlanRecordEditor editor in editors)
            {
                if (editor.EditorStatus != JHSchool.Editor.EditorStatus.NoChanged)
                {
                    synclist.Add(editor.ID);
                }

                if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                {
                    insertReq.AddElement("GraduationPlan");
                    insertReq.AddElement("GraduationPlan", "Name", editor.Name);
                    insertReq.AddElement("GraduationPlan", "Content", "<GraduationPlan></GraduationPlan>", true);
                    foreach (var subject in editor.Subjects)
                    {
                        DSXmlHelper helper = new DSXmlHelper("Subject");
                        helper.SetAttribute(".", "GradeYear", subject.GradeYear);
                        helper.SetAttribute(".", "Semester", subject.Semester);
                        helper.SetAttribute(".", "Credit", subject.Credit);
                        helper.SetAttribute(".", "Period", subject.Period);
                        helper.SetAttribute(".", "Domain", subject.Domain);
                        helper.SetAttribute(".", "FullName", subject.FullName);
                        helper.SetAttribute(".", "Level", subject.Level);
                        helper.SetAttribute(".", "CalcFlag", "" + subject.CalcFlag);
                        helper.SetAttribute(".", "SubjectName", subject.SubjectName);
                        helper.AddElement("Grouping");
                        helper.SetAttribute("Grouping", "RowIndex", "" + subject.RowIndex);
                        insertReq.AddElement("GraduationPlan/Content/GraduationPlan", helper.BaseElement);
                    }

                    do_insert = true;
                    //<GraduationPlan>
                    //<Subject Category="一般科目" Credit="2" Domain="外國語文"
                    //Entry="學業" FullName="ESL" GradeYear="2" Level=""
                    //NotIncludedInCalc="False" NotIncludedInCredit="False"
                    //Required="必修" RequiredBy="校訂" Semester="2" SubjectName="ESL">
                    //<Grouping RowIndex="1" startLevel=""/>
                    //</Subject>
                    //</GraduationPlan>
                }
                else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                {
                    updateReq.AddElement("GraduationPlan");
                    updateReq.AddElement("GraduationPlan", "Field");
                    updateReq.AddElement("GraduationPlan/Field", "Name", editor.Name);
                    updateReq.AddElement("GraduationPlan/Field", "Content", "<GraduationPlan></GraduationPlan>", true);
                    foreach (var subject in editor.Subjects)
                    {
                        DSXmlHelper helper = new DSXmlHelper("Subject");
                        helper.SetAttribute(".", "GradeYear", subject.GradeYear);
                        helper.SetAttribute(".", "Semester", subject.Semester);
                        helper.SetAttribute(".", "Credit", subject.Credit);
                        helper.SetAttribute(".", "Period", subject.Period);
                        helper.SetAttribute(".", "Domain", subject.Domain);
                        helper.SetAttribute(".", "FullName", subject.FullName);
                        helper.SetAttribute(".", "Level", subject.Level);
                        helper.SetAttribute(".", "CalcFlag", "" + subject.CalcFlag);
                        helper.SetAttribute(".", "SubjectName", subject.SubjectName);
                        helper.AddElement("Grouping");
                        helper.SetAttribute("Grouping", "RowIndex", "" + subject.RowIndex);
                        updateReq.AddElement("GraduationPlan/Field/Content/GraduationPlan", helper.BaseElement);
                    }
                    updateReq.AddElement("GraduationPlan", "Condition");
                    updateReq.AddElement("GraduationPlan/Condition", "ID", editor.ID);

                    do_update = true;
                }
                else if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Delete)
                {
                    deleteReq.AddElement("GraduationPlan", "ID", editor.ID);

                    do_delete = true;
                }
            }

            if (do_insert)
            {
                DSXmlHelper response = FISCA.Authentication.DSAServices.CallService("SmartSchool.GraduationPlan.Insert", new DSRequest(insertReq)).GetContent();
                foreach (XmlElement each in response.GetElements("NewID"))
                {
                    synclist.Add(each.InnerText);
                }
            }
            if (do_update)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.GraduationPlan.Update", new DSRequest(updateReq));
            }
            if (do_delete)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.GraduationPlan.Delete", new DSRequest(deleteReq));
            }

            if (synclist.Count > 0)
            {
                ProgramPlan.Instance.SyncDataBackground(synclist);
            }
        }
Ejemplo n.º 41
0
        // 以後交給 DAL
        private void setSchoolInfoData(SchoolInfoEntity ScInfoEntity)
        {
            //Framework.Feature.Config.SetSchoolInfo();
            // 學校基本資料
            DSXmlHelper helper = new DSXmlHelper("GetSchoolInfoResponse");

            helper.AddElement("SchoolInformation");
            helper.AddElement("SchoolInformation", "ChineseName", ScInfoEntity.ChinsesName);
            helper.AddElement("SchoolInformation", "EnglishName", ScInfoEntity.EnglishName);
            helper.AddElement("SchoolInformation", "Address", ScInfoEntity.ChineseAddress);
            helper.AddElement("SchoolInformation", "EnglishAddress", ScInfoEntity.EnglishAddress);
            helper.AddElement("SchoolInformation", "Code", ScInfoEntity.Code);
            helper.AddElement("SchoolInformation", "Fax", ScInfoEntity.Fax);
            helper.AddElement("SchoolInformation", "Telephone", ScInfoEntity.Telephone);

            helper.AddElement("SchoolInformation", "ChancellorChineseName", ScInfoEntity.ChancellorChsName);
            helper.AddElement("SchoolInformation", "ChancellorEnglishName", ScInfoEntity.ChancellorEngName);
            helper.AddElement("SchoolInformation", "ChancellorCellPhone", ScInfoEntity.ChancellorCellPhone);
            helper.AddElement("SchoolInformation", "ChancellorEmail", ScInfoEntity.ChancellorEmail);

            helper.AddElement("SchoolInformation", "EduDirectorName", ScInfoEntity.EduDirectorName);
            helper.AddElement("SchoolInformation", "EduDirectorCellPhone", ScInfoEntity.EduDirectorCellPhone);
            helper.AddElement("SchoolInformation", "EduDirectorEmail", ScInfoEntity.EduDirectorEmail);

            helper.AddElement("SchoolInformation", "StuDirectorName", ScInfoEntity.StuDirectorName);
            helper.AddElement("SchoolInformation", "StuDirectorCellPhone", ScInfoEntity.StuDirectorCellPhone);
            helper.AddElement("SchoolInformation", "StuDirectorEmail", ScInfoEntity.StuDirectorEmail);

            helper.AddElement("SchoolInformation", "AssociatedWithName", ScInfoEntity.AssociatedWithName);
            helper.AddElement("SchoolInformation", "AssociatedWithCellPhone", ScInfoEntity.AssociatedWithCellPhone);
            helper.AddElement("SchoolInformation", "AssociatedWithEmail", ScInfoEntity.AssociatedWithEmail);

            helper.AddElement("SchoolInformation", "OtherTitle", ScInfoEntity.OtherTitle);
            helper.AddElement("SchoolInformation", "OtherName", ScInfoEntity.OtherName);
            helper.AddElement("SchoolInformation", "OtherCellPhone", ScInfoEntity.OtherCellPhone);
            helper.AddElement("SchoolInformation", "OtherEmail", ScInfoEntity.OtherEmail);


            Config.SetSchoolInfo(helper.BaseElement);

            // 學年度學期
            DSXmlHelper helper1 = new DSXmlHelper("SetSystemConfigRequest");

            helper1.AddElement("SystemConfig");
            helper1.AddElement("SystemConfig", "DefaultSchoolYear", SchoolInfoEnt.SchoolYear);
            helper1.AddElement("SystemConfig", "DefaultSemester", SchoolInfoEnt.Semester);
            Config.SetSystemConfig(helper1.BaseElement);
        }
Ejemplo n.º 42
0
        void bkw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bkw    = (BackgroundWorker)sender;
            List <string>    errors = new List <string>();

            e.Result = errors;
            object[] args       = (object[])e.Argument;
            string   subject    = "" + args[0];
            string   level      = "" + args[1];
            string   credit     = "" + args[2];
            string   entry      = "" + args[3];
            string   required   = "" + args[4];
            string   requiredby = "" + args[5];
            //int schoolYear = SystemInformation.SchoolYear;
            //int semester = SystemInformation.Semester;
            int schoolYear = (int)args[6];
            int semester   = (int)args[7];
            int intlevel;

            if (!int.TryParse(level, out intlevel))
            {
                intlevel = int.MinValue;
            }

            AccessHelper accessHelper = new AccessHelper();
            Dictionary <ClassRecord, string> newCourseID = new Dictionary <ClassRecord, string>();
            List <ClassRecord> selectedClassList         = accessHelper.ClassHelper.GetSelectedClass();
            double             totle   = selectedClassList.Count;
            double             counter = 0;

            if (totle == 0)
            {
                totle = 1;
            }
            else
            {
                totle *= 3;
            }
            bkw.ReportProgress(1, errors);
            #region 檢查重複開課
            foreach (ClassRecord classRecord in selectedClassList)
            {
                foreach (CourseRecord courseRec in accessHelper.CourseHelper.GetClassCourse(schoolYear, semester, classRecord))
                {
                    if (courseRec.Subject == subject)
                    {
                        errors.Add(classRecord.ClassName + ":已有相同科目(" + subject + (intlevel > 0 ? " " + GetNumber(intlevel) : "") + ")的課程。");
                    }
                }
            }
            #endregion
            if (errors.Count == 0)
            {
                #region 開課
                foreach (ClassRecord classRecord in selectedClassList)
                {
                    string courseID = SmartSchool.Feature.Course.AddCourse.Insert(classRecord.ClassName + " " + subject + (intlevel > 0 ? " " + GetNumber(intlevel) : ""), "" + schoolYear, "" + semester);
                    newCourseID.Add(classRecord, courseID);
                    counter++;
                    bkw.ReportProgress((int)(counter * 100d / totle));
                }
                #endregion
                #region 修改課程資料
                DSXmlHelper updateCourseReq = new DSXmlHelper("UpdateRequest");
                foreach (ClassRecord classRecord in selectedClassList)
                {
                    updateCourseReq.AddElement("Course");
                    updateCourseReq.AddElement("Course", "Field");
                    updateCourseReq.AddElement("Course/Field", "Subject", subject);
                    updateCourseReq.AddElement("Course/Field", "SubjectLevel", level);
                    updateCourseReq.AddElement("Course/Field", "RefClassID", classRecord.ClassID);
                    updateCourseReq.AddElement("Course/Field", "Credit", credit);
                    updateCourseReq.AddElement("Course/Field", "IsRequired", (required == "必修" ? "必" : "選"));
                    updateCourseReq.AddElement("Course/Field", "RequiredBy", requiredby);
                    updateCourseReq.AddElement("Course/Field", "ScoreType", entry);
                    updateCourseReq.AddElement("Course", "Condition", "<ID>" + newCourseID[classRecord] + "</ID>", true);
                    counter++;
                    bkw.ReportProgress((int)(counter * 100d / totle));
                }
                SmartSchool.Feature.Course.EditCourse.UpdateCourse(new DSRequest(updateCourseReq));
                #endregion
                #region 加入學生修課
                DSXmlHelper InsertAttendReq = new DSXmlHelper("InsertSCAttend");
                bool        hasAttend       = false;
                foreach (ClassRecord classRecord in selectedClassList)
                {
                    foreach (StudentRecord studentRec in classRecord.Students)
                    {
                        InsertAttendReq.AddElement("Attend");
                        InsertAttendReq.AddElement("Attend", "RefCourseID", newCourseID[classRecord]);
                        InsertAttendReq.AddElement("Attend", "RefStudentID", studentRec.StudentID);
                        hasAttend = true;
                    }
                    counter++;
                    bkw.ReportProgress((int)(counter * 100d / totle));
                }
                if (hasAttend)
                {
                    SmartSchool.Feature.Course.AddCourse.AttendCourse(InsertAttendReq);
                }
                #endregion
                SmartSchool.Broadcaster.Events.Items["課程/新增"].Invoke();
            }
        }
Ejemplo n.º 43
0
        void _BGWAbsenceWeekListByAbsence_DoWork(object sender, DoWorkEventArgs e)
        {
            string reportName = "缺曠週報表";

            object[] args = e.Argument as object[];

            Dictionary <string, List <string> > config = args[0] as Dictionary <string, List <string> >;
            DateTime startDate  = (DateTime)args[1];
            DateTime endDate    = (DateTime)args[2];
            int      size       = (int)args[3];
            bool     CheckClass = (bool)args[4];

            bool CheckWeek = (bool)args[5];

            DateTime firstDate = startDate;

            #region 快取學生缺曠紀錄資料

            List <ClassRecord> selectedClass = Class.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource);
            selectedClass.Sort(new Comparison <ClassRecord>(CommonMethods.ClassComparer));

            Dictionary <string, List <StudentRecord> > classStudentList = new Dictionary <string, List <StudentRecord> >();

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

            //紀錄每一個 Column 的 Index
            Dictionary <string, int> columnTable = new Dictionary <string, int>();

            //紀錄每一個學生的缺曠紀錄
            Dictionary <string, Dictionary <string, Dictionary <string, int> > > studentAbsenceList = new Dictionary <string, Dictionary <string, Dictionary <string, int> > >();

            //紀錄每一個學生本週累計的缺曠紀錄
            Dictionary <string, Dictionary <string, int> > studentWeekAbsenceList = new Dictionary <string, Dictionary <string, int> >();

            //紀錄每一個學生學期累計的缺曠紀錄
            Dictionary <string, Dictionary <string, int> > studentSemesterAbsenceList = new Dictionary <string, Dictionary <string, int> >();

            //節次對照表
            Dictionary <string, string> periodList = new Dictionary <string, string>();

            int allStudentNumber = 0;

            //計算學生總數,取得所有學生ID
            foreach (ClassRecord aClass in selectedClass)
            {
                List <StudentRecord> classStudent = new List <StudentRecord>(); //取得一般生
                foreach (StudentRecord each in aClass.Students)
                {
                    if (each.Status == StudentRecord.StudentStatus.一般)
                    {
                        classStudent.Add(each);
                    }
                }

                classStudent.Sort(new Comparison <StudentRecord>(CommonMethods.ClassSeatNoComparer));

                foreach (StudentRecord aStudent in classStudent)
                {
                    allStudentID.Add(aStudent.ID);
                }
                if (!classStudentList.ContainsKey(aClass.ID))
                {
                    classStudentList.Add(aClass.ID, classStudent);
                }
                allStudentNumber += classStudent.Count;
            }

            //取得 Period List
            List <K12.Data.PeriodMappingInfo> PeriodInfoList = K12.Data.PeriodMapping.SelectAll();

            foreach (PeriodMappingInfo var in PeriodInfoList)
            {
                string name = var.Name;
                string type = var.Type;
                if (!periodList.ContainsKey(name))
                {
                    periodList.Add(name, type);
                }
            }

            //產生 DSRequest
            DSXmlHelper helper = new DSXmlHelper("Request");
            helper.AddElement("Field");
            helper.AddElement("Field", "All");
            helper.AddElement("Condition");
            foreach (string var in allStudentID)
            {
                helper.AddElement("Condition", "RefStudentID", var);
            }
            helper.AddElement("Condition", "StartDate", startDate.ToShortDateString());

            if (CheckWeek) //new,True就是取得至星期日內
            {
                helper.AddElement("Condition", "EndDate", endDate.ToShortDateString());
            }
            else //new,false就是取得到星期五的缺曠內容
            {
                helper.AddElement("Condition", "EndDate", endDate.AddDays(-2).ToShortDateString());
            }

            helper.AddElement("Order");
            helper.AddElement("Order", "OccurDate", "desc");
            DSResponse dsrsp = Get.GetAttendance(new DSRequest(helper));

            foreach (XmlElement var in dsrsp.GetContent().GetElements("Attendance"))
            {
                string studentID = var.SelectSingleNode("RefStudentID").InnerText;
                string occurDate = DateTime.Parse(var.SelectSingleNode("OccurDate").InnerText).ToShortDateString();

                if (!studentAbsenceList.ContainsKey(studentID))
                {
                    studentAbsenceList.Add(studentID, new Dictionary <string, Dictionary <string, int> >());
                }
                if (!studentAbsenceList[studentID].ContainsKey(occurDate))
                {
                    studentAbsenceList[studentID].Add(occurDate, new Dictionary <string, int>());
                }

                if (!studentWeekAbsenceList.ContainsKey(studentID))
                {
                    studentWeekAbsenceList.Add(studentID, new Dictionary <string, int>());
                }

                foreach (XmlElement period in var.SelectNodes("Detail/Attendance/Period"))
                {
                    string type    = periodList.ContainsKey(period.InnerText) ? periodList[period.InnerText] : "";
                    string absence = period.GetAttribute("AbsenceType");
                    if (!studentAbsenceList[studentID][occurDate].ContainsKey(type + "_" + absence))
                    {
                        studentAbsenceList[studentID][occurDate].Add(type + "_" + absence, 0);
                    }
                    studentAbsenceList[studentID][occurDate][type + "_" + absence]++;

                    if (!studentWeekAbsenceList[studentID].ContainsKey(type + "_" + absence))
                    {
                        studentWeekAbsenceList[studentID].Add(type + "_" + absence, 0);
                    }
                    studentWeekAbsenceList[studentID][type + "_" + absence]++;
                }
            }

            //產生 DSRequest,本學期累計
            helper = new DSXmlHelper("Request");
            helper.AddElement("Field");
            helper.AddElement("Field", "All");
            helper.AddElement("Condition");
            foreach (string var in allStudentID)
            {
                helper.AddElement("Condition", "RefStudentID", var);
            }
            helper.AddElement("Condition", "SchoolYear", K12.Data.School.DefaultSchoolYear);
            helper.AddElement("Condition", "Semester", K12.Data.School.DefaultSemester);

            if (CheckWeek) //new,True就是取得至星期日內
            {
                helper.AddElement("Condition", "EndDate", endDate.ToShortDateString());
            }
            else
            {
                helper.AddElement("Condition", "EndDate", endDate.AddDays(-2).ToShortDateString());
            }
            helper.AddElement("Order");
            helper.AddElement("Order", "OccurDate", "desc");
            dsrsp = Get.GetAttendance(new DSRequest(helper));

            foreach (XmlElement var in dsrsp.GetContent().GetElements("Attendance"))
            {
                string studentID = var.SelectSingleNode("RefStudentID").InnerText;

                if (!studentSemesterAbsenceList.ContainsKey(studentID))
                {
                    studentSemesterAbsenceList.Add(studentID, new Dictionary <string, int>());
                }

                foreach (XmlElement period in var.SelectNodes("Detail/Attendance/Period"))
                {
                    string type    = periodList.ContainsKey(period.InnerText) ? periodList[period.InnerText] : "";
                    string absence = period.GetAttribute("AbsenceType");
                    if (!studentSemesterAbsenceList[studentID].ContainsKey(type + "_" + absence))
                    {
                        studentSemesterAbsenceList[studentID].Add(type + "_" + absence, 0);
                    }
                    studentSemesterAbsenceList[studentID][type + "_" + absence]++;
                }
            }

            #endregion


            //取得學生英文別名
            //Dictionary<string, string> StudentEXTDic = tool.GetStudentEXT(allStudentID);



            //計算使用者自訂項目
            int allAbsenceNumber = 7;
            foreach (string type in config.Keys)
            {
                allAbsenceNumber += config[type].Count;
            }
            int current = 1;
            int all     = allAbsenceNumber + allStudentNumber;

            #region 動態產生範本

            Workbook template = new Workbook();

            template.Open(new MemoryStream(Properties.Resources.缺曠週報表_依假別), FileFormatType.Excel2003);

            Range tempStudent    = template.Worksheets[0].Cells.CreateRange(0, 4, true);
            Range tempEachColumn = template.Worksheets[0].Cells.CreateRange(4, 1, true);

            Workbook prototype = new Workbook();
            prototype.Copy(template);

            prototype.Worksheets[0].Cells.CreateRange(0, 4, true).Copy(tempStudent);

            int titleRow = 2;

            int dayNumber;
            if (CheckWeek)
            {
                dayNumber = 7;
            }
            else
            {
                dayNumber = 5;
            }

            int colIndex = 4;

            int dayStartIndex = colIndex;
            int dayEndIndex;
            int dayColumnNumber;

            //根據使用者設定的缺曠別,產生 Column

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

            foreach (string type in config.Keys)
            {
                if (config[type].Count == 0)
                {
                    continue;
                }

                int typeStartIndex = colIndex;

                foreach (string var in config[type])
                {
                    string SaveVar = type + "_" + var;
                    prototype.Worksheets[0].Cells.CreateRange(colIndex, 1, true).Copy(tempEachColumn);
                    prototype.Worksheets[0].Cells[titleRow + 2, colIndex].PutValue(var);
                    Cell _c = prototype.Worksheets[0].Cells[titleRow + 2, colIndex];
                    _c.Style.Rotation = -90; //將文字改為垂直
                    columnTable.Add(SaveVar, colIndex - 4);

                    if (!perList.Contains(SaveVar))
                    {
                        perList.Add(type + "_" + var);
                    }

                    colIndex++;
                    _BGWAbsenceWeekListByAbsence.ReportProgress((int)(((double)current++ *100.0) / (double)all));
                }

                int typeEndIndex = colIndex;

                Range typeRange = prototype.Worksheets[0].Cells.CreateRange(titleRow, typeStartIndex, titleRow + 2, typeEndIndex - typeStartIndex);
                typeRange.SetOutlineBorder(BorderType.LeftBorder, CellBorderType.Medium, Color.Black);
                typeRange.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Medium, Color.Black);

                prototype.Worksheets[0].Cells.CreateRange(titleRow + 1, typeStartIndex, 1, typeEndIndex - typeStartIndex).Merge();
                prototype.Worksheets[0].Cells[titleRow + 1, typeStartIndex].PutValue(type);
            }

            dayEndIndex     = colIndex;
            dayColumnNumber = dayEndIndex - dayStartIndex;
            if (dayColumnNumber == 0)
            {
                dayColumnNumber = 1;
            }

            prototype.Worksheets[0].Cells.CreateRange(titleRow, dayStartIndex, 1, dayColumnNumber).Merge();
            Range dayRange = prototype.Worksheets[0].Cells.CreateRange(dayStartIndex, dayColumnNumber, true);

            //prototype.Worksheets[0].Cells[titleRow, dayStartIndex].PutValue(firstDate.ToShortDateString() + " (" + CommonMethods.GetChineseDayOfWeek(firstDate) + ")");
            //columnTable.Add(firstDate.ToShortDateString(), dayStartIndex);

            //以一個日期為單位進行 Column 複製
            //for (int i = 1; i < dayNumber; i++)
            //{
            //    firstDate = firstDate.AddDays(1);

            //    dayStartIndex += dayColumnNumber;
            //    prototype.Worksheets[0].Cells.CreateRange(dayStartIndex, dayColumnNumber, true).Copy(dayRange);
            //    prototype.Worksheets[0].Cells[titleRow, dayStartIndex].PutValue(firstDate.ToShortDateString() + " (" + CommonMethods.GetChineseDayOfWeek(firstDate) + ")");
            //    columnTable.Add(firstDate.ToShortDateString(), dayStartIndex);
            //    _BGWAbsenceWeekListByAbsence.ReportProgress((int)(((double)current++ * 100.0) / (double)all));
            //}

            //dayStartIndex += dayColumnNumber;
            //prototype.Worksheets[0].Cells.CreateRange(dayStartIndex, dayColumnNumber, true).Copy(dayRange);
            prototype.Worksheets[0].Cells[titleRow, dayStartIndex].PutValue("本週合計(Week)");
            columnTable.Add("本週合計(Week)", dayStartIndex);
            _BGWAbsenceWeekListByAbsence.ReportProgress((int)(((double)current++ *100.0) / (double)all));

            dayStartIndex += dayColumnNumber;
            prototype.Worksheets[0].Cells.CreateRange(dayStartIndex, dayColumnNumber, true).Copy(dayRange);

            //2011/3/10 - 調整顯示字樣
            prototype.Worksheets[0].Cells[titleRow, dayStartIndex].PutValue("本學期累計(Semester)");

            columnTable.Add("本學期累計(Semester)", dayStartIndex);
            _BGWAbsenceWeekListByAbsence.ReportProgress((int)(((double)current++ *100.0) / (double)all));

            dayStartIndex += dayColumnNumber;

            //合併標題列
            prototype.Worksheets[0].Cells.CreateRange(0, 0, 1, dayStartIndex).Merge();
            prototype.Worksheets[0].Cells.CreateRange(1, 0, 1, dayStartIndex).Merge();

            Range prototypeRow    = prototype.Worksheets[0].Cells.CreateRange(5, 1, false);
            Range prototypeHeader = prototype.Worksheets[0].Cells.CreateRange(0, 5, false);

            current++;

            #endregion

            #region 產生報表

            Workbook wb = new Workbook();
            wb.Copy(prototype);
            Worksheet ws = wb.Worksheets[0];

            #region 判斷紙張大小
            if (size == 0)
            {
                ws.PageSetup.PaperSize = PaperSizeType.PaperA3;
                ws.PageSetup.Zoom      = 90;
            }
            else if (size == 1)
            {
                ws.PageSetup.PaperSize = PaperSizeType.PaperA4;
                ws.PageSetup.Zoom      = 65;
            }
            else if (size == 2)
            {
                ws.PageSetup.PaperSize = PaperSizeType.PaperB4;
                ws.PageSetup.Zoom      = 80;
            }
            #endregion

            int index     = 0;
            int dataIndex = 0;

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

            #region 檢查是否有資料
            if (CheckClass) //如果需要過慮資料
            {
                foreach (ClassRecord CheckClassData in selectedClass)
                {
                    List <StudentRecord> classStudent = classStudentList[CheckClassData.ID];
                    bool jumpNext = false;

                    foreach (StudentRecord CheckStudentData in classStudent)
                    {
                        if (studentWeekAbsenceList.ContainsKey(CheckStudentData.ID))                 //如果studentWeekAbsenceList內包含了該學生ID
                        {
                            foreach (string ajn in studentWeekAbsenceList[CheckStudentData.ID].Keys) //取得該學生假別
                            {
                                if (perList.Contains(ajn))                                           //如果假別的確包含於清單中
                                {
                                    if (!list.Contains(CheckClassData.ID))                           //如果清單中不包含就加入
                                    {
                                        list.Add(CheckClassData.ID);
                                        jumpNext = true;
                                    }
                                }

                                if (jumpNext)
                                {
                                    break;
                                }
                            }
                        }

                        if (jumpNext)
                        {
                            break;
                        }
                    }
                }
            }
            else //如果不需要過慮資料
            {
                foreach (ClassRecord CheckClassData in selectedClass)
                {
                    list.Add(CheckClassData.ID);
                }
            }
            #endregion

            foreach (ClassRecord classInfo in selectedClass)
            {
                if (list.Contains(classInfo.ID))
                {
                    List <StudentRecord> classStudent = classStudentList[classInfo.ID];

                    //如果不是第一頁,就在上一頁的資料列下邊加黑線
                    if (index != 0)
                    {
                        ws.Cells.CreateRange(index - 1, 0, 1, dayStartIndex).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
                    }

                    //複製 Header
                    ws.Cells.CreateRange(index, 5, false).Copy(prototypeHeader);

                    //填寫基本資料

                    string TeacherName = "";
                    if (classInfo.Teacher != null)
                    {
                        TeacherName = classInfo.Teacher.Name + " 老師";
                    }

                    ws.Cells[index, 0].PutValue("SchoolYear:" + tool.GetSchoolChange(K12.Data.School.DefaultSchoolYear) + " Semester:" + K12.Data.School.DefaultSemester + " " + School.ChineseName + " 學生缺曠課表");
                    if (CheckWeek) //new,True就是取得至星期日內
                    {
                        ws.Cells[index + 1, 0].PutValue("班導師: " + TeacherName + "  缺曠統計區間: " + startDate.ToShortDateString() + " ~ " + endDate.ToShortDateString() + "  列印日期:" + DateTime.Today.ToShortDateString());
                    }
                    else
                    {
                        ws.Cells[index + 1, 0].PutValue("班導師: " + TeacherName + "  缺曠統計區間: " + startDate.ToShortDateString() + " ~ " + endDate.AddDays(-2).ToShortDateString() + "  列印日期:" + DateTime.Today.ToShortDateString());
                    }

                    dataIndex = index + 5;

                    int studentCount = 0;
                    while (studentCount < classStudent.Count)
                    {
                        //複製每一個 row
                        ws.Cells.CreateRange(dataIndex, 1, false).Copy(prototypeRow);
                        if (studentCount % 5 == 0 && studentCount != 0)
                        {
                            Range eachFiveRow = ws.Cells.CreateRange(dataIndex, 0, 1, dayStartIndex);
                            eachFiveRow.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Double, Color.Black);
                        }

                        //填寫學生缺曠資料
                        StudentRecord student   = classStudent[studentCount];
                        string        studentID = student.ID;
                        ws.Cells[dataIndex, 0].PutValue(student.Class != null ? student.Class.Name : "");
                        ws.Cells[dataIndex, 1].PutValue(student.SeatNo);
                        ws.Cells[dataIndex, 2].PutValue(student.Name);
                        ws.Cells[dataIndex, 3].PutValue(student.EnglishName);
                        //英文別名
                        //if (StudentEXTDic.ContainsKey(student.ID))
                        //{
                        //    ws.Cells[dataIndex, 4].PutValue(StudentEXTDic[student.ID]);
                        //}

                        int startCol;
                        //if (studentAbsenceList.ContainsKey(studentID))
                        //{
                        //    foreach (string date in studentAbsenceList[studentID].Keys)
                        //    {
                        //        Dictionary<string, int> dateAbsence = studentAbsenceList[studentID][date];

                        //        startCol = columnTable[date];

                        //        foreach (string var in dateAbsence.Keys)
                        //        {
                        //            if (columnTable.ContainsKey(var))
                        //            {
                        //                ws.Cells[dataIndex, startCol + columnTable[var]].PutValue(dateAbsence[var]);
                        //            }
                        //        }
                        //    }
                        //}

                        if (studentWeekAbsenceList.ContainsKey(studentID))
                        {
                            startCol = columnTable["本週合計(Week)"];

                            Dictionary <string, int> studentWeek = studentWeekAbsenceList[studentID];

                            foreach (string var in studentWeek.Keys)
                            {
                                if (columnTable.ContainsKey(var))
                                {
                                    ws.Cells[dataIndex, startCol + columnTable[var]].PutValue(studentWeekAbsenceList[studentID][var]);
                                }
                            }
                        }

                        if (studentSemesterAbsenceList.ContainsKey(studentID))
                        {
                            startCol = columnTable["本學期累計(Semester)"];

                            Dictionary <string, int> studentSemester = studentSemesterAbsenceList[studentID];

                            foreach (string var in studentSemester.Keys)
                            {
                                if (columnTable.ContainsKey(var))
                                {
                                    ws.Cells[dataIndex, startCol + columnTable[var]].PutValue(studentSemester[var]);
                                }
                            }
                        }

                        studentCount++;
                        dataIndex++;
                        _BGWAbsenceWeekListByAbsence.ReportProgress((int)(((double)current++ *100.0) / (double)all));
                    }

                    //資料列上邊各加上黑線
                    ws.Cells.CreateRange(index + 4, 0, 1, dayStartIndex).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);

                    index = dataIndex;


                    //設定分頁
                    ws.HPageBreaks.Add(index, dayStartIndex);
                }
            }



            //最後一頁的資料列下邊加上黑線
            if (dataIndex != 0)
            {
                ws.Cells.CreateRange(dataIndex - 1, 0, 1, dayStartIndex).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
            }

            #endregion

            string path = Path.Combine(Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path     = Path.Combine(path, reportName + ".xlt");
            e.Result = new object[] { reportName, path, wb };
        }
Ejemplo n.º 44
0
        public void Export()
        {
            if (!IsValid())
            {
                return;
            }

            // 取得換算原則
            DSResponse d = Config.GetMDReduce();

            if (!d.HasContent)
            {
                MsgBox.Show("取得獎懲換算規則失敗:" + d.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DSXmlHelper h    = d.GetContent();
            int         ab   = int.Parse(h.GetText("Merit/AB"));
            int         bc   = int.Parse(h.GetText("Merit/BC"));
            int         wa   = int.Parse(txtA.Tag.ToString());
            int         wb   = int.Parse(txtB.Tag.ToString());
            int         wc   = int.Parse(txtC.Tag.ToString());
            int         want = (wa * ab * bc) + (wb * bc) + wc;

            List <string> _studentIDList = new List <string>();
            Workbook      book           = new Workbook();
            Worksheet     sheet          = book.Worksheets[0];
            string        schoolName     = School.ChineseName;
            string        A1Name         = "";

            if (rbType1.Checked)
            {
                DSXmlHelper helper = new DSXmlHelper("Request");
                helper.AddElement("Condition");
                foreach (string classid in _classList)
                {
                    helper.AddElement("Condition", "ClassID", classid);
                }

                helper.AddElement("Condition", "SchoolYear", cboSchoolYear.SelectedItem.ToString());
                helper.AddElement("Condition", "Semester", cboSemester.SelectedItem.ToString());
                helper.AddElement("Order");
                helper.AddElement("Order", "GradeYear", "ASC");
                helper.AddElement("Order", "DisplayOrder", "ASC");
                helper.AddElement("Order", "ClassName", "ASC");
                helper.AddElement("Order", "SeatNo", "ASC");
                helper.AddElement("Order", "Name", "ASC");

                DSResponse dsrsp = GetResponse(new DSRequest(helper));
                if (!dsrsp.HasContent)
                {
                    MsgBox.Show("查詢結果失敗:" + dsrsp.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                helper = dsrsp.GetContent();

                Cell A1 = sheet.Cells["A1"];
                A1.Style.Borders.SetColor(Color.Black);

                A1Name = schoolName + " (" + cboSchoolYear.SelectedItem.ToString() +
                         "/" + cboSemester.SelectedItem.ToString() + ") 獎勵特殊表現";

                sheet.Name = "獎勵特殊表現";
                A1.PutValue(A1Name);
                A1.Style.HorizontalAlignment = TextAlignmentType.Center;
                sheet.Cells.Merge(0, 0, 1, 7);

                FormatCell(sheet.Cells["A2"], "班級");
                FormatCell(sheet.Cells["B2"], "座號");
                FormatCell(sheet.Cells["C2"], "姓名");
                FormatCell(sheet.Cells["D2"], "學號");
                FormatCell(sheet.Cells["E2"], "大功");
                FormatCell(sheet.Cells["F2"], "小功");
                FormatCell(sheet.Cells["G2"], "嘉獎");
                int index = 1;
                foreach (XmlElement e in helper.GetElements("Student"))
                {
                    string da = e.SelectSingleNode("MeritA").InnerText;
                    string db = e.SelectSingleNode("MeritB").InnerText;
                    string dc = e.SelectSingleNode("MeritC").InnerText;

                    int a, b, c, total;
                    if (!int.TryParse(da, out a))
                    {
                        a = 0;
                    }
                    if (!int.TryParse(db, out b))
                    {
                        b = 0;
                    }
                    if (!int.TryParse(dc, out c))
                    {
                        c = 0;
                    }
                    total = (a * ab * bc) + (b * bc) + c;
                    if (total < want)
                    {
                        continue;
                    }

                    _studentIDList.Add(e.GetAttribute("StudentID"));

                    int rowIndex = index + 2;
                    FormatCell(sheet.Cells["A" + rowIndex], e.SelectSingleNode("ClassName").InnerText);
                    FormatCell(sheet.Cells["B" + rowIndex], e.SelectSingleNode("SeatNo").InnerText);
                    FormatCell(sheet.Cells["C" + rowIndex], e.SelectSingleNode("Name").InnerText);
                    FormatCell(sheet.Cells["D" + rowIndex], e.SelectSingleNode("StudentNumber").InnerText);

                    FormatCell(sheet.Cells["E" + rowIndex], e.SelectSingleNode("MeritA").InnerText);
                    FormatCell(sheet.Cells["F" + rowIndex], e.SelectSingleNode("MeritB").InnerText);
                    FormatCell(sheet.Cells["G" + rowIndex], e.SelectSingleNode("MeritC").InnerText);
                    index++;
                }
            }
            else // 若統計累計時的處理
            {
                DSXmlHelper helper = new DSXmlHelper("Request");
                helper.AddElement("Condition");
                foreach (string classid in _classList)
                {
                    helper.AddElement("Condition", "ClassID", classid);
                }
                helper.AddElement("Order");
                helper.AddElement("Order", "GradeYear", "ASC");
                helper.AddElement("Order", "DisplayOrder", "ASC");
                helper.AddElement("Order", "ClassName", "ASC");
                helper.AddElement("Order", "SeatNo", "ASC");
                helper.AddElement("Order", "Name", "ASC");
                DSResponse dsrsp = GetResponse(new DSRequest(helper));
                if (!dsrsp.HasContent)
                {
                    MsgBox.Show("查詢結果失敗:" + dsrsp.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                helper = dsrsp.GetContent();

                Cell A1 = sheet.Cells["A1"];
                A1.Style.Borders.SetColor(Color.Black);

                A1Name = schoolName + "  獎勵累計 學生清單";

                sheet.Name = "獎勵特殊表現";
                A1.PutValue(A1Name);
                A1.Style.HorizontalAlignment = TextAlignmentType.Center;
                sheet.Cells.Merge(0, 0, 1, 7);

                FormatCell(sheet.Cells["A2"], "班級");
                FormatCell(sheet.Cells["B2"], "座號");
                FormatCell(sheet.Cells["C2"], "姓名");
                FormatCell(sheet.Cells["D2"], "學號");
                FormatCell(sheet.Cells["E2"], "大功");
                FormatCell(sheet.Cells["F2"], "小功");
                FormatCell(sheet.Cells["G2"], "嘉獎");

                int index = 3;
                foreach (XmlElement e in helper.GetElements("Student"))
                {
                    _studentIDList.Add(e.GetAttribute("StudentID"));
                    string da = e.SelectSingleNode("MeritA").InnerText;
                    string db = e.SelectSingleNode("MeritB").InnerText;
                    string dc = e.SelectSingleNode("MeritC").InnerText;

                    int a, b, c, total;
                    if (!int.TryParse(da, out a))
                    {
                        a = 0;
                    }
                    if (!int.TryParse(db, out b))
                    {
                        b = 0;
                    }
                    if (!int.TryParse(dc, out c))
                    {
                        c = 0;
                    }
                    total = (a * ab * bc) + (b * bc) + c;
                    if (total < want)
                    {
                        continue;
                    }

                    FormatCell(sheet.Cells["A" + index], e.SelectSingleNode("ClassName").InnerText);
                    FormatCell(sheet.Cells["B" + index], e.SelectSingleNode("SeatNo").InnerText);
                    FormatCell(sheet.Cells["C" + index], e.SelectSingleNode("Name").InnerText);
                    FormatCell(sheet.Cells["D" + index], e.SelectSingleNode("StudentNumber").InnerText);
                    FormatCell(sheet.Cells["E" + index], e.SelectSingleNode("MeritA").InnerText);
                    FormatCell(sheet.Cells["F" + index], e.SelectSingleNode("MeritB").InnerText);
                    FormatCell(sheet.Cells["G" + index], e.SelectSingleNode("MeritC").InnerText);
                    index++;
                }
            }

            h = new DSXmlHelper("Request");
            h.AddElement("Field");
            h.AddElement("Field", "All");
            h.AddElement("Condition");
            h.AddElement("Condition", "MeritFlag", "1");
            h.AddElement("Condition", "RefStudentID", "-1");

            foreach (string sid in _studentIDList)
            {
                h.AddElement("Condition", "RefStudentID", sid);
            }
            if (rbType1.Checked)
            {
                h.AddElement("Condition", "SchoolYear", cboSchoolYear.Text);
                h.AddElement("Condition", "Semester", cboSemester.Text);
            }
            h.AddElement("Order");
            h.AddElement("Order", "GradeYear", "ASC");
            h.AddElement("Order", "ClassDisplayOrder", "ASC");
            h.AddElement("Order", "ClassName", "ASC");
            h.AddElement("Order", "SeatNo", "ASC");
            h.AddElement("Order", "RefStudentID", "ASC");
            h.AddElement("Order", "OccurDate", "ASC");

            d = QueryDiscipline.GetDiscipline(new DSRequest(h));
            if (!d.HasContent)
            {
                MsgBox.Show("取得明細資料錯誤:" + d.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            h = d.GetContent();
            book.Worksheets.Add();
            sheet      = book.Worksheets[book.Worksheets.Count - 1];
            sheet.Name = schoolName + "獎勵累計明細";
            Cell titleCell = sheet.Cells["A1"];

            titleCell.Style.Borders.SetColor(Color.Black);

            titleCell.PutValue(sheet.Name);
            titleCell.Style.HorizontalAlignment = TextAlignmentType.Center;
            sheet.Cells.Merge(0, 0, 1, 7);

            FormatCell(sheet.Cells["A2"], "班級");
            FormatCell(sheet.Cells["B2"], "座號");
            FormatCell(sheet.Cells["C2"], "姓名");
            FormatCell(sheet.Cells["D2"], "學號");
            FormatCell(sheet.Cells["E2"], "學年度");
            FormatCell(sheet.Cells["F2"], "學期");
            FormatCell(sheet.Cells["G2"], "日期");
            FormatCell(sheet.Cells["H2"], "大功");
            FormatCell(sheet.Cells["I2"], "小功");
            FormatCell(sheet.Cells["J2"], "嘉獎");
            FormatCell(sheet.Cells["K2"], "事由");

            int ri = 3;

            foreach (XmlElement e in h.GetElements("Discipline"))
            {
                FormatCell(sheet.Cells["A" + ri], e.SelectSingleNode("ClassName").InnerText);
                FormatCell(sheet.Cells["B" + ri], e.SelectSingleNode("SeatNo").InnerText);
                FormatCell(sheet.Cells["C" + ri], e.SelectSingleNode("Name").InnerText);
                FormatCell(sheet.Cells["D" + ri], e.SelectSingleNode("StudentNumber").InnerText);
                FormatCell(sheet.Cells["E" + ri], e.SelectSingleNode("SchoolYear").InnerText);
                FormatCell(sheet.Cells["F" + ri], e.SelectSingleNode("Semester").InnerText);
                FormatCell(sheet.Cells["G" + ri], e.SelectSingleNode("OccurDate").InnerText);
                FormatCell(sheet.Cells["H" + ri], e.SelectSingleNode("Detail/Discipline/Merit/@A").InnerText);
                FormatCell(sheet.Cells["I" + ri], e.SelectSingleNode("Detail/Discipline/Merit/@B").InnerText);
                FormatCell(sheet.Cells["J" + ri], e.SelectSingleNode("Detail/Discipline/Merit/@C").InnerText);
                FormatCell(sheet.Cells["K" + ri], e.SelectSingleNode("Reason").InnerText);
                ri++;
            }

            string path = Path.Combine(Application.StartupPath, "Reports");

            //如果目錄不存在則建立。
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            path = Path.Combine(path, book.Worksheets[0].Name + ".xls");
            int i = 1;

            while (true)
            {
                string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path);
                if (!File.Exists(newPath))
                {
                    path = newPath;
                    break;
                }
            }
            try
            {
                book.Save(path);
            }
            catch (Exception ex)
            {
                MsgBox.Show("檔案儲存失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                Process.Start(path);
            }
            catch (Exception ex)
            {
                MsgBox.Show("檔案開啟失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        public void SaveConfiguration(IEnumerable <ConfigurationRecord> configurations)
        {
            MultiThreadWorker <ConfigurationRecord> worker = new MultiThreadWorker <ConfigurationRecord>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 20;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <ConfigurationRecord> e)
            {
                DSXmlHelper insert = new DSXmlHelper("Request");
                DSXmlHelper update = new DSXmlHelper("Request");
                DSXmlHelper delete = new DSXmlHelper("Request");
                bool        insert_exec = false, update_exec = false, delete_exec = false;

                foreach (ConfigurationRecord eachConf in e.List)
                {
                    if (eachConf.EditAction == 1) //新增
                    {
                        insert.AddElement("Configuration");
                        insert.AddElement("Configuration", "Name", eachConf.Namespace);
                        insert.AddElement("Configuration", "Content", eachConf.GetXml(), true);
                        insert_exec = true;
                    }
                    else if (eachConf.EditAction == 2) //修改
                    {
                        update.AddElement("Configuration");
                        update.AddElement("Configuration", "Content", eachConf.GetXml(), true);
                        update.AddElement("Configuration", "Condition");
                        update.AddElement("Configuration/Condition", "Name", eachConf.Namespace);
                        update_exec = true;
                    }
                    else if (eachConf.EditAction == 3) //刪除
                    {
                        delete.AddElement("Configuration");
                        delete.AddElement("Configuration", "Name", eachConf.Namespace);
                        delete_exec = true;
                    }
                    else
                    {
                        throw new ArgumentException("沒有這一種的啦。");
                    }
                }

                if (insert_exec)
                {
                    DSAServices.CallService("SmartSchool.Configuration.User.Insert", new DSRequest(insert));
                }

                if (update_exec)
                {
                    DSAServices.CallService("SmartSchool.Configuration.User.Update", new DSRequest(update));
                }

                if (delete_exec)
                {
                    DSAServices.CallService("SmartSchool.Configuration.User.Delete", new DSRequest(delete));
                }
            };

            List <PackageWorkEventArgs <ConfigurationRecord> > results = worker.Run(configurations);

            foreach (PackageWorkEventArgs <ConfigurationRecord> each in results)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Ejemplo n.º 46
0
        public override void Save()
        {
            // 產生新增成績 Request
            int insertStudentCount = 0;
            int updateStudentCount = 0;
            int deleteStudentCount = 0;
            int usCount            = 0;

            DSXmlHelper insertHelper = new DSXmlHelper("Request");
            DSXmlHelper updateHelper = new DSXmlHelper("Request");
            DSXmlHelper deleteHelper = new DSXmlHelper("Request");
            DSXmlHelper usHelper     = new DSXmlHelper("Request");

            insertHelper.AddElement("ScoreSheetList");
            updateHelper.AddElement("ScoreSheetList");
            deleteHelper.AddElement("ScoreSheet");

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string attendid = row.Tag.ToString();

                foreach (DataGridViewCell cell in row.Cells)
                {
                    IExamCell ic = cell.Tag as IExamCell;
                    if (ic == null)
                    {
                        continue;
                    }
                    ColumnSetting setting = dataGridView1.Columns[cell.ColumnIndex].Tag as ColumnSetting;
                    string        examid  = setting.Key;
                    if (ic is ScoreExamCell && ic.IsDirty)
                    {
                        usCount++;
                        usHelper.AddElement("Attend");
                        usHelper.AddElement("Attend", "Score", ic.GetValue());
                        usHelper.AddElement("Attend", "ID", attendid);
                    }
                    else if (string.IsNullOrEmpty(ic.Key) && ic.IsDirty)
                    {
                        insertStudentCount++;
                        insertHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "ExamID", examid);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "AttendID", attendid);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue());
                    }
                    else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && !string.IsNullOrEmpty(ic.GetValue()))
                    {
                        updateStudentCount++;
                        updateHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue());
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "ID", ic.Key);
                    }
                    else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && string.IsNullOrEmpty(ic.GetValue()))
                    {
                        deleteStudentCount++;
                        deleteHelper.AddElement("ScoreSheet", "ID", ic.Key);
                    }
                }
            }

            if (insertStudentCount > 0)
            {
                EditCourse.InsertSCEScore(new DSRequest(insertHelper));
            }
            if (updateStudentCount > 0)
            {
                EditCourse.UpdateSCEScore(new DSRequest(updateHelper));
            }
            if (deleteStudentCount > 0)
            {
                EditCourse.DeleteSCEScore(new DSRequest(deleteHelper));
            }
            if (usCount > 0)
            {
                EditCourse.UpdateAttend(usHelper);
            }

            SaveButtonVisible = false;
            LoadContent(RunningID);
        }
Ejemplo n.º 47
0
        public static void SaveClassRecordEditor(IEnumerable <ClassRecordEditor> editors)
        {
            MultiThreadWorker <ClassRecordEditor> worker = new MultiThreadWorker <ClassRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <ClassRecordEditor> e)
            {
                DSXmlHelper   updateHelper = new DSXmlHelper("Request");
                DSXmlHelper   insertHelper = new DSXmlHelper("Request");
                DSXmlHelper   deleteHelper = new DSXmlHelper("Request");
                List <string> synclist = new List <string>();
                bool          hasUpdate = false, hasInsert = false, hasDelete = false;

                foreach (var editor in e.List)
                {
                    #region 更新
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                    {
                        updateHelper.AddElement("Class");
                        updateHelper.AddElement("Class", "Field");
                        updateHelper.AddElement("Class/Field", "ClassName", editor.Name);
                        updateHelper.AddElement("Class/Field", "NamingRule", editor.NamingRule);
                        updateHelper.AddElement("Class/Field", "GradeYear", editor.GradeYear);
                        updateHelper.AddElement("Class/Field", "RefDepartmentID", editor.RefDepartmentID);
                        updateHelper.AddElement("Class/Field", "RefGraduationPlanID", editor.RefProgramPlanID);
                        updateHelper.AddElement("Class/Field", "RefScoreCalcRuleID", editor.RefScoreCalcRuleID);
                        updateHelper.AddElement("Class/Field", "RefTeacherID", editor.RefTeacherID);
                        updateHelper.AddElement("Class/Field", "DisplayOrder", editor.DisplayOrder);
                        updateHelper.AddElement("Class/Field", "ClassNumber", editor.DisplayOrder);
                        updateHelper.AddElement("Class", "Condition");
                        updateHelper.AddElement("Class/Condition", "ID", editor.ID);

                        hasUpdate = true;
                        synclist.Add(editor.ID);
                    }
                    #endregion

                    #region 新增
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                    {
                        insertHelper.AddElement("Class");
                        insertHelper.AddElement("Class", "Field");
                        insertHelper.AddElement("Class/Field", "ClassName", editor.Name);
                        insertHelper.AddElement("Class/Field", "NamingRule", editor.NamingRule);
                        insertHelper.AddElement("Class/Field", "GradeYear", editor.GradeYear);
                        insertHelper.AddElement("Class/Field", "RefDepartmentID", editor.RefDepartmentID);
                        insertHelper.AddElement("Class/Field", "RefGraduationPlanID", editor.RefProgramPlanID);
                        insertHelper.AddElement("Class/Field", "RefScoreCalcRuleID", editor.RefScoreCalcRuleID);
                        insertHelper.AddElement("Class/Field", "RefTeacherID", editor.RefTeacherID);
                        insertHelper.AddElement("Class/Field", "DisplayOrder", editor.DisplayOrder);
                        insertHelper.AddElement("Class/Field", "ClassNumber", editor.DisplayOrder);

                        hasInsert = true;
                    }
                    #endregion

                    #region 刪除
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Delete)
                    {
                        deleteHelper.AddElement("Class");
                        deleteHelper.AddElement("Class", "ID", editor.ID);

                        hasDelete = true;
                        synclist.Add(editor.ID);
                    }
                    #endregion
                }

                if (hasUpdate)
                {
                    DSAServices.CallService("SmartSchool.Class.Update", new DSRequest(updateHelper.BaseElement));
                }

                if (hasInsert)
                {
                    DSXmlHelper response = DSAServices.CallService("SmartSchool.Class.Insert", new DSRequest(insertHelper.BaseElement)).GetContent();
                    foreach (XmlElement each in response.GetElements("NewID"))
                    {
                        synclist.Add(each.InnerText);
                    }
                }

                if (hasDelete)
                {
                    DSAServices.CallService("SmartSchool.Class.Delete", new DSRequest(deleteHelper.BaseElement));
                }

                Class.Instance.SyncDataBackground(synclist);
            };
            List <PackageWorkEventArgs <ClassRecordEditor> > packages = worker.Run(editors);
            foreach (PackageWorkEventArgs <ClassRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Ejemplo n.º 48
0
        private void GetChengeObj()
        {
            //人數限制
            if (!string.IsNullOrEmpty(tbGrade1Limit.Text.Trim())) //一年級人限
            {
                ClubPrimary.Grade1Limit = tool.StringIsInt_DefIsZero(tbGrade1Limit.Text.Trim());
            }
            else
            {
                ClubPrimary.Grade1Limit = null;
            }
            if (!string.IsNullOrEmpty(tbGrade2Limit.Text.Trim())) //二年級人限
            {
                ClubPrimary.Grade2Limit = tool.StringIsInt_DefIsZero(tbGrade2Limit.Text.Trim());
            }
            else
            {
                ClubPrimary.Grade2Limit = null;
            }
            if (!string.IsNullOrEmpty(tbGrade3Limit.Text.Trim())) //三年級人限
            {
                ClubPrimary.Grade3Limit = tool.StringIsInt_DefIsZero(tbGrade3Limit.Text.Trim());
            }
            else
            {
                ClubPrimary.Grade3Limit = null;
            }
            if (!string.IsNullOrEmpty(tbLimit.Text.Trim())) //人數上限
            {
                ClubPrimary.Limit = tool.StringIsInt_DefIsZero(tbLimit.Text.Trim());
            }
            else
            {
                ClubPrimary.Limit = null;
            }

            //性別限制
            if (cbGenderRestrict.SelectedItem != null) //男女限制
            {
                string res = cbGenderRestrict.GetItemText(cbGenderRestrict.SelectedItem);
                if (res == "")
                {
                    ClubPrimary.GenderRestrict = "";
                }
                else
                {
                    ClubPrimary.GenderRestrict = res;
                }
            }

            //科別限制
            DSXmlHelper dsXml = new DSXmlHelper("Department");

            foreach (ListViewItem each in listDepartment.Items)
            {
                if (each.Checked)
                {
                    dsXml.AddElement("Dept");
                    dsXml.AddText("Dept", each.Text);
                }
            }
            ClubPrimary.DeptRestrict = dsXml.BaseElement.OuterXml;
        }
Ejemplo n.º 49
0
        public static DSResponse GetTeacherListWithSupervisedByClassInfo(params string[] teacherIdList)
        {
            DSXmlHelper helper = new DSXmlHelper("GetDetailListRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "TeacherName");
            helper.AddElement("Field", "Nickname");
            helper.AddElement("Field", "Gender");
            helper.AddElement("Field", "IDNumber");
            helper.AddElement("Field", "ContactPhone");
            helper.AddElement("Field", "Category");
            helper.AddElement("Field", "SupervisedByClassID");
            helper.AddElement("Field", "SupervisedByClassName");
            helper.AddElement("Field", "SupervisedByGradeYear");
            helper.AddElement("Field", "Status");
            helper.AddElement("Condition");
            if (teacherIdList.Length > 0)
            {
                helper.AddElement("Condition", "IDList");
                foreach (string id in teacherIdList)
                {
                    helper.AddElement("Condition/IDList", "ID", id);
                }
            }
            helper.AddElement("Order");
            helper.AddElement("Order", "TeacherName");
            return(DSAServices.CallService("SmartSchool.Teacher.GetDetailListWithSupervisedByClassInfo", new DSRequest(helper)));
        }
Ejemplo n.º 50
0
        public override void Save()
        {
            List <AttendInfo> insertList = new List <AttendInfo>();  //新增清單
            List <AttendInfo> updateList = new List <AttendInfo>();  //更新清單
            List <AttendInfo> deleteList = new List <AttendInfo>();  //刪除清單

            GetList(insertList, updateList, deleteList);

            try
            {
                List <string> synclist = new List <string>();
                DSXmlHelper   helper   = new DSXmlHelper("InsertSCAttend");
                foreach (AttendInfo each in insertList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<RefStudentID>" + each.RefStudentID.ToString() + "</RefStudentID>");
                    DSXmlHelper.AppendChild(attend, "<RefCourseID>" + RunningID + "</RefCourseID>");
                    DSXmlHelper.AppendChild(attend, "<IsRequired>" + each.IsRequired + "</IsRequired>");
                    DSXmlHelper.AppendChild(attend, "<RequiredBy>" + each.RequiredBy + "</RequiredBy>");
                    //DSXmlHelper.AppendChild(attend, "<GradeYear>" + each.GradeYear + "</GradeYear>");
                    helper.AddElement(".", attend);
                }
                if (insertList.Count > 0)
                {
                    DSXmlHelper insertResult = AddCourse.AttendCourse(helper).GetContent();
                    foreach (XmlElement each in insertResult.GetElements("NewID"))
                    {
                        synclist.Add(each.InnerText);
                    }
                }

                helper = new DSXmlHelper("UpdateSCAttend");
                foreach (AttendInfo each in updateList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<ID>" + each.Identity + "</ID>");
                    DSXmlHelper.AppendChild(attend, "<IsRequired>" + each.IsRequired + "</IsRequired>");
                    DSXmlHelper.AppendChild(attend, "<RequiredBy>" + each.RequiredBy + "</RequiredBy>");
                    synclist.Add(each.Identity.ToString());

                    helper.AddElement(".", attend);
                }
                if (updateList.Count > 0)
                {
                    EditCourse.UpdateAttend(helper);
                }

                helper = new DSXmlHelper("DeleteSCAttendRequest");
                foreach (AttendInfo each in deleteList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<ID>" + each.Identity + "</ID>");
                    synclist.Add(each.Identity.ToString());

                    helper.AddElement(".", attend);
                }
                if (deleteList.Count > 0)
                {
                    EditCourse.DeleteAttend(helper);
                }

                #region Log

                StringBuilder desc = new StringBuilder("");
                desc.AppendLine("課程名稱:" + Course.Instance.Items[RunningID].Name);
                if (insertList.Count > 0)
                {
                    desc.AppendLine("加入修課學生:");
                }
                foreach (AttendInfo info in insertList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }
                if (deleteList.Count > 0)
                {
                    desc.AppendLine("移除課程修課學生:");
                }
                foreach (AttendInfo info in deleteList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }
                if (updateList.Count > 0)
                {
                    desc.AppendLine("課程修課學生修課資訊調整:");
                }
                foreach (AttendInfo info in updateList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }

                //CurrentUser.Instance.AppLog.Write(EntityType.Course, "修改課程修課學生", RunningID, desc.ToString(), "課程", "");
                FISCA.LogAgent.ApplicationLog.Log("課程基本資料", "修改課程修課學生", desc.ToString());

                #endregion

                //SCAttend.Instance.SyncDataBackground(synclist);
                LoadContent(RunningID);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗:" + ex.Message);
            }
        }
Ejemplo n.º 51
0
        public void Dispatch(ElectronicPaper ePaper)
        {
            string epaperId = EditElectronicPaper.Insert(
                ePaper.Name,
                ePaper.SchoolYear,
                ePaper.Semester,
                ePaper.ViewerType.ToString(),
                ePaper.Metadata);

            List <DSXmlHelper> requests = new List <DSXmlHelper>();
            DSXmlHelper        papers   = null;
            int count = 0;

            IProgressReceiver receiver = ePaper.ProgressReceiver;

            if (receiver == null)
            {
                receiver = new ElectronicPaperProgress();
            }

            foreach (PaperItem eachPaper in ePaper)
            {
                if (eachPaper.Viewers.Count <= 0)
                {
                    throw new ArgumentException("每一張電子報表至少要有一個 Viewer。");
                }

                if (count % 10 == 0)
                {
                    papers = new DSXmlHelper("Request");
                    requests.Add(papers);
                }

                DSXmlHelper paper = new DSXmlHelper(papers.AddElement("Paper"));
                foreach (string eachViewer in eachPaper.Viewers)
                {
                    paper.AddElement(".", "RefElectronicPaperID", epaperId);
                    paper.AddElement(".", "Format", eachPaper.Format);
                    paper.AddElement(".", "Content", eachPaper.Content);
                    //paper.AddElement(".", "ViewerType", ePaper.ViewerType.ToString());
                    paper.AddElement(".", "ViewerID", eachViewer);

                    count++;
                }
            }

            if (count > 0)
            {
                if (receiver != null)
                {
                    receiver.ProcessStart();
                }

                int current = 1;
                foreach (DSXmlHelper each in requests)
                {
                    EditElectronicPaper.InsertPaperItem(each);

                    if (receiver != null)
                    {
                        receiver.ProcessProgress((int)(((float)current / (float)requests.Count) * 100f));
                    }

                    current++;
                }

                if (receiver != null)
                {
                    receiver.ProcessEnd();
                }
            }
        }
Ejemplo n.º 52
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region DoWork
            object[] objs         = (object[])e.Argument;
            int      schoolyear   = Framework.Int.Parse(objs[0] as string);
            int      semester     = Framework.Int.Parse(objs[1] as string);
            string   domain       = objs[2] as string;
            string   subject      = objs[3] as string;
            string   periodcredit = objs[4] as string;
            string   required     = objs[5] as string;

            PeriodCredit pc = new PeriodCredit();
            pc.Parse(periodcredit);

            double total   = _classes.Count;
            double counter = 0;
            if (total == 0)
            {
                total = 1;
            }
            else
            {
                total *= 2;
            }
            _worker.ReportProgress(1, "正在檢查班級課程…");

            _classes.Sort(SortClassesByClassName);

            #region 檢查重複開課
            List <string> errors = new List <string>();

            List <string> classIDs = new List <string>();
            foreach (JHClassRecord cla in _classes)
            {
                classIDs.Add(cla.ID);
            }

            Dictionary <string, List <JHCourseRecord> > classExistCourses = new Dictionary <string, List <JHCourseRecord> >();
            List <JHCourseRecord> orphanCourse = new List <JHCourseRecord>();

            foreach (JHCourseRecord course in JHCourse.SelectBySchoolYearAndSemester(schoolyear, semester))
            {
                if (!classIDs.Contains(course.RefClassID))
                {
                    orphanCourse.Add(course);
                    continue;
                }

                if (!classExistCourses.ContainsKey(course.RefClassID))
                {
                    classExistCourses.Add(course.RefClassID, new List <JHCourseRecord>());
                }
                classExistCourses[course.RefClassID].Add(course);
            }

            foreach (JHClassRecord cla in _classes)
            {
                if (!classExistCourses.ContainsKey(cla.ID))
                {
                    continue;
                }

                foreach (JHCourseRecord course in classExistCourses[cla.ID])
                {
                    if (course.Subject == subject)
                    {
                        errors.Add(cla.Name + ":已有相同科目(" + subject + ")的課程。");
                    }
                }

                foreach (JHCourseRecord course in orphanCourse)
                {
                    if (course.Name == cla.Name + " " + subject)
                    {
                        errors.Add(cla.Name + ":已有相同課程名稱(" + course.Name + ")的課程。");
                    }
                }
            }

            if (errors.Count > 0)
            {
                e.Result = errors;
                return;
            }
            #endregion

            #region 開課
            Dictionary <string, string> classNewCourse = new Dictionary <string, string>();

            DSXmlHelper req = new DSXmlHelper("UpdateRequest");

            foreach (JHClassRecord cla in _classes)
            {
                JHCourseRecord newCourse = new JHCourseRecord();
                newCourse.CalculationFlag = "1";
                newCourse.Period          = pc.Period;
                newCourse.Credit          = pc.Credit;
                newCourse.Domain          = domain;
                newCourse.Subject         = subject;
                newCourse.Name            = cla.Name + " " + subject;
                newCourse.SchoolYear      = schoolyear;
                newCourse.Semester        = semester;
                newCourse.RefClassID      = cla.ID;

                //建立Course時也將CourseExtendRecord建立
                string             course_id = JHCourse.Insert(newCourse);
                CourseExtendRecord courseEx  = new CourseExtendRecord();
                courseEx.Ref_course_id = int.Parse(course_id);
                courseEx.GradeYear     = cla.GradeYear == null ? -1 : int.Parse(cla.GradeYear + "");
                courseEx.Save();

                classNewCourse.Add(cla.ID, course_id);
                req.AddElement("Course");
                req.AddElement("Course", "Field");
                req.AddElement("Course/Field", "IsRequired", required.Replace("修", ""));
                req.AddElement("Course", "Condition");
                req.AddElement("Course/Condition", "ID", classNewCourse[cla.ID]);

                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在進行開課…");
            }

            //更新必選修
            if (classNewCourse.Count > 0)
            {
                JHSchool.Feature.Legacy.EditCourse.UpdateCourse(new DSRequest(req));
            }

            #endregion

            #region 加入學生修課

            foreach (JHClassRecord cla in _classes)
            {
                List <JHSCAttendRecord> scattends = new List <JHSchool.Data.JHSCAttendRecord>();
                foreach (JHStudentRecord stu in cla.Students)
                {
                    JHSCAttendRecord scattend = new JHSchool.Data.JHSCAttendRecord();
                    scattend.RefCourseID  = classNewCourse[cla.ID];
                    scattend.RefStudentID = stu.ID;

                    scattends.Add(scattend);
                }

                if (scattends.Count > 0)
                {
                    JHSCAttend.Insert(scattends);
                }

                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在加入學生修課…");
            }
            #endregion

            // 加這主要是重新整理
            Course.Instance.SyncDataBackground(classNewCourse.Values);

            e.Result = string.Empty;

            #endregion
        }
Ejemplo n.º 53
0
        private XmlElement GetContent()
        {
            DSXmlHelper helper = new DSXmlHelper("ScoreCalcRule");
            XmlElement  element;

            #region 成績計算規則
            helper.AddElement("成績計算規則");
            helper.AddElement("成績計算規則", "各項成績計算位數");

            element = helper.AddElement("成績計算規則/各項成績計算位數", "科目成績計算");
            element.SetAttribute("位數", "" + numericUpDown1.Value);
            element.SetAttribute("進位方式", GetRadioButtonResult(radioButton1, radioButton2, radioButton3));
            element = helper.AddElement("成績計算規則/各項成績計算位數", "領域成績計算");
            element.SetAttribute("位數", "" + numericUpDown2.Value);
            element.SetAttribute("進位方式", GetRadioButtonResult(radioButton4, radioButton5, radioButton6));
            element = helper.AddElement("成績計算規則/各項成績計算位數", "學習領域成績計算");
            element.SetAttribute("位數", "" + numericUpDown3.Value);
            element.SetAttribute("進位方式", GetRadioButtonResult(radioButton7, radioButton8, radioButton9));
            element = helper.AddElement("成績計算規則/各項成績計算位數", "畢業成績計算");
            element.SetAttribute("位數", "" + numericUpDown4.Value);
            element.SetAttribute("進位方式", GetRadioButtonResult(radioButton10, radioButton11, radioButton12));
            #endregion

            #region 畢業條件
            helper.AddElement("畢業條件");
            helper.AddElement("畢業條件", "學業成績畢業條件");
            helper.AddElement("畢業條件", "日常生活表現畢業條件");

            //LearnDomainEach
            element = helper.AddElement("畢業條件/學業成績畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkScore1.Checked);
            element.SetAttribute("Type", "LearnDomainEach");
            element.SetAttribute("學習領域", "" + numDomain1.Value);
            element.SetAttribute("等第", cboDegree1.Text);

            //LearnDomainLast
            element = helper.AddElement("畢業條件/學業成績畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkScore2.Checked);
            element.SetAttribute("Type", "LearnDomainLast");
            element.SetAttribute("學習領域", "" + numDomain2.Value);
            element.SetAttribute("等第", cboDegree2.Text);

            //GraduateDomain
            element = helper.AddElement("畢業條件/學業成績畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkScore3.Checked);
            element.SetAttribute("Type", "GraduateDomain");
            element.SetAttribute("學習領域", "" + numDomain3.Value);
            element.SetAttribute("等第", cboDegree3.Text);


            //AbsenceAmountEach
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily1.Checked);
            element.SetAttribute("Type", "AbsenceAmountEach");
            element.SetAttribute("節數", "" + numPeriod1.Value);
            if (lblSetAbsence1.Text.StartsWith("("))
            {
                lblSetAbsence1.Text = lblSetAbsence1.Text.Substring(1, lblSetAbsence1.Text.Length - 1);
            }
            if (lblSetAbsence1.Text.EndsWith(")"))
            {
                lblSetAbsence1.Text = lblSetAbsence1.Text.Substring(0, lblSetAbsence1.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence1.Text);

            //AbsenceAmountLast
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily1b.Checked);
            element.SetAttribute("Type", "AbsenceAmountLast");
            element.SetAttribute("節數", "" + numPeriod1b.Value);
            if (lblSetAbsence1b.Text.StartsWith("("))
            {
                lblSetAbsence1b.Text = lblSetAbsence1b.Text.Substring(1, lblSetAbsence1b.Text.Length - 1);
            }
            if (lblSetAbsence1b.Text.EndsWith(")"))
            {
                lblSetAbsence1b.Text = lblSetAbsence1b.Text.Substring(0, lblSetAbsence1b.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence1b.Text);

            //AbsenceAmountAll added by Cloud 2014.2.13
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily1c.Checked);
            element.SetAttribute("Type", "AbsenceAmountAll");
            element.SetAttribute("節數", "" + numPeriod1c.Value);
            if (lblSetAbsence1c.Text.StartsWith("("))
            {
                lblSetAbsence1c.Text = lblSetAbsence1c.Text.Substring(1, lblSetAbsence1c.Text.Length - 1);
            }
            if (lblSetAbsence1c.Text.EndsWith(")"))
            {
                lblSetAbsence1c.Text = lblSetAbsence1c.Text.Substring(0, lblSetAbsence1c.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence1c.Text);

            //AbsenceAmountEachFraction
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily2.Checked);
            element.SetAttribute("Type", "AbsenceAmountEachFraction");
            element.SetAttribute("節數", txtPeriod2.Text);
            if (lblSetAbsence2.Text.StartsWith("("))
            {
                lblSetAbsence2.Text = lblSetAbsence2.Text.Substring(1, lblSetAbsence2.Text.Length - 1);
            }
            if (lblSetAbsence2.Text.EndsWith(")"))
            {
                lblSetAbsence2.Text = lblSetAbsence2.Text.Substring(0, lblSetAbsence2.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence2.Text);
            element.SetAttribute("每日節數", numOfPeriod.Value + "");

            //AbsenceAmountLastFraction
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily2b.Checked);
            element.SetAttribute("Type", "AbsenceAmountLastFraction");
            element.SetAttribute("節數", txtPeriod2b.Text);
            if (lblSetAbsence2b.Text.StartsWith("("))
            {
                lblSetAbsence2b.Text = lblSetAbsence2b.Text.Substring(1, lblSetAbsence2b.Text.Length - 1);
            }
            if (lblSetAbsence2b.Text.EndsWith(")"))
            {
                lblSetAbsence2b.Text = lblSetAbsence2b.Text.Substring(0, lblSetAbsence2b.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence2b.Text);
            element.SetAttribute("每日節數", numOfPeriod.Value + "");

            //AbsenceAmountGraduateFraction (所有學期缺課節數合計未超過上課節數,2013/12/5,新增)
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily2c.Checked);
            element.SetAttribute("Type", "AbsenceAmountAllFraction");
            element.SetAttribute("節數", txtPeriod2c.Text);
            if (lblSetAbsence2c.Text.StartsWith("("))
            {
                lblSetAbsence2c.Text = lblSetAbsence2c.Text.Substring(1, lblSetAbsence2c.Text.Length - 1);
            }
            if (lblSetAbsence2c.Text.EndsWith(")"))
            {
                lblSetAbsence2c.Text = lblSetAbsence2c.Text.Substring(0, lblSetAbsence2c.Text.Length - 1);
            }
            element.SetAttribute("假別", lblSetAbsence2c.Text);

            if (lblSetAbsence2d.Text.StartsWith("("))
            {
                lblSetAbsence2d.Text = lblSetAbsence2d.Text.Substring(1, lblSetAbsence2d.Text.Length - 1);
            }
            if (lblSetAbsence2d.Text.EndsWith(")"))
            {
                lblSetAbsence2d.Text = lblSetAbsence2d.Text.Substring(0, lblSetAbsence2d.Text.Length - 1);
            }
            if (lblSetAbsence2e.Text.StartsWith("("))
            {
                lblSetAbsence2e.Text = lblSetAbsence2e.Text.Substring(1, lblSetAbsence2e.Text.Length - 1);
            }
            if (lblSetAbsence2e.Text.EndsWith(")"))
            {
                lblSetAbsence2e.Text = lblSetAbsence2e.Text.Substring(0, lblSetAbsence2e.Text.Length - 1);
            }
            element.SetAttribute("核可假別", lblSetAbsence2d.Text);
            element.SetAttribute("核可節次別", lblSetAbsence2e.Text);
            element.SetAttribute("每日節數", numOfPeriod.Value + "");

            //DemeritAmountEach
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily3.Checked);
            element.SetAttribute("Type", "DemeritAmountEach");
            element.SetAttribute("大過", "" + numTimes3.Value);
            element.SetAttribute("功過相抵", "" + rbCounterbalance1.Checked);
            element.SetAttribute("獎勵換算", GetMeritConversion1());
            element.SetAttribute("懲戒換算", GetDemeritConversion1());

            //DemeritAmountLast
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily3b.Checked);
            element.SetAttribute("Type", "DemeritAmountLast");
            element.SetAttribute("大過", "" + numTimes3b.Value);
            element.SetAttribute("功過相抵", "" + rbCounterbalance1b.Checked);
            element.SetAttribute("獎勵換算", GetMeritConversion1b());
            element.SetAttribute("懲戒換算", GetDemeritConversion1b());

            //DemeritAmountAll (所有學期懲戒累計未超過,2013/12/5.新增)
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily3c.Checked);
            element.SetAttribute("Type", "DemeritAmountAll");
            element.SetAttribute("大過", "" + numTimes3c.Value);
            element.SetAttribute("功過相抵", "" + rbCounterbalance1c.Checked);
            element.SetAttribute("獎勵換算", GetMeritConversion1c());
            element.SetAttribute("懲戒換算", GetDemeritConversion1c());

            //DailyBehavior
            //<條件 Checked="False" Type="DailyBehavior" 項目="4" 表現程度="2"/>
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily4.Checked);
            element.SetAttribute("Type", "DailyBehavior");
            element.SetAttribute("項目", "" + numTimes4.Value);
            element.SetAttribute("表現程度", "" + ((KeyValuePair <string, string>)cboPerformanceDegree1.SelectedItem).Key);

            //DailyBehaviorLast
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily4b.Checked);
            element.SetAttribute("Type", "DailyBehaviorLast");
            element.SetAttribute("項目", "" + numTimes4b.Value);
            element.SetAttribute("表現程度", "" + ((KeyValuePair <string, string>)cboPerformanceDegree1b.SelectedItem).Key);

            //DailyBehaviorAll
            element = helper.AddElement("畢業條件/日常生活表現畢業條件", "條件");
            element.SetAttribute("Checked", "" + chkDaily4c.Checked);
            element.SetAttribute("Type", "DailyBehaviorAll");
            element.SetAttribute("項目", "" + numTimes4c.Value);
            element.SetAttribute("表現程度", "" + ((KeyValuePair <string, string>)cboPerformanceDegree1c.SelectedItem).Key);

            #endregion

            return(helper.BaseElement);
        }
        /// <summary>
        /// 儲存所有教授設定。
        /// </summary>
        /// <param name="records"></param>
        public static void SaveAllEditors(this IEnumerable <TCInstructRecordEditor> records)
        {
            MultiThreadWorker <TCInstructRecordEditor> worker = new MultiThreadWorker <TCInstructRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <TCInstructRecordEditor> e)
            {
                DSXmlHelper   updateHelper = new DSXmlHelper("Request");
                DSXmlHelper   insertHelper = new DSXmlHelper("Request");
                DSXmlHelper   deleteHelper = new DSXmlHelper("Request");
                List <string> synclist     = new List <string>();
                bool          hasUpdate    = false;
                bool          hasInsert    = false;
                bool          hasRemove    = false;
                foreach (var editor in e.List)
                {
                    if (editor.EditorStatus == EditorStatus.Insert)
                    {
                        #region 新增修課
                        insertHelper.AddElement("Instruct");
                        insertHelper.AddElement("Instruct", "RefTeacherID", editor.RefTeacherID);
                        insertHelper.AddElement("Instruct", "RefCourseID", editor.RefCourseID);
                        insertHelper.AddElement("Instruct", "Sequence", editor.Sequence);
                        hasInsert = true;
                        #endregion
                    }
                    if (editor.EditorStatus == EditorStatus.Update)
                    {
                        #region 修改
                        updateHelper.AddElement("Instruct");
                        updateHelper.AddElement("Instruct", "RefTeacherID", editor.RefTeacherID);
                        updateHelper.AddElement("Instruct", "RefCourseID", editor.RefCourseID);
                        updateHelper.AddElement("Instruct", "Sequence", editor.Sequence);
                        updateHelper.AddElement("Instruct", "Condition");
                        updateHelper.AddElement("Instruct/Condition", "ID", editor.TCInstructRecord.ID);
                        synclist.Add(editor.TCInstructRecord.ID);
                        hasUpdate = true;
                        #endregion
                    }
                    if (editor.EditorStatus == EditorStatus.Delete)
                    {
                        #region 刪除
                        deleteHelper.AddElement("Instruct");
                        deleteHelper.AddElement("Instruct", "ID", editor.TCInstructRecord.ID);
                        synclist.Add(editor.TCInstructRecord.ID);
                        hasRemove = true;
                        #endregion
                    }
                }

                if (hasInsert)
                {
                    DSResponse resp = FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.InsertTCInstruct", new DSRequest(insertHelper.BaseElement));
                    foreach (var item in resp.GetContent().GetElements("NewID"))
                    {
                        synclist.Add(item.InnerText);
                    }
                }

                if (hasUpdate)
                {
                    FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.UpdateTCInstruct", new DSRequest(updateHelper.BaseElement));
                }

                if (hasRemove)
                {
                    FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.DeleteTCInstruct", new DSRequest(deleteHelper.BaseElement));
                }

                if (synclist.Count > 0)
                {
                    TCInstruct.Instance.SyncDataBackground(synclist);
                }
            };
            List <PackageWorkEventArgs <TCInstructRecordEditor> > packages = worker.Run(records);
            foreach (PackageWorkEventArgs <TCInstructRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Ejemplo n.º 55
0
        public static DSResponse SearchStudent(string key, int pageSize, int startPage, bool _SearchInStudentID, bool _SearchInSSN, bool _SearchInName, params string[] _StatusList)
        {
            key = "%" + key.Replace("*", "%") + "%";

            DSXmlHelper helper = CreateBriefFieldHelper();

            helper.AddElement("Condition");
            foreach (string status in _StatusList)
            {
                helper.AddElement("Condition", "Status", status);
            }
            helper.AddElement("Condition", "Search");
            helper.AddElement("Condition/Search", "Or");
            if (_SearchInStudentID)
            {
                helper.AddElement("Condition/Search/Or", "StudentNumber", key);
            }

            if (_SearchInSSN)
            {
                helper.AddElement("Condition/Search/Or", "IDNumber", key);
            }

            if (_SearchInName)
            {
                helper.AddElement("Condition/Search/Or", "Name", key);
            }

            helper.AddElement("Order");
            helper.AddElement("Order", "SeatNo");
            helper.AddElement("Pagination");
            helper.AddElement("Pagination", "PageSize", pageSize.ToString());
            helper.AddElement("Pagination", "StartPage", startPage.ToString());
            DSRequest dsreq = new DSRequest(helper);

            return(DSAServices.CallService("SmartSchool.Student.GetAbstractListWithTag", dsreq));
        }
Ejemplo n.º 56
0
        private void buttonX1_Click(object sender_, EventArgs e_)
        {
            var uqid = textBoxX1.Text.Trim();

            if (uqid == "")
            {
                return;
            }

            this.dgvResult.Rows.Insert(0, uqid, "處理中...");
            var targetRow = dgvResult.Rows[0];

            var result           = "";
            BackgroundWorker bkw = new BackgroundWorker();

            bkw.RunWorkerCompleted += delegate
            {
                targetRow.Cells[1].Value = result;
                if (result.EndsWith("假單已核可。"))
                {
                    _SuccessCount++;
                }
                else
                {
                    _FailedCount++;
                    targetRow.Cells[0].ErrorText = "!";
                }
                labelX2.Text = "執行紀錄:"
                               + (_ApproveCount > _SuccessCount + _FailedCount ? "處理中:" + (_ApproveCount - _SuccessCount - _FailedCount) : "")
                               + (_SuccessCount > 0 ? " 已核可:" + _SuccessCount : "")
                               + (_FailedCount > 0 ? " 發生錯誤:" + _FailedCount : "");
            };
            bkw.DoWork += delegate
            {
                try
                {
                    AccessHelper accessHelper = new AccessHelper();
                    var          list         = accessHelper.Select <LeaveRequestRecord>("uqid='" + uqid + "'");
                    if (list.Count == 0)
                    {
                        result = "查無此假單。";
                        return;
                    }
                    foreach (var lrRec in list)
                    {
                        var lrHint = (lrRec.RefTeacherID == null ? ("學生:" + K12.Data.Student.SelectByID("" + lrRec.RefStudentID).Name + ",") : "公假單,");

                        Dictionary <string, XmlElement> dicCurrentStudentAttendance = new Dictionary <string, XmlElement>();
                        #region 取得缺曠紀錄
                        #region 整理學生ID
                        List <string> idList = new List <string>();
                        foreach (var lrcStudent in lrRec.Content.Students)
                        {
                            idList.Add(lrcStudent.StudentID);
                        }
                        #endregion
                        DSXmlHelper helper = new DSXmlHelper("Request");
                        helper.AddElement("Field");
                        helper.AddElement("Field", "All");
                        helper.AddElement("Condition");
                        foreach (string id in idList)
                        {
                            helper.AddElement("Condition", "RefStudentID", id);
                        }
                        //if ( schoolYear > 0 )
                        //    helper.AddElement("Condition", "SchoolYear", schoolYear.ToString());
                        //if ( semester > 0 )
                        //    helper.AddElement("Condition", "Semester", semester.ToString());
                        helper.AddElement("Order");
                        helper.AddElement("Order", "OccurDate", "desc");

                        foreach (XmlElement attendanceElement in FISCA.Authentication.DSAServices.CallService("SmartSchool.Student.Attendance.GetAttendance", new DSRequest(helper)).GetContent().GetElements("Attendance"))
                        {
                            XmlElement var = attendanceElement;
                            DateTime   occurdate;
                            DateTime.TryParse(var.SelectSingleNode("OccurDate").InnerText, out occurdate);
                            string studentID = var.SelectSingleNode("RefStudentID").InnerText;

                            var key = studentID + "^^" + occurdate.ToString("yyyy/MM/dd");
                            dicCurrentStudentAttendance.Add(key, attendanceElement);
                            //int schoolyear = 0;
                            //int.TryParse(var.SelectSingleNode("SchoolYear").InnerText, out schoolyear);
                            //int semester2 = 0;
                            //int.TryParse(var.SelectSingleNode("Semester").InnerText, out semester2);

                            //foreach (XmlElement element in var.SelectNodes("Detail/Attendance/Period"))
                            //{
                            //    string period = element.InnerText;
                            //    string periodtype = element.GetAttribute("AttendanceType");
                            //    string attendance = element.GetAttribute("AbsenceType");

                            //    //if ( !periodList.Contains(period) || !absenceList.Contains(attendance) )
                            //    //    continue;

                            //    //Attendance_islo attendanceInfo = new Attendance_islo(schoolyear, semester2, occurdate, period, periodtype, attendance, var);

                            //    //if (!studentAttendanceInfo.ContainsKey(studentID))
                            //    //    studentAttendanceInfo.Add(studentID, new List<SmartSchool.Customization.Data.StudentExtension.AttendanceInfo>());
                            //    //studentAttendanceInfo[studentID].Add(attendanceInfo);
                            //}
                        }
                        #endregion
                        Dictionary <StringBuilder, string> studentLogMsg = new Dictionary <StringBuilder, string>();
                        var         hasInsert    = false;
                        DSXmlHelper InsertHelper = new DSXmlHelper("InsertRequest");
                        var         hasUpdate    = false;
                        DSXmlHelper updateHelper = new DSXmlHelper("UpdateRequest");
                        #region 彙整寫入資料
                        XmlDocument doc = new XmlDocument();
                        foreach (var lrcStudent in lrRec.Content.Students)
                        {
                            StringBuilder appLogMsg = new StringBuilder();
                            appLogMsg.Append("假單編號:");
                            appLogMsg.AppendLine(lrRec.key);
                            appLogMsg.Append("事由:");
                            appLogMsg.AppendLine(lrRec.Content.Reason);
                            foreach (var lrcDate in lrRec.Content.Dates)
                            {
                                appLogMsg.Append("日期:");
                                appLogMsg.AppendLine(DateTime.Parse(lrcDate.Date).ToString("yyyy/MM/dd"));

                                var key = lrcStudent.StudentID + "^^" + DateTime.Parse(lrcDate.Date).ToString("yyyy/MM/dd");

                                if (dicCurrentStudentAttendance.ContainsKey(key))
                                {
                                    var currentAttendanceElement = dicCurrentStudentAttendance[key];
                                    #region 更新
                                    foreach (var lrcPeriod in lrcDate.Periods)
                                    {
                                        if (lrcPeriod.Absence != "")
                                        {
                                            bool hasOverride   = false;
                                            var  attendanceEle = currentAttendanceElement.SelectSingleNode("Detail/Attendance") as XmlElement;
                                            if (attendanceEle != null)
                                            {
                                                foreach (XmlElement attendItem in currentAttendanceElement.SelectNodes("Detail/Attendance/Period"))
                                                {
                                                    string period     = attendItem.InnerText;
                                                    string attendance = attendItem.GetAttribute("AbsenceType");
                                                    if (period == lrcPeriod.Period)
                                                    {
                                                        appLogMsg.AppendLine(string.Format("\t節次 {0}:改為{1}(原為{2})", lrcPeriod.Period, lrcPeriod.Absence, attendItem.GetAttribute("AbsenceType")));

                                                        hasOverride = true;
                                                        attendItem.SetAttribute("AbsenceType", lrcPeriod.Absence);
                                                    }
                                                }
                                                if (!hasOverride)
                                                {
                                                    appLogMsg.AppendLine(string.Format("\t節次 {0}:設為{1}", lrcPeriod.Period, lrcPeriod.Absence));
                                                    XmlElement attendItem = currentAttendanceElement.OwnerDocument.CreateElement("Period");
                                                    attendItem.InnerText = lrcPeriod.Period;
                                                    attendItem.SetAttribute("AbsenceType", lrcPeriod.Absence);
                                                    attendanceEle.AppendChild(attendItem);
                                                }
                                                updateHelper.AddElement("Attendance");
                                                updateHelper.AddElement("Attendance", "Field");
                                                updateHelper.AddElement("Attendance/Field", "Detail", attendanceEle.OuterXml, true);
                                                updateHelper.AddElement("Attendance", "Condition");
                                                updateHelper.AddElement("Attendance/Condition", "ID", currentAttendanceElement.GetAttribute("ID"));
                                                hasUpdate = true;
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 新增
                                    XmlElement attendanceEle = doc.CreateElement("Attendance");
                                    foreach (var lrcPeriod in lrcDate.Periods)
                                    {
                                        if (lrcPeriod.Absence != "")
                                        {
                                            appLogMsg.AppendLine(string.Format("\t節次 {0}:設為{1}", lrcPeriod.Period, lrcPeriod.Absence));
                                            XmlElement attendItem = doc.CreateElement("Period");
                                            attendItem.InnerText = lrcPeriod.Period;
                                            attendItem.SetAttribute("AbsenceType", lrcPeriod.Absence);
                                            attendanceEle.AppendChild(attendItem);
                                        }
                                    }

                                    #region 自動判斷學年度
                                    string schoolYear = K12.Data.School.DefaultSchoolYear;
                                    string semester   = K12.Data.School.DefaultSemester;

                                    var occurDate = DateTime.Parse(lrcDate.Date);
                                    int syBase    = occurDate.Year - 1911;
                                    if (occurDate.Month < 8 && occurDate.Month >= 2)
                                    {
                                        schoolYear = (syBase - 1).ToString();
                                        semester   = "2";
                                    }
                                    else
                                    {
                                        if (occurDate.Month < 2)
                                        {
                                            schoolYear = (syBase - 1).ToString();
                                        }
                                        else
                                        {
                                            schoolYear = (syBase).ToString();
                                        }
                                        semester = "1";
                                    }
                                    #endregion
                                    InsertHelper.AddElement("Attendance");
                                    InsertHelper.AddElement("Attendance", "Field");
                                    InsertHelper.AddElement("Attendance/Field", "RefStudentID", lrcStudent.StudentID);
                                    InsertHelper.AddElement("Attendance/Field", "SchoolYear", "" + schoolYear);
                                    InsertHelper.AddElement("Attendance/Field", "Semester", "" + semester);
                                    InsertHelper.AddElement("Attendance/Field", "OccurDate", DateTime.Parse(lrcDate.Date).ToString("yyyy/MM/dd"));
                                    InsertHelper.AddElement("Attendance/Field", "Detail", attendanceEle.OuterXml, true);
                                    hasInsert = true;
                                    #endregion
                                }
                            }
                            studentLogMsg.Add(appLogMsg, lrcStudent.StudentID);
                        }
                        #endregion
                        #region 寫入資料
                        if (hasInsert)
                        {
                            //Log_sb.AppendLine(GetString(InsertHelper, "新增"));
                            FISCA.Authentication.DSAServices.CallService("SmartSchool.Student.Attendance.Insert", new DSRequest(InsertHelper));
                        }
                        if (hasUpdate)
                        {
                            //Log_sb.AppendLine(GetString(updateHelper, "更新"));
                            FISCA.Authentication.DSAServices.CallService("SmartSchool.Student.Attendance.Update", new DSRequest(updateHelper));
                        }
                        if (hasUpdate || hasInsert)
                        {
                            foreach (var log in studentLogMsg.Keys)
                            {
                                FISCA.LogAgent.ApplicationLog.Log("線上請假系統", "假單核可", "student", studentLogMsg[log], log.ToString());
                            }
                        }
                        result         = lrHint + "假單已核可。";
                        lrRec.Approved = true;
                        lrRec.Save();
                        #endregion
                    }
                }
                catch (Exception exc)
                {
                    result = "執行發生錯誤:" + exc.Message;
                }
            };
            _ApproveCount++;
            labelX2.Text = "執行紀錄:"
                           + (_ApproveCount > _SuccessCount + _FailedCount ? "處理中:" + (_ApproveCount - _SuccessCount - _FailedCount) : "")
                           + (_SuccessCount > 0 ? " 已核可:" + _SuccessCount : "")
                           + (_FailedCount > 0 ? " 發生錯誤:" + _FailedCount : "");
            bkw.RunWorkerAsync();
            this.textBoxX1.Text = "";
            this.textBoxX1.SelectAll();
        }
Ejemplo n.º 57
0
        public static List <CourseRecord> GetAllCourses()
        {
            DSRequest   dsreq  = new DSRequest();
            DSXmlHelper helper = new DSXmlHelper("GetDetailListRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "CourseName");
            helper.AddElement("Field", "SchoolYear");
            helper.AddElement("Field", "Semester");
            helper.AddElement("Field", "Period");
            helper.AddElement("Field", "Credit");
            //helper.AddElement("Field", "IsRequired");
            //helper.AddElement("Field", "RequiredBy");
            helper.AddElement("Field", "RefExamTemplateID");
            helper.AddElement("Field", "RefClassID");
            helper.AddElement("Field", "Subject");
            helper.AddElement("Field", "Domain");
            helper.AddElement("Field", "ScoreCalcFlag");
            helper.AddElement("Condition");
            helper.AddElement("Order");
            helper.AddElement("Order", "ID");
            helper.AddElement("Order", "Sequence");
            dsreq.SetContent(helper);
            DSResponse          dsrsp  = DSAServices.CallService("SmartSchool.Course.GetDetailList", dsreq);
            List <CourseRecord> result = new List <CourseRecord>();

            foreach (XmlElement var in dsrsp.GetContent().GetElements("Course"))
            {
                result.Add(new CourseRecord(var));
            }
            return(result);
        }
Ejemplo n.º 58
0
 public SchoolYearScoreEditor(string refStudentID)
 {
     InitializeComponent();
     _StudentID = refStudentID;
     beforeXml.AddElement("SubjectGradeYear");
     afterXml.AddElement("SubjectGradeYear");
     beforeXml.AddElement("SubjectCollection");
     beforeXml.AddElement("EntryCollection");
     afterXml.AddElement("SubjectCollection");
     afterXml.AddElement("EntryCollection");
     comboBoxEx3.Items.AddRange(new object[] { "1", "2", "3", "4" });
     labelX10.Text = Student.Instance.Items[_StudentID].IDNumber + "  " + Student.Instance.Items[_StudentID].Name;
     for (int s = 3; s > 0; s--)
     {
         comboBoxEx1.Items.Add(CurrentUser.Instance.SchoolYear - s);
     }
     ValidateAll();
 }
Ejemplo n.º 59
0
        public static List <CourseRecord> GetCourses(IEnumerable <string> primaryKeys)
        {
            bool        hasKey = false;
            DSRequest   dsreq  = new DSRequest();
            DSXmlHelper helper = new DSXmlHelper("GetDetailListRequest");

            helper.AddElement("Field");
            helper.AddElement("Field", "ID");
            helper.AddElement("Field", "CourseName");
            helper.AddElement("Field", "SchoolYear");
            helper.AddElement("Field", "Semester");
            helper.AddElement("Field", "Period");
            helper.AddElement("Field", "Credit");
            //helper.AddElement("Field", "IsRequired");
            //helper.AddElement("Field", "RequiredBy");
            helper.AddElement("Field", "RefExamTemplateID");
            helper.AddElement("Field", "RefClassID");
            helper.AddElement("Field", "Subject");
            helper.AddElement("Field", "Domain");
            helper.AddElement("Field", "ScoreCalcFlag");
            helper.AddElement("Condition");
            foreach (var key in primaryKeys)
            {
                helper.AddElement("Condition", "ID", key);
                hasKey = true;
            }
            helper.AddElement("Order");
            List <CourseRecord> result = new List <CourseRecord>();

            if (hasKey)
            {
                dsreq.SetContent(helper);
                DSResponse dsrsp = DSAServices.CallService("SmartSchool.Course.GetDetailList", dsreq);
                foreach (XmlElement var in dsrsp.GetContent().GetElements("Course"))
                {
                    result.Add(new CourseRecord(var));
                }
            }
            return(result);
        }
Ejemplo n.º 60
0
        public static void SaveTagRecordEditor(IEnumerable <TagRecordEditor> editors)
        {
            MultiThreadWorker <TagRecordEditor> worker = new MultiThreadWorker <TagRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <TagRecordEditor> e)
            {
                DSXmlHelper   updateHelper = new DSXmlHelper("Request");
                DSXmlHelper   insertHelper = new DSXmlHelper("Request");
                DSXmlHelper   deleteHelper = new DSXmlHelper("Request");
                List <string> synclist = new List <string>();
                bool          hasUpdate = false, hasInsert = false, hasDelete = false;

                foreach (var editor in e.List)
                {
                    #region 更新
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                    {
                        updateHelper.AddElement("Tag");
                        updateHelper.AddElement("Tag", "Field");
                        updateHelper.AddElement("Tag/Field", "Prefix", editor.Prefix);
                        updateHelper.AddElement("Tag/Field", "Name", editor.Name);
                        updateHelper.AddElement("Tag/Field", "Color", editor.ColorCode.ToString());
                        updateHelper.AddElement("Tag", "Condition");
                        updateHelper.AddElement("Tag/Condition", "ID", editor.ID);

                        hasUpdate = true;
                        synclist.Add(editor.ID);
                    }
                    #endregion

                    #region 新增
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                    {
                        insertHelper.AddElement("Tag");
                        insertHelper.AddElement("Tag", "Field");
                        insertHelper.AddElement("Tag", "Prefix", editor.Prefix);
                        insertHelper.AddElement("Tag", "Name", editor.Name.ToString());
                        insertHelper.AddElement("Tag", "Color", editor.ColorCode.ToString());
                        insertHelper.AddElement("Tag", "Category", editor.Category);

                        hasInsert = true;
                    }
                    #endregion

                    #region 刪除
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Delete)
                    {
                        deleteHelper.AddElement("Tag");
                        deleteHelper.AddElement("Tag", "ID", editor.ID);

                        hasDelete = true;
                        synclist.Add(editor.ID);
                    }
                    #endregion
                }

                if (hasUpdate)
                {
                    DSAServices.CallService("SmartSchool.Tag.Update", new DSRequest(updateHelper.BaseElement));
                }

                if (hasInsert)
                {
                    DSXmlHelper response = DSAServices.CallService("SmartSchool.Tag.Insert", new DSRequest(insertHelper.BaseElement)).GetContent();
                    foreach (XmlElement each in response.GetElements("NewID"))
                    {
                        synclist.Add(each.InnerText);
                    }
                }

                if (hasDelete)
                {
                    DSAServices.CallService("SmartSchool.Tag.Delete", new DSRequest(deleteHelper.BaseElement));
                }

                Tag.Instance.SyncDataBackground(synclist);
            };
            List <PackageWorkEventArgs <TagRecordEditor> > packages = worker.Run(editors);
            foreach (PackageWorkEventArgs <TagRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }