Пример #1
0
        public override string Import(List <Campus.DocumentValidator.IRowStream> Rows)
        {
            if (mOption.Action == ImportAction.InsertOrUpdate)
            {
                List <CLUBRecord> ClubInsertList = new List <CLUBRecord>();
                List <CLUBRecord> ClubUpdateList = new List <CLUBRecord>();

                foreach (IRowStream Row in Rows)
                { //教師名稱
                    string SchoolYear = Row.GetValue("學年度");
                    string Semester   = Row.GetValue("學期");
                    string CLUBName   = Row.GetValue("社團名稱");
                    string name       = SchoolYear + "," + Semester + "," + CLUBName;

                    if (Importbot.ClubDic.ContainsKey(name)) //更新
                    {
                        CLUBRecord club = Importbot.ClubDic[name];
                        if (!Log_Dic.ContainsKey(club.UID))
                        {
                            ImputLog i_n = new ImputLog();
                            i_n.lo_CLUB = club.CopyExtension();
                            Log_Dic.Add(club.UID, i_n);
                        }

                        Importbot.SetClub(Row, club);
                        ClubUpdateList.Add(club);
                    }
                    else
                    {
                        //新增
                        CLUBRecord club = new CLUBRecord();
                        club.SchoolYear = int.Parse(SchoolYear);
                        club.Semester   = int.Parse(Semester);
                        club.ClubName   = CLUBName;

                        Importbot.SetClub(Row, club);
                        ClubInsertList.Add(club);
                    }
                }

                if (ClubInsertList.Count > 0)
                {
                    StringBuilder mstrLog1 = new StringBuilder();
                    mstrLog1.AppendLine("新增匯入社團:");
                    foreach (CLUBRecord each in ClubInsertList)
                    {
                        mstrLog1.AppendLine(Importbot.GetLogString(each));
                    }
                    tool._A.InsertValues(ClubInsertList);
                    FISCA.LogAgent.ApplicationLog.Log("社團", "新增匯入", mstrLog1.ToString());
                }

                if (ClubUpdateList.Count > 0)
                {
                    StringBuilder mstrLog2 = new StringBuilder();
                    mstrLog2.AppendLine("更新匯入社團:");
                    foreach (CLUBRecord each in ClubUpdateList)
                    {
                        if (Log_Dic.ContainsKey(each.UID))
                        {
                            Log_Dic[each.UID].New_club = each.CopyExtension();
                            mstrLog2.AppendLine(Importbot.SetLog(Log_Dic[each.UID]));
                        }
                    }
                    tool._A.UpdateValues(ClubUpdateList);
                    FISCA.LogAgent.ApplicationLog.Log("社團", "更新匯入", mstrLog2.ToString());
                }
                ClubEvents.RaiseAssnChanged();
            }

            return("");
        }
Пример #2
0
        public string SetLog(ImputLog log)
        {
            //檢查與確認資料是否被修改
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", log.New_club.SchoolYear, log.New_club.Semester, log.New_club.ClubName));
            if (log.lo_CLUB.ClubNumber != log.New_club.ClubNumber)
            {
                sb.AppendLine(ByOne("代碼", log.lo_CLUB.ClubNumber, log.New_club.ClubNumber));
            }

            if (log.lo_CLUB.Location != log.New_club.Location)
            {
                sb.AppendLine(ByOne("場地", log.lo_CLUB.Location, log.New_club.Location));
            }

            if (log.lo_CLUB.ClubCategory != log.New_club.ClubCategory)
            {
                sb.AppendLine(ByOne("類型", log.lo_CLUB.ClubCategory, log.New_club.ClubCategory));
            }

            if (log.lo_CLUB.Level != log.New_club.Level)
            {
                sb.AppendLine(ByOne("評等", log.lo_CLUB.Level, log.New_club.Level));
            }

            if (log.lo_CLUB.RefTeacherID != log.New_club.RefTeacherID)
            {
                ByTeacher("老師1", log.lo_CLUB.RefTeacherID, log.New_club.RefTeacherID);
            }

            if (log.lo_CLUB.RefTeacherID2 != log.New_club.RefTeacherID2)
            {
                ByTeacher("老師2", log.lo_CLUB.RefTeacherID2, log.New_club.RefTeacherID2);
            }

            if (log.lo_CLUB.RefTeacherID3 != log.New_club.RefTeacherID3)
            {
                ByTeacher("老師3", log.lo_CLUB.RefTeacherID3, log.New_club.RefTeacherID3);
            }

            if (log.lo_CLUB.About != log.New_club.About)
            {
                sb.AppendLine(ByOne("簡介", log.lo_CLUB.About, log.New_club.About));
            }

            if (log.lo_CLUB.DeptRestrict != log.New_club.DeptRestrict)
            {
                sb.AppendLine(ByOne("科別", GetDeptName(log.lo_CLUB.DeptRestrict), GetDeptName(log.New_club.DeptRestrict)));
            }

            if (log.lo_CLUB.GenderRestrict != log.New_club.GenderRestrict)
            {
                sb.AppendLine(ByOne("限制:性別", log.lo_CLUB.GenderRestrict, log.New_club.GenderRestrict));
            }

            if (log.lo_CLUB.Grade1Limit != log.New_club.Grade1Limit)
            {
                sb.AppendLine(ByOne("限制:一年級人數", ByInet(log.lo_CLUB.Grade1Limit), ByInet(log.New_club.Grade1Limit)));
            }

            if (log.lo_CLUB.Grade2Limit != log.New_club.Grade2Limit)
            {
                sb.AppendLine(ByOne("限制:二年級人數", ByInet(log.lo_CLUB.Grade2Limit), ByInet(log.New_club.Grade2Limit)));
            }

            if (log.lo_CLUB.Grade3Limit != log.New_club.Grade3Limit)
            {
                sb.AppendLine(ByOne("限制:二年級人數", ByInet(log.lo_CLUB.Grade3Limit), ByInet(log.New_club.Grade3Limit)));
            }

            if (log.lo_CLUB.Grade3Limit != log.New_club.Grade3Limit)
            {
                sb.AppendLine(ByOne("限制:二年級人數", ByInet(log.lo_CLUB.Grade3Limit), ByInet(log.New_club.Grade3Limit)));
            }
            sb.AppendLine("");
            return(sb.ToString());
        }