/// <summary>
        /// 取得各校之相關基本資料(社團/學生)
        /// </summary>
        public Dictionary <string, AcrossRecord> SchoolClubDetail(List <LoginSchool> LoginSchoolList)
        {
            Dictionary <string, AcrossRecord> AcrossDic = new Dictionary <string, AcrossRecord>();

            foreach (LoginSchool login in LoginSchoolList)
            {
                Connection me = new Connection();
                me.Connect(login.School_Name, tool._contract, FISCA.Authentication.DSAServices.PassportToken);
                me = me.AsContract(tool._contract);

                //取得 - 學年度/學期
                //目前系統中有參與記錄的學生 & 是否鎖定
                Dictionary <string, OnlineSCJoin> StudentSCJoinDic = RunService.GetSCJoinStudent(me, _SchoolYear.ToString(), _Semester.ToString());

                AcrossRecord ar = new AcrossRecord();
                ar.School       = login.School_Name;
                ar.SchoolRemake = login.Remark;

                //取得可選社之學生
                //年級/班級/座號/姓名/科別
                //StudentSCJoinDic - 是否有社團參與記錄
                //StudentPresidentDic - 是否有'前期'社長副/社長記錄
                ar.StudentDic = GetStuentList(me, StudentSCJoinDic);

                //取得預設(學年度,學期)學校之社團記錄
                ar.ClubDic = RunService.GetClubList(me, _SchoolYear.ToString(), _Semester.ToString());

                if (!AcrossDic.ContainsKey(login.School_Name))
                {
                    AcrossDic.Add(login.School_Name, ar);
                }
            }

            return(AcrossDic);
        }
예제 #2
0
        /// <summary>
        /// 取得各校之相關基本資料(社團/學生/志願序)
        /// </summary>
        static public Dictionary <string, AcrossRecord> SchoolClubDetail(List <LoginSchool> LoginSchoolList)
        {
            Dictionary <string, AcrossRecord> AcrossDic = new Dictionary <string, AcrossRecord>();

            if (FISCA.Authentication.DSAServices.PassportToken != null)
            {
                foreach (LoginSchool login in LoginSchoolList)
                {
                    Connection me = new Connection();
                    me.Connect(login.School_Name, _contract, FISCA.Authentication.DSAServices.PassportToken);
                    me = me.AsContract(_contract);

                    //取得本學年度/學期
                    //目前系統中有參與記錄的學生 & 是否鎖定
                    Dictionary <string, OnlineSCJoin> StudentSCJoinDic = RunService.GetDefSCJoinStudent(me);

                    //取得指定學年度學期的社長副社長清單
                    Dictionary <string, OnlinePresident> StudentPresidentDic = RunService.GetDefPresident(me);

                    AcrossRecord ar = new AcrossRecord();
                    ar.School       = login.School_Name;
                    ar.SchoolRemake = login.Remark;

                    //取得可選社之學生
                    //年級/班級/座號/姓名/科別
                    //StudentSCJoinDic - 是否有社團參與記錄
                    //StudentPresidentDic - 是否有'前期'社長副/社長記錄
                    ar.StudentDic = RunService.GetStuentList(me, StudentSCJoinDic, StudentPresidentDic);

                    //取得預設(學年度,學期)學校之社團記錄
                    ar.ClubDic = RunService.GetDefClubList(me);

                    //取得學生之選填志願內容
                    ar.VolunteerList = RunService.GetDefVolunteer(me, login);

                    if (!AcrossDic.ContainsKey(login.School_Name))
                    {
                        AcrossDic.Add(login.School_Name, ar);
                    }
                }
            }

            return(AcrossDic);
        }
        /// <summary>
        /// 取得學生清單
        /// </summary>
        public Dictionary <string, OnlineStudent> GetStuentList(Connection me, Dictionary <string, OnlineSCJoin> SCJoinDic)
        {
            Envelope rsp      = me.SendRequest("_.GetStudentsCanChoose", new Envelope(RunService.GetRequest(null, null)));
            XElement students = XElement.Parse(rsp.Body.XmlString);

            Dictionary <string, OnlineStudent> StudentDic = new Dictionary <string, OnlineStudent>();

            foreach (XElement stud in students.Elements("Student"))
            {
                OnlineStudent os = new OnlineStudent(stud);
                os.School = me.AccessPoint.Name;

                if (!StudentDic.ContainsKey(os.Id))
                {
                    StudentDic.Add(os.Id, os);
                }

                //是否有社團參與記錄
                if (SCJoinDic.ContainsKey(os.Id))
                {
                    os.原有社團 = SCJoinDic[os.Id];
                }
            }
            return(StudentDic);
        }
