public frmFilter()
        {
            InitializeComponent();

            this.opening_infos = new List<UDT.CSOpeningInfo>();
            Access = new FISCA.UDT.AccessHelper();
            Query = new FISCA.Data.QueryHelper();
            bw = new BackgroundWorker();
            bw.WorkerSupportsCancellation = true;
            rng = new Random(Guid.NewGuid().GetHashCode());

            this.Load += new EventHandler(frmFilter_Load);
            this.FormClosed += new FormClosedEventHandler(frmFilter_FormClosed);
            this.dgvData.DataError += new DataGridViewDataErrorEventHandler(dgvData_DataError);
            this.dgvData.CurrentCellDirtyStateChanged += new EventHandler(dgvData_CurrentCellDirtyStateChanged);

            Event.DeliverActiveRecord.Received += new EventHandler<Event.DeliverCSAttendEventArgs>(ActiveRecord_Received);
            Task task = Task.Factory.StartNew(() =>
            {
                CourseSelection.BusinessLogic.TeachingEvaluationAchiving.IsAchieving(0, 0, "0");
            });
        }
Ejemplo n.º 2
0
 public Instance()
 {
     _A       = new FISCA.UDT.AccessHelper();
     _subjDic = new Dictionary <string, int>();
 }
Ejemplo n.º 3
0
        public static void Main()
        {
            #region 處理垃圾資料用


            FISCA.UDT.AccessHelper accessHelper = new FISCA.UDT.AccessHelper();
            string           query         = "action='匯入更新'";
            List <SchoolLog> SchoolLogList = accessHelper.Select <SchoolLog>(query);

            List <SchoolLog> WaitDel = new List <SchoolLog>();

            StringBuilder sb = new StringBuilder();
            foreach (SchoolLog log in SchoolLogList)
            {
                sb.Clear();
                sb.Append("<root>");
                sb.Append(log.Detail);
                sb.Append("</root>");
                try
                {
                    bool     chkDel  = false;
                    XElement elmRoot = XElement.Parse(sb.ToString());
                    foreach (XElement elm in elmRoot.Elements("Student"))
                    {
                        if (elm.Element("ClassName") != null && elm.Element("NewClassName") != null && elm.Element("StudentStatus") != null && elm.Element("NewStudentStatus") != null)
                        {
                            if (elm.Element("ClassName").Value == elm.Element("NewClassName").Value&& elm.Element("StudentStatus").Value == elm.Element("NewStudentStatus").Value)
                            {
                                chkDel = true;
                                break;
                            }
                        }
                    }
                    if (chkDel)
                    {
                        WaitDel.Add(log);
                    }
                }
                catch (Exception ex)
                {
                }
            }

            #endregion



            Campus.Configuration.Config.Initialize(
                new Campus.Configuration.UserConfigManager(new Campus.Configuration.ConfigProvider_User(), FISCA.Authentication.DSAServices.UserAccount),
                new Campus.Configuration.ConfigurationManager(new Campus.Configuration.ConfigProvider_App()),
                new Campus.Configuration.ConfigurationManager(new Campus.Configuration.ConfigProvider_Global())
                );

            InitMainPanel();

            SchemaManager Manager = new SchemaManager(FISCA.Authentication.DSAServices.DefaultConnection);

            Manager.SyncSchema(new SchoolLog());
            Manager.SyncSchema(new Action());
            Manager.SyncSchema(new upload_url());

            MainPanel.RibbonBarItems["自動編班"]["動作設定"].Image  = Properties.Resources.achievement_config_128;
            MainPanel.RibbonBarItems["自動編班"]["動作設定"].Size   = RibbonBarButton.MenuButtonSize.Medium;
            MainPanel.RibbonBarItems["自動編班"]["動作設定"].Click += (sender, e) => new frmActionList().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["動作設定"].Enable = Permissions.動作設定權限;

            MainPanel.RibbonBarItems["自動編班"]["查詢紀錄"].Image  = Properties.Resources.admissions_search_128;
            MainPanel.RibbonBarItems["自動編班"]["查詢紀錄"].Size   = RibbonBarButton.MenuButtonSize.Medium;
            MainPanel.RibbonBarItems["自動編班"]["查詢紀錄"].Click += (sender, e) => new QueryLog().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["查詢紀錄"].Enable = Permissions.查詢紀錄權限;

            //Jean 新增 局端解鎖 20191231
            MainPanel.RibbonBarItems["自動編班"]["局端手動解鎖"].Click += (sender, e) => new frmUnlock().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["局端手動解鎖"].Image  = Properties.Resources.classmate_128;
            MainPanel.RibbonBarItems["自動編班"]["局端手動解鎖"].Size   = RibbonBarButton.MenuButtonSize.Medium;


            MainPanel.RibbonBarItems["自動編班"]["查詢編班"].Click += (sender, e) => new frmClassOrder().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["查詢編班"].Image  = Properties.Resources.classmate_128;
            MainPanel.RibbonBarItems["自動編班"]["查詢編班"].Size   = RibbonBarButton.MenuButtonSize.Medium;

            MainPanel.RibbonBarItems["自動編班"]["查詢特殊身份學生"].Click += (sender, e) => new frmSpecial().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["查詢特殊身份學生"].Image  = Properties.Resources.student_a_128;
            MainPanel.RibbonBarItems["自動編班"]["查詢特殊身份學生"].Size   = RibbonBarButton.MenuButtonSize.Medium;

            MainPanel.RibbonBarItems["自動編班"]["各校人數超過上限班級統計"].Click += (sender, e) => new frmSchoolClassCount().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["各校人數超過上限班級統計"].Image  = Properties.Resources.classmate_128;
            MainPanel.RibbonBarItems["自動編班"]["各校人數超過上限班級統計"].Size   = RibbonBarButton.MenuButtonSize.Medium;

            // 2017/1/4 穎驊新增 局端可列印統計 全市班級類別統計
            MainPanel.RibbonBarItems["自動編班"]["各校人數班級類別統計"].Click += (sender, e) => new frmSchoolClassTypeCount().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["各校人數班級類別統計"].Image  = Properties.Resources.classmate_128;
            MainPanel.RibbonBarItems["自動編班"]["各校人數班級類別統計"].Size   = RibbonBarButton.MenuButtonSize.Medium;

            MainPanel.RibbonBarItems["自動編班"]["查詢學生調整班級"].Click += (sender, e) => new frmStudentChangeClass().ShowDialog();
            MainPanel.RibbonBarItems["自動編班"]["查詢學生調整班級"].Image  = Properties.Resources.classmate_128;
            MainPanel.RibbonBarItems["自動編班"]["查詢學生調整班級"].Size   = RibbonBarButton.MenuButtonSize.Medium;


            MainPanel.SelectedSourceChanged += delegate
            {
                if (MainPanel.SelectedSource.Count > 0)
                {
                    MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Enable  = true;
                    MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Enable = true;
                }
                else
                {
                    MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Enable  = false;
                    MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Enable = false;
                }
            };

            MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Enable = false;
            MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Click += (sender, e) => new frmClubStatus().ShowDialog();
            MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Image  = Properties.Resources.recreation_zoom_64;
            MainPanel.RibbonBarItems["查詢"]["查詢社團狀態"].Size   = RibbonBarButton.MenuButtonSize.Medium;

            MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Enable = false;
            MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Click += (sender, e) => new frmClassDetail().ShowDialog();
            MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Image  = Properties.Resources.mask_zoom_64;
            MainPanel.RibbonBarItems["查詢"]["查詢無導師班級"].Size   = RibbonBarButton.MenuButtonSize.Medium;


            FISCA.Permission.Catalog AdminCatalog = FISCA.Permission.RoleAclSource.Instance["自動編班"]["功能按鈕"];
            AdminCatalog.Add(new RibbonFeature(Permissions.查詢紀錄, "查詢紀錄"));
            AdminCatalog.Add(new RibbonFeature(Permissions.動作設定, "動作設定"));
        }
        public static void AddMenuButton()
        {
            //string googleAcc = "*****@*****.**", googlePWD = "<Cg4&YYN";
            string googleAcc = "*****@*****.**", googlePWD = "A123456&";

            var accessHelper = new FISCA.UDT.AccessHelper();
            var ribbonBarItem = K12.Presentation.NLDPanels.Course.RibbonBarItems["課程行事曆"];
            var syncButton = ribbonBarItem["同步修課學生"];

            Catalog button_syncCalendar = RoleAclSource.Instance["課程"]["功能按鈕"];
            button_syncCalendar.Add(new RibbonFeature("Sync_Course_Calendar_Student", "同步修課學生"));
            bool isEnabled = UserAcl.Current["Sync_Course_Calendar_Student"].Executable;

            syncButton.Enable = isEnabled;
            K12.Presentation.NLDPanels.Course.SelectedSourceChanged += delegate(object sender, EventArgs e)
            {
                syncButton.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0) && isEnabled);
            };

            //syncButton.Enable = false;
            //K12.Presentation.NLDPanels.Course.SelectedSourceChanged += delegate(object sender, EventArgs e)
            //{
            //    syncButton.Enable = K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0;
            //};
            syncButton.Click += delegate
            {
                bool hasFaild = false;
                FISCA.Presentation.MotherForm.SetStatusBarMessage("修課學生行事曆同步中...", 0);
                List<string> selectedSource = new List<string>(K12.Presentation.NLDPanels.Course.SelectedSource);
                BackgroundWorker bkw = new System.ComponentModel.BackgroundWorker() { WorkerReportsProgress = true };
                bkw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("修課學生行事曆同步中...", e.ProgressPercentage);
                };
                bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    SectionSyncColumn.Reload();
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("修課學生行事曆同步完成");
                    if (hasFaild)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("修課學生行事曆同步完成,其中部分資同步失敗,請稍後再試。");
                    }
                };
                bkw.DoWork += delegate
                {
                    int count = 0;
                    int syncedSections = 0;
                    Dictionary<string, List<string>> courseAttend = new Dictionary<string, List<string>>();

                    //foreach (var item in K12.Data.SCAttend.SelectByCourseIDs(selectedSource))

                    AccessHelper helper = new AccessHelper();
                    string condition2 = "ref_course_id in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition2 != "ref_course_id in (")
                            condition2 += ",";
                        condition2 += "'" + key + "'";
                    }
                    condition2 += ")";

                    foreach (var item in helper.Select<SCAttendExt>(condition2))
                    {
                        if (!courseAttend.ContainsKey(item.CourseID.ToString()))
                            courseAttend.Add(item.CourseID.ToString(), new List<string>());
                        courseAttend[item.CourseID.ToString()].Add(item.StudentID.ToString());
                        count++;
                    }

                    Dictionary<string, Calendar> courseCalendar = new Dictionary<string, Calendar>();
                    string condition = "RefCourseID in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition != "RefCourseID in (")
                            condition += ",";
                        condition += "'" + key + "'";
                    }
                    condition += ")";
                    foreach (Calendar cal in accessHelper.Select<Calendar>(condition))
                    {
                        if (!courseCalendar.ContainsKey(cal.RefCourseID))
                            courseCalendar.Add(cal.RefCourseID, cal);
                    }
                    bkw.ReportProgress(5);
                    CalendarService myService = new CalendarService("ischool.CourseCalendar");
                    myService.setUserCredentials(googleAcc, googlePWD);
                    bkw.ReportProgress(20);
                    foreach (K12.Data.CourseRecord course in K12.Data.Course.SelectByIDs(courseAttend.Keys))
                    {
                        Calendar targetCal = null;
                        try
                        {
                            if (!courseCalendar.ContainsKey(course.ID))
                            {
                                #region 建立新Calender
                                string[] colorLists = new string[]{"#A32929","#B1365F","#7A367A","#5229A3","#29527A","#2952A3","#1B887A",
                            "#28754E","#0D7813","#528800","#88880E","#AB8B00","#BE6D00","#B1440E",
                            "#865A5A","#705770","#4E5D6C","#5A6986","#4A716C","#6E6E41","#8D6F47"};
                                CalendarEntry newCal = new CalendarEntry();
                                newCal.Title.Text = course.Name;
                                newCal.Summary.Text = "科目:" + course.Subject
                                    + "\n學年度:" + course.SchoolYear
                                    + "\n學期:" + course.Semester
                                    + "\n學分數:" + course.Credit;
                                newCal.TimeZone = "Asia/Taipei";
                                //targetCalender.Hidden = false;
                                newCal.Color = colorLists[new Random(DateTime.Now.Millisecond).Next(0, colorLists.Length)];
                                Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");
                                newCal = (CalendarEntry)myService.Insert(postUri, newCal);
                                #endregion
                                String calendarURI = newCal.Id.Uri.ToString();
                                String calendarID = calendarURI.Substring(calendarURI.LastIndexOf("/") + 1);
                                targetCal = new Calendar() { RefCourseID = course.ID, GoogleCalanderID = calendarID };
                                targetCal.Save();
                                courseCalendar.Add(course.ID, targetCal);
                            }
                            else
                            {
                                targetCal = courseCalendar[course.ID];
                            }
                        }
                        catch { hasFaild = true; }
                        if (targetCal != null)
                        {
                            List<string> aclList = new List<string>(targetCal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                            foreach (var student in K12.Data.Student.SelectByIDs(courseAttend[course.ID]))
                            {
                                try
                                {
                                    if (student.SALoginName != "" && !aclList.Contains(student.SALoginName))
                                    {
                                        #region 新增分享
                                        AclEntry entry = new AclEntry();
                                        entry.Scope = new AclScope();
                                        entry.Scope.Type = AclScope.SCOPE_USER;
                                        entry.Scope.Value = student.SALoginName;
                                        entry.Role = AclRole.ACL_CALENDAR_READ;
                                        try
                                        {
                                            AclEntry insertedEntry = myService.Insert(new Uri("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"), entry);
                                        }
                                        catch (GDataRequestException gex)
                                        {
                                            if (!gex.InnerException.Message.Contains("(409)"))
                                                throw;
                                        }
                                        #endregion
                                        aclList.Add(student.SALoginName);
                                        targetCal.ACLList += (targetCal.ACLList == "" ? "" : "%") + student.SALoginName;
                                    }
                                }
                                catch
                                {
                                    hasFaild = true;
                                }
                                syncedSections++;
                                int p = syncedSections * 80 / count + 20;
                                if (p > 100) p = 100;
                                if (p < 0) p = 0;
                                bkw.ReportProgress(p);
                            }
                        }
                    }
                    courseCalendar.Values.SaveAll();
                };
                bkw.RunWorkerAsync();
            };
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            if (UserAcl.Current[typeof(SectionDetail)].Viewable)
                K12.Presentation.NLDPanels.Course.AddDetailBulider<SectionDetail>();

            Catalog detail = RoleAclSource.Instance["課程"]["資料項目"];
            detail.Add(new DetailItemFeature(typeof(SectionDetail)));

            SectionSyncColumn.SetupColumn();
            SyncSection.AddMenuButton();
            ResetCalendar.AddMenuButton();

            //return;
            //這是另一個隱藏版功能,需要製做牧牛杖
            var accessHelper = new FISCA.UDT.AccessHelper();
            #region 重建ACLlist
            var ribbonBarItem = K12.Presentation.NLDPanels.Course.RibbonBarItems["課程行事曆"];
            var syncButton = ribbonBarItem["重建修課學生同步狀態"];
            syncButton.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0));
            K12.Presentation.NLDPanels.Course.SelectedSourceChanged += delegate(object sender, EventArgs e)
            {

                syncButton.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0));
            };
            syncButton.Click += delegate
            {
                bool hasFaild = false;
                FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步中...", 0);
                List<string> selectedSource = new List<string>(K12.Presentation.NLDPanels.Course.SelectedSource);
                BackgroundWorker bkw = new System.ComponentModel.BackgroundWorker() { WorkerReportsProgress = true };
                bkw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步中...", e.ProgressPercentage);
                };
                bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    SectionSyncColumn.Reload();
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步完成");
                    if (hasFaild)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("課程行事曆同步完成,其中部分資料同步失敗,請稍後再試。");
                    }
                };
                bkw.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    string condition = "RefCourseID in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition != "RefCourseID in (")
                            condition += ",";
                        condition += "'" + key + "'";
                    }
                    condition += ")";
                    bkw.ReportProgress(3);
                    CalendarService myService = new CalendarService("ischool.CourseCalendar");
                    var calendarRecords = accessHelper.Select<Calendar>(condition);
                    myService.setUserCredentials(googleAcc, googlePWD);
                    foreach (Calendar targetCal in calendarRecords)
                    {
                        try
                        {
                            List<string> aclList = new List<string>();
                            AtomFeed calFeed = myService.Query(new FeedQuery("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"));
                            foreach (AtomEntry atomEntry in calFeed.Entries)
                            {
                                if (atomEntry is AtomEntry)
                                {
                                    AclEntry aclEntry = (AclEntry)atomEntry;
                                    if (aclEntry.Scope.Type == AclScope.SCOPE_USER && aclEntry.Role.Value == AclRole.ACL_CALENDAR_READ.Value)
                                        aclList.Add(aclEntry.Scope.Value);
                                    //if (aclEntry.Scope.Value == acc)
                                    //{
                                    //    aclEntry.Delete();
                                    //}
                                }
                            }
                            targetCal.ACLList = "";
                            foreach (string acc in aclList)
                            {
                                targetCal.ACLList += (targetCal.ACLList == "" ? "" : "%") + acc;
                            }
                        }
                        catch
                        {
                            hasFaild = true;
                        }
                    }
                    calendarRecords.SaveAll();
                    bkw.ReportProgress(20);
                };
                bkw.RunWorkerAsync();
            };
            #endregion
            #region 產生ACL清單
            var syncButton2 = ribbonBarItem["列出行事曆現況"];
            syncButton2.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0));
            K12.Presentation.NLDPanels.Course.SelectedSourceChanged += delegate(object sender, EventArgs e)
            {
                syncButton2.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0));
            };
            syncButton2.Click += delegate
            {
                bool hasFaild = false;
                FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆現況產生中...", 0);
                List<string> selectedSource = new List<string>(K12.Presentation.NLDPanels.Course.SelectedSource);
                BackgroundWorker bkw = new System.ComponentModel.BackgroundWorker() { WorkerReportsProgress = true };
                Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
                wb.Worksheets[0].Cells[0, 0].PutValue("課程編號");
                wb.Worksheets[0].Cells[0, 1].PutValue("課程名稱");
                wb.Worksheets[0].Cells[0, 2].PutValue("修課學生帳號");
                wb.Worksheets[0].Cells[0, 3].PutValue("系統註記分享帳號");
                wb.Worksheets[0].Cells[0, 4].PutValue("行事曆上實際分享帳號");
                wb.Worksheets[0].Cells[0, 5].PutValue("修課學生學號");
                wb.Worksheets[0].Cells[0, 6].PutValue("修課學生姓名");
                bkw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆現況產生中...", e.ProgressPercentage);
                };
                bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    SectionSyncColumn.Reload();
                    Completed("課程行事曆現況", wb);
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆現況產生完成");
                    if (hasFaild)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("課程行事曆現況產生完成,其中部分資料發生錯誤,請稍後再試。");
                    }
                };
                bkw.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    int rowIndex = 1;
                    Dictionary<string, Calendar> courseCalendar = new Dictionary<string, Calendar>();
                    string condition = "RefCourseID in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition != "RefCourseID in (")
                            condition += ",";
                        condition += "'" + key + "'";
                    }
                    condition += ")";
                    foreach (Calendar cal in accessHelper.Select<Calendar>(condition))
                    {
                        if (!courseCalendar.ContainsKey(cal.RefCourseID))
                            courseCalendar.Add(cal.RefCourseID, cal);
                    }
                    Dictionary<string, List<string>> courseAttend = new Dictionary<string, List<string>>();
                    string condition2 = "ref_course_id in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition2 != "ref_course_id in (")
                            condition2 += ",";
                        condition2 += "'" + key + "'";
                    }
                    condition2 += ")";
                    foreach (var item in accessHelper.Select<SCAttendExt>(condition2))
                    {
                        if (!courseAttend.ContainsKey(item.CourseID.ToString()))
                            courseAttend.Add(item.CourseID.ToString(), new List<string>());
                        courseAttend[item.CourseID.ToString()].Add(item.StudentID.ToString());
                    }
                    bkw.ReportProgress(3);
                    CalendarService myService = new CalendarService("ischool.CourseCalendar");
                    //var calendarRecords = accessHelper.Select<Calendar>(condition);
                    myService.setUserCredentials(googleAcc, googlePWD);
                    Dictionary<string, K12.Data.StudentRecord> studentMail = new Dictionary<string, K12.Data.StudentRecord>();
                    foreach (K12.Data.CourseRecord courseRec in K12.Data.Course.SelectByIDs(selectedSource))
                    {
                        List<string> realACLList = new List<string>();
                        List<string> markedACLList = new List<string>();
                        List<string> attendACLList = new List<string>();
                        if (courseAttend.ContainsKey(courseRec.ID))
                        {
                            foreach (var student in K12.Data.Student.SelectByIDs(courseAttend[courseRec.ID]))
                            {
                                if (student.SALoginName != "")
                                {
                                    attendACLList.Add(student.SALoginName);
                                    if (!studentMail.ContainsKey(student.SALoginName.ToLower()))
                                    {
                                        studentMail.Add(student.SALoginName.ToLower(), student);
                                    }
                                }
                            }
                        }
                        if (courseCalendar.ContainsKey(courseRec.ID))
                        {
                            Calendar targetCal = courseCalendar[courseRec.ID];
                            markedACLList.AddRange(targetCal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                            try
                            {
                                AtomFeed calFeed = myService.Query(new FeedQuery("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"));
                                foreach (AtomEntry atomEntry in calFeed.Entries)
                                {
                                    if (atomEntry is AtomEntry)
                                    {
                                        AclEntry aclEntry = (AclEntry)atomEntry;
                                        if (aclEntry.Scope.Type == AclScope.SCOPE_USER && aclEntry.Role.Value == AclRole.ACL_CALENDAR_READ.Value)
                                            realACLList.Add(aclEntry.Scope.Value);
                                    }
                                }
                            }
                            catch
                            {
                                hasFaild = true;
                            }
                        }
                        if (realACLList.Count == 0 && markedACLList.Count == 0 && attendACLList.Count == 0)
                        {
                            wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                            wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                            rowIndex++;
                        }
                        else
                        {
                            foreach (string mail in attendACLList)
                            {
                                string realMail = "";
                                string markedMail = "";
                                foreach (var item in realACLList)
                                {
                                    if (item.ToLower() == mail.ToLower())
                                    {
                                        realMail = item;
                                        break;
                                    }
                                }
                                foreach (var item in markedACLList)
                                {
                                    if (item.ToLower() == mail.ToLower())
                                    {
                                        markedMail = item;
                                        break;
                                    }
                                }
                                wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                                wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                                wb.Worksheets[0].Cells[rowIndex, 2].PutValue(mail);
                                if (markedMail != "") wb.Worksheets[0].Cells[rowIndex, 3].PutValue(markedMail);
                                if (realMail != "") wb.Worksheets[0].Cells[rowIndex, 4].PutValue(realMail);
                                if (studentMail.ContainsKey(mail.ToLower()))
                                {
                                    wb.Worksheets[0].Cells[rowIndex, 5].PutValue(studentMail[mail.ToLower()].StudentNumber);
                                    wb.Worksheets[0].Cells[rowIndex, 6].PutValue(studentMail[mail.ToLower()].Name);
                                }
                                if (realMail != "") realACLList.Remove(realMail);
                                if (markedMail != "") markedACLList.Remove(markedMail);
                                rowIndex++;
                            }
                            foreach (string mail in markedACLList)
                            {
                                string realMail = "";
                                foreach (var item in realACLList)
                                {
                                    if (item.ToLower() == mail.ToLower())
                                    {
                                        realMail = item;
                                        break;
                                    }
                                }
                                wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                                wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                                //wb.Worksheets[0].Cells[rowIndex, 2].PutValue("");
                                wb.Worksheets[0].Cells[rowIndex, 3].PutValue(mail);
                                if (realMail != "") wb.Worksheets[0].Cells[rowIndex, 4].PutValue(realMail);
                                if (studentMail.ContainsKey(mail.ToLower()))
                                {
                                    wb.Worksheets[0].Cells[rowIndex, 5].PutValue(studentMail[mail.ToLower()].StudentNumber);
                                    wb.Worksheets[0].Cells[rowIndex, 6].PutValue(studentMail[mail.ToLower()].Name);
                                }
                                if (realMail != "") realACLList.Remove(realMail);
                                rowIndex++;
                            }
                            foreach (string mail in realACLList)
                            {
                                wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                                wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                                //wb.Worksheets[0].Cells[rowIndex, 2].PutValue("");
                                //wb.Worksheets[0].Cells[rowIndex, 3].PutValue("");
                                wb.Worksheets[0].Cells[rowIndex, 4].PutValue(mail);
                                if (studentMail.ContainsKey(mail.ToLower()))
                                {
                                    wb.Worksheets[0].Cells[rowIndex, 5].PutValue(studentMail[mail.ToLower()].StudentNumber);
                                    wb.Worksheets[0].Cells[rowIndex, 6].PutValue(studentMail[mail.ToLower()].Name);
                                }
                                rowIndex++;
                            }
                            //if (realACLList.Count > 0)
                            //{
                            //    foreach (var acc in realACLList)
                            //    {
                            //        wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                            //        wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                            //        wb.Worksheets[0].Cells[rowIndex, 2].PutValue(acc);
                            //        rowIndex++;
                            //    }
                            //}
                            //else
                            //{
                            //    wb.Worksheets[0].Cells[rowIndex, 0].PutValue(courseRec.ID);
                            //    wb.Worksheets[0].Cells[rowIndex, 1].PutValue(courseRec.Name);
                            //    rowIndex++;
                            //}
                        }
                    }
                    bkw.ReportProgress(20);
                };
                bkw.RunWorkerAsync();
            };
            #endregion
        }