Esempio n. 1
0
        public static bool loadClassInfo()
        {
            if (m_classid == -1)
            {
                return(false);
            }

            Classes c = m_db.getClassById(m_classid);

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

            string   dir      = Application.StartupPath + "\\conf\\";
            string   filename = m_schoolid + "-" + m_classid + ".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!");
                Log.Debug(g_ClassInfoStr);
            }
            else
            {
                Log.Error("getClassInfo error.");
                g_ClassInfoStr = fo.ReadFile();
                Log.Error("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;
                int nGrade   = g_ClassInfo.Data.Grade;
                Global.setGrade(nGrade);
                Global.setClassID(nClassID);
                Global.setClassname(g_ClassInfo.Data.Name);
                Global.setUploadInvalidData(g_ClassInfo.Data.UploadInvalidData);
                g_Studentlist.Clear();

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

                //write to RueSqlite.db
                {
                    //更新学生信息
                    if (g_Studentlist.Count > 0)
                    {
                        int nDel = m_db.delUser(nClassID, 2);
                        int nAdd = m_db.addUser(g_Studentlist);
                        int a    = nDel;
                    }
                }
            }
            return(true);
        }