Ejemplo n.º 1
0
        public static bool loadSchoolInfo()
        {
            log.Info("Global.loadSchoolInfo() Now.");
            loadSchoolConfig();

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

            string strSchoolInfo = Common.getSchoolInfo();

            if (strSchoolInfo.Length > 0)
            {
                //更新本地缓存
                fo.WriteFile(strSchoolInfo);
                g_SchoolInfoStr = strSchoolInfo;
                log.Info("Global.loadSchoolInfo() ...2-ok..." + g_ClassInfoStr);
            }
            else
            {
                log.Info("getSchoolInfo error.");
                g_SchoolInfoStr = fo.ReadFile();
                log.Info("Global.loadClassInfo() ...2-err..." + g_ClassInfoStr);
            }

            if (strSchoolInfo.Length > 0)
            {
                SchoolInfo  info        = JsonOper.DeserializeJsonToObject <SchoolInfo>(strSchoolInfo);
                User[]      si          = info.teacherlist;
                List <User> teacherlist = new List <User>();
                foreach (User u in si)
                {
                    teacherlist.Add(u);
                }

                m_coursetable = info.coursetable;
                int nDel = m_db.delTeachers(m_schoolid);
                int nAdd = m_db.addUser(teacherlist);
                int a    = nDel;
                Global.setSchoolname(info.schoolname);
                m_db.delSchool(info.schoolid);
                m_db.addSchool(info.schoolid, info.schoolname);

                string coursetimes = info.coursetime;
                m_db.delCourseTime();
                m_db.addCourseTime(coursetimes);
                log.Info("Global.loadSchoolInfo() Over.");
                g_SchoolInfoStr = strSchoolInfo;
                return(true);
            }
            else
            {
                log.Info("getSchoolInfo error.");
                m_schoolname = m_db.getSchoolname(m_schoolid);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void loadClassInfo()
        {
            //从配置文件中获取
            string schoolid    = config.AppSettings.Settings["schoolid"].Value;
            string classroomid = config.AppSettings.Settings["classroomid"].Value;
            string hdip        = config.AppSettings.Settings["hdip"].Value;
            string updateflag  = config.AppSettings.Settings["hdip-autoupdate"].Value;

            string dir      = Application.StartupPath + "\\conf\\";
            string filename = schoolid + "-" + classroomid + ".conf";
            string filepath = dir + filename;

            FileOper fo = new FileOper(dir, filename);

            string strClassInfo = Common.getClassInfo();

            if (strClassInfo.Length > 0)
            {
                //更新本地缓存
                fo.DeleteFile();
                fo.Context = strClassInfo;
                fo.WriteFile();
            }
        }
Ejemplo n.º 3
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);
        }