Esempio n. 1
0
        /// <summary>
        /// 取得新的社團幹部對象
        /// </summary>
        public List <CadresRecord> GetNewCadresList()
        {
            List <CadresRecord> list = new List <CadresRecord>();

            if (_new_Club != null && _Cadres.Count != 0)
            {
                foreach (CadresRecord each in _Cadres)
                {
                    CadresRecord cadre = new CadresRecord();
                    cadre.RefStudentID = each.RefStudentID; //學生
                    cadre.CadreName    = each.CadreName;    //幹部名稱
                    cadre.RefClubID    = _new_Club.UID;

                    list.Add(cadre);
                }
            }
            return(list);
        }
Esempio n. 2
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //檢查目標學年期,是否有相同名稱之社團資料
            //如果有則移除該社團
            //並透過覆製功能進行新增動作
            _SkipList = GetExistClub();

            var copyClubList   = new List <CLUBRecord>();
            var copyClubIDList = new List <string>();


            foreach (var item in _CopyList)
            {
                //如果是重覆社團則不處理
                if (!_SkipList.Contains(item.ClubName))
                {
                    copyClubList.Add(item);
                    copyClubIDList.Add(item.UID);
                }
            }

            if (copyClubList.Count == 0)
            {
                return;
            }

            int LogSchoolYear = 90;
            int LogSemester   = 1;

            if (copyClubList.Count > 0)
            {
                LogSchoolYear = copyClubList[0].SchoolYear;
                LogSemester   = copyClubList[0].Semester;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("已進行複製社團作業:");
            sb.AppendLine(string.Format("由學年度「{0}」學期「{1}」複製至學年度「{2}」學期「{3}」", LogSchoolYear.ToString(), LogSemester.ToString(), _SchoolYear.ToString(), _Semester.ToString()));
            if (_CopyOtherStudent)
            {
                sb.AppendLine("(已勾選複製學生選項)");
            }
            sb.AppendLine("");
            sb.AppendLine("新學期社團清單如下:");

            foreach (CLUBRecord each in copyClubList)
            {
                #region 複製社團基本資料

                //如果是重覆社團則不處理
                if (_SkipList.Contains(each.ClubName))
                {
                    continue;
                }

                CLUBRecord cr = new CLUBRecord();
                cr.About          = each.About;
                cr.ClubNumber     = each.ClubNumber;
                cr.ClubCategory   = each.ClubCategory;
                cr.ClubName       = each.ClubName;
                cr.DeptRestrict   = each.DeptRestrict;
                cr.GenderRestrict = each.GenderRestrict;
                cr.Grade1Limit    = each.Grade1Limit;
                cr.Grade2Limit    = each.Grade2Limit;
                cr.Grade3Limit    = each.Grade3Limit;
                cr.Limit          = each.Limit;
                cr.Location       = each.Location;
                cr.Photo1         = each.Photo1;
                cr.Photo2         = each.Photo2;
                cr.RefTeacherID   = each.RefTeacherID;
                cr.RefTeacherID2  = each.RefTeacherID2;
                cr.RefTeacherID3  = each.RefTeacherID3;
                cr.Level          = each.Level;

                if (_CopyPresidentStudent)
                {
                    //社長,副社長
                    cr.President     = each.President;
                    cr.VicePresident = each.VicePresident;
                }

                //使用者所設定之學年度學期
                cr.SchoolYear = _SchoolYear;
                cr.Semester   = _Semester;
                _NewInsertList.Add(cr);

                sb.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", cr.SchoolYear.ToString(), cr.Semester.ToString(), cr.ClubName));


                #endregion
            }

            //新增之社團ID
            List <string> newIDList = new List <string>();

            try
            {
                newIDList = _AccessHelper.InsertValues(_NewInsertList);
            }
            catch (Exception ex)
            {
                SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                e.Cancel = true;
                return;
            }

            FISCA.LogAgent.ApplicationLog.Log("社團", "複製社團", sb.ToString());

            if (_CopyOtherStudent || _CopyCadresStudent || _CopyPresidentStudent)
            {
                #region 複製社團學生

                //取得社團
                List <CLUBRecord> newClubRecord = _AccessHelper.Select <CLUBRecord>(string.Format("UID in('{0}')", string.Join("','", newIDList)));

                Dictionary <string, List <CadresRecord> > studentCadreDic = new Dictionary <string, List <CadresRecord> >();

                Dictionary <string, List <SCJoin> > studentSCJDic = new Dictionary <string, List <SCJoin> >();

                //取得原有社團之學生社團記錄
                List <SCJoin> scjStudentList = _AccessHelper.Select <SCJoin>(string.Format("ref_club_id in ('{0}')", string.Join("','", copyClubIDList)));

                foreach (SCJoin each in scjStudentList)
                {
                    if (!studentSCJDic.ContainsKey(each.RefClubID))
                    {
                        studentSCJDic.Add(each.RefClubID, new List <SCJoin>());
                    }
                    studentSCJDic[each.RefClubID].Add(each);
                }

                //取得原有社團之學生幹部記錄
                List <CadresRecord> cadreStudentList = _AccessHelper.Select <CadresRecord>(string.Format("ref_club_id in ('{0}')", string.Join("','", copyClubIDList)));

                foreach (CadresRecord each in cadreStudentList)
                {
                    if (!studentCadreDic.ContainsKey(each.RefClubID))
                    {
                        studentCadreDic.Add(each.RefClubID, new List <CadresRecord>());
                    }
                    studentCadreDic[each.RefClubID].Add(each);
                }

                _InsertSCJList = new List <SCJoin>();
                List <CadresRecord> newCadresRecordList = new List <CadresRecord>();

                foreach (CLUBRecord newClubRec in newClubRecord)
                {
                    foreach (CLUBRecord copyClubRec in copyClubList)
                    {
                        if (newClubRec.ClubName == copyClubRec.ClubName)
                        {
                            if (studentSCJDic.ContainsKey(copyClubRec.UID))
                            {
                                foreach (var scjRec in studentSCJDic[copyClubRec.UID])
                                {
                                    if (_CopyPresidentStudent &&
                                        (copyClubRec.President == scjRec.RefStudentID ||
                                         copyClubRec.VicePresident == scjRec.RefStudentID))
                                    {
                                        #region 複製社長副社長
                                        SCJoin scj = new SCJoin();
                                        scj.RefStudentID = scjRec.RefStudentID;
                                        scj.RefClubID    = newClubRec.UID;

                                        //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態)
                                        if (IsNowLock)
                                        {
                                            scj.Lock = scjRec.Lock;
                                        }
                                        else
                                        {
                                            scj.Lock = true;
                                        }

                                        _InsertSCJList.Add(scj);
                                        #endregion
                                        continue;
                                    }
                                    if (_CopyCadresStudent &&
                                        studentCadreDic.ContainsKey(copyClubRec.UID))
                                    {
                                        bool match = false;
                                        #region 複製社團幹部
                                        foreach (var cadresRec in studentCadreDic[copyClubRec.UID])
                                        {
                                            if (cadresRec.RefStudentID == scjRec.RefStudentID)
                                            {
                                                CadresRecord cadre = new CadresRecord();
                                                cadre.RefStudentID = cadresRec.RefStudentID; //學生
                                                cadre.CadreName    = cadresRec.CadreName;    //幹部名稱
                                                cadre.RefClubID    = newClubRec.UID;
                                                newCadresRecordList.Add(cadre);

                                                SCJoin scj = new SCJoin();
                                                scj.RefStudentID = scjRec.RefStudentID;
                                                scj.RefClubID    = newClubRec.UID;

                                                //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態)
                                                if (IsNowLock)
                                                {
                                                    scj.Lock = scjRec.Lock;
                                                }
                                                else
                                                {
                                                    scj.Lock = true;
                                                }

                                                _InsertSCJList.Add(scj);
                                                match = true;
                                                break;
                                            }
                                        }
                                        #endregion
                                        if (match)
                                        {
                                            continue;
                                        }
                                    }

                                    if (_CopyOtherStudent)
                                    {
                                        #region 複製一般社員
                                        SCJoin scj = new SCJoin();
                                        scj.RefStudentID = scjRec.RefStudentID;
                                        scj.RefClubID    = newClubRec.UID;

                                        //鎖定狀態 - 2021/4/15(鎖定狀態,依原鎖定狀態)
                                        if (IsNowLock)
                                        {
                                            scj.Lock = scjRec.Lock;
                                        }
                                        else
                                        {
                                            scj.Lock = true;
                                        }

                                        _InsertSCJList.Add(scj);
                                        #endregion
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }


                try
                {
                    _AccessHelper.InsertValues(_InsertSCJList);
                    _AccessHelper.InsertValues(newCadresRecordList);
                }
                catch (Exception ex)
                {
                    SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                    e.Cancel = true;
                    return;
                }

                #endregion
            }
        }
Esempio n. 3
0
        private List <CadresRecord> GetInsertList()
        {
            //儲存時,社長與副社長資料,儲存於社團Record
            List <CadresRecord>       InsertList = new List <CadresRecord>();
            Dictionary <string, bool> Dic        = new Dictionary <string, bool>();

            Dic.Add("社長", false);
            Dic.Add("副社長", false);
            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                DataGridViewTextBoxCell    cell_0 = (DataGridViewTextBoxCell)row.Cells[Column1.Index];
                DataGridViewComboBoxExCell cell_1 = (DataGridViewComboBoxExCell)row.Cells[Column2.Index];
                if ("" + cell_0.Value == "社長") //社長
                {
                    Dic["社長"] = true;
                    //在Cell-1內所選的學生是誰?
                    if (StudentDic.ContainsKey("" + cell_1.Value))
                    {
                        StudentRecord sr = StudentDic["" + cell_1.Value];
                        ClubPrimary.President = sr.ID;
                    }
                    else
                    {
                        ClubPrimary.President = string.Empty;
                    }
                }
                else if ("" + cell_0.Value == "副社長") //副社長
                {
                    Dic["副社長"] = true;
                    if (StudentDic.ContainsKey("" + cell_1.Value))
                    {
                        StudentRecord sr = StudentDic["" + cell_1.Value];
                        ClubPrimary.VicePresident = sr.ID;
                    }
                    else
                    {
                        ClubPrimary.VicePresident = string.Empty;
                    }
                }
                else //其他Row
                {
                    if (StudentDic.ContainsKey("" + cell_1.Value))
                    {
                        StudentRecord sr = StudentDic["" + cell_1.Value];
                        CadresRecord  cr = new CadresRecord();
                        cr.CadreName    = "" + cell_0.Value;
                        cr.RefStudentID = sr.ID;
                        cr.RefClubID    = ClubPrimary.UID;
                        InsertList.Add(cr);
                    }
                }
            }

            if (!Dic["社長"])
            {
                ClubPrimary.President = string.Empty;
            }
            if (!Dic["副社長"])
            {
                ClubPrimary.VicePresident = string.Empty;
            }

            return(InsertList);
        }
Esempio n. 4
0
        public override string Import(List <IRowStream> Rows)
        {
            if (mOption.Action == ImportAction.InsertOrUpdate)
            {
                StringBuilder sb_log = new StringBuilder();

                //加入 社長/副社長
                List <CLUBRecord> ClubUpdateList = new List <CLUBRecord>();

                //加入 其他社團幹部
                List <CadresRecord> CadreInsertList = new List <CadresRecord>();

                //取得學號對應ID
                List <string> studentNumber = new List <string>();
                foreach (IRowStream Row in Rows)
                {
                    string StudentNumber = Row.GetValue("學號");
                    if (!studentNumber.Contains(StudentNumber))
                    {
                        studentNumber.Add(StudentNumber);
                    }
                }

                Importbot.GetStudentIDList(studentNumber);

                foreach (IRowStream Row in Rows)
                {
                    //教師名稱
                    string SchoolYear    = Row.GetValue("學年度");
                    string Semester      = Row.GetValue("學期");
                    string CLUBName      = Row.GetValue("社團名稱");
                    string CadreName     = Row.GetValue("幹部名稱");
                    string StudentNumber = Row.GetValue("學號");

                    string name = SchoolYear + "," + Semester + "," + CLUBName;
                    if (Importbot.ClubDic.ContainsKey(name))
                    {
                        CLUBRecord record = Importbot.ClubDic[name];

                        if (Importbot.StudentDic.ContainsKey(StudentNumber))
                        {
                            StudDe stud = Importbot.StudentDic[StudentNumber];

                            if (CadreName == "社長")
                            {
                                if (record.President != stud.id)
                                {
                                    record.President = stud.id;
                                    ClubUpdateList.Add(record);
                                    sb_log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", SchoolYear, Semester, CLUBName));
                                    sb_log.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」幹部名稱「{3}」", stud.ClassName, stud.seat_no, stud.Name, CadreName));
                                    sb_log.AppendLine("");
                                }
                                else
                                {
                                    sb_log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", SchoolYear, Semester, CLUBName));
                                    sb_log.AppendLine(string.Format("學生「{0}」已是社長(未調整)", stud.Name));
                                    sb_log.AppendLine("");
                                }
                            }
                            else if (CadreName == "副社長")
                            {
                                if (record.VicePresident != stud.id)
                                {
                                    record.VicePresident = stud.id;
                                    ClubUpdateList.Add(record);

                                    sb_log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", SchoolYear, Semester, CLUBName));
                                    sb_log.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」幹部名稱「{3}」", stud.ClassName, stud.seat_no, stud.Name, CadreName));
                                    sb_log.AppendLine("");
                                }
                                else
                                {
                                    sb_log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", SchoolYear, Semester, CLUBName));
                                    sb_log.AppendLine(string.Format("學生「{0}」已是副社長(未調整)", stud.Name));
                                    sb_log.AppendLine("");
                                }
                            }
                            else
                            {
                                //其他幹部直接新增
                                CadresRecord cadres = new CadresRecord();
                                cadres.CadreName    = CadreName;
                                cadres.RefClubID    = record.UID;
                                cadres.RefStudentID = stud.id;

                                CadreInsertList.Add(cadres);

                                sb_log.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", SchoolYear, Semester, CLUBName));
                                sb_log.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」幹部名稱「{3}」", stud.ClassName, stud.seat_no, stud.Name, CadreName));
                                sb_log.AppendLine("");
                            }
                        }
                    }
                }

                if (ClubUpdateList.Count > 0)
                {
                    tool._A.UpdateValues(ClubUpdateList);
                }

                if (CadreInsertList.Count > 0)
                {
                    tool._A.InsertValues(CadreInsertList);
                }

                if (ClubUpdateList.Count > 0 || CadreInsertList.Count > 0)
                {
                    FISCA.LogAgent.ApplicationLog.Log("社團", "匯入社團幹部", sb_log.ToString());
                }
            }

            return("");
        }