예제 #4
0
        public ExportAcrossClubStudent(string sy, string s)
        {
            Workbook         wb  = new Workbook();
            Exception        exc = null;
            BackgroundWorker bgw = new BackgroundWorker()
            {
                WorkerReportsProgress = true
            };

            bgw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
            {
                MotherForm.SetStatusBarMessage("匯出選社結果(跨部別)", e.ProgressPercentage);
            };
            bgw.DoWork += delegate
            {
                try
                {
                    #region 跨部別
                    {
                        bgw.ReportProgress(1);
                        AccessHelper access = new AccessHelper();
                        loginSchoolList = access.Select <LoginSchool>();
                        //DIC
                        Dictionary <string, OnlineVolunteer> volunteerDic = new Dictionary <string, OnlineVolunteer>();
                        Dictionary <string, OnlineSCJoin>    scjoinDic    = new Dictionary <string, OnlineSCJoin>();
                        Dictionary <string, string>          clubNameDic  = new Dictionary <string, string>();
                        //--
                        wb.Open(new MemoryStream(Properties.Resources.匯出選社結果_跨部別__範本), FileFormatType.Excel2007Xlsx);

                        Worksheet[] ws    = new Worksheet[2];
                        int         sheet = 0;
                        int         p     = 10;
                        foreach (LoginSchool school in loginSchoolList)
                        {
                            p = p + 90 / loginSchoolList.Count;
                            bgw.ReportProgress(p);
                            ws[sheet] = wb.Worksheets[sheet];

                            Connection connection = new Connection();
                            connection.Connect(school.School_Name, "ClubAcrossdivisions", FISCA.Authentication.DSAServices.PassportToken);
                            ws[sheet].Name = school.GetFullName();

                            // 取得社團清單
                            Envelope        rsp      = connection.SendRequest("_.GetClubList", new Envelope(RunService.GetRequest(sy, s)));
                            XDocument       clubDoc  = XDocument.Parse(rsp.Body.XmlString);
                            List <XElement> clubList = clubDoc.Element("Response").Elements("K12.clubrecord.universal").ToList();
                            foreach (XElement club in clubList)
                            {
                                clubNameDic.Add(club.Element("Uid").Value, club.Element("ClubName").Value);
                            }
                            // 取得學生志願序
                            volunteerDic.Clear();
                            rsp = connection.SendRequest("_.GetStudentVolunteer", new Envelope(RunService.GetRequest(sy, s)));
                            XDocument       volunteerDoc = XDocument.Parse(rsp.Body.XmlString);
                            List <XElement> volunteers   = volunteerDoc.Element("Response").Elements("K12.volunteer.universal").ToList();
                            foreach (XElement volunteer in volunteers)
                            {
                                OnlineVolunteer vol = new OnlineVolunteer(volunteer);

                                volunteerDic.Add(vol.RefStudentId, vol);
                            }

                            // 取得學生入選紀錄
                            scjoinDic.Clear();
                            rsp = connection.SendRequest("_.GetStudentSCJoin", new Envelope(RunService.GetRequest(sy, s)));
                            XDocument       scjDoc  = XDocument.Parse(rsp.Body.XmlString);
                            List <XElement> scjoins = scjDoc.Element("Response").Elements("Student").ToList();
                            foreach (XElement scjoin in scjoins)
                            {
                                OnlineSCJoin scj = new OnlineSCJoin(scjoin);
                                scjoinDic.Add(scj.StudentId, scj);
                            }

                            // 讀取志願數上限設定
                            List <ConfigRecord> crList = access.Select <K12.Club.Volunteer.ConfigRecord>();
                            for (int i = 6; i < int.Parse(crList[0].Content) + 6; i++)
                            {
                                ws[sheet].Cells.CopyColumn(ws[sheet].Cells, 4, i);
                                ws[sheet].Cells[0, i].PutValue("志願" + (i - 5));
                            }

                            // 取得所有學生
                            rsp = connection.SendRequest("_.GetAllStudent", new Envelope(RunService.GetRequest(sy, s)));
                            XDocument       allStudentDoc = XDocument.Parse(rsp.Body.XmlString);
                            List <XElement> students      = allStudentDoc.Element("Response").Elements("Student").ToList();

                            int index = 1;
                            foreach (XElement student in students)
                            {
                                if (scjoinDic.ContainsKey(student.Element("Id").Value))
                                {
                                    ws[sheet].Cells.CopyRow(ws[sheet].Cells, 1, index);
                                    ws[sheet].Cells[index, 0].PutValue(student.Element("ClassName").Value);
                                    ws[sheet].Cells[index, 1].PutValue(student.Element("SeatNo").Value);
                                    ws[sheet].Cells[index, 2].PutValue(student.Element("Name").Value);
                                    ws[sheet].Cells[index, 3].PutValue(student.Element("StudentNumber").Value);
                                    ws[sheet].Cells[index, 4].PutValue(scjoinDic[student.Element("Id").Value].ClubName);
                                    ws[sheet].Cells[index, 5].PutValue(scjoinDic[student.Element("Id").Value].IsLock == true ? "是" : "");

                                    List <XElement> club = XDocument.Parse(volunteerDic[student.Element("Id").Value].Content).Element("xml").Elements("Club").ToList();
                                    int             i    = 1;
                                    // 取得志願數設定
                                    int clubCount = int.Parse("" + crList[0].Content);
                                    foreach (XElement clubID in club)
                                    {
                                        ws[sheet].Cells[index, 5 + i].PutValue(clubNameDic[clubID.Attribute("Ref_Club_ID").Value]);
                                        if (i == clubCount)
                                        {
                                            break;
                                        }
                                        i++;
                                    }
                                    index++;
                                }
                            }
                            sheet++;
                        }
                    }
                    #endregion

                    #region
                    {
//                        bgw.ReportProgress(51);
//                        AccessHelper access = new AccessHelper();
//                        List<CLUBRecord> _clubList = access.Select<CLUBRecord>(/*"school_year = "+School.DefaultSchoolYear+" AND semester = "+ School.DefaultSemester*/).ToList();
//                        foreach (CLUBRecord club in _clubList)
//                        {
//                            clubDic.Add(club.UID, club.ClubName);
//                        }
//                        //取得Sheet
//                        Worksheet ws = wb.Worksheets[0];
//                        ws.Name = School.ChineseName;
//                        QueryHelper qh = new QueryHelper();

//                        #region SQL
//                        string selectSQL = string.Format(@"
//SELECT
//	student.id
//    , class.class_name
//    , class.grade_year
//    , seat_no,name
//    , student_number
//    , student.ref_class_id
//    , scjoin.ref_club_id
//    , scjoin.lock
//    , clubrecord.club_name
//    , clubrecord.school_year
//    , clubrecord.semester
//    , volunteer.content
//    , $k12.config.universal.content as wish_limit
//FROM
//    student
//    LEFT OUTER JOIN class on class.id = student.ref_class_id
//    LEFT OUTER JOIN $k12.scjoin.universal AS scjoin
//        ON scjoin.ref_student_id::bigint = student.id
//    LEFT OUTER JOIN $k12.clubrecord.universal AS clubrecord
//        ON clubrecord.uid = scjoin.ref_club_id::bigint
//    LEFT OUTER JOIN $k12.volunteer.universal AS volunteer
//        ON volunteer.ref_student_id::bigint = student.id
//            AND volunteer.school_year = clubrecord.school_year
//            AND volunteer.semester = clubrecord.semester
//    LEFT OUTER JOIN $k12.config.universal ON config_name = '學生選填志願數'
//WHERE
//    student.status in (1, 2)
//    AND clubrecord.school_year = {0}
//    AND clubrecord.semester = {1}
//ORDER BY
//    class.grade_year
//    , class.display_order
//    , class.class_name
//    , student.seat_no
//    , student.id"
//                        , sy, s);
//                        #endregion

//                        // 取得學生社團資料
//                        DataTable dt = qh.Select(selectSQL);

//                        bgw.ReportProgress(55);
//                        int index = 1;
//                        foreach (DataRow dr in dt.Rows)
//                        {
//                            bgw.ReportProgress(55 + 45 * index / dt.Rows.Count);
//                            int wishLimit = (dr["wish_limit"] == null ? 5 : int.Parse("" + dr["wish_limit"]));
//                            if (index == 1)
//                            {
//                                int count = 6;
//                                int countLimit = count + wishLimit;
//                                for (int i = count; i < countLimit; i++)
//                                {
//                                    ws.Cells.CopyColumn(ws.Cells, 4, i);
//                                    ws.Cells[0, i].PutValue("志願" + (i - 5));
//                                }
//                            }
//                            else
//                                ws.Cells.CopyRow(ws.Cells, 1, index);

//                            ws.Cells[index, 0].PutValue("" + dr["class_name"]);
//                            ws.Cells[index, 1].PutValue("" + dr["seat_no"]);
//                            ws.Cells[index, 2].PutValue("" + dr["name"]);
//                            ws.Cells[index, 3].PutValue("" + dr["student_number"]);
//                            ws.Cells[index, 4].PutValue("" + dr["club_name"]);
//                            ws.Cells[index, 5].PutValue(("" + dr["lock"]) == "true" ? "是" : "");

//                            // 學生志願序
//                            if (dr["content"] != null && "" + dr["content"] != "")
//                            {
//                                XDocument content = XDocument.Parse("" + dr["content"]);
//                                List<XElement> clubList = content.Element("xml").Elements("Club").ToList();
//                                int count = 6;
//                                int countLimit = count + wishLimit - 1;
//                                foreach (XElement club in clubList)
//                                {
//                                    ws.Cells[index, count].PutValue(clubDic[club.Attribute("Ref_Club_ID").Value]);
//                                    count++;
//                                    if (count > countLimit)
//                                        break;
//                                }
//                            }
//                            index++;
//                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    exc = ex;
                }
            };

            bgw.RunWorkerCompleted += delegate
            {
                if (exc == null)
                {
                    #region Excel 存檔
                    {
                        SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
                        SaveFileDialog1.Filter   = "Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*";
                        SaveFileDialog1.FileName = "匯出選社結果(跨部別)";
                        try
                        {
                            if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                wb.Save(SaveFileDialog1.FileName);
                                Process.Start(SaveFileDialog1.FileName);
                                MotherForm.SetStatusBarMessage("匯出選社結果(跨部別),列印完成!!");
                            }
                            else
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存");
                                return;
                            }
                        }
                        catch
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!");
                            MotherForm.SetStatusBarMessage("檔案儲存錯誤,請檢查檔案是否開啟中!!");
                        }
                    }
                    #endregion
                }
                else
                {
                    throw new Exception("匯出選社結果 發生錯誤", exc);
                }
            };

            bgw.RunWorkerAsync();
        }
예제 #5
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //開始列印學生清單
            #region 資料整理

            //取得需連線學校
            LoginSchoolList = tool._A.Select <LoginSchool>();

            // 取得社團老師資料 key : DSNS
            Dictionary <string, ClubTeacher> clubTeacherDic = new Dictionary <string, ClubTeacher>();

            // 2018/01/23 羿均 新增 取得學校相關資料
            SchoolClubDic = tool.SchoolClubDetail(LoginSchoolList);

            foreach (AcrossRecord Across in SchoolClubDic.Values)
            {
                foreach (OnlineClub club in Across.ClubDic.Values)
                {
                    if (!Mergerdic.ContainsKey(club.ClubName))
                    {
                        OnlineMergerClub Mclub = new OnlineMergerClub(tool.Point);
                        Mergerdic.Add(club.ClubName, Mclub);
                        Mclub.AddClub(club);
                    }
                    Mergerdic[club.ClubName].AddClub(club);
                }
            }

            //選擇了哪些社團(使用名稱進行比對)
            List <string>     ClubIDList     = K12.Club.Volunteer.ClubAdmin.Instance.SelectedSource;
            List <CLUBRecord> ClubRecordList = tool._A.Select <CLUBRecord>(ClubIDList);

            //社團名稱清單
            List <string> ClubNameList = new List <string>();
            foreach (CLUBRecord club in ClubRecordList)
            {
                ClubNameList.Add(club.ClubName);
            }

            //社團名稱 + 社團參與記錄學生
            Dictionary <string, List <OnlineSCJoin> > dic = new Dictionary <string, List <OnlineSCJoin> >();
            List <string> ClubNewNameList = new List <string>();
            foreach (LoginSchool school in LoginSchoolList)
            {
                schoolMark = school.Remark;
                Connection me = new Connection();
                me.Connect(school.School_Name, tool._contract, FISCA.Authentication.DSAServices.PassportToken);
                Dictionary <string, OnlineSCJoin> ScjList = RunService.GetSCJoinByClubName(me, ClubNameList);

                foreach (OnlineSCJoin each in ScjList.Values)
                {
                    // 2018/01/24 羿均 紀錄:主要連線學校社團老師
                    if (school.School_Name == tool.Point)
                    {
                        if (!clubTeacherDic.ContainsKey(school.School_Name))
                        {
                            ClubTeacher ct = new ClubTeacher();
                            ct.SchoolName = school.School_Name;
                            ct.Teacher1   = each.TeacherName;
                            ct.Teacher2   = each.TeacherName2;
                            ct.Teacher3   = each.TeacherName3;

                            clubTeacherDic.Add(school.School_Name, ct);
                        }
                    }

                    string name = each.ClubName;
                    if (!dic.ContainsKey(name))
                    {
                        dic.Add(name, new List <OnlineSCJoin>());
                        ClubNewNameList.Add(name);
                    }
                    // 2018/01/23 羿均 新增部別欄位
                    each.SchoolReMark = school.Remark;

                    dic[name].Add(each);
                }
            }

            ClubNewNameList.Sort();

            #endregion

            #region 報表範本整理

            Campus.Report.ReportConfiguration ConfigurationInCadre = new Campus.Report.ReportConfiguration(ConfigName);
            Aspose.Words.Document             Template;

            if (ConfigurationInCadre.Template == null)
            {
                //如果範本為空,則建立一個預設範本
                Campus.Report.ReportConfiguration ConfigurationInCadre_1 = new Campus.Report.ReportConfiguration(ConfigName);
                ConfigurationInCadre_1.Template = new Campus.Report.ReportTemplate(Properties.Resources.社團點名單_週報表樣式範本, Campus.Report.TemplateType.Word);
                Template = ConfigurationInCadre_1.Template.ToDocument();
            }
            else
            {
                //如果已有範本,則取得樣板
                Template = ConfigurationInCadre.Template.ToDocument();
            }

            #endregion

            #region 範本再修改

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

            XmlElement day = (XmlElement)e.Argument;

            if (day == null)
            {
                MsgBox.Show("第一次使用報表請先進行[日期設定]");
                return;
            }
            else
            {
                config.Clear();
                foreach (XmlElement xml in day.SelectNodes("item"))
                {
                    config.Add(xml.InnerText);
                }
            }


            SCJoinDataLoad scjoinData = new SCJoinDataLoad();

            DataTable table = new DataTable();
            table.Columns.Add("學校名稱");
            table.Columns.Add("社團名稱");
            table.Columns.Add("學年度");
            table.Columns.Add("學期");

            table.Columns.Add("上課地點");
            table.Columns.Add("社團類型");
            table.Columns.Add("社團代碼");
            //table.Columns.Add("社團老師");
            table.Columns.Add("社團老師1");
            table.Columns.Add("社團老師2");
            table.Columns.Add("社團老師3");

            table.Columns.Add("列印日期");
            table.Columns.Add("上課開始");
            table.Columns.Add("上課結束");
            table.Columns.Add("人數");

            for (int x = 1; x <= 日期多少天; x++)
            {
                table.Columns.Add(string.Format("日期_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("社團_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("部別名稱_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("班級_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("座號_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("姓名_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("學號_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("性別_{0}", x));
            }

            #endregion

            foreach (string each in scjoinData.CLUBRecordDic.Keys)
            {
                //社團資料
                CLUBRecord cr = scjoinData.CLUBRecordDic[each];
            }

            foreach (string each in ClubNewNameList)
            {
                DataRow row = table.NewRow();

                row["學校名稱"] = K12.Data.School.ChineseName;
                row["學年度"]  = School.DefaultSchoolYear;
                row["學期"]   = School.DefaultSemester;

                row["列印日期"] = DateTime.Today.ToShortDateString();
                row["上課開始"] = config[0];
                row["上課結束"] = config[config.Count - 1];
                row["社團名稱"] = each;
                // 2018/01/23 羿均 新增合併欄位:
                row["上課地點"] = Mergerdic[each].Location;
                row["社團類型"] = Mergerdic[each].ClubCategory;
                row["社團代碼"] = Mergerdic[each].ClubNumber;

                row["社團老師1"] = clubTeacherDic[tool.Point].Teacher1;
                row["社團老師2"] = clubTeacherDic[tool.Point].Teacher2;
                row["社團老師3"] = clubTeacherDic[tool.Point].Teacher3;
                //特殊
                //if (dic[each].Count > 0)
                //row["社團老師"] = dic[each][0].TeacherName;

                for (int x = 1; x <= config.Count; x++)
                {
                    row[string.Format("日期_{0}", x)] = config[x - 1];
                }

                dic[each].Sort(SortStudentSCJoin);
                int y = 1;
                foreach (OnlineSCJoin scjoin in dic[each])
                {
                    if (y <= 學生多少個)
                    {
                        row[string.Format("部別名稱_{0}", y)] = scjoin.SchoolReMark;
                        row[string.Format("班級_{0}", y)]   = scjoin.ClassName;
                        row[string.Format("座號_{0}", y)]   = scjoin.SeatNo;
                        row[string.Format("姓名_{0}", y)]   = scjoin.StudentName;
                        row[string.Format("學號_{0}", y)]   = scjoin.StudentNumber;
                        row[string.Format("性別_{0}", y)]   = scjoin.Gender;
                        y++;
                    }
                }

                row["人數"] = y - 1;
                table.Rows.Add(row);
            }

            Document PageOne = (Document)Template.Clone(true);
            PageOne.MailMerge.Execute(table);
            e.Result = PageOne;
        }
예제 #6
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //開始列印學生清單


            #region 資料整理

            //取得需連線學校
            LoginSchoolList = tool._A.Select <LoginSchool>();

            //選擇了哪些社團(使用名稱進行比對)
            List <string>     ClubIDList     = K12.Club.Volunteer.ClubAdmin.Instance.SelectedSource;
            List <CLUBRecord> ClubRecordList = tool._A.Select <CLUBRecord>(ClubIDList);

            //社團名稱清單
            List <string> ClubNameList = new List <string>();
            foreach (CLUBRecord club in ClubRecordList)
            {
                ClubNameList.Add(club.ClubName);
            }

            //社團名稱 + 社團參與記錄學生
            Dictionary <string, List <OnlineSCJoin> > dic = new Dictionary <string, List <OnlineSCJoin> >();
            List <string> ClubNewNameList = new List <string>();
            foreach (LoginSchool school in LoginSchoolList)
            {
                Connection me = new Connection();
                me.Connect(school.School_Name, tool._contract, FISCA.Authentication.DSAServices.PassportToken);
                Dictionary <string, OnlineSCJoin> ScjList = RunService.GetSCJoinByClubName(me, ClubNameList);

                foreach (OnlineSCJoin each in ScjList.Values)
                {
                    string name = each.ClubName;
                    if (!dic.ContainsKey(name))
                    {
                        dic.Add(name, new List <OnlineSCJoin>());
                        ClubNewNameList.Add(name);
                    }
                    dic[name].Add(each);
                }
            }

            ClubNewNameList.Sort();

            #endregion

            #region 報表範本整理

            Campus.Report.ReportConfiguration ConfigurationInCadre = new Campus.Report.ReportConfiguration(ConfigName);
            Aspose.Words.Document             Template;

            if (ConfigurationInCadre.Template == null)
            {
                //如果範本為空,則建立一個預設範本
                Campus.Report.ReportConfiguration ConfigurationInCadre_1 = new Campus.Report.ReportConfiguration(ConfigName);
                ConfigurationInCadre_1.Template = new Campus.Report.ReportTemplate(Properties.Resources.班級點名單_週報表樣式範本, Campus.Report.TemplateType.Word);
                Template = ConfigurationInCadre_1.Template.ToDocument();
            }
            else
            {
                //如果已有範本,則取得樣板
                Template = ConfigurationInCadre.Template.ToDocument();
            }

            #endregion

            #region 範本再修改

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

            XmlElement day = (XmlElement)e.Argument;

            if (day == null)
            {
                MsgBox.Show("第一次使用報表請先進行[日期設定]");
                return;
            }
            else
            {
                config.Clear();
                foreach (XmlElement xml in day.SelectNodes("item"))
                {
                    config.Add(xml.InnerText);
                }
            }

            DataTable table = new DataTable();
            table.Columns.Add("學校名稱");
            table.Columns.Add("社團名稱");
            table.Columns.Add("學年度");
            table.Columns.Add("學期");

            table.Columns.Add("社團老師");

            table.Columns.Add("列印日期");
            table.Columns.Add("上課開始");
            table.Columns.Add("上課結束");
            table.Columns.Add("人數");

            for (int x = 1; x <= 日期多少天; x++)
            {
                table.Columns.Add(string.Format("日期_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("社團_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("班級_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("座號_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("姓名_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("學號_{0}", x));
            }

            for (int x = 1; x <= 學生多少個; x++)
            {
                table.Columns.Add(string.Format("性別_{0}", x));
            }

            #endregion

            foreach (string each in ClubNewNameList)
            {
                DataRow row = table.NewRow();

                row["學校名稱"] = K12.Data.School.ChineseName;
                row["學年度"]  = School.DefaultSchoolYear;
                row["學期"]   = School.DefaultSemester;
                row["列印日期"] = DateTime.Today.ToShortDateString();
                row["上課開始"] = config[0];
                row["上課結束"] = config[config.Count - 1];
                row["社團名稱"] = each;

                //特殊
                if (dic[each].Count > 0)
                {
                    row["社團老師"] = dic[each][0].TeacherName;
                }

                for (int x = 1; x <= config.Count; x++)
                {
                    row[string.Format("日期_{0}", x)] = config[x - 1];
                }

                dic[each].Sort(SortStudentSCJoin);
                int y = 1;
                foreach (OnlineSCJoin scjoin in dic[each])
                {
                    if (y <= 學生多少個)
                    {
                        row[string.Format("班級_{0}", y)] = scjoin.ClassName;
                        row[string.Format("座號_{0}", y)] = scjoin.SeatNo;
                        row[string.Format("姓名_{0}", y)] = scjoin.StudentName;
                        row[string.Format("學號_{0}", y)] = scjoin.StudentNumber;
                        row[string.Format("性別_{0}", y)] = scjoin.Gender;
                        y++;
                    }
                }

                row["人數"] = y - 1;
                table.Rows.Add(row);
            }

            Document PageOne = (Document)Template.Clone(true);
            PageOne.MailMerge.Execute(table);
            e.Result = PageOne;
        }