示例#1
0
        public static bool loadClassInfo()
        {
            log.Info("Global.loadClassInfo() now...");
            loadSchoolConfig();

            log.Info("Global.loadClassInfo() ...1...");
            Classes c = m_db.getClassByRoomid(m_classroomid);

            if (c != null)
            {
                Global.setClassID(c.id);
                Global.setClassname(c.name);
            }

            string   dir      = Application.StartupPath + "\\conf\\";
            string   filename = m_schoolid + "-" + m_classroomid + ".conf";
            FileOper fo       = new FileOper(dir, filename);

            string strClassInfo = Common.getClassInfo();

            if (strClassInfo.Length > 0)
            {
                //更新本地缓存
                fo.WriteFile(strClassInfo);

                g_ClassInfoStr = strClassInfo;
                log.Info("Global.loadClassInfo() ...2-ok..." + g_ClassInfoStr);
            }
            else
            {
                log.Info("getClassInfo error.");
                g_ClassInfoStr = fo.ReadFile();
                log.Info("Global.loadClassInfo() ...2-err..." + g_ClassInfoStr);
            }

            if (g_ClassInfoStr.Length > 0)
            {
                g_ClassInfo        = JsonOper.DeserializeJsonToObject <ClassInfo>(g_ClassInfoStr);
                g_StudentInfoArray = g_ClassInfo.Data.Student;
                g_TeacherArray     = g_ClassInfo.Data.Teacher;
                int nClassID = g_ClassInfo.Data.ID;
                Global.setClassID(nClassID);
                Global.setClassname(g_ClassInfo.Data.Name);
                g_Studentlist.Clear();

                foreach (StudentInfo s in g_StudentInfoArray)
                {
                    User u = new User();
                    u.id        = Int32.Parse(s.ID);
                    u.name      = s.Name;
                    u.seat      = s.SEAT.Replace("-", "");
                    u.type      = 2;//student
                    u.schoolid  = m_schoolid;
                    u.classid   = nClassID;
                    u.classname = Global.getClassname();
                    g_Studentlist.Add(u);
                }

                //write to RueSqlite.db
                {
                    //更新班级教室信息
                    {
                        int nDel = m_db.delClass(m_classroomid);
                        int nAdd = m_db.addClass(nClassID, 0, Global.getClassname(), m_schoolid, m_classroomid, m_hdip);
                        int a    = nAdd;
                    }
                    log.Info("Global.loadClassInfo() ...3.1...");
                    //更新学生信息

                    log.Info("Global.loadClassInfo() ...3.2...");
                    if (g_Studentlist.Count > 0)
                    {
                        int nDel = m_db.delUser(nClassID, 2);
                        log.Info("Global.loadClassInfo() ...3.3...");
                        int nAdd = m_db.addUser(g_Studentlist);
                        log.Info("Global.loadClassInfo() ...3.4...");
                        int a = nDel;
                    }
                }
            }
            log.Info("Global.loadClassInfo() Over.");
            return(true);
        }