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;
 }
        private static DSXmlHelper CallService(string serviceName, DSXmlHelper request)
        {
            string Server;

            //if (Diagnostic.DebugMode && Diagnostic.Options.UseInsideGlobalConfigurationServer)
            //    Server = Diagnostic.Options.InsideGlobalConfigurationServer;
            //else
                Server = "quality";

            if (Connection == null)
            {
                try
                {
                    Connection = new DSConnection(Server, "anonymous", "");
                    Connection.Connect();
                }
                catch (Exception ex)
                {
                    ExceptionReport report = new ExceptionReport();
                    report.AddType(typeof(HttpWebResponse), true);
                    report.AddType(typeof(HttpWebRequest), true);

                    Console.WriteLine("嘗試連線到組態儲存主機失敗({0})。", Server);
                    Console.WriteLine(report.Transform(ex));

                    throw;
                }
            }

            return Connection.SendRequest(serviceName, request);
        }
Example #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));
 }
        private void ReLoad()
        {
            dataGridView1.Rows.Clear();
            foreach (string each in classIDList)
            {
                //傳入 class類型 / classID系統編號
                //取得該班級的所有電子報表
                DSXmlHelper helper = QueryElectronicPaper.GetPaperItemByViewer("Class", each).GetContent();

                foreach (XmlElement paper in helper.GetElements("PaperItem"))
                {
                    DSXmlHelper paperHelper = new DSXmlHelper(paper);

                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridView1);

                    //儲存電子報表編號
                    row.Cells[0].Value = paperHelper.GetText("@ID");

                    //班級名稱
                    ClassRecord cr = K12.Data.Class.SelectByID(each);
                    row.Cells[1].Value = cr.Name;

                    //電子報表名稱
                    row.Cells[2].Value = paperHelper.GetText("PaperName");
                    //製表日期
                    row.Cells[3].Value = paperHelper.GetText("Timestamp");

                    dataGridView1.Rows.Add(row);
                }
            }
        }
 //���ե�
 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));
 }
Example #6
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 "";
        }
Example #7
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));
 }
        private static Dictionary<string, ConfigurationRecord> SendRequest(DSXmlHelper request)
        {
            string srvname = "SmartSchool.Configuration.GetDetailList";
            Dictionary<string, ConfigurationRecord> records = new Dictionary<string, ConfigurationRecord>();

            DSXmlHelper response = DSAServices.CallService(srvname, new DSRequest(request)).GetContent();

            foreach (XmlElement each in response.GetElements("Configuration"))
            {
                XmlHelper helper = new XmlHelper(each);
                string name = helper.GetString("Name");

                XmlElement configdata = null;
                foreach (XmlNode content in helper.GetElement("Content").ChildNodes)
                {
                    if (content.NodeType == XmlNodeType.Element) //內容可能是以「Configurations」為 Root,也可能是舊的格式。
                        configdata = content as XmlElement;
                }

                if (configdata == null)
                    configdata = XmlHelper.LoadXml("<" + ConfigurationRecord.RootName + "/>");

                records.Add(name, new ConfigurationRecord(name, configdata as XmlElement));
            }

            return records;
        }
        public Dictionary<string, ConfigurationRecord> GetAllConfiguration()
        {
            DSXmlHelper request = new DSXmlHelper("Request");
            request.AddElement("Content");

            return SendRequest(request);
        }
Example #10
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));
 }
 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));
 }
Example #12
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));
 }
Example #13
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 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));
 }
        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;
        }
Example #16
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));
 }
        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;
        }
 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));
 }
Example #19
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 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;
        }
Example #21
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);
 }
Example #22
0
        public static List<string> AddCourseTeacher(DSXmlHelper request)
        {
            DSResponse rsp=DSAServices.CallService("SmartSchool.Course.AddCourseTeacher", new DSRequest(request));

            List<string> newidlist=new List<string>();
            foreach (var each in rsp.GetContent().GetElements("NewID"))
                newidlist.Add(each.InnerText);

            return newidlist;
        }
 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;
        }
 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);
 }
Example #26
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);
 }
 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));
 }
Example #28
0
        public static List<StudPhotoEntity> GetStudentPhotoBitmap(List<StudPhotoEntity> StudPhotoEntityList)
        {
            List<string> StudentIDList = new List<string>();
            foreach (StudPhotoEntity spe in StudPhotoEntityList)
                if (!string.IsNullOrEmpty(spe.StudentID))
                    StudentIDList.Add(spe.StudentID);

            DSXmlHelper xmlHelper = new DSXmlHelper("Request");

            DSResponse DSRsp = GetDetailList(new string[] { "ID", "FreshmanPhoto", "GraduatePhoto" }, StudentIDList.ToArray());

            Dictionary<string, string> FreshmanPhotoStr = new Dictionary<string, string>();
            Dictionary<string, string> GraduatePhotoStr = new Dictionary<string, string>();

            if (DSRsp != null)
                foreach (XmlElement elm in DSRsp.GetContent().BaseElement.SelectNodes("Student"))
                {
                    if (!FreshmanPhotoStr.ContainsKey(elm.GetAttribute("ID")))
                    {
                        if (!string.IsNullOrEmpty(elm.SelectSingleNode("FreshmanPhoto").InnerText))
                            FreshmanPhotoStr.Add(elm.GetAttribute("ID"), elm.SelectSingleNode("FreshmanPhoto").InnerText);
                    }
                    if (!GraduatePhotoStr.ContainsKey(elm.GetAttribute("ID")))
                    {
                        if (!string.IsNullOrEmpty(elm.SelectSingleNode("GraduatePhoto").InnerText))
                            GraduatePhotoStr.Add(elm.GetAttribute("ID"), elm.SelectSingleNode("GraduatePhoto").InnerText);
                    }

                }

            foreach (StudPhotoEntity spe in StudPhotoEntityList)
            {
                if (spe._PhotoKind == StudPhotoEntity.PhotoKind.入學)
                {
                    if (FreshmanPhotoStr.ContainsKey(spe.StudentID))
                    {
                        spe.FreshmanPhotoBitmap = Photo.ConvertFromBase64Encoding(FreshmanPhotoStr[spe.StudentID], true);
                    }
                }

                if (spe._PhotoKind == StudPhotoEntity.PhotoKind.畢業)
                {
                    if (GraduatePhotoStr.ContainsKey(spe.StudentID))
                    {
                        spe.GraduatePhotoBitmap = Photo.ConvertFromBase64Encoding(GraduatePhotoStr[spe.StudentID], true);
                    }

                }
            }

            return StudPhotoEntityList;
        }
 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));
 }
Example #30
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);
 }
Example #31
0
        public BatchAddressLatitudeManager(List <string> StudIDList, AddressTye at)
        {
            _AddressType       = at;
            _StudAddressRecDic = new Dictionary <string, JHAddressRecord>();

            foreach (JHAddressRecord addRec in JHAddress.SelectByStudentIDs(StudIDList))
            {
                if (!_StudAddressRecDic.ContainsKey(addRec.RefStudentID))
                {
                    _StudAddressRecDic.Add(addRec.RefStudentID, addRec);
                }
            }

            foreach (KeyValuePair <string, JHAddressRecord> studAddRec in _StudAddressRecDic)
            {
                string Address = "", latitude = "", longitude = "";

                if (_AddressType == AddressTye.Permanent)
                {
                    Address = studAddRec.Value.Permanent.County + studAddRec.Value.Permanent.Town + studAddRec.Value.Permanent.District + studAddRec.Value.Permanent.Area + studAddRec.Value.Permanent.Detail;
                }

                if (_AddressType == AddressTye.Mailing)
                {
                    Address = studAddRec.Value.Mailing.County + studAddRec.Value.Mailing.Town + studAddRec.Value.Mailing.District + studAddRec.Value.Mailing.Area + studAddRec.Value.Mailing.Detail;
                }

                if (_AddressType == AddressTye.Address1)
                {
                    Address = studAddRec.Value.Address1.County + studAddRec.Value.Address1.Town + studAddRec.Value.Address1.District + studAddRec.Value.Address1.Area + studAddRec.Value.Address1.Detail;
                }

                try
                {
                    DSXmlHelper h = new DSXmlHelper("Request");
                    h.AddText(".", Address);

                    DSResponse rsp = FISCA.Authentication.DSAServices.CallService("SmartSchool.Common.QueryCoordinates", new DSRequest(h));
                    h = rsp.GetContent();
                    if (h.GetElement("Error") == null)
                    {
                        latitude  = h.GetText("Latitude");
                        longitude = h.GetText("Longitude");
                    }
                }
                catch (Exception ex)
                {
                }


                // 回寫經緯度

                if (_AddressType == AddressTye.Permanent)
                {
                    studAddRec.Value.Permanent.Latitude  = latitude;
                    studAddRec.Value.Permanent.Longitude = longitude;
                }

                if (_AddressType == AddressTye.Mailing)
                {
                    studAddRec.Value.Mailing.Latitude  = latitude;
                    studAddRec.Value.Mailing.Longitude = longitude;
                }

                if (_AddressType == AddressTye.Address1)
                {
                    studAddRec.Value.Address1.Latitude  = latitude;
                    studAddRec.Value.Address1.Longitude = longitude;
                }
            }

            // 更新 DAL
            List <JHAddressRecord> addRecList = new List <JHAddressRecord>();

            foreach (JHAddressRecord addrec in _StudAddressRecDic.Values)
            {
                addRecList.Add(addrec);
            }

            JHAddress.Update(addRecList);
        }
Example #32
0
        public System.Xml.XmlElement CreateNameList(string schoolYear, string semester, List <XmlElement> list)
        {
            XmlDocument doc = new XmlDocument();
            Dictionary <string, string> deptCode = new Dictionary <string, string>();

            #region 建立科別代碼查詢表
            foreach (XmlElement var in SmartSchool.Feature.Basic.Config.GetDepartment().GetContent().GetElements("Department"))
            {
                deptCode.Add(var.SelectSingleNode("Name").InnerText, var.SelectSingleNode("Code").InnerText);
            }
            #endregion
            //依年級科別排序資料
            //list.Sort(CompareUpdateRecord);

            //排序學號
            list.Sort(StudentNumberComparison);

            // 取得學校對照解析用
            Dictionary <string, string> schooDict = Util.GetSchoolListDict();

            #region 產生Xml
            Dictionary <string, Dictionary <string, XmlElement> > gradeyear_dept_map = new Dictionary <string, Dictionary <string, XmlElement> >();
            doc.LoadXml("<異動名冊 類別=\"新生名冊\" 學年度=\"" + schoolYear + "\" 學期=\"" + semester + "\" 學校代號=\"" + CurrentUser.Instance.SchoolCode + "\" 學校名稱=\"" + CurrentUser.Instance.SchoolChineseName + "\"/>");
            foreach (XmlElement var in list)
            {
                DSXmlHelper helper    = new DSXmlHelper(var);
                string      gradeyear = "_";// 預設沒有年級
                gradeyear = helper.GetText("GradeYear");
                string     dept = helper.GetText("Department");
                XmlElement deptgradeNode;
                #region 清單
                if (!gradeyear_dept_map.ContainsKey(gradeyear))
                {
                    gradeyear_dept_map.Add(gradeyear, new Dictionary <string, XmlElement>());
                }
                if (!(gradeyear_dept_map[gradeyear].ContainsKey(dept)))
                {
                    deptgradeNode = doc.CreateElement("清單");
                    deptgradeNode.SetAttribute("科別", dept);
                    deptgradeNode.SetAttribute("年級", gradeyear);
                    deptgradeNode.SetAttribute("科別代號", (deptCode.ContainsKey(dept) ? deptCode[dept] : ""));
                    gradeyear_dept_map[gradeyear].Add(dept, deptgradeNode);
                    doc.DocumentElement.AppendChild(deptgradeNode);
                }
                else
                {
                    deptgradeNode = gradeyear_dept_map[gradeyear][dept];
                }
                #endregion
                #region 異動紀錄
                XmlElement dataElement = doc.CreateElement("異動紀錄");
                dataElement.SetAttribute("編號", helper.GetText("@ID"));
                dataElement.SetAttribute("異動代號", helper.GetText("UpdateCode"));
                dataElement.SetAttribute("異動日期", CDATE(helper.GetText("UpdateDate")));
                dataElement.SetAttribute("學號", helper.GetText("StudentNumber"));
                dataElement.SetAttribute("姓名", helper.GetText("Name"));
                dataElement.SetAttribute("身分證號", helper.GetText("IDNumber"));
                dataElement.SetAttribute("身份證號", helper.GetText("IDNumber"));
                dataElement.SetAttribute("性別", helper.GetText("Gender"));
                dataElement.SetAttribute("性別代號", (helper.GetText("Gender") == "男" ? "1" :(helper.GetText("Gender") == "女" ? "2" : "")));
                dataElement.SetAttribute("出生年月日", CDATE(helper.GetText("Birthdate")));
                dataElement.SetAttribute("入學資格代號", helper.GetText("UpdateCode"));

                string schoolName = helper.GetText("ContextInfo/ContextInfo/GraduateSchool").Trim();
                //if (schoolName != "")
                //{
                //    switch (helper.GetText("UpdateCode"))
                //    {
                //        case "001": schoolName += " 畢業"; break;
                //        case "003": schoolName += " 結業"; break;
                //        case "004":schoolName += " 修滿"; break;
                //        case "002":
                //        case "005":
                //        case "006":
                //        case "007":
                //        case "008":
                //        default:
                //            break;
                //    }
                //}

                // 學校所在地
                string GrSchoolLocationCode = helper.GetText("ContextInfo/ContextInfo/GraduateSchoolLocationCode");
                // 學校設立別
                string GrSchoolType = "";
                // 取得學校代碼
                if (schooDict.ContainsKey(schoolName))
                {
                    string schoolcode = schooDict[schoolName];
                    if (GrSchoolLocationCode == "")
                    {
                        GrSchoolLocationCode = schoolcode.Substring(0, 2);
                    }
                    GrSchoolType = schoolcode.Substring(2, 1);
                }

                if (schoolName.Length > 3)
                {
                    // 解析國中
                    int StartX = 0, LenX = 0;
                    StartX     = schoolName.IndexOf("立");
                    LenX       = schoolName.Length - StartX;
                    schoolName = schoolName.Substring(StartX + 1, LenX - 1);
                }

                dataElement.SetAttribute("畢業國中", schoolName);
                dataElement.SetAttribute("畢業國中所在縣市代號", GrSchoolLocationCode);
                dataElement.SetAttribute("畢業國中學校設立別", GrSchoolType);
                dataElement.SetAttribute("備註", helper.GetText("Comment"));
                #endregion

                #region 2009年新制增加
                dataElement.SetAttribute("班別", helper.GetText("ContextInfo/ContextInfo/ClassType"));
                dataElement.SetAttribute("特殊身份代碼", helper.GetText("ContextInfo/ContextInfo/SpecialStatus"));
                dataElement.SetAttribute("註1", helper.GetText("ContextInfo/ContextInfo/IDNumberComment"));
                dataElement.SetAttribute("國中畢業年度", helper.GetText("ContextInfo/ContextInfo/GraduateSchoolYear"));
                dataElement.SetAttribute("註2", helper.GetText("ContextInfo/ContextInfo/GraduateComment"));
                #endregion

                deptgradeNode.AppendChild(dataElement);
            }
            #endregion

            #region 排序科別代碼

            List <XmlElement> deptList = new List <XmlElement>();
            foreach (XmlElement var in doc.DocumentElement.SelectNodes("清單"))
            {
                deptList.Add(var);
            }
            deptList.Sort(DepartmentCodeComparison);

            DSXmlHelper docHelper = new DSXmlHelper(doc.DocumentElement);
            while (docHelper.PathExist("清單"))
            {
                docHelper.RemoveElement("清單");
            }

            foreach (XmlElement var in deptList)
            {
                docHelper.AddElement(".", var);
            }

            #endregion

            return(doc.DocumentElement);
        }
Example #33
0
        void btnItem_Click(object sender, EventArgs e)
        {
            if (itmPanelLeft.SelectedItems.Count > 0)
            {
                btnDelete.Enabled = true;
                btnAD.Enabled     = true;

                //ListViewItem item = lstList.SelectedItems[0];
                ButtonItem item  = sender as ButtonItem;
                string     id    = item.Tag.ToString();
                DSResponse dsrsp = QueryStudent.GetUpdateRecordBatch(id);

                listView.SuspendLayout();
                if (dsrsp.HasContent)
                {
                    DSXmlHelper helper = dsrsp.GetContent();
                    provider = new SummaryProvider(helper);
                    //lblADCounter.Text = "【" + provider.Title + "】 各科人數統計";
                    lblADCounter.Text = "【" + provider.Title + "】 人數統計";
                    lblADInfo.Text    = "【" + provider.Title + "】 核准文號";
                    buttonX1.Visible  = true;
                    buttonX2.Visible  = true;

                    XmlNode contentNode = helper.GetElement("UpdateRecordBatch/Content");
                    if (contentNode == null)
                    {
                        return;
                    }
                    source = (XmlElement)contentNode.FirstChild;

                    //處理看板資訊
                    StringBuilder builder = new StringBuilder("");
                    foreach (Department dept in provider.GetDepartments())
                    {
                        builder = builder.Append("◎").Append(dept.Name).Append(" ")
                                  .Append("男生 <font color='blue'>").Append(dept.Male).Append("</font> 人 ")
                                  .Append("女生 <font color='blue'>").Append(dept.Female).Append("</font> 人 ")
                                  .Append("(合計 <font color='blue'>").Append(dept.Total).Append("</font> 人)");

                        if (dept.Unknow > 0)
                        {
                            builder = builder.Append("<font color='red'>").Append(dept.Unknow)
                                      .Append("</font>人未填性別");
                        }
                        builder = builder.Append("<br/>");
                    }
                    lblListContent.Text = builder.ToString();
                    lblADName1.Text     = provider.Title;
                    lblADName2.Text     = provider.Title;
                    lblADName3.Text     = provider.Title;

                    // 處理核准日期與文號
                    string adString = "";
                    if (!string.IsNullOrEmpty(provider.ADNumber))
                    {
                        adString += "核准文號 <font color='red'>" + provider.ADNumber + "</font> ";
                        adString += "核准日期 <font color='red'>" + provider.ADDate + "</font>";
                    }
                    else
                    {
                        adString = "<font color='red'>未登錄</font>";
                    }
                    lblAD.Text = adString;

                    //處理ListView呈現資料
                    listView.Clear();

                    foreach (IEntryFormat format in provider.GetEntities())
                    {
                        // 若無群組則先加上群組
                        // 因為沒有科別先註掉
                        //if (listView.Groups[format.Group] == null)
                        //    listView.Groups.Add(format.Group, format.Group);

                        // 若沒有欄名則先加上欄名
                        if (listView.Columns.Count == 0)
                        {
                            foreach (string column in format.DisplayColumns.Keys)
                            {
                                listView.Columns.Add(column, format.DisplayColumns[column].Width);
                            }
                        }

                        // 欄位都有了則依據欄位填入其屬性值
                        ListViewItem rowItem = null;
                        for (int i = 0; i < listView.Columns.Count; i++)
                        {
                            string columnName = listView.Columns[i].Text;
                            string value      = format.DisplayColumns[columnName].Value;
                            if (i == 0)
                            {
                                rowItem = new ListViewItem(value);
                            }
                            else
                            {
                                rowItem.SubItems.Add(value);
                            }
                        }
                        rowItem.Tag   = format;
                        rowItem.Group = listView.Groups[format.Group];
                        listView.Items.Add(rowItem);
                    }
                }
                listView.ResumeLayout();
            }
            else
            {
                btnDelete.Enabled = false;
                btnAD.Enabled     = false;
            }

            this.itemPanel1.RecalcLayout();
        }
Example #34
0
 public static void DeleteAttend(DSXmlHelper request)
 {
     FISCA.Authentication.DSAServices.CallService("SmartSchool.Course.DeleteSCAttend", new DSRequest(request));
 }
Example #35
0
        public void FillSemesterSubjectScoreInfoWithResit(AccessHelper accesshelper, bool filterRepeat, List <StudentRecord> students)
        {
            //抓科目成績
            accesshelper.StudentHelper.FillSemesterSubjectScore(filterRepeat, students);
            foreach (StudentRecord var in students)
            {
                //及格標準<年及,及格標準>
                Dictionary <int, decimal> applyLimit = new Dictionary <int, decimal>();

                //補考標準<年及,及格標準>
                Dictionary <int, decimal> resitLimit = new Dictionary <int, decimal>();

                // 預設兩位輸入限制
                string DecimalNumber = "2";

                // 學生的成績身分
                string calRole = "";


                // 2019/07/02 穎驊註解, 此高中補考判斷邏輯 是從 原高中補考系統搬過來
                // 研究其精神後, 其為擇優判斷, 會先以 "預設"類別的分數 當頂, 然後不斷下行尋找符合的類別, 假如其標準較低, 則將之當作新標準
                // 此缺點為,如果有類別 的標準分數設定 較 "預設" 高, 將無法被正確顯示,
                // 與佳樺討論過後,基本上這狀況比較不會發生, 因為 特殊生分的學生(體保、原住民、身心障礙)的計算標準 只會更低 頂多打平
                // 所以不會有問題,

                #region 處理計算規則
                XmlElement scoreCalcRule = SmartSchool.Evaluation.ScoreCalcRule.ScoreCalcRule.Instance.GetStudentScoreCalcRuleInfo(var.StudentID) == null ? null : SmartSchool.Evaluation.ScoreCalcRule.ScoreCalcRule.Instance.GetStudentScoreCalcRuleInfo(var.StudentID).ScoreCalcRuleElement;
                if (scoreCalcRule == null)
                {
                }
                else
                {
                    DSXmlHelper helper = new DSXmlHelper(scoreCalcRule);
                    foreach (XmlElement element in helper.GetElements("及格標準/學生類別"))
                    {
                        string cat    = element.GetAttribute("類別");
                        bool   useful = false;
                        //掃描學生的類別作比對
                        foreach (CategoryInfo catinfo in var.StudentCategorys)
                        {
                            if (catinfo.Name == cat || catinfo.FullName == cat)
                            {
                                useful = true;
                            }
                        }
                        //學生是指定的類別或類別為"預設"
                        if (cat == "預設" || useful)
                        {
                            decimal tryParseDecimal;
                            for (int gyear = 1; gyear <= 4; gyear++)
                            {
                                switch (gyear)
                                {
                                case 1:
                                    if (decimal.TryParse(element.GetAttribute("一年級及格標準"), out tryParseDecimal))
                                    {
                                        if (!applyLimit.ContainsKey(gyear))
                                        {
                                            applyLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (applyLimit[gyear] > tryParseDecimal)
                                        {
                                            applyLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    if (decimal.TryParse(element.GetAttribute("一年級補考標準"), out tryParseDecimal))
                                    {
                                        if (!resitLimit.ContainsKey(gyear))
                                        {
                                            resitLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (resitLimit[gyear] > tryParseDecimal)
                                        {
                                            resitLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    break;

                                case 2:
                                    if (decimal.TryParse(element.GetAttribute("二年級及格標準"), out tryParseDecimal))
                                    {
                                        if (!applyLimit.ContainsKey(gyear))
                                        {
                                            applyLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (applyLimit[gyear] > tryParseDecimal)
                                        {
                                            applyLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    if (decimal.TryParse(element.GetAttribute("二年級補考標準"), out tryParseDecimal))
                                    {
                                        if (!resitLimit.ContainsKey(gyear))
                                        {
                                            resitLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (resitLimit[gyear] > tryParseDecimal)
                                        {
                                            resitLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    break;

                                case 3:
                                    if (decimal.TryParse(element.GetAttribute("三年級及格標準"), out tryParseDecimal))
                                    {
                                        if (!applyLimit.ContainsKey(gyear))
                                        {
                                            applyLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (applyLimit[gyear] > tryParseDecimal)
                                        {
                                            applyLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    if (decimal.TryParse(element.GetAttribute("三年級補考標準"), out tryParseDecimal))
                                    {
                                        if (!resitLimit.ContainsKey(gyear))
                                        {
                                            resitLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (resitLimit[gyear] > tryParseDecimal)
                                        {
                                            resitLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    break;

                                case 4:
                                    if (decimal.TryParse(element.GetAttribute("四年級及格標準"), out tryParseDecimal))
                                    {
                                        if (!applyLimit.ContainsKey(gyear))
                                        {
                                            applyLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (applyLimit[gyear] > tryParseDecimal)
                                        {
                                            applyLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    if (decimal.TryParse(element.GetAttribute("四年級補考標準"), out tryParseDecimal))
                                    {
                                        if (!resitLimit.ContainsKey(gyear))
                                        {
                                            resitLimit.Add(gyear, tryParseDecimal);
                                        }
                                        if (resitLimit[gyear] > tryParseDecimal)
                                        {
                                            resitLimit[gyear] = tryParseDecimal;
                                        }
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }

                            calRole = cat;
                        }
                    }


                    // 抓取該學生 成績計算規則 的 科目成績計算位數
                    foreach (XmlElement element in helper.GetElements("各項成績計算位數/科目成績計算位數"))
                    {
                        DecimalNumber = element.GetAttribute("位數");
                    }
                }
                #endregion



                foreach (SemesterSubjectScoreInfo score in var.SemesterSubjectScoreList)
                {
                    bool    canResit = false;
                    decimal s        = 0;

                    // 補考標準
                    decimal makeUpStandard = 40;

                    // 及格標準
                    decimal passStandard = 60;

                    decimal mScore;
                    decimal pScore;

                    if (decimal.TryParse(score.Detail.GetAttribute("原始成績"), out s))
                    {
                        if (resitLimit.ContainsKey(score.GradeYear))
                        {
                            makeUpStandard = resitLimit[score.GradeYear];
                        }
                        canResit = (s >= makeUpStandard);
                    }

                    if (applyLimit.ContainsKey(score.GradeYear))
                    {
                        passStandard = applyLimit[score.GradeYear];
                    }

                    // 檢查如果學生學期科目上有設定,使用學期科目成績上設定
                    if (decimal.TryParse(score.Detail.GetAttribute("修課及格標準"), out pScore))
                    {
                        passStandard = pScore;
                    }

                    if (decimal.TryParse(score.Detail.GetAttribute("修課補考標準"), out mScore))
                    {
                        makeUpStandard = mScore;
                    }

                    if (s > 0)
                    {
                        canResit = (s >= makeUpStandard);
                    }

                    score.Detail.SetAttribute("及格標準", passStandard.ToString());
                    score.Detail.SetAttribute("達補考標準", canResit ? "是" : "否");
                    score.Detail.SetAttribute("補考標準", makeUpStandard.ToString());
                    score.Detail.SetAttribute("位數限制", DecimalNumber);
                    score.Detail.SetAttribute("成績身分", calRole);
                }
            }
        }
Example #36
0
 public void PopXml(string xml)
 {
     textBoxX1.Text = DSXmlHelper.Format(xml);
 }
        private void BehaviorCommentSettingForm_Load(object sender, EventArgs e)
        {
            // 儲存使用者目前的設定 <中文節次名稱,英文節次名稱>
            Dictionary <string, AbsenceEng> userSettingDict = new Dictionary <string, AbsenceEng>();

            // ESL 的目前設定 作為和學務作業缺曠類別的對照
            List <string> eslSetList = new List <string>();

            string query = "SELECT * from $esl.attendance_absence";

            QueryHelper qh = new QueryHelper();
            DataTable   dt = qh.Select(query);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    DataGridViewRow row = new DataGridViewRow();

                    row.CreateCells(dataGridViewX1);

                    row.Tag            = dr["uid"];
                    row.Cells[0].Value = dr["name"];
                    row.Cells[1].Value = dr["english_name"];
                    row.Cells[2].Value = dr["english_abbreviation"];


                    // 建立原本資訊的字典,作為對照用
                    oriCommentDict.Add("" + dr["uid"], "" + dr["name"] + "_" + dr["english_name"] + "_" + dr["english_abbreviation"]);

                    dataGridViewX1.Rows.Add(row);

                    eslSetList.Add("" + dr["name"]);

                    userSettingDict.Add("" + dr["name"], new AbsenceEng()
                    {
                        EnglishName = "" + dr["english_name"], EnglishAbbreviation = "" + dr["english_abbreviation"]
                    });
                }
            }
            else
            {
                //儲存 學務作業目前設定的缺曠類別,作為提醒使用者設定需與學務作業一致
                List <string> _behaviorSetList = new List <string>();

                //取得Xml結構
                DSResponse  _dsrsp  = Config.GetAbsenceList();
                DSXmlHelper _helper = _dsrsp.GetContent();
                foreach (XmlElement element in _helper.GetElements("Absence"))
                {
                    string name = element.GetAttribute("Name");

                    _behaviorSetList.Add(name);
                }

                foreach (string abs in _behaviorSetList)
                {
                    DataGridViewRow row = new DataGridViewRow();

                    row.CreateCells(dataGridViewX1);

                    row.Cells[0].Value = abs;

                    dataGridViewX1.Rows.Add(row);
                }
            }

            //儲存 學務作業目前設定的缺曠類別,作為提醒使用者設定需與學務作業一致
            List <string> behaviorSetList = new List <string>();

            //取得Xml結構
            DSResponse  dsrsp  = Config.GetAbsenceList();
            DSXmlHelper helper = dsrsp.GetContent();

            foreach (XmlElement element in helper.GetElements("Absence"))
            {
                string name = element.GetAttribute("Name");

                behaviorSetList.Add(name);
            }

            List <string> behaviorSetList_OriOlrder = new List <string>(); // 記住原順序的List

            behaviorSetList_OriOlrder.AddRange(behaviorSetList);

            eslSetList.Sort();
            behaviorSetList.Sort();



            if (!eslSetList.SequenceEqual(behaviorSetList))
            {
                dataGridViewX1.Rows.Clear();

                foreach (string abs in behaviorSetList_OriOlrder)
                {
                    DataGridViewRow row = new DataGridViewRow();

                    row.CreateCells(dataGridViewX1);

                    row.Cells[0].Value = abs;
                    row.Cells[1].Value = userSettingDict.ContainsKey(abs) ? userSettingDict[abs].EnglishName : "";
                    row.Cells[2].Value = userSettingDict.ContainsKey(abs) ? userSettingDict[abs].EnglishAbbreviation : "";

                    dataGridViewX1.Rows.Add(row);
                }
            }
        }
Example #38
0
        /// <summary>
        /// 取得學生及格與補考標準,參數用學生IDList,回傳:key:StudentID,1_及,數字
        /// </summary>
        /// <param name="StudRecList"></param>
        /// <returns></returns>
        public static Dictionary <string, Dictionary <string, decimal> > GetStudentApplyLimitDict(List <SmartSchool.Customization.Data.StudentRecord> StudRecList)
        {
            Dictionary <string, Dictionary <string, decimal> > retVal = new Dictionary <string, Dictionary <string, decimal> >();


            foreach (SmartSchool.Customization.Data.StudentRecord studRec in StudRecList)
            {
                //及格標準<年級,及格與補考標準>
                if (!retVal.ContainsKey(studRec.StudentID))
                {
                    retVal.Add(studRec.StudentID, new Dictionary <string, decimal>());
                }

                XmlElement scoreCalcRule = SmartSchool.Evaluation.ScoreCalcRule.ScoreCalcRule.Instance.GetStudentScoreCalcRuleInfo(studRec.StudentID) == null ? null : SmartSchool.Evaluation.ScoreCalcRule.ScoreCalcRule.Instance.GetStudentScoreCalcRuleInfo(studRec.StudentID).ScoreCalcRuleElement;
                if (scoreCalcRule == null)
                {
                }
                else
                {
                    DSXmlHelper helper = new DSXmlHelper(scoreCalcRule);
                    decimal     tryParseDecimal;
                    decimal     tryParseDecimala;

                    foreach (XmlElement element in helper.GetElements("及格標準/學生類別"))
                    {
                        string cat    = element.GetAttribute("類別");
                        bool   useful = false;
                        //掃描學生的類別作比對
                        foreach (CategoryInfo catinfo in studRec.StudentCategorys)
                        {
                            if (catinfo.Name == cat || catinfo.FullName == cat)
                            {
                                useful = true;
                            }
                        }
                        //學生是指定的類別或類別為"預設"
                        if (cat == "預設" || useful)
                        {
                            for (int gyear = 1; gyear <= 4; gyear++)
                            {
                                switch (gyear)
                                {
                                case 1:
                                    if (decimal.TryParse(element.GetAttribute("一年級及格標準"), out tryParseDecimal))
                                    {
                                        string k1s = gyear + "_及";

                                        if (!retVal[studRec.StudentID].ContainsKey(k1s))
                                        {
                                            retVal[studRec.StudentID].Add(k1s, tryParseDecimal);
                                        }

                                        if (retVal[studRec.StudentID][k1s] > tryParseDecimal)
                                        {
                                            retVal[studRec.StudentID][k1s] = tryParseDecimal;
                                        }
                                    }

                                    if (decimal.TryParse(element.GetAttribute("一年級補考標準"), out tryParseDecimala))
                                    {
                                        string k1a = gyear + "_補";

                                        if (!retVal[studRec.StudentID].ContainsKey(k1a))
                                        {
                                            retVal[studRec.StudentID].Add(k1a, tryParseDecimala);
                                        }

                                        if (retVal[studRec.StudentID][k1a] > tryParseDecimala)
                                        {
                                            retVal[studRec.StudentID][k1a] = tryParseDecimala;
                                        }
                                    }

                                    break;

                                case 2:
                                    if (decimal.TryParse(element.GetAttribute("二年級及格標準"), out tryParseDecimal))
                                    {
                                        string k2s = gyear + "_及";

                                        if (!retVal[studRec.StudentID].ContainsKey(k2s))
                                        {
                                            retVal[studRec.StudentID].Add(k2s, tryParseDecimal);
                                        }

                                        if (retVal[studRec.StudentID][k2s] > tryParseDecimal)
                                        {
                                            retVal[studRec.StudentID][k2s] = tryParseDecimal;
                                        }
                                    }

                                    if (decimal.TryParse(element.GetAttribute("二年級補考標準"), out tryParseDecimala))
                                    {
                                        string k2a = gyear + "_補";

                                        if (!retVal[studRec.StudentID].ContainsKey(k2a))
                                        {
                                            retVal[studRec.StudentID].Add(k2a, tryParseDecimala);
                                        }

                                        if (retVal[studRec.StudentID][k2a] > tryParseDecimala)
                                        {
                                            retVal[studRec.StudentID][k2a] = tryParseDecimala;
                                        }
                                    }

                                    break;

                                case 3:
                                    if (decimal.TryParse(element.GetAttribute("三年級及格標準"), out tryParseDecimal))
                                    {
                                        string k3s = gyear + "_及";

                                        if (!retVal[studRec.StudentID].ContainsKey(k3s))
                                        {
                                            retVal[studRec.StudentID].Add(k3s, tryParseDecimal);
                                        }

                                        if (retVal[studRec.StudentID][k3s] > tryParseDecimal)
                                        {
                                            retVal[studRec.StudentID][k3s] = tryParseDecimal;
                                        }
                                    }

                                    if (decimal.TryParse(element.GetAttribute("三年級補考標準"), out tryParseDecimala))
                                    {
                                        string k3a = gyear + "_補";

                                        if (!retVal[studRec.StudentID].ContainsKey(k3a))
                                        {
                                            retVal[studRec.StudentID].Add(k3a, tryParseDecimala);
                                        }

                                        if (retVal[studRec.StudentID][k3a] > tryParseDecimala)
                                        {
                                            retVal[studRec.StudentID][k3a] = tryParseDecimala;
                                        }
                                    }

                                    break;

                                case 4:
                                    if (decimal.TryParse(element.GetAttribute("四年級及格標準"), out tryParseDecimal))
                                    {
                                        string k4s = gyear + "_及";

                                        if (!retVal[studRec.StudentID].ContainsKey(k4s))
                                        {
                                            retVal[studRec.StudentID].Add(k4s, tryParseDecimal);
                                        }

                                        if (retVal[studRec.StudentID][k4s] > tryParseDecimal)
                                        {
                                            retVal[studRec.StudentID][k4s] = tryParseDecimal;
                                        }
                                    }

                                    if (decimal.TryParse(element.GetAttribute("四年級補考標準"), out tryParseDecimala))
                                    {
                                        string k4a = gyear + "_補";

                                        if (!retVal[studRec.StudentID].ContainsKey(k4a))
                                        {
                                            retVal[studRec.StudentID].Add(k4a, tryParseDecimala);
                                        }

                                        if (retVal[studRec.StudentID][k4a] > tryParseDecimala)
                                        {
                                            retVal[studRec.StudentID][k4a] = tryParseDecimala;
                                        }
                                    }

                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(retVal);
        }
Example #39
0
        protected override void OnBackgroundWorkerCompleted(object result)
        {
            _initialized = false;

            _deletedRows  = new Dictionary <string, string>();
            _addedRows    = new List <string>();
            _reserveFaces = new ReserveFaces();

            List <object> resultObject = result as List <object>;

            _commentList = resultObject[0] as CommentList;
            List <string> faceList = resultObject[1] as List <string>;
            DSXmlHelper   helper   = null;

            if (resultObject.Count > 2)
            {
                helper = resultObject[2] as DSXmlHelper;
            }
            else
            {
                helper = new DSXmlHelper("BOOM");
            }

            dgView.Rows.Clear();
            dgView.Columns.Clear();

            dgView.Columns.Add(colSchoolYear);
            dgView.Columns.Add(colSemester);
            //int columnIndex;
            //DataGridViewColumn col;
            //columnIndex = dataGridViewX1.Columns.Add(colSchoolYear);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 80;

            //columnIndex = dataGridViewX1.Columns.Add(colSemester);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 60;

            //columnIndex = dataGridViewX1.Columns.Add(colTB);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 125;

            //columnIndex = dataGridViewX1.Columns.Add(colTT);
            //col = dataGridViewX1.Columns[columnIndex];
            //col.Width = 100;

            //文字評量 Face Column
            int index = 0;

            foreach (string face in faceList)
            {
                int colIndex = dgView.Columns.Add("colItem" + index, face);
                dgView.Columns[colIndex].SortMode = DataGridViewColumnSortMode.NotSortable;
                index++;
            }

            //int index = 0;
            //foreach (XmlElement element in helper.GetElements("DiffItem"))
            //{
            //    string name = element.GetAttribute("Name");
            //    System.Windows.Forms.DataGridViewTextBoxColumn newCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
            //    newCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
            //    newCol.HeaderText = name;
            //    newCol.MinimumWidth = 45;
            //    newCol.Name = "colItem" + index;
            //    newCol.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
            //    dataGridViewX1.Columns.Add(newCol);
            //    index++;
            //}
            //colTT.DisplayIndex = dataGridViewX1.Columns.Count - 1;


            _valueManager.AddValue(ADD_ROW_COUNT, "0");
            //helper = info.ScoreList.GetContent();
            _valueManager.AddValue(ORI_ROW_COUNT, helper.GetElements("SemesterMoralScore").Length.ToString());

            foreach (XmlElement element in helper.GetElements("SemesterMoralScore"))
            {
                int              rowIndex = dgView.Rows.Add();
                DataGridViewRow  row      = dgView.Rows[rowIndex];
                DataGridViewCell cell;
                string           schoolYear = element.SelectSingleNode("SchoolYear").InnerText;
                string           semester   = element.SelectSingleNode("Semester").InnerText;
                string           key;

                cell       = row.Cells[colSchoolYear.Index];
                cell.Value = schoolYear;
                cell.Tag   = schoolYear;
                key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", colSchoolYear.HeaderText);
                _valueManager.AddValue(key, cell.Value.ToString());
                cell.ReadOnly = true;

                cell       = row.Cells[colSemester.Index];
                cell.Value = element.SelectSingleNode("Semester").InnerText;
                cell.Tag   = element.SelectSingleNode("Semester").InnerText;
                key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", colSemester.HeaderText);
                _valueManager.AddValue(key, cell.Value.ToString());
                cell.ReadOnly = true;

                JHSchool.Legacy.RecordInfo rinfo = new JHSchool.Legacy.RecordInfo();
                rinfo.IsAddedRow = false;
                rinfo.ID         = element.GetAttribute("ID");
                row.Tag          = rinfo;

                foreach (XmlNode node in element.SelectNodes("TextScore/Morality"))
                {
                    string face = node.SelectSingleNode("@Face").InnerText;

                    //如果 face 不存在對照表中,偷偷保留下來
                    if (!_commentList.ContainsFace(face))
                    {
                        _reserveFaces.Add(rinfo.ID, face, node.InnerText);
                    }

                    foreach (DataGridViewColumn column in dgView.Columns)
                    {
                        if (column.HeaderText != face)
                        {
                            continue;
                        }
                        cell       = row.Cells[column.Index];
                        cell.Value = node.InnerText;
                        cell.Tag   = node.InnerText;
                        key        = VALUE_KEY.Replace("SchoolYear", schoolYear).Replace("Semester", semester).Replace("ColumnText", column.HeaderText);
                        _valueManager.AddValue(key, cell.Value.ToString());
                        cell.ReadOnly = false;
                    }
                }
            }
            _initialized = true;
        }
Example #40
0
        public override string Import(List <Campus.DocumentValidator.IRowStream> Rows)
        {
            if (mOption.Action == ImportAction.InsertOrUpdate)
            {
                #region 學號:學生系統編號
                Dictionary <string, string> StudentDic = new Dictionary <string, string>();
                List <string> StudentNumberList        = new List <string>();
                foreach (IRowStream Row in Rows)
                {
                    string StudentNumber = Row.GetValue("學號");
                    if (!StudentNumberList.Contains(StudentNumber))
                    {
                        StudentNumberList.Add(StudentNumber);
                    }
                }

                DataTable dt = tool._Q.Select(string.Format("select id,student_number from student where student_number in ('{0}')", string.Join("','", StudentNumberList)));
                //學生ID清單
                List <string> StudentIDList = new List <string>();
                foreach (DataRow row in dt.Rows)
                {
                    string id     = "" + row["id"];
                    string number = "" + row["student_number"];
                    if (!StudentDic.ContainsKey(number))
                    {
                        StudentDic.Add(number, id);
                    }
                    if (!StudentIDList.Contains(id))
                    {
                        StudentIDList.Add(id);
                    }
                }

                //學生Log專用的記錄
                List <StudentRecord> StudentList = K12.Data.Student.SelectByIDs(StudentIDList);
                Dictionary <string, StudentRecord> StudentLogDic = new Dictionary <string, StudentRecord>();
                foreach (StudentRecord each in StudentList)
                {
                    if (!StudentLogDic.ContainsKey(each.ID))
                    {
                        StudentLogDic.Add(each.ID, each);
                    }
                }
                #endregion

                Dictionary <string, CLUBRecord> ClubDic    = new Dictionary <string, CLUBRecord>();
                Dictionary <string, CLUBRecord> ClubLogDic = new Dictionary <string, CLUBRecord>();
                List <CLUBRecord> CLUBList = tool._A.Select <CLUBRecord>();
                foreach (CLUBRecord each in CLUBList)
                {
                    string CourseKey = each.SchoolYear + "," + each.Semester + "," + each.ClubName;
                    if (!ClubDic.ContainsKey(CourseKey))
                    {
                        ClubDic.Add(CourseKey, each);
                    }
                    if (!ClubLogDic.ContainsKey(each.UID))
                    {
                        ClubLogDic.Add(each.UID, each);
                    }
                }

                //系統內是否已經有志願序清單
                //學年度學期學號 : 志願序
                Dictionary <string, VolunteerRecord> VolunteerDic = new Dictionary <string, VolunteerRecord>();
                List <VolunteerRecord> vrList = tool._A.Select <VolunteerRecord>(string.Format("ref_student_id in ('{0}')", string.Join("','", StudentDic.Values)));
                foreach (VolunteerRecord each in vrList)
                {
                    string kkey = each.SchoolYear + "," + each.Semester + "," + each.RefStudentID;
                    if (!VolunteerDic.ContainsKey(kkey))
                    {
                        VolunteerDic.Add(kkey, each);
                    }

                    //Log
                    if (!Log_Dic.ContainsKey(kkey))
                    {
                        LogVolunteer im = new LogVolunteer();
                        im.lo_Vol  = each.CopyExtension();
                        im.ClubDic = ClubLogDic;
                        Log_Dic.Add(kkey, im);
                    }
                }

                List <VolunteerRecord> VolunteerInsertList = new List <VolunteerRecord>();
                List <VolunteerRecord> VolunteerUpdateList = new List <VolunteerRecord>();

                foreach (IRowStream Row in Rows)
                { //教師名稱
                    string StudentNumber = Row.GetValue("學號");
                    //取得學生ID
                    if (StudentDic.ContainsKey(StudentNumber))
                    {
                        string SchoolYear = Row.GetValue("學年度");
                        string Semester   = Row.GetValue("學期");

                        string jkey = SchoolYear + "," + Semester + "," + StudentDic[StudentNumber];
                        if (!VolunteerDic.ContainsKey(jkey))
                        {
                            #region 取得志願XML
                            DSXmlHelper dsx = new DSXmlHelper("xml");
                            for (int x = 1; x <= 學生選填志願數; x++)
                            {
                                //依學年度+學期+社團名稱 找到社團
                                string CLUBName = Row.GetValue("志願" + x);
                                if (!string.IsNullOrEmpty(CLUBName))
                                {
                                    string CourseKey = SchoolYear + "," + Semester + "," + CLUBName;

                                    if (ClubDic.ContainsKey(CourseKey))
                                    {
                                        string clubID = ClubDic[CourseKey].UID;
                                        dsx.AddElement("Club");
                                        dsx.SetAttribute("Club", "Index", "" + x);
                                        dsx.SetAttribute("Club", "Ref_Club_ID", clubID);
                                    }
                                }
                            }
                            #endregion

                            //建立Record
                            VolunteerRecord Vol = new VolunteerRecord();
                            Vol.SchoolYear   = int.Parse(SchoolYear);
                            Vol.Semester     = int.Parse(Semester);
                            Vol.RefStudentID = StudentDic[StudentNumber];
                            Vol.Content      = dsx.BaseElement.OuterXml;

                            VolunteerInsertList.Add(Vol);
                        }
                        else
                        {
                            #region 取得志願XML
                            DSXmlHelper dsx = new DSXmlHelper("xml");
                            for (int x = 1; x <= 學生選填志願數; x++)
                            {
                                //依學年度+學期+社團名稱 找到社團
                                string CLUBName = Row.GetValue("志願" + x);
                                if (!string.IsNullOrEmpty(CLUBName))
                                {
                                    string CourseKey = SchoolYear + "," + Semester + "," + CLUBName;

                                    if (ClubDic.ContainsKey(CourseKey))
                                    {
                                        string clubID = ClubDic[CourseKey].UID;
                                        dsx.AddElement("Club");
                                        dsx.SetAttribute("Club", "Index", "" + x);
                                        dsx.SetAttribute("Club", "Ref_Club_ID", clubID);
                                    }
                                }
                            }
                            #endregion

                            VolunteerRecord Vol = VolunteerDic[jkey];
                            Vol.Content = dsx.BaseElement.OuterXml;
                            VolunteerUpdateList.Add(Vol);

                            if (Log_Dic.ContainsKey(jkey))
                            {
                                Log_Dic[jkey].New_Vol = Vol;
                            }
                        }
                    }
                }

                if (VolunteerInsertList.Count > 0)
                {
                    StringBuilder mstrLog1 = new StringBuilder();
                    mstrLog1.AppendLine("新增社團志願序:");
                    foreach (VolunteerRecord each in VolunteerInsertList)
                    {
                        if (StudentLogDic.ContainsKey(each.RefStudentID))
                        {
                            mstrLog1.AppendLine(Importbot.GetLogString(ClubLogDic, each, StudentLogDic[each.RefStudentID]));
                        }
                    }
                    tool._A.InsertValues(VolunteerInsertList);
                    FISCA.LogAgent.ApplicationLog.Log("社團", "新增匯入志願序", mstrLog1.ToString());
                }

                if (VolunteerUpdateList.Count > 0)
                {
                    StringBuilder mstrLog2 = new StringBuilder();
                    mstrLog2.AppendLine("更新社團志願序:");
                    foreach (VolunteerRecord each in VolunteerUpdateList)
                    {
                        string CourseKey = each.SchoolYear + "," + each.Semester + "," + each.RefStudentID;
                        if (Log_Dic.ContainsKey(CourseKey))
                        {
                            if (StudentLogDic.ContainsKey(each.RefStudentID))
                            {
                                string classname = StudentLogDic[each.RefStudentID].Class != null ? StudentLogDic[each.RefStudentID].Class.Name : "";
                                string SeatNo    = StudentLogDic[each.RefStudentID].SeatNo.HasValue ? StudentLogDic[each.RefStudentID].SeatNo.Value.ToString() : "";
                                mstrLog2.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」學號「{3}」", classname, SeatNo, StudentLogDic[each.RefStudentID].Name, StudentLogDic[each.RefStudentID].StudentNumber));
                            }
                            mstrLog2.AppendLine(Importbot.SetLog(Log_Dic[CourseKey]));
                        }
                    }
                    tool._A.UpdateValues(VolunteerUpdateList);
                    FISCA.LogAgent.ApplicationLog.Log("社團", "更新匯入志願序", mstrLog2.ToString());
                }
            }

            return("");
        }
Example #41
0
        /// <summary>
        /// 依據各別的DataTable建立UDT資料
        /// (By 異動資料)
        /// </summary>
        public static void Update_ExtendMethod(this GetUDTXml xml, string Element)
        {
            foreach (DataRow dr in xml.dataTable.Rows)
            {
                //先判斷是否為Dic內存之資料
                if (xml.XmlUDTDic.ContainsKey("" + dr[1]))
                {
                    string      student = "" + dr[1];
                    DSXmlHelper XmlDoc  = xml.XmlUDTDic[student]._XmlHelper;

                    #region Element

                    XmlDoc.AddElement(Element);
                    XmlDoc.SetAttribute(Element, "ID", "" + dr[0]);

                    XmlDoc.AddElement(Element, "RefStudentID");
                    XmlDoc.SetText(Element + "/RefStudentID", "" + dr[1]);

                    XmlDoc.AddElement(Element, "SchoolYear");
                    XmlDoc.SetText(Element + "/SchoolYear", "" + dr[2]);

                    XmlDoc.AddElement(Element, "Semester");
                    XmlDoc.SetText(Element + "/Semester", "" + dr[3]);

                    XmlDoc.AddElement(Element, "S_Name");
                    XmlDoc.SetText(Element + "/S_Name", "" + dr[4]);

                    XmlDoc.AddElement(Element, "S_StudentNumber");
                    XmlDoc.SetText(Element + "/S_StudentNumber", "" + dr[5]);

                    XmlDoc.AddElement(Element, "S_Gender");
                    XmlDoc.SetText(Element + "/S_Gender", "" + dr[6]);

                    XmlDoc.AddElement(Element, "S_IDNumber");
                    XmlDoc.SetText(Element + "/S_IDNumber", "" + dr[7]);

                    XmlDoc.AddElement(Element, "S_Birthdate");
                    XmlDoc.SetText(Element + "/S_Birthdate", UDT_S.ChangeTime("" + dr[8]));

                    XmlDoc.AddElement(Element, "S_GradeYear");
                    XmlDoc.SetText(Element + "/S_GradeYear", "" + dr[9]);

                    XmlDoc.AddElement(Element, "S_Dept");
                    XmlDoc.SetText(Element + "/S_Dept", "" + dr[10]);

                    XmlDoc.AddElement(Element, "Update_Date");
                    XmlDoc.SetText(Element + "/Update_Date", UDT_S.ChangeTime("" + dr[11]));

                    XmlDoc.AddElement(Element, "Update_Code");
                    XmlDoc.SetText(Element + "/Update_Code", "" + dr[12]);

                    XmlDoc.AddElement(Element, "Update_Type");
                    XmlDoc.SetText(Element + "/Update_Type", "" + dr[13]);

                    XmlDoc.AddElement(Element, "Update_Reason");
                    XmlDoc.SetText(Element + "/Update_Reason", "" + dr[14]);

                    XmlDoc.AddElement(Element, "Update_Desc");
                    XmlDoc.SetText(Element + "/Update_Desc", "" + dr[15]);

                    XmlDoc.AddElement(Element, "AD_Date");
                    XmlDoc.SetText(Element + "/AD_Date", "" + dr[16]);

                    XmlDoc.AddElement(Element, "AD_Numbar");
                    XmlDoc.SetText(Element + "/AD_Numbar", "" + dr[17]);

                    XmlDoc.AddElement(Element, "Last_AD_Date");
                    XmlDoc.SetText(Element + "/Last_AD_Date", UDT_S.ChangeTime("" + dr[18]));

                    XmlDoc.AddElement(Element, "Last_AD_Numbar");
                    XmlDoc.SetText(Element + "/Last_AD_Numbar", "" + dr[19]);

                    XmlDoc.AddElement(Element, "Comment");
                    XmlDoc.SetText(Element + "/Comment", "" + dr[20]);
                    //XML
                    XmlDoc.AddElement(Element, "ConText_Info");
                    XmlDoc.AddXmlString(Element + "/ConText_Info", "" + dr[21]);

                    XmlDoc.AddElement(Element, "Last_Update_Date");
                    XmlDoc.SetText(Element + "/Last_Update_Date", UDT_S.ChangeTime("" + dr[22]));

                    #endregion

                    #region  UpdateRecord - 原生結構

                    //<UpdateRecord ID="100540" RefStudentID="54139">
                    //    <SchoolYear>99</SchoolYear>
                    //    <Semester>2</Semester>
                    //    <Name>呂小鍾</Name>
                    //    <StudentNumber>712043</StudentNumber>
                    //    <Gender>男</Gender>
                    //    <IDNumber>J12254139</IDNumber>
                    //    <Birthdate>1993/08/15</Birthdate>
                    //    <GradeYear>3</GradeYear>
                    //    <Department>汽車科</Department>
                    //    <UpdateDate>2011/06/23</UpdateDate>
                    //    <UpdateCode>001</UpdateCode>
                    //    <UpdateType />
                    //    <UpdateReason />
                    //    <UpdateDescription>持國民中學畢業證明書者(含國中補校)</UpdateDescription>
                    //    <ADDate>1753/01/01</ADDate>
                    //    <ADNumber>澔字第1111111號</ADNumber>
                    //    <LastADDate />
                    //    <LastADNumber />
                    //    <Comment />
                    //    <ContextInfo>
                    //        <ContextInfo>
                    //            <GraduateComment>
                    //            </GraduateComment>
                    //            <ClassType> 3</ClassType>
                    //            <SpecialStatus>
                    //            </SpecialStatus>
                    //            <GraduateSchool> 市立光華國中</GraduateSchool>
                    //            <GraduateSchoolYear> 99</GraduateSchoolYear>
                    //            <GraduateSchoolCode> 183503</GraduateSchoolCode>
                    //            <GraduateSchoolLocationCode> 18</GraduateSchoolLocationCode>
                    //        </ContextInfo>
                    //    </ContextInfo>
                    //</UpdateRecord>

                    #endregion
                }
            }
        }
Example #42
0
        public static void UpdatePhone(DSXmlHelper phoneNode)
        {
            DSRequest dsreq = new DSRequest(phoneNode);

            DSAServices.CallService("SmartSchool.Student.UpdatePhone", dsreq);
        }
        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;
                }
            }
        }
Example #44
0
        private CLUBRecord GetClub()
        {
            CLUBRecord club = new CLUBRecord();

            club.ClubName     = txtClubName.Text.Trim();          //社團名稱
            club.SchoolYear   = intSchoolYear.Value;              //學年度
            club.Semester     = intSemester.Value;                //學期
            club.ClubCategory = cbCategory.Text.Trim();           //類型
            club.ClubNumber   = tbClubNumber.Text.Trim();         //類型

            if (!string.IsNullOrEmpty(tbGrade1Limit.Text.Trim())) //一年級人限
            {
                club.Grade1Limit = tool.StringIsInt_DefIsZero(tbGrade1Limit.Text.Trim());
            }
            if (!string.IsNullOrEmpty(tbGrade2Limit.Text.Trim())) //二年級人限
            {
                club.Grade2Limit = tool.StringIsInt_DefIsZero(tbGrade2Limit.Text.Trim());
            }
            if (!string.IsNullOrEmpty(tbGrade3Limit.Text.Trim())) //三年級人限
            {
                club.Grade3Limit = tool.StringIsInt_DefIsZero(tbGrade3Limit.Text.Trim());
            }
            if (!string.IsNullOrEmpty(tbLimit.Text.Trim())) //三年級人限
            {
                club.Limit = tool.StringIsInt_DefIsZero(tbLimit.Text.Trim());
            }

            if (cbGenderRestrict.SelectedItem != null) //男女限制
            {
                string res = cbGenderRestrict.GetItemText(cbGenderRestrict.SelectedItem);
                club.GenderRestrict = res;
            }

            //社團老師

            if (cbTeacher.SelectedItem != null)
            {
                TeacherObj cbi = (TeacherObj)cbTeacher.SelectedItem;
                club.RefTeacherID = cbi.TeacherID;
            }


            if (cbTeacher2.SelectedItem != null)
            {
                TeacherObj cbi = (TeacherObj)cbTeacher2.SelectedItem;
                club.RefTeacherID2 = cbi.TeacherID;
            }


            if (cbTeacher3.SelectedItem != null)
            {
                TeacherObj cbi = (TeacherObj)cbTeacher3.SelectedItem;
                club.RefTeacherID3 = cbi.TeacherID;
            }


            //社團場地
            if (!string.IsNullOrEmpty(cbLocation.Text.Trim()))
            {
                club.Location = cbLocation.Text.Trim();
            }

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

            foreach (ListViewItem each in listDepartment.Items)
            {
                if (each.Checked)
                {
                    dsXml.AddElement("Dept");
                    dsXml.AddText("Dept", each.Text);
                }
            }
            club.DeptRestrict = dsXml.BaseElement.OuterXml;
            club.About        = tbAboutClub.Text.Trim(); //簡介

            return(club);
        }
Example #45
0
        public GetDisciplineUDTXml(List <GraduateUDT> InsertArchiveList)
        {
            //建立學生ID 清單
            List <string> list = new List <string>();

            foreach (GraduateUDT each in InsertArchiveList)
            {
                if (!list.Contains(each.StudentID))
                {
                    list.Add(each.StudentID);
                }
            }

            //QueryHelper
            QueryHelper _queryhelper = new QueryHelper();
            string      sqlStr1      = "Select * From discipline where " + UDT_S.PopOneCondition("ref_student_id", list);

            //取得所有學生ID的獎懲資料
            DataTable dt1 = _queryhelper.Select(sqlStr1);

            foreach (GraduateUDT each in InsertArchiveList)
            {
                if (!XmlUDTDic.ContainsKey(each.StudentID))
                {
                    XmlUdtHelp H = new XmlUdtHelp(each, "DisciplineList"); //Mini盒子
                    XmlUDTDic.Add(each.StudentID, H);
                }
            }

            foreach (DataRow dr in dt1.Rows)
            {
                //先判斷是否為Dic內存之資料
                if (XmlUDTDic.ContainsKey("" + dr[8]))
                {
                    string      student = "" + dr[8];
                    DSXmlHelper XmlDoc  = XmlUDTDic[student]._XmlHelper;

                    #region Element

                    XmlDoc.AddElement("Discipline");
                    XmlDoc.SetAttribute("Discipline", "ID", "" + dr[0]);

                    XmlDoc.AddElement("Discipline", "RefStudentID");
                    XmlDoc.SetText("Discipline/RefStudentID", "" + dr[8]);

                    XmlDoc.AddElement("Discipline", "SchoolYear");
                    XmlDoc.SetText("Discipline/SchoolYear", "" + dr[1]);

                    XmlDoc.AddElement("Discipline", "Semester");
                    XmlDoc.SetText("Discipline/Semester", "" + dr[2]);

                    XmlDoc.AddElement("Discipline", "OccurDate");
                    XmlDoc.SetText("Discipline/OccurDate", UDT_S.ChangeTime("" + dr[4]));

                    XmlDoc.AddElement("Discipline", "RegisterDate");
                    XmlDoc.SetText("Discipline/RegisterDate", UDT_S.ChangeTime("" + dr[12]));

                    //0懲戒,1獎勵,2留察
                    XmlDoc.AddElement("Discipline", "MeritFlag");
                    XmlDoc.SetText("Discipline/MeritFlag", "" + dr[10]);

                    XmlDoc.AddElement("Discipline", "Reason");
                    XmlDoc.SetText("Discipline/Reason", "" + dr[6]);
                    //XML
                    XmlDoc.AddElement("Discipline", "Detail");
                    XmlDoc.AddXmlString("Discipline/Detail", "" + dr[7]);

                    #endregion

                    #region DisciplineRecord - 原生Xml結構

                    //<Discipline ID="315122">
                    //    <RefStudentID>57097</RefStudentID>
                    //    <Name>王小彥</Name>
                    //    <StudentNumber>J00114</StudentNumber>
                    //    <SeatNo>1</SeatNo>
                    //    <ClassName>普一甲</ClassName>
                    //    <Gender>女</Gender>
                    //    <SchoolYear>100</SchoolYear>
                    //    <Semester>1</Semester>
                    //    <OccurDate>2011/07/09</OccurDate>
                    //    <GradeYear />
                    //    <Reason>群育:自動參加花燈創意比賽,熱心公務。</Reason>
                    //    <Type>1</Type>
                    //    <MeritFlag>1</MeritFlag>
                    //    <RegisterDate>2011/08/11</RegisterDate>
                    //    <Detail>
                    //        <Discipline>
                    //            <Merit A="0" B="0" C="1" />
                    //            <Demerit A="0" B="1" C="0" ClearDate="" ClearReason="" Cleared="" />
                    //        </Discipline>
                    //    </Detail>
                    //    </Discipline>

                    #endregion
                }
            }
        }
Example #46
0
        public override void Save()
        {
            if (!ValidAll())
            {
                FISCA.Presentation.Controls.MsgBox.Show("資料內容有誤, 請先修正後再行儲存!", "內容錯誤", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            //string studentName = "";
            //foreach (BriefStudentData student in SmartSchool.StudentRelated.Student.Instance.SelectionStudents)
            //{
            //    if (student.ID == RunningID)
            //        studentName = student.Name;
            //}

            string studentName = JHSchool.Student.Instance.Items[RunningID].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 dgView.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                JHSchool.Legacy.RecordInfo rinfo = row.Tag as JHSchool.Legacy.RecordInfo;
                if (!rinfo.IsAddedRow)
                {
                    string id         = rinfo.ID;
                    bool   changed    = false;
                    string schoolYear = "" + row.Cells[colSchoolYear.Index].Value;
                    string semester   = "" + row.Cells[colSemester.Index].Value;
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        string columnText = dgView.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", "TextScore");

                        bool hasRoot = false;
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            DataGridViewColumn column = cell.OwningColumn;
                            if (column.Name.StartsWith("colItem"))
                            {
                                if (!hasRoot)
                                {
                                    uh.AddElement("SemesterMoralScore/TextScore", "Content");
                                    hasRoot = true;
                                }
                                XmlElement element = uh.AddElement("SemesterMoralScore/TextScore/Content", "Morality", GetValue(cell));
                                element.SetAttribute("Face", column.HeaderText);
                            }
                        }

                        foreach (string other_face in _reserveFaces.GetFacesByID(id))
                        {
                            if (!hasRoot)
                            {
                                uh.AddElement("SemesterMoralScore/TextScore", "Content");
                                hasRoot = true;
                            }
                            XmlElement element = uh.AddElement("SemesterMoralScore/TextScore/Content", "Morality", _reserveFaces.GetComment(id, other_face));
                            element.SetAttribute("Face", other_face);
                        }
                    }
                }


                // 處理 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.Index]));
                    ih.AddElement("SemesterMoralScore", "Semester", GetValue(row.Cells[colSemester.Index]));
                    //ih.AddElement("SemesterMoralScore", "SupervisedByDiff", GetValue(row.Cells[colTB.Name]));
                    //ih.AddElement("SemesterMoralScore", "SupervisedByComment", GetValue(row.Cells[colTT.Name]));
                    ih.AddElement("SemesterMoralScore", "TextScore");
                    bool hasRoot = false;
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        DataGridViewColumn column = cell.OwningColumn;
                        if (column.Name.StartsWith("colItem"))
                        {
                            if (!hasRoot)
                            {
                                ih.AddElement("SemesterMoralScore/TextScore", "Content");
                                hasRoot = true;
                            }
                            XmlElement element = ih.AddElement("SemesterMoralScore/TextScore/Content", "Morality", GetValue(cell));
                            element.SetAttribute("Face", column.HeaderText);
                            isb.Append("\t").Append(column.HeaderText).Append(":").Append(GetValue(row.Cells[column.Name])).Append("\n");
                        }
                    }
                    ic++;
                }
            }

            string ustring = usb.ToString();

            usb = new StringBuilder("");
            usb.Append("修改【").Append(studentName).Append("】資料:\n");
            usb.Append(ustring);

            try
            {
                if (_deletedRows.Count > 0)
                {
                    DSXmlHelper dh = new DSXmlHelper("Request");
                    dh.AddElement("SemesterMoralScore");
                    foreach (string id in _deletedRows.Keys)
                    {
                        dsb.Append("刪除【").Append(studentName).Append("-").Append(_deletedRows[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);
        }
Example #47
0
 public XmlUdtHelp(GraduateUDT GraUDT, string RootElement)
 {
     _GraUDT    = GraUDT;
     _XmlHelper = new DSXmlHelper(RootElement);
 }
Example #48
0
        /// <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;
                }
            }
        }
Example #49
0
        private void InitializeDataGridViewColumn()
        {
            #region DataGridView的Column建立

            ColumnIndex.Clear();

            DSResponse       dsrsp      = Framework.Feature.Config.GetPeriodList();
            DSXmlHelper      helper     = dsrsp.GetContent();
            PeriodCollection collection = new PeriodCollection();
            foreach (XmlElement element in helper.GetElements("Period"))
            {
                PeriodInfo info = new PeriodInfo(element);
                collection.Items.Add(info);
            }
            int ColumnsIndex = dataGridView.Columns.Add("colClassName", "班級");
            ColumnIndex.Add("班級", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = true;

            ColumnsIndex = dataGridView.Columns.Add("colSeatNo", "座號");
            ColumnIndex.Add("座號", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = true;

            ColumnsIndex = dataGridView.Columns.Add("colName", "姓名");
            ColumnIndex.Add("姓名", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = true;
            dataGridView.Columns[ColumnsIndex].Frozen       = true; //由此開始可拖移

            ColumnsIndex = dataGridView.Columns.Add("colSchoolNumber", "學號");
            ColumnIndex.Add("學號", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = true;

            ColumnsIndex = dataGridView.Columns.Add("colSchoolYear", "學年度");
            ColumnIndex.Add("學年度", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = false;

            ColumnsIndex = dataGridView.Columns.Add("colSemester", "學期");
            ColumnIndex.Add("學期", ColumnsIndex);
            dataGridView.Columns[ColumnsIndex].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[ColumnsIndex].ReadOnly     = false;

            _startIndex = ColumnIndex["學期"] + 1;

            List <string> cols = new List <string>()
            {
                "學年度", "學期"
            };

            foreach (PeriodInfo info in collection.GetSortedList())
            {
                cols.Add(info.Name);

                int columnIndex = dataGridView.Columns.Add(info.Name, info.Name);
                ColumnIndex.Add(info.Name, columnIndex); //節次
                DataGridViewColumn column = dataGridView.Columns[columnIndex];
                column.SortMode     = DataGridViewColumnSortMode.NotSortable;
                column.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                column.ReadOnly     = true;
                column.Tag          = info;
            }

            Campus.Windows.DataGridViewImeDecorator dec = new Campus.Windows.DataGridViewImeDecorator(this.dataGridView, cols);


            #endregion
        }
Example #50
0
        public System.Xml.XmlElement CreateNameList(string schoolYear, string semester, List <XmlElement> list)
        {
            // 取得 StudentID
            List <string> StudentIDList = DAL.DALTransfer.GetUpdatRecordStudentIDList(list);

            //// 取得學生地址
            //Dictionary<string,JHSchool.Data.JHAddressRecord> AddressRecDic= DAL.DALTransfer.GetStudentAddressRecordDic(StudentIDList);

            // 取得學生家長
            Dictionary <string, JHSchool.Data.JHParentRecord> ParentRecDic = DAL.DALTransfer.GetParentRecordDic(StudentIDList);

            //// 取得學生民國生日
            //Dictionary<string,string> BirthDic =DAL.DALTransfer.GetChiBirthday1(StudentIDList );

            XmlDocument doc = new XmlDocument();
            Dictionary <string, string> deptCode = new Dictionary <string, string>();

            #region 建立科別代碼查詢表

            /* 這段沒用到先註
             *
             * foreach (XmlElement var in SmartSchool.Feature.Basic.Config.GetDepartment().GetContent().GetElements("Department"))
             * {
             *  deptCode.Add(var.SelectSingleNode("Name").InnerText, var.SelectSingleNode("Code").InnerText);
             * }
             */
            #endregion
            //依年級科別排序資料
            //list.Sort(CompareUpdateRecord);

            //排序學號
            list.Sort(StudentNumberComparison);

            //// 取得學生地址
            Dictionary <string, JHSchool.Data.JHAddressRecord> AddressRecDic = DAL.DALTransfer.GetStudentAddressRecordDic(StudentIDList);

            #region 產生Xml
            Dictionary <string, Dictionary <string, XmlElement> > gradeyear_dept_map = new Dictionary <string, Dictionary <string, XmlElement> >();
            doc.LoadXml("<異動名冊 類別=\"新生名冊\" 學年度=\"" + schoolYear + "\" 學期=\"" + semester + "\" 學校代號=\"" + Framework.Legacy.GlobalOld.SchoolInformation.Code + "\" 學校名稱=\"" + GlobalOld.SchoolInformation.ChineseName + "\"/>");
            foreach (XmlElement var in list)
            {
                DSXmlHelper helper    = new DSXmlHelper(var);
                string      gradeyear = helper.GetText("GradeYear");
                string      dept      = helper.GetText("Department");
                XmlElement  deptgradeNode;


                #region 清單
                if (!gradeyear_dept_map.ContainsKey(gradeyear))
                {
                    gradeyear_dept_map.Add(gradeyear, new Dictionary <string, XmlElement>());
                }
                if (!(gradeyear_dept_map[gradeyear].ContainsKey(dept)))
                {
                    deptgradeNode = doc.CreateElement("清單");
                    deptgradeNode.SetAttribute("科別", dept);
                    deptgradeNode.SetAttribute("年級", gradeyear);
//                    deptgradeNode.SetAttribute("科別代號", (deptCode.ContainsKey(dept) ? deptCode[dept] : ""));
                    gradeyear_dept_map[gradeyear].Add(dept, deptgradeNode);
                    doc.DocumentElement.AppendChild(deptgradeNode);
                }
                else
                {
                    deptgradeNode = gradeyear_dept_map[gradeyear][dept];
                }
                #endregion


                #region 異動紀錄
                XmlElement dataElement = doc.CreateElement("異動紀錄");
                dataElement.SetAttribute("編號", helper.GetText("@ID"));
                dataElement.SetAttribute("異動代號", helper.GetText("UpdateCode"));
                dataElement.SetAttribute("異動日期", CDATE(helper.GetText("UpdateDate")));
                dataElement.SetAttribute("學號", helper.GetText("StudentNumber"));
                dataElement.SetAttribute("姓名", helper.GetText("Name"));
                dataElement.SetAttribute("身分證號", helper.GetText("IDNumber"));
                dataElement.SetAttribute("性別", helper.GetText("Gender"));
                dataElement.SetAttribute("性別代號", (helper.GetText("Gender") == "男" ? "1" : (helper.GetText("Gender") == "女" ? "2" : "")));
                dataElement.SetAttribute("出生年月日", CDATE(helper.GetText("Birthdate")));
                dataElement.SetAttribute("入學資格代號", helper.GetText("UpdateCode"));
                dataElement.SetAttribute("生日", helper.GetText("Birthdate"));

                // new
                dataElement.SetAttribute("班別", helper.GetText("ContextInfo/ContextInfo/OriginClassName"));
                dataElement.SetAttribute("地址", helper.GetText("ContextInfo/ContextInfo/OriginAddress"));
                dataElement.SetAttribute("入學年月", helper.GetText("ContextInfo/ContextInfo/EnrollmentSchoolYear"));
                dataElement.SetAttribute("備註", helper.GetText("Comment"));
                dataElement.SetAttribute("異動年級", helper.GetText("GradeYear"));

                string StudentID = helper.GetAttribute("@RefStudentID");

                if (ParentRecDic.ContainsKey(StudentID))
                {
                    dataElement.SetAttribute("監護人", ParentRecDic[StudentID].Custodian.Name);
                    //dataElement.SetAttribute("戶籍地址", AddressRecDic[StudentID].Permanent.County + AddressRecDic[StudentID].Permanent.District + AddressRecDic[StudentID].Permanent.Area + AddressRecDic[StudentID].Permanent.Detail);
                    dataElement.SetAttribute("戶籍地址", AddressRecDic[StudentID].PermanentAddress);
                }
                //if (AddressRecDic.ContainsKey(StudentID))
                //{
                //    dataElement.SetAttribute("戶籍縣市", AddressRecDic[StudentID].Permanent.County);
                //    dataElement.SetAttribute("戶籍里", AddressRecDic[StudentID].Permanent.District);
                //    dataElement.SetAttribute("戶籍鄰", AddressRecDic[StudentID].Permanent.Area);
                //    dataElement.SetAttribute("戶籍其他", AddressRecDic[StudentID].Permanent.Detail);
                //}

                //if(BirthDic.ContainsKey(StudentID ))
                //    dataElement.SetAttribute("民國出生年月日",BirthDic[StudentID]);

                string schoolName = helper.GetText("ContextInfo/ContextInfo/GraduateSchool");

                /*
                 * if (schoolName != "")
                 * {
                 *  switch (helper.GetText("UpdateCode"))
                 *  {
                 *      case "001": schoolName += " 畢業"; break;
                 *      case "003": schoolName += " 結業"; break;
                 *      case "004": schoolName += " 修滿"; break;
                 *      case "002":
                 *      case "005":
                 *      case "006":
                 *      case "007":
                 *      case "008":
                 *      default:
                 *          break;
                 *  }
                 * }
                 */
                //dataElement.SetAttribute("畢業國中", schoolName);
                dataElement.SetAttribute("畢業國小", schoolName);

                dataElement.SetAttribute("畢業國小所在縣市代號", helper.GetText("ContextInfo/ContextInfo/GraduateSchoolLocationCode"));
//                dataElement.SetAttribute("備註", helper.GetText("Comment"));
                #endregion
                deptgradeNode.AppendChild(dataElement);
            }
            #endregion

            /*
             #region 排序科別代碼
             *
             * List<XmlElement> deptList = new List<XmlElement>();
             * foreach (XmlElement var in doc.DocumentElement.SelectNodes("清單"))
             *  deptList.Add(var);
             * deptList.Sort(DepartmentCodeComparison);
             *
             * DSXmlHelper docHelper = new DSXmlHelper(doc.DocumentElement);
             * while (docHelper.PathExist("清單")) docHelper.RemoveElement("清單");
             *
             * foreach (XmlElement var in deptList)
             *  docHelper.AddElement(".", var);
             *
             #endregion
             */
            return(doc.DocumentElement);
        }
Example #51
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                pgImport.Minimum  = 0;
                pgImport.Maximum  = 100;
                pgImport.Value    = 0;
                btnImport.Enabled = false;

                ImportMessage("產生匯入資料…");

                XmlElement     output = DSXmlHelper.LoadXml("<ImportClass/>");
                SheetHelper    sheet = new SheetHelper(Context.SourceFile);
                SheetRowSource sheetSource = new SheetRowSource(sheet, Context);
                int            ProgressStep = 10;
                int            progress = 0, firstRow = sheet.FirstDataRowIndex, maxRow = sheet.MaxDataRowIndex;

                for (int rowIndex = firstRow; rowIndex <= maxRow; rowIndex++)
                {
                    sheetSource.BindRow(rowIndex);

                    XmlElement record = CreateChild(output, "Class");
                    if (Context.CurrentMode == ImportMode.Insert)
                    {
                        GenerateInsertXml(sheetSource, record);
                    }
                    else
                    {
                        GenerateUpdateXml(sheetSource, record);
                    }

                    //回報進度。
                    if (((++progress) % ProgressStep) == 0)
                    {
                        int percentage = progress * 100 / (maxRow - firstRow);
                        pgImport.Value = percentage;
                    }
                }

                if (Context.SelectedFields.Contains("班導師"))
                {
                    ConvertTeacherField(output);
                }

                //if (Context.SelectedFields.Contains("科別"))
                //    ConvertDeptField(output);

                if (Context.SelectedFields.Contains("課程規劃"))
                {
                    ConvertGraduationPlanField(output);
                }

                if (Context.SelectedFields.Contains("計算規則"))
                {
                    ConvertScoreCalcRuleField(output);
                }

                pgImport.Value = 100;

                ImportMessage("上傳資料到主機,請稍後…");
                //GeneralActionLog log = new GeneralActionLog();
                //log.Source = "匯入班級基本資料";
                //log.Diagnostics = output.OuterXml;

                if (Context.CurrentMode == ImportMode.Insert)
                {
                    Context.DataSource.InsertImportData(output);
                    //log.ActionName = "新增匯入";
                    //log.Description = "新增匯入 " + sheet.DataRowCount + " 筆班級資料。";
                }
                else
                {
                    Context.DataSource.UpdateImportData(output);

                    //log.ActionName = "更新匯入";
                    //log.Description = "更新匯入 " + sheet.DataRowCount + " 筆班級資料。";
                }

                //CurrentUser.Instance.AppLog.Write(log);

                ImportMessage("匯入完成。");
                wpImport.FinishButtonEnabled = eWizardButtonState.True;
                wpImport.BackButtonEnabled   = eWizardButtonState.False;

                Class.Instance.SyncAllBackground();

                // 與 DAL 同步
                JHSchool.Data.JHClass.RemoveAll();
                JHSchool.Data.JHClass.SelectAll();
                //SmartSchool.ClassRelated.Class.Instance.Reflash();
            }
            catch (Exception ex)
            {
                //CurrentUser user = CurrentUser.Instance;
                //BugReporter.ReportException(user.SystemName, user.SystemVersion, ex, false);

                btnImport.Enabled = true;

                ImportMessage("上傳資料失敗");
                FISCA.Presentation.Controls.MsgBox.Show(ex.Message);
            }
        }
Example #52
0
        internal static void SaveStudentTagRecordEditor(IEnumerable <JHSchool.Editor.StudentTagRecordEditor> editors)
        {
            MultiThreadWorker <JHSchool.Editor.StudentTagRecordEditor> worker = new MultiThreadWorker <JHSchool.Editor.StudentTagRecordEditor>();

            worker.MaxThreads     = 3;
            worker.PackageSize    = 100;
            worker.PackageWorker += delegate(object sender, PackageWorkEventArgs <JHSchool.Editor.StudentTagRecordEditor> 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", "RefStudentID", editor.RefEntityID);
                        deleteHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

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

                        insertHelper.AddElement("Tag");
                        insertHelper.AddElement("Tag", "RefStudentID", 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", "RefStudentID", 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", "RefStudentID", editor.RefEntityID);
                        deleteHelper.AddElement("Tag", "RefTagID", editor.RefTagID);

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

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

                if (hasDelete)
                {
                    DSAServices.CallService("SmartSchool.Tag.RemoveStudentTag", new DSRequest(deleteHelper.BaseElement));
                }
            };
            List <PackageWorkEventArgs <JHSchool.Editor.StudentTagRecordEditor> > packages = worker.Run(editors);
            foreach (PackageWorkEventArgs <JHSchool.Editor.StudentTagRecordEditor> each in packages)
            {
                if (each.HasException)
                {
                    throw each.Exception;
                }
            }
        }
Example #53
0
 public static void InsertPaperItem(DSXmlHelper request)
 {
     FeatureBase.CallService("SmartSchool.ElectronicPaper.InsertPaperItem", new DSRequest(request));
 }
Example #54
0
        public static void SaveStudentRecordEditor(IEnumerable <JHSchool.Editor.StudentRecordEditor> editors)
        {
            DSXmlHelper    updateHelper = new DSXmlHelper("UpdateStudentList");
            DSXmlHelper    insertHelper = new DSXmlHelper("InsertRequest");
            List <LogInfo> logs         = new List <LogInfo>();
            List <string>  reflashList  = new List <string>();
            bool           hasUpdate    = false;

            foreach (var editor in editors)
            {
                if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Update)
                {
                    #region 更新
                    LogInfo log = new LogInfo()
                    {
                        Action = "修改學生資料", Entity = "Student", EntityID = editor.ID
                    };
                    string description = "";
                    updateHelper.AddElement("Student");
                    updateHelper.AddElement("Student", "Field");
                    if (editor.Birthday != editor.Student.Birthday)
                    {
                        updateHelper.AddElement("Student/Field", "Birthdate", editor.Birthday);
                        description += "生日 由\"" + editor.Student.Birthday + "\"變更為\"" + editor.Birthday + "\"";
                    }
                    if (editor.Gender != editor.Student.Gender)
                    {
                        updateHelper.AddElement("Student/Field", "Gender", editor.Gender);
                        description += "性別 由\"" + editor.Student.Gender + "\"變更為\"" + editor.Gender + "\"";
                    }
                    if (editor.IDNumber != editor.Student.IDNumber)
                    {
                        updateHelper.AddElement("Student/Field", "IDNumber", editor.IDNumber);
                        description += "身分證號 由\"" + editor.Student.IDNumber + "\"變更為\"" + editor.IDNumber + "\"";
                    }
                    if (editor.Name != editor.Student.Name)
                    {
                        updateHelper.AddElement("Student/Field", "Name", editor.Name);
                        description += "姓名 由\"" + editor.Student.Name + "\"變更為\"" + editor.Name + "\"";
                    }
                    if (editor.SeatNo != editor.Student.SeatNo)
                    {
                        updateHelper.AddElement("Student/Field", "SeatNo", editor.SeatNo);
                        description += "座號 由\"" + editor.Student.SeatNo + "\"變更為\"" + editor.SeatNo + "\"";
                    }
                    if (editor.Status != editor.Student.Status)
                    {
                        updateHelper.AddElement("Student/Field", "Status", editor.Status);
                        description += "狀態 由\"" + editor.Student.Status + "\"變更為\"" + editor.Status + "\"";
                    }
                    if (editor.StudentNumber != editor.Student.StudentNumber)
                    {
                        updateHelper.AddElement("Student/Field", "StudentNumber", editor.StudentNumber);
                        description += "學號 由\"" + editor.Student.StudentNumber + "\"變更為\"" + editor.StudentNumber + "\"";
                    }
                    if (editor.RefClassID != editor.Student.RefClassID)
                    {
                        updateHelper.AddElement("Student/Field", "RefClassID", editor.RefClassID);
                        description += "班級 由\"" + (editor.Student.Class == null ? "" : editor.Student.Class.Name) + "\"變更為\"" + (JHSchool.Class.Instance.Items[editor.RefClassID] == null ? "" : JHSchool.Class.Instance.Items[editor.RefClassID].Name) + "\"";
                    }
                    //if (editor.OverrideDepartmentID != editor.Student.OverrideDepartmentID)
                    //{
                    //    updateHelper.AddElement("Student/Field", "OverrideDeptID", editor.OverrideDepartmentID);
                    //    description += "指定科別 由\"" + (JHSchool.Department.Instance[editor.Student.OverrideDepartmentID] == null ? "" : JHSchool.Department.Instance[editor.Student.OverrideDepartmentID].FullName) + "\"變更為\"" + (JHSchool.Department.Instance[editor.OverrideDepartmentID] == null ? "" : JHSchool.Department.Instance[editor.OverrideDepartmentID].FullName) + "\"";
                    //}
                    if (editor.Nationality != editor.Student.Nationality)
                    {
                        updateHelper.AddElement("Student/Field", "Nationality", editor.Nationality);
                        description += "國籍 由\"" + editor.Student.Nationality + "\"變更為\"" + editor.Nationality + "\"";
                    }


                    //天啊,這個 Log 怎麼寫比較好。

                    //if (editor.OverrideProgramPlanID != editor.Student.OverrideProgramPlanID)
                    //{
                    //    updateHelper.AddElement("Student/Field", "RefGraduationPlanID", editor.OverrideProgramPlanID);
                    //    description += "指定課程規劃 由\"" + (JHSchool.Department.Instance[editor.Student.OverrideDepartmentID] == null ? "" : JHSchool.Department.Instance[editor.Student.OverrideDepartmentID].FullName) + "\"變更為\"" + (JHSchool.Department.Instance[editor.OverrideDepartmentID] == null ? "" : JHSchool.Department.Instance[editor.OverrideDepartmentID].FullName) + "\"";
                    //}
                    updateHelper.AddElement("Student/Field", "RefGraduationPlanID", "" + editor.OverrideProgramPlanID);
                    updateHelper.AddElement("Student/Field", "RefScoreCalcRuleID", "" + editor.OverrideScoreCalcRuleID);

                    updateHelper.AddElement("Student", "Condition");
                    updateHelper.AddElement("Student/Condition", "ID", editor.ID);
                    log.Description = description;
                    logs.Add(log);
                    hasUpdate = true;
                    reflashList.Add(editor.ID);
                    #endregion
                    #region 新增
                    if (editor.EditorStatus == JHSchool.Editor.EditorStatus.Insert)
                    {
                        throw new NotImplementedException("新增學生尚未實作");
                    }
                    #endregion
                }
                if (hasUpdate)
                {
                    DSAServices.CallService("SmartSchool.Student.Update", new DSRequest(updateHelper.BaseElement));
                    logs.SaveAll();
                    Student.Instance.SyncDataBackground(reflashList);
                }
            }
        }
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            ClassClubTraMag mag = new ClassClubTraMag(_SchoolYear, _Semester, PrintLost);

            //依據使用者所選擇的學年期
            //取得相關學生之社團結算成績

            //列印不及格學生清單時,排除所有學期成績60分(含)以上之學生
            //取得範本

            #region 建立範本

            Workbook template = new Workbook();
            template.Open(new MemoryStream(Properties.Resources.班級社團成績單_範本), FileFormatType.Excel97To2003);
            if (PrintLost) //不及格確認單
            {
                PriontName = "班級社團成績不及格(確認單)";
            }
            else
            {
                PriontName = "班級社團成績單";
            }

            Workbook prototype = new Workbook();
            prototype.Copy(template);
            Worksheet ptws = prototype.Worksheets[0];

            #region 建立標頭Column

            評量比例 評 = new 評量比例();
            if (評._wp == null)
            {
                e.Cancel = true;
                return;
            }

            ColumnNameList = new List <string>();
            ColumnNameList.Add("座號");
            ColumnNameList.Add("姓名");
            ColumnNameList.Add("學號");
            ColumnNameList.Add("性別");
            ColumnNameList.Add("社團");
            foreach (string each in 評.ColumnDic.Keys)
            {
                ColumnNameList.Add(each + "(" + 評.ProportionDic[each] + "%)");
            }
            ColumnNameList.Add("學期成績");
            if (PrintLost) //不及格確認單
            {
                ColumnNameList.Add("簽名");
            }

            int ColumnNameIndex = 0;
            //Jean Aspose更新
            Style style = prototype.CreateStyle();
            style.IsTextWrapped = true;
            foreach (string each in ColumnNameList)
            {
                ptws.Cells[2, ColumnNameIndex].SetStyle(style);
                ptws.Cells[2, ColumnNameIndex].PutValue(each);
                if (ColumnNameIndex >= 5)
                {
                    ptws.Cells.SetColumnWidth(ColumnNameIndex, 10);
                    tool.SetCellBro(ptws, 2, ColumnNameIndex, 1, 1);
                }
                ColumnNameIndex++;
            }

            #endregion

            Range ptHeader  = ptws.Cells.CreateRange(0, 3, false);
            Range ptEachRow = ptws.Cells.CreateRange(3, 1, false);

            //建立Excel檔案
            Workbook wb = new Workbook();
            wb.Copy(prototype);

            //取得第一張
            Worksheet ws = wb.Worksheets[0];

            int dataIndex = 0;
            int CountPage = 1;

            int DetalIndex = 5;

            #endregion

            #region 填資料

            foreach (string classID in mag.TraDic.Keys)
            {
                if (mag.TraDic[classID].Count == 0)
                {
                    continue;
                }
                ws.Cells.CreateRange(dataIndex, 3, false).CopyStyle(ptHeader);
                ws.Cells.CreateRange(dataIndex, 3, false).CopyValue(ptHeader);

                ClassRecord cr = mag.ClassDic[classID];

                ws.Cells.Merge(dataIndex, 0, 1, ColumnNameList.Count);
                string TitleName = string.Format("{0}學年度 第{1}學期 {2}", _SchoolYear.ToString(), _Semester.ToString(), PriontName);
                ws.Cells[dataIndex, 0].PutValue(TitleName);
                dataIndex++;

                //班級
                ws.Cells.Merge(dataIndex, 0, 1, 3);
                ws.Cells[dataIndex, 0].PutValue(string.Format("班級:{0}", cr.Name));

                ws.Cells.Merge(dataIndex, 4, 1, 3);
                //教師
                if (!string.IsNullOrEmpty(cr.RefTeacherID))
                {
                    #region 教師
                    if (mag.TeacherDic.ContainsKey(cr.RefTeacherID))
                    {
                        TeacherRecord tr = mag.TeacherDic[cr.RefTeacherID];
                        //是否有暱稱
                        if (!string.IsNullOrEmpty(tr.Nickname))
                        {
                            string TeacherString = "班導師:" + tr.Name + "(" + tr.Nickname + ")";
                            ws.Cells[dataIndex, 4].PutValue(TeacherString);
                        }
                        else
                        {
                            string TeacherString = "班導師:" + mag.TeacherDic[cr.RefTeacherID].Name;
                            ws.Cells[dataIndex, 4].PutValue(TeacherString);
                        }
                    }
                    #endregion
                }

                //頁數
                ws.Cells.Merge(dataIndex, ColumnNameList.Count - 3, 1, 3);
                ws.Cells[dataIndex, ColumnNameList.Count - 3].PutValue("日期:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + " 頁數:" + CountPage.ToString());

                dataIndex += 2;

                mag.TraDic[classID].Sort(SortTraDic);

                foreach (ClassClubTraObj each in mag.TraDic[classID])
                {
                    ws.Cells.CreateRange(dataIndex, 1, false).CopyStyle(ptEachRow);
                    ws.Cells.CreateRange(dataIndex, 1, false).CopyValue(ptEachRow);

                    ws.Cells[dataIndex, 0].PutValue(each.studentRecord.SeatNo.HasValue ? each.studentRecord.SeatNo.Value.ToString() : "");
                    ws.Cells[dataIndex, 1].PutValue(each.studentRecord.Name);
                    ws.Cells[dataIndex, 2].PutValue(each.studentRecord.StudentNumber);
                    ws.Cells[dataIndex, 3].PutValue(each.studentRecord.Gender);

                    //社團
                    if (each.club != null)
                    {
                        ws.Cells[dataIndex, 4].PutValue(each.club.ClubName);
                    }

                    if (each.SCJoin != null)
                    {
                        if (!string.IsNullOrEmpty(each.SCJoin.Score))
                        {
                            int x = 0;

                            XmlElement xml = DSXmlHelper.LoadXml(each.SCJoin.Score);

                            foreach (XmlElement each1 in xml.SelectNodes("Item"))
                            {
                                x++;
                                string name = each1.GetAttribute("Name");
                                if (評.ColumnDic.ContainsKey(name))
                                {
                                    ws.Cells[dataIndex, DetalIndex + 評.ColumnDic[name]].PutValue(each1.GetAttribute("Score"));
                                }
                            }
                        }
                    }

                    for (int x = 3; x < ColumnNameList.Count; x++)
                    {
                        tool.SetCellBro(ws, dataIndex, x, 1, 1);
                    }

                    //學期成績
                    if (PrintLost) //不及格確認單
                    {
                        ws.Cells.SetColumnWidth(ColumnNameList.Count - 1, 14);

                        if (each.RSR != null)
                        {
                            ws.Cells.SetColumnWidth(ColumnNameList.Count - 2, 8);
                            string Score = each.RSR.ResultScore.HasValue ? each.RSR.ResultScore.Value.ToString() : "";
                            ws.Cells[dataIndex, ColumnNameList.Count - 2].PutValue(Score);
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        if (each.RSR != null) //有學期成績
                        {
                            ws.Cells.SetColumnWidth(ColumnNameList.Count - 1, 8);
                            string Score = each.RSR.ResultScore.HasValue ? each.RSR.ResultScore.Value.ToString() : "";
                            ws.Cells[dataIndex, ColumnNameList.Count - 1].PutValue(Score);
                        }
                        else
                        {
                        }
                    }

                    dataIndex++;
                }

                CountPage++; //每班增加1頁

                ws.HPageBreaks.Add(dataIndex, ColumnNameList.Count);
            }

            #endregion

            e.Result = wb;
        }
Example #56
0
        public static void SaveSemesterHistoryRecordEditor(IEnumerable <JHSchool.Editor.SemesterHistoryRecordEditor> editors)
        {
            Dictionary <string, List <JHSchool.Editor.SemesterHistoryRecordEditor> > grouped = new Dictionary <string, List <JHSchool.Editor.SemesterHistoryRecordEditor> >();

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

            DSXmlHelper helper     = new DSXmlHelper("UpdateStudentList");
            bool        hasChanged = false;

            List <LogInfo> logs = new List <LogInfo>();

            foreach (var primaryKey in grouped.Keys)
            {
                List <SemesterInfo> contentsSemester = new List <SemesterInfo>();
                Dictionary <SemesterInfo, JHSchool.Editor.SemesterHistoryRecordEditor> changedValues = new Dictionary <SemesterInfo, JHSchool.Editor.SemesterHistoryRecordEditor>();
                Dictionary <SemesterInfo, SemesterHistoryRecord> values = new Dictionary <SemesterInfo, SemesterHistoryRecord>();

                foreach (var item in grouped[primaryKey])//把這個人的變更資料依學期整裡好
                {
                    if (item.EditorStatus == JHSchool.Editor.EditorStatus.NoChanged)
                    {
                        continue;                                                             //沒變更的就跳過
                    }
                    SemesterInfo semester = new SemesterInfo()
                    {
                        SchoolYear = item.SchoolYear, Semester = item.Semester
                    };
                    if (!contentsSemester.Contains(semester))
                    {
                        contentsSemester.Add(semester);
                    }
                    if (!changedValues.ContainsKey(semester))
                    {
                        changedValues.Add(semester, item);
                    }
                    else
                    {
                        changedValues[semester] = item;
                    }
                }
                if (changedValues.Count == 0)
                {
                    continue;                          //更本沒有資料有變更就換下一個人
                }
                helper.AddElement("Student");

                foreach (var item in SemesterHistory.Instance[primaryKey])//把原來就有的學期資料整裡好
                {
                    SemesterInfo semester = new SemesterInfo()
                    {
                        SchoolYear = item.SchoolYear, Semester = item.Semester
                    };
                    if (!contentsSemester.Contains(semester))
                    {
                        contentsSemester.Add(semester);
                    }
                    if (!values.ContainsKey(semester))
                    {
                        values.Add(semester, item);
                    }
                    else
                    {
                        values[semester] = item;
                    }
                }
                contentsSemester.Sort();
                hasChanged = true;
                helper.AddElement("Student", "Field");
                helper.AddElement("Student/Field", "SemesterHistory");
                helper.AddElement("Student", "Condition");
                helper.AddElement("Student/Condition", "ID", primaryKey);
                foreach (var semester in contentsSemester)
                {
                    if (changedValues.ContainsKey(semester))
                    {
                        if (changedValues[semester].EditorStatus != JHSchool.Editor.EditorStatus.Delete)
                        {
                            XmlElement element = helper.AddElement("Student/Field/SemesterHistory", "History");
                            element.SetAttribute("SchoolYear", "" + semester.SchoolYear);
                            element.SetAttribute("Semester", "" + semester.Semester);
                            element.SetAttribute("GradeYear", "" + changedValues[semester].GradeYear);
                            element.SetAttribute("SeatNo", "" + changedValues[semester].SeatNo);
                            element.SetAttribute("ClassName", "" + changedValues[semester].ClassName);
                            element.SetAttribute("Teacher", "" + changedValues[semester].Teacher);
                            element.SetAttribute("SchoolDayCount", "" + changedValues[semester].SchoolDayCount);
                            if (values.ContainsKey(semester))
                            {
                                LogInfo logInfo = new LogInfo()
                                {
                                    Action = "修改學期歷程", Entity = "Student", EntityID = primaryKey
                                };
                                logInfo.Description = "修改 「" + semester.SchoolYear + "」學年度 第「" + semester.Semester + "」學期" +
                                                      (changedValues[semester].GradeYear != values[semester].GradeYear ? ("\n\t年級由「" + values[semester].GradeYear + "」年級變更為「" + changedValues[semester].GradeYear + "」年級") : "") +
                                                      (changedValues[semester].ClassName != values[semester].ClassName ? ("\n\t班級由「" + values[semester].ClassName + "」變更為「" + changedValues[semester].ClassName + "」") : "") +
                                                      (changedValues[semester].SeatNo != values[semester].SeatNo ? ("\n\t座號由「" + values[semester].SeatNo + "」變更為「" + changedValues[semester].SeatNo + "」") : "") +
                                                      (changedValues[semester].Teacher != values[semester].Teacher ? ("\n\t班導師由「" + values[semester].Teacher + "」變更為「" + changedValues[semester].Teacher + "」") : "") + (changedValues[semester].SchoolDayCount != values[semester].SchoolDayCount  ? ("\n\t上課天數由「" + values[semester].SchoolDayCount + "」變更為「" + changedValues[semester].SchoolDayCount + "」") : "");
                                logs.Add(logInfo);
                            }
                            else
                            {
                                LogInfo logInfo = new LogInfo()
                                {
                                    Action = "新增學期歷程", Entity = "Student", EntityID = primaryKey
                                };
                                logInfo.Description = "新增 「" + semester.SchoolYear + "」學年度 第「" + semester.Semester + "」學期" +
                                                      "\n\t年級為「" + changedValues[semester].GradeYear + "」年級" +
                                                      "\n\t班級為「" + changedValues[semester].ClassName + "」" +
                                                      "\n\t座號為「" + changedValues[semester].SeatNo + "」" +
                                                      "\n\t班導師為「" + changedValues[semester].Teacher + "」" +
                                                      "\n\t上課天數為「" + changedValues[semester].SchoolDayCount + "」";
                                logs.Add(logInfo);
                            }
                        }
                        else
                        {
                            logs.Add(new LogInfo()
                            {
                                Action = "刪除學期歷程", Entity = "Student", EntityID = primaryKey, Description = "刪除 「" + semester.SchoolYear + "」學年度 第「" + semester.Semester + "」學期學期歷程。"
                            });
                        }
                    }
                    else
                    {
                        XmlElement element = helper.AddElement("Student/Field/SemesterHistory", "History");
                        element.SetAttribute("SchoolYear", "" + semester.SchoolYear);
                        element.SetAttribute("Semester", "" + semester.Semester);
                        element.SetAttribute("GradeYear", "" + values[semester].GradeYear);
                        element.SetAttribute("SeatNo", "" + values[semester].SeatNo);
                        element.SetAttribute("ClassName", "" + values[semester].ClassName);
                        element.SetAttribute("Teacher", "" + values[semester].Teacher);
                        element.SetAttribute("SchoolDayCount", "" + values[semester].SchoolDayCount);
                    }
                }
            }
            if (hasChanged)
            {
                DSAServices.CallService("SmartSchool.Student.Update", new DSRequest(helper.BaseElement));
                logs.SaveAll();
                SemesterHistory.Instance.SyncDataBackground(grouped.Keys);
            }
        }
        public System.Xml.XmlElement CreateNameList(string schoolYear, string semester, List <XmlElement> list)
        {
            XmlDocument doc = new XmlDocument();
            Dictionary <string, string> deptCode = new Dictionary <string, string>();

            #region 建立科別代碼查詢表

            /* 這段沒用到先註
             *
             * foreach (XmlElement var in SmartSchool.Feature.Basic.Config.GetDepartment().GetContent().GetElements("Department"))
             * {
             *  deptCode.Add(var.SelectSingleNode("Name").InnerText, var.SelectSingleNode("Code").InnerText);
             * }
             */
            #endregion
            //依年級科別排序資料
            //list.Sort(CompareUpdateRecord);

            //排序學號
            list.Sort(StudentNumberComparison);

            #region 產生Xml
            Dictionary <string, Dictionary <string, XmlElement> > gradeyear_dept_map = new Dictionary <string, Dictionary <string, XmlElement> >();
            doc.LoadXml("<異動名冊 類別=\"中輟學生名冊\" 學年度=\"" + schoolYear + "\" 學期=\"" + semester + "\" 學校代號=\"" + Framework.Legacy.GlobalOld.SchoolInformation.Code + "\" 學校名稱=\"" + GlobalOld.SchoolInformation.ChineseName + "\"/>");
            foreach (XmlElement var in list)
            {
                DSXmlHelper helper    = new DSXmlHelper(var);
                string      gradeyear = helper.GetText("GradeYear");
                string      dept      = helper.GetText("Department");
                XmlElement  deptgradeNode;


                #region 清單
                if (!gradeyear_dept_map.ContainsKey(gradeyear))
                {
                    gradeyear_dept_map.Add(gradeyear, new Dictionary <string, XmlElement>());
                }
                if (!(gradeyear_dept_map[gradeyear].ContainsKey(dept)))
                {
                    deptgradeNode = doc.CreateElement("清單");
                    deptgradeNode.SetAttribute("科別", dept);
                    deptgradeNode.SetAttribute("年級", gradeyear);
                    //                    deptgradeNode.SetAttribute("科別代號", (deptCode.ContainsKey(dept) ? deptCode[dept] : ""));
                    gradeyear_dept_map[gradeyear].Add(dept, deptgradeNode);
                    doc.DocumentElement.AppendChild(deptgradeNode);
                }
                else
                {
                    deptgradeNode = gradeyear_dept_map[gradeyear][dept];
                }
                #endregion


                #region 異動紀錄
                XmlElement dataElement = doc.CreateElement("異動紀錄");
                dataElement.SetAttribute("編號", helper.GetText("@ID"));
                dataElement.SetAttribute("異動代號", helper.GetText("UpdateCode"));
                dataElement.SetAttribute("異動日期", CDATE(helper.GetText("UpdateDate")));
                dataElement.SetAttribute("學號", helper.GetText("StudentNumber"));
                dataElement.SetAttribute("姓名", helper.GetText("Name"));
                dataElement.SetAttribute("身分證號", helper.GetText("IDNumber"));
                dataElement.SetAttribute("性別", helper.GetText("Gender"));
                dataElement.SetAttribute("性別代號", (helper.GetText("Gender") == "男" ? "1" : (helper.GetText("Gender") == "女" ? "2" : "")));
                dataElement.SetAttribute("出生年月日", CDATE(helper.GetText("Birthdate")));
                dataElement.SetAttribute("入學資格代號", helper.GetText("UpdateCode"));
                dataElement.SetAttribute("異動原因或事項", helper.GetText("UpdateDescription"));

                // new
                dataElement.SetAttribute("班別", helper.GetText("ContextInfo/ContextInfo/OriginClassName"));
                dataElement.SetAttribute("地址", helper.GetText("ContextInfo/ContextInfo/OriginAddress"));
                dataElement.SetAttribute("入學年月", helper.GetText("ContextInfo/ContextInfo/EnrollmentSchoolYear"));
                dataElement.SetAttribute("學籍核准文號", helper.GetText("LastADNumber"));
                dataElement.SetAttribute("異動年級", helper.GetText("GradeYear"));


                string schoolName = helper.GetText("ContextInfo/ContextInfo/GraduateSchool");

                /*
                 * if (schoolName != "")
                 * {
                 *  switch (helper.GetText("UpdateCode"))
                 *  {
                 *      case "001": schoolName += " 畢業"; break;
                 *      case "003": schoolName += " 結業"; break;
                 *      case "004": schoolName += " 修滿"; break;
                 *      case "002":
                 *      case "005":
                 *      case "006":
                 *      case "007":
                 *      case "008":
                 *      default:
                 *          break;
                 *  }
                 * }
                 */
                //dataElement.SetAttribute("畢業國中", schoolName);
                dataElement.SetAttribute("畢業國小", schoolName);

                dataElement.SetAttribute("畢業國小所在縣市代號", helper.GetText("ContextInfo/ContextInfo/GraduateSchoolLocationCode"));
                dataElement.SetAttribute("備註", helper.GetText("Comment"));
                #endregion
                deptgradeNode.AppendChild(dataElement);
            }
            #endregion

            /*
             #region 排序科別代碼
             *
             * List<XmlElement> deptList = new List<XmlElement>();
             * foreach (XmlElement var in doc.DocumentElement.SelectNodes("清單"))
             *  deptList.Add(var);
             * deptList.Sort(DepartmentCodeComparison);
             *
             * DSXmlHelper docHelper = new DSXmlHelper(doc.DocumentElement);
             * while (docHelper.PathExist("清單")) docHelper.RemoveElement("清單");
             *
             * foreach (XmlElement var in deptList)
             *  docHelper.AddElement(".", var);
             *
             #endregion
             */
            return(doc.DocumentElement);
        }
        public void Export()
        {
            dataGridView.EndEdit();
            if (!IsValid())
            {
                MsgBox.Show("輸入資料有誤,請修正後再進行匯出!", "驗證錯誤", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DSXmlHelper helper = new DSXmlHelper("Request");

            helper.AddElement(".", "SchoolYear", School.DefaultSchoolYear);
            helper.AddElement(".", "Semester", School.DefaultSemester);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (!IsCheckedRow(row))
                {
                    continue;
                }
                XmlElement e = helper.AddElement("Absence");
                e.SetAttribute("Name", row.Cells[1].Value.ToString());
                e.SetAttribute("PeriodCount", row.Cells[2].Value.ToString());
            }

            foreach (string id in _classidList)
            {
                helper.AddElement(".", "ClassID", id);
            }
            DSResponse dsrsp = QueryAttendance.GetAttendanceStatistic(new DSRequest(helper));

            if (!dsrsp.HasContent)
            {
                MsgBox.Show("取得回覆資料失敗:" + dsrsp.GetFault().Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DSXmlHelper rsp    = dsrsp.GetContent();
            Workbook    book   = new Workbook();
            string      A1Name = string.Empty;

            book.Worksheets.Clear();
            foreach (XmlElement e in rsp.GetElements("Absence"))
            {
                int       sheetIndex = book.Worksheets.Add();
                Worksheet sheet      = book.Worksheets[sheetIndex];
                sheet.Name = e.GetAttribute("Type");

                string schoolName = School.ChineseName;
                Cell   A1         = sheet.Cells["A1"];
                A1.Style.Borders.SetColor(Color.Black);
                A1Name = "扣分累計學生清單(" + e.GetAttribute("Type") + ")";
                A1.PutValue(A1Name);
                A1.Style.HorizontalAlignment = TextAlignmentType.Center;
                sheet.Cells.Merge(0, 0, 1, 5);

                FormatCell(sheet.Cells["A2"], "班級");
                FormatCell(sheet.Cells["B2"], "座號");
                FormatCell(sheet.Cells["C2"], "姓名");
                FormatCell(sheet.Cells["D2"], "學號");
                FormatCell(sheet.Cells["E2"], "累積節次");
                //FormatCell(sheet.Cells["F2"], "累積扣分");

                int index = 3;
                foreach (XmlElement s in e.SelectNodes("Student"))
                {
                    FormatCell(sheet.Cells["A" + index], s.GetAttribute("ClassName"));
                    FormatCell(sheet.Cells["B" + index], s.GetAttribute("SeatNo"));
                    FormatCell(sheet.Cells["C" + index], s.GetAttribute("Name"));
                    FormatCell(sheet.Cells["D" + index], s.GetAttribute("StudentNumber"));
                    FormatCell(sheet.Cells["E" + index], s.GetAttribute("PeriodCount"));
                    //FormatCell(sheet.Cells["F" + index], s.GetAttribute("Subtract"));
                    index++;
                }
            }

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

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

            path = Path.Combine(path, "缺曠累計名單" + ".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 (IOException)
            {
                try
                {
                    FileInfo file         = new FileInfo(path);
                    string   nameTempalte = file.FullName.Replace(file.Extension, "") + "{0}.xls";
                    int      count        = 1;
                    string   fileName     = string.Format(nameTempalte, count);
                    while (File.Exists(fileName))
                    {
                        fileName = string.Format(nameTempalte, count++);
                    }

                    book.Save(fileName);
                    path = fileName;
                }
                catch (Exception ex)
                {
                    MsgBox.Show("檔案儲存失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            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 static void InsertPaperItem(DSXmlHelper request)
 {
     FISCA.Authentication.DSAServices.CallService("SmartSchool.ElectronicPaper.InsertPaperItem", new DSRequest(request));
 }
Example #60
0
        private void _BGWDisciplineNotification_DoWork(object sender, DoWorkEventArgs e)
        {
            #region 表頭
            GetReduceList(); //獎懲對照表

            string reportName = "獎懲通知單";

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

            DateTime     startDate          = (DateTime)args[0];
            DateTime     endDate            = (DateTime)args[1];
            bool         printHasRecordOnly = (bool)args[2];
            MemoryStream templateStream     = (MemoryStream)args[3];
            string       receiveName        = (string)args[4];
            string       receiveAddress     = (string)args[5];
            string       condName           = (string)args[6];
            int          condNumber         = int.Parse((string)args[7]);
            bool         IsInsertDate       = (bool)args[8];
            bool         printStudentList   = (bool)args[9];

            ChengeDemerit(condName, condNumber);

            Dictionary <string, int> MDMapping = new Dictionary <string, int>();
            MDMapping.Add("大功", 0);
            MDMapping.Add("小功", 1);
            MDMapping.Add("嘉獎", 2);
            MDMapping.Add("大過", 3);
            MDMapping.Add("小過", 4);
            MDMapping.Add("警告", 5);

            int flag = 2;
            if (!string.IsNullOrEmpty(condName))
            {
                flag = (MDMapping[condName] < 3) ? 1 : 0;
            }

            MDFilter filter = new MDFilter();
            if (flag < 2)
            {
                filter.SetCondition(MDMapping[condName], condNumber);
            }
            #endregion

            #region 快取資訊

            //學生資訊
            Dictionary <string, Dictionary <string, string> > studentInfo = new Dictionary <string, Dictionary <string, string> >();

            //獎懲累計資料
            Dictionary <string, Dictionary <string, int> > studentDiscipline = new Dictionary <string, Dictionary <string, int> >();

            //獎懲明細
            Dictionary <string, List <string> > studentDisciplineDetail = new Dictionary <string, List <string> >();

            //所有學生ID
            List <string> allStudentID = new List <string>();

            //學生人數
            int currentStudentCount = 1;
            int totalStudentNumber  = 0;

            //獎勵項目
            Dictionary <string, string> meritTable = new Dictionary <string, string>();
            meritTable.Add("大功", "A");
            meritTable.Add("小功", "B");
            meritTable.Add("嘉獎", "C");

            //懲戒項目
            Dictionary <string, string> demeritTable = new Dictionary <string, string>();
            demeritTable.Add("大過", "A");
            demeritTable.Add("小過", "B");
            demeritTable.Add("警告", "C");

            #endregion

            #region 依據 ClassID 建立班級學生清單
            List <StudentRecord>     classStudent = SelectedStudents;
            Dictionary <string, int> StudMeritSum = new Dictionary <string, int>();

            foreach (StudentRecord aStudent in classStudent)
            {
                string aStudentID = aStudent.ID;


                if (!StudMeritSum.ContainsKey(aStudentID))
                {
                    StudMeritSum.Add(aStudentID, 0);
                }

                if (!studentInfo.ContainsKey(aStudentID))
                {
                    studentInfo.Add(aStudentID, new Dictionary <string, string>());
                }

                TeacherRecord objT = aStudent.Class == null ? null : aStudent.Class.Teacher;

                studentInfo[aStudentID].Add("Name", aStudent.Name);
                studentInfo[aStudentID].Add("EnName", aStudent.EnglishName);



                studentInfo[aStudentID].Add("ClassName", aStudent.Class == null ? "" : aStudent.Class.Name);

                if (aStudent.SeatNo.HasValue)
                {
                    studentInfo[aStudentID].Add("SeatNo", aStudent.SeatNo.Value.ToString());
                }
                else
                {
                    studentInfo[aStudentID].Add("SeatNo", "");
                }

                studentInfo[aStudentID].Add("StudentNumber", aStudent.StudentNumber);
                studentInfo[aStudentID].Add("Teacher", objT == null ? "" : objT.Name);

                if (!studentDiscipline.ContainsKey(aStudentID))
                {
                    studentDiscipline.Add(aStudentID, new Dictionary <string, int>());
                }
                if (!studentDisciplineDetail.ContainsKey(aStudentID))
                {
                    studentDisciplineDetail.Add(aStudentID, new List <string>());
                }

                if (!allStudentID.Contains(aStudentID))
                {
                    allStudentID.Add(aStudentID);
                }
            }
            #endregion

            //雙語部 - 英文別名欄位
            //學生ID : 英文別名
            Dictionary <string, string> StudentEXTDic = tool.GetStudentEXT(allStudentID);

            #region 取得獎懲資料 日期區間
            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);
            }

            if (IsInsertDate)
            {
                helper.AddElement("Condition", "StartDate", startDate.ToShortDateString());
                helper.AddElement("Condition", "EndDate", endDate.ToShortDateString());
            }
            else
            {
                helper.AddElement("Condition", "StartRegisterDate", startDate.ToShortDateString());
                helper.AddElement("Condition", "EndRegisterDate", endDate.ToShortDateString());
            }

            helper.AddElement("Order");
            helper.AddElement("Order", "OccurDate", "asc");
            DSResponse dsrsp = tool.GetDiscipline(new DSRequest(helper));

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

                DateTime occurDate     = DateTime.Parse(var.SelectSingleNode("OccurDate").InnerText);
                string   occurMonthDay = occurDate.Month + "/" + occurDate.Day;
                string   reason        = var.SelectSingleNode("Reason").InnerText;

                if (!studentDisciplineDetail.ContainsKey(studentID))
                {
                    studentDisciplineDetail.Add(studentID, new List <string>());
                }

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

                if (var.SelectSingleNode("MeritFlag").InnerText == "1")
                {
                    XmlElement meritElement = (XmlElement)var.SelectSingleNode("Detail/Discipline/Merit");
                    if (meritElement == null)
                    {
                        continue;
                    }

                    if (MeritDemerit == "獎勵")
                    {
                        if (StudMeritSum.ContainsKey(studentID))
                        {
                            StudMeritSum[studentID] += GetMeritType(meritElement);
                        }
                    }

                    bool          comma        = false;
                    StringBuilder detailString = new StringBuilder("");
                    detailString.Append(occurMonthDay + " ");
                    if (!string.IsNullOrEmpty(reason))
                    {
                        detailString.Append(reason + " ");
                    }

                    foreach (string merit in meritTable.Keys)
                    {
                        int tryTimes;
                        int times = int.TryParse(meritElement.GetAttribute(meritTable[merit]), out tryTimes) ? tryTimes : 0;
                        if (times > 0)
                        {
                            if (!studentDiscipline[studentID].ContainsKey("Range" + merit))
                            {
                                studentDiscipline[studentID].Add("Range" + merit, 0);
                            }
                            studentDiscipline[studentID]["Range" + merit] += times;
                            if (comma)
                            {
                                detailString.Append(",");
                            }
                            detailString.Append(merit + times + "次");
                            comma = true;
                        }
                    }

                    studentDisciplineDetail[studentID].Add(detailString.ToString());
                }
                else if (var.SelectSingleNode("MeritFlag").InnerText == "0")
                {
                    XmlElement demeritElement = (XmlElement)var.SelectSingleNode("Detail/Discipline/Demerit");
                    if (demeritElement == null)
                    {
                        continue;
                    }

                    bool cleared = false;
                    if (demeritElement.GetAttribute("Cleared") == "是")
                    {
                        cleared = true;
                    }

                    #region 懲戒比例換算 & 判斷

                    if (cleared == false && MeritDemerit == "懲戒")
                    {
                        if (StudMeritSum.ContainsKey(studentID))
                        {
                            StudMeritSum[studentID] += GetDemeritType(demeritElement);
                        }
                    }

                    #endregion

                    bool          comma        = false;
                    StringBuilder detailString = new StringBuilder("");
                    detailString.Append(occurMonthDay + " ");
                    if (!string.IsNullOrEmpty(reason))
                    {
                        detailString.Append(reason + " ");
                    }

                    foreach (string demerit in demeritTable.Keys)
                    {
                        int tryTimes;
                        int times = int.TryParse(demeritElement.GetAttribute(demeritTable[demerit]), out tryTimes) ? tryTimes : 0;
                        if (times > 0)
                        {
                            if (!studentDiscipline[studentID].ContainsKey("Range" + demerit))
                            {
                                studentDiscipline[studentID].Add("Range" + demerit, 0);
                            }
                            if (!cleared)
                            {
                                studentDiscipline[studentID]["Range" + demerit] += times;
                                if (comma)
                                {
                                    detailString.Append(",");
                                }
                                detailString.Append(demerit + times + "次");
                                comma = true;
                            }
                        }
                    }

                    if (!cleared)
                    {
                        studentDisciplineDetail[studentID].Add(detailString.ToString());
                    }
                }
            }
            #endregion

            #region 取得獎懲資料 學期累計
            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", School.DefaultSchoolYear);
            helper.AddElement("Condition", "Semester", School.DefaultSemester);
            helper.AddElement("Order");
            helper.AddElement("Order", "OccurDate", "asc");
            dsrsp = tool.GetDiscipline(new DSRequest(helper));

            foreach (XmlElement var in dsrsp.GetContent().GetElements("Discipline"))
            {
                DateTime occurDate = DateTime.Parse(var.SelectSingleNode("OccurDate").InnerText);
                if (occurDate.CompareTo(endDate) == 1)
                {
                    continue;
                }

                string studentID = var.SelectSingleNode("RefStudentID").InnerText;

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

                if (var.SelectSingleNode("MeritFlag").InnerText == "1")
                {
                    XmlElement meritElement = (XmlElement)var.SelectSingleNode("Detail/Discipline/Merit");
                    if (meritElement == null)
                    {
                        continue;
                    }

                    foreach (string merit in meritTable.Keys)
                    {
                        int tryTimes;
                        int times = int.TryParse(meritElement.GetAttribute(meritTable[merit]), out tryTimes) ? tryTimes : 0;
                        if (times > 0)
                        {
                            if (!studentDiscipline[studentID].ContainsKey("Semester" + merit))
                            {
                                studentDiscipline[studentID].Add("Semester" + merit, 0);
                            }
                            studentDiscipline[studentID]["Semester" + merit] += times;
                        }
                    }
                }
                else
                {
                    XmlElement demeritElement = (XmlElement)var.SelectSingleNode("Detail/Discipline/Demerit");
                    if (demeritElement == null)
                    {
                        continue;
                    }

                    bool cleared = false;
                    if (demeritElement.GetAttribute("Cleared") == "是")
                    {
                        cleared = true;
                    }

                    foreach (string demerit in demeritTable.Keys)
                    {
                        int tryTimes;
                        int times = int.TryParse(demeritElement.GetAttribute(demeritTable[demerit]), out tryTimes) ? tryTimes : 0;
                        if (times > 0)
                        {
                            if (!studentDiscipline[studentID].ContainsKey("Semester" + demerit))
                            {
                                studentDiscipline[studentID].Add("Semester" + demerit, 0);
                            }
                            if (!cleared)
                            {
                                studentDiscipline[studentID]["Semester" + demerit] += times;
                            }
                        }
                    }
                }
            }
            #endregion

            #region 取得學生通訊地址資料
            List <AddressRecord> AddressList = K12.Data.Address.SelectByStudentIDs(allStudentID);
            foreach (AddressRecord var in AddressList)
            {
                string studentID = var.RefStudentID;

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

                studentInfo[studentID].Add("Address", "");
                studentInfo[studentID].Add("ZipCode", "");
                studentInfo[studentID].Add("ZipCode1", "");
                studentInfo[studentID].Add("ZipCode2", "");
                studentInfo[studentID].Add("ZipCode3", "");
                studentInfo[studentID].Add("ZipCode4", "");
                studentInfo[studentID].Add("ZipCode5", "");

                if (receiveAddress == "聯絡地址")
                {
                    if (!string.IsNullOrEmpty(var.MailingAddress))
                    {
                        studentInfo[studentID]["Address"] = var.MailingCounty + var.MailingTown + var.MailingDistrict + var.MailingArea + var.MailingDetail;
                    }

                    if (!string.IsNullOrEmpty(var.MailingZipCode))
                    {
                        studentInfo[studentID]["ZipCode"] = var.MailingZipCode;

                        if (var.MailingZipCode.Length >= 1)
                        {
                            studentInfo[studentID]["ZipCode1"] = var.MailingZipCode.Substring(0, 1);
                        }
                        if (var.MailingZipCode.Length >= 2)
                        {
                            studentInfo[studentID]["ZipCode2"] = var.MailingZipCode.Substring(1, 1);
                        }
                        if (var.MailingZipCode.Length >= 3)
                        {
                            studentInfo[studentID]["ZipCode3"] = var.MailingZipCode.Substring(2, 1);
                        }
                        if (var.MailingZipCode.Length >= 4)
                        {
                            studentInfo[studentID]["ZipCode4"] = var.MailingZipCode.Substring(3, 1);
                        }
                        if (var.MailingZipCode.Length >= 5)
                        {
                            studentInfo[studentID]["ZipCode5"] = var.MailingZipCode.Substring(4, 1);
                        }
                    }
                }
                else if (receiveAddress == "其他地址")
                {
                    if (!string.IsNullOrEmpty(var.Address1Address))
                    {
                        studentInfo[studentID]["Address"] = var.Address1County + var.Address1Town + var.Address1District + var.Address1Area + var.Address1Detail;
                    }

                    if (!string.IsNullOrEmpty(var.Address1ZipCode))
                    {
                        studentInfo[studentID]["ZipCode"] = var.Address1ZipCode;

                        if (var.Address1ZipCode.Length >= 1)
                        {
                            studentInfo[studentID]["ZipCode1"] = var.Address1ZipCode.Substring(0, 1);
                        }
                        if (var.Address1ZipCode.Length >= 2)
                        {
                            studentInfo[studentID]["ZipCode2"] = var.Address1ZipCode.Substring(1, 1);
                        }
                        if (var.Address1ZipCode.Length >= 3)
                        {
                            studentInfo[studentID]["ZipCode3"] = var.Address1ZipCode.Substring(2, 1);
                        }
                        if (var.Address1ZipCode.Length >= 4)
                        {
                            studentInfo[studentID]["ZipCode4"] = var.Address1ZipCode.Substring(3, 1);
                        }
                        if (var.Address1ZipCode.Length >= 5)
                        {
                            studentInfo[studentID]["ZipCode5"] = var.Address1ZipCode.Substring(4, 1);
                        }
                    }
                }
                else //戶籍地址
                {
                    if (!string.IsNullOrEmpty(var.PermanentAddress))
                    {
                        studentInfo[studentID]["Address"] = var.PermanentCounty + var.PermanentTown + var.PermanentDistrict + var.PermanentArea + var.PermanentDetail;
                    }

                    if (!string.IsNullOrEmpty(var.PermanentZipCode))
                    {
                        studentInfo[studentID]["ZipCode"] = var.PermanentZipCode;

                        if (var.PermanentZipCode.Length >= 1)
                        {
                            studentInfo[studentID]["ZipCode1"] = var.PermanentZipCode.Substring(0, 1);
                        }
                        if (var.PermanentZipCode.Length >= 2)
                        {
                            studentInfo[studentID]["ZipCode2"] = var.PermanentZipCode.Substring(1, 1);
                        }
                        if (var.PermanentZipCode.Length >= 3)
                        {
                            studentInfo[studentID]["ZipCode3"] = var.PermanentZipCode.Substring(2, 1);
                        }
                        if (var.PermanentZipCode.Length >= 4)
                        {
                            studentInfo[studentID]["ZipCode4"] = var.PermanentZipCode.Substring(3, 1);
                        }
                        if (var.PermanentZipCode.Length >= 5)
                        {
                            studentInfo[studentID]["ZipCode5"] = var.PermanentZipCode.Substring(4, 1);
                        }
                    }
                }
            }
            #endregion

            #region 取得學生監護人父母親資料
            dsrsp = tool.GetMultiParentInfo(allStudentID.ToArray());
            foreach (XmlElement var in dsrsp.GetContent().GetElements("ParentInfo"))
            {
                string studentID = var.GetAttribute("StudentID");

                studentInfo[studentID].Add("CustodianName", var.SelectSingleNode("CustodianName").InnerText);
                studentInfo[studentID].Add("FatherName", var.SelectSingleNode("FatherName").InnerText);
                studentInfo[studentID].Add("MotherName", var.SelectSingleNode("MotherName").InnerText);
            }
            #endregion

            #region 產生報表

            Aspose.Words.Document template = new Aspose.Words.Document(templateStream, "", Aspose.Words.LoadFormat.Doc, "");
            template.MailMerge.Execute(
                new string[] { "學校名稱", "學校地址", "學校電話", "學校英文名稱" },
                new object[] { School.ChineseName, School.Address, School.Telephone, School.EnglishName }
                );

            Aspose.Words.Document doc = new Aspose.Words.Document();
            doc.RemoveAllChildren();

            Aspose.Words.Node sectionNode = template.Sections[0].Clone();

            totalStudentNumber = studentDiscipline.Count;

            foreach (string student in studentDiscipline.Keys)
            {
                if (printHasRecordOnly)
                {
                    if (studentDisciplineDetail[student].Count == 0)
                    {
                        continue;
                    }
                }

                if (MeritDemerit == "獎勵")
                {
                    if (StudMeritSum[student] < MaxMerit)
                    {
                        continue;
                    }
                }
                else if (MeritDemerit == "懲戒")
                {
                    if (StudMeritSum[student] < MaxDemerit)
                    {
                        continue;
                    }
                }
                else //未設定
                {
                }

                #region 過濾不需要列印的學生

                if (flag < 2)
                {
                    int A = 0, B = 0, C = 0;

                    if (flag == 1)
                    {
                        int tryM;
                        A = studentDiscipline[student].TryGetValue("Range大功", out tryM) ? tryM : 0;
                        B = studentDiscipline[student].TryGetValue("Range小功", out tryM) ? tryM : 0;
                        C = studentDiscipline[student].TryGetValue("Range嘉獎", out tryM) ? tryM : 0;
                    }
                    else if (flag == 0)
                    {
                        int tryD;
                        A = studentDiscipline[student].TryGetValue("Range大過", out tryD) ? tryD : 0;
                        B = studentDiscipline[student].TryGetValue("Range小過", out tryD) ? tryD : 0;
                        C = studentDiscipline[student].TryGetValue("Range警告", out tryD) ? tryD : 0;
                    }

                    //if (filter.IsFilter(A, B, C))
                    //    continue;
                }

                #endregion

                Aspose.Words.Document eachDoc = new Aspose.Words.Document();
                eachDoc.RemoveAllChildren();
                eachDoc.Sections.Add(eachDoc.ImportNode(sectionNode, true));

                //合併列印的資料
                Dictionary <string, object> mapping = new Dictionary <string, object>();

                Dictionary <string, string> eachStudentInfo = studentInfo[student];

                XmlElement SchoolXml  = K12.Data.School.Configuration["學校資訊"].PreviousData;
                XmlElement SchoolXml2 = (XmlElement)SchoolXml.SelectSingleNode("EnglishAddress");
                if (SchoolXml2 != null)
                {
                    mapping.Add("學校英文地址", SchoolXml2.InnerText);
                }
                else
                {
                    mapping.Add("學校英文地址", "");
                }

                //學生資料
                mapping.Add("學生姓名", eachStudentInfo["Name"]);
                mapping.Add("英文姓名", eachStudentInfo["EnName"]);
                mapping.Add("班級", eachStudentInfo["ClassName"]);
                mapping.Add("座號", eachStudentInfo["SeatNo"]);
                mapping.Add("學號", eachStudentInfo["StudentNumber"]);
                mapping.Add("導師", eachStudentInfo["Teacher"]);
                mapping.Add("資料期間", startDate.ToShortDateString() + " 至 " + endDate.ToShortDateString());

                //收件人資料
                if (receiveName == "監護人姓名")
                {
                    mapping.Add("收件人姓名", eachStudentInfo["CustodianName"]);
                }
                else if (receiveName == "父親姓名")
                {
                    mapping.Add("收件人姓名", eachStudentInfo["FatherName"]);
                }
                else if (receiveName == "母親姓名")
                {
                    mapping.Add("收件人姓名", eachStudentInfo["MotherName"]);
                }
                else
                {
                    mapping.Add("收件人姓名", eachStudentInfo["Name"]);
                }

                //收件人地址資料
                mapping.Add("收件人地址", eachStudentInfo["Address"]);
                mapping.Add("郵遞區號", eachStudentInfo["ZipCode"]);
                mapping.Add("0", eachStudentInfo["ZipCode1"]);
                mapping.Add("1", eachStudentInfo["ZipCode2"]);
                mapping.Add("2", eachStudentInfo["ZipCode3"]);
                mapping.Add("4", eachStudentInfo["ZipCode4"]);
                mapping.Add("5", eachStudentInfo["ZipCode5"]);

                if (StudentEXTDic.ContainsKey(student))
                {
                    mapping.Add("英文別名", StudentEXTDic[student]);
                }
                else
                {
                    mapping.Add("英文別名", "");
                }

                mapping.Add("學年度", tool.GetSchoolChange(School.DefaultSchoolYear));
                mapping.Add("學期", School.DefaultSemester);

                Dictionary <string, int> eachStudentDiscipline = studentDiscipline[student];

                //學生獎懲累計資料
                int count;
                mapping.Add("學期累計大功", eachStudentDiscipline.TryGetValue("Semester大功", out count) ? "" + count : "0");
                mapping.Add("學期累計小功", eachStudentDiscipline.TryGetValue("Semester小功", out count) ? "" + count : "0");
                mapping.Add("學期累計嘉獎", eachStudentDiscipline.TryGetValue("Semester嘉獎", out count) ? "" + count : "0");
                mapping.Add("學期累計大過", eachStudentDiscipline.TryGetValue("Semester大過", out count) ? "" + count : "0");
                mapping.Add("學期累計小過", eachStudentDiscipline.TryGetValue("Semester小過", out count) ? "" + count : "0");
                mapping.Add("學期累計警告", eachStudentDiscipline.TryGetValue("Semester警告", out count) ? "" + count : "0");
                mapping.Add("本期累計大功", eachStudentDiscipline.TryGetValue("Range大功", out count) ? "" + count : "0");
                mapping.Add("本期累計小功", eachStudentDiscipline.TryGetValue("Range小功", out count) ? "" + count : "0");
                mapping.Add("本期累計嘉獎", eachStudentDiscipline.TryGetValue("Range嘉獎", out count) ? "" + count : "0");
                mapping.Add("本期累計大過", eachStudentDiscipline.TryGetValue("Range大過", out count) ? "" + count : "0");
                mapping.Add("本期累計小過", eachStudentDiscipline.TryGetValue("Range小過", out count) ? "" + count : "0");
                mapping.Add("本期累計警告", eachStudentDiscipline.TryGetValue("Range警告", out count) ? "" + count : "0");

                //獎懲明細
                object[] objectValues = new object[] { studentDisciplineDetail[student] };
                mapping.Add("獎懲明細", objectValues);

                string[] keys   = new string[mapping.Count];
                object[] values = new object[mapping.Count];
                int      i      = 0;
                foreach (string key in mapping.Keys)
                {
                    keys[i]     = key;
                    values[i++] = mapping[key];
                }

                //合併列印
                eachDoc.MailMerge.MergeField           += new Aspose.Words.Reporting.MergeFieldEventHandler(DisciplineNotification_MailMerge_MergeField);
                eachDoc.MailMerge.RemoveEmptyParagraphs = true;
                eachDoc.MailMerge.Execute(keys, values);

                Aspose.Words.Node eachSectionNode = eachDoc.Sections[0].Clone();
                doc.Sections.Add(doc.ImportNode(eachSectionNode, true));

                //回報進度
                _BGWDisciplineNotification.ReportProgress((int)(((double)currentStudentCount++ *100.0) / (double)totalStudentNumber));
            }

            #endregion

            #region 產生學生清單

            Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
            if (printStudentList)
            {
                if (printHasRecordOnly)
                {
                    int CountRow = 0;
                    wb.Worksheets[0].Cells[CountRow, 0].PutValue("班級");
                    wb.Worksheets[0].Cells[CountRow, 1].PutValue("座號");
                    wb.Worksheets[0].Cells[CountRow, 2].PutValue("學號");
                    wb.Worksheets[0].Cells[CountRow, 3].PutValue("學生姓名");
                    wb.Worksheets[0].Cells[CountRow, 4].PutValue("英文姓名");
                    wb.Worksheets[0].Cells[CountRow, 5].PutValue("英文別名");
                    wb.Worksheets[0].Cells[CountRow, 6].PutValue("收件人姓名");
                    wb.Worksheets[0].Cells[CountRow, 7].PutValue("地址");
                    CountRow++;
                    foreach (string each in studentInfo.Keys)
                    {
                        if (studentDisciplineDetail[each].Count == 0)
                        {
                            continue;
                        }

                        if (MeritDemerit == "獎勵")
                        {
                            if (StudMeritSum[each] < MaxMerit)
                            {
                                continue;
                            }
                        }
                        else if (MeritDemerit == "懲戒")
                        {
                            if (StudMeritSum[each] < MaxDemerit)
                            {
                                continue;
                            }
                        }
                        else //未設定
                        {
                        }

                        wb.Worksheets[0].Cells[CountRow, 0].PutValue(studentInfo[each]["ClassName"]);
                        wb.Worksheets[0].Cells[CountRow, 1].PutValue(studentInfo[each]["SeatNo"]);
                        wb.Worksheets[0].Cells[CountRow, 2].PutValue(studentInfo[each]["StudentNumber"]);
                        wb.Worksheets[0].Cells[CountRow, 3].PutValue(studentInfo[each]["Name"]);
                        wb.Worksheets[0].Cells[CountRow, 4].PutValue(studentInfo[each]["EnName"]);
                        wb.Worksheets[0].Cells[CountRow, 5].PutValue(studentInfo[each]["ExName"]);
                        //收件人資料
                        if (receiveName == "監護人姓名")
                        {
                            wb.Worksheets[0].Cells[CountRow, 6].PutValue(studentInfo[each]["CustodianName"]);
                        }
                        else if (receiveName == "父親姓名")
                        {
                            wb.Worksheets[0].Cells[CountRow, 6].PutValue(studentInfo[each]["FatherName"]);
                        }
                        else if (receiveName == "母親姓名")
                        {
                            wb.Worksheets[0].Cells[CountRow, 6].PutValue(studentInfo[each]["MotherName"]);
                        }
                        else
                        {
                            wb.Worksheets[0].Cells[CountRow, 6].PutValue(studentInfo[each]["Name"]);
                        }

                        wb.Worksheets[0].Cells[CountRow, 7].PutValue(studentInfo[each]["ZipCode"] + " " + studentInfo[each]["Address"]);
                        CountRow++;
                    }
                    wb.Worksheets[0].AutoFitColumns();
                }
            }
            #endregion

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

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path     = Path.Combine(path, reportName + ".doc");
            path2    = Path.Combine(path2, reportName + "(學生清單).xls");
            e.Result = new object[] { reportName, path, doc, path2, printStudentList, wb };
        }