Exemplo n.º 1
0
        public string ReturnResult()
        {
            FileOper fo = new FileOper();

            fo.DirName  = DateTime.Now.ToString("yyyyMMdd");
            fo.FilePath = Application.StartupPath + "\\" + fo.DirName + "\\";
            fo.FileName = _id + ".txt";
            string content = fo.ReadFile();

            return(content);
        }
Exemplo n.º 2
0
        public void ReadFileEvent()
        {
            if (this.InvokeRequired)
            {
                InvokeCompeitiveReadFile readCallback = new InvokeCompeitiveReadFile(ReadFileEvent);
                this.Invoke(readCallback, new object[] { });
            }
            else
            {
                string answerStr = fo.ReadFile();
                _rightList = new ArrayList();
                for (int i = 0; i < answerStr.Split(',').Length; i++)
                {
                    if (answerStr.Split(',')[i] != "" && answerStr.Split(',')[i].Split(':')[1] == _req_answer)
                    {
                        _rightList.Add(si[i].Name);
                    }
                }
                if (_rightList.Count > 2 || (answerStr.Split(',').Length - 1) == si.Length)
                {
                    t1.Enabled = false;
                    t.Enabled  = false;

                    if (f11 == null)
                    {
                        Common.uploadCompetitiveAnswer(_xitiId, _req_answer, answerStr, _rightList);

                        f11 = new Form11(_req_answer, _rightList);
                        f11.Show();
                    }
                    else
                    {
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static int loadSchoolInfo_Local()
        {
            string dir      = Application.StartupPath + "\\conf\\";
            string filename = m_schoolid + ".conf";

            FileOper fo   = new FileOper(dir, filename);
            string   data = fo.ReadFile();

            if (data.Length > 0)
            {
                //TODO: 如果文件中有,从文件中获取
                //TODO: 如果文件中没有,则从DB中获取
                g_SchoolInfoStr = data;

                SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(data);
                Global.setSchoolname(info.schoolname);
                g_szClasses = info.classlist;
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 4
0
        public static int loadSchoolInfo(int schoolid, string authcode)
        {
            int ret = 0;

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

            string strSchoolInfo = Common.getSchoolInfo(schoolid, authcode);

            if (strSchoolInfo.Length > 0)
            {
                SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(strSchoolInfo);
                if (info.schoolid > 0)
                {
                    Global.saveSchoolConfig(schoolid, authcode);
                    g_szAwardType = info.awardtypelist;
                    //更新本地缓存
                    fo.WriteFile(strSchoolInfo);
                    g_SchoolInfoStr = strSchoolInfo;
                    Log.Info("Global.loadSchoolInfo() ...2-ok!");
                    Log.Debug(g_SchoolInfoStr);

                    ret = 1;
                }
            }
            else
            {
                Log.Info("getSchoolInfo error, load from conf now...");
                string data = fo.ReadFile();
                if (data.Length > 0)
                {
                    g_SchoolInfoStr = data;
                    ret             = 2;
                }

                Log.Info("Global.loadSchoolInfo() ...2-err..." + g_SchoolInfoStr);
            }

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

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

                g_szClasses = info.classlist;
                int nClassDel = m_db.delClassBySchoolid(m_schoolid);
                int nClassAdd = 0;
                foreach (Classes c in g_szClasses)
                {
                    nClassAdd += m_db.addClass(c);
                }
                Log.Info("Global.loadSchoolInfo() nClassDel=" + nClassDel + ", nClassAdd=" + nClassAdd);

                string coursetimes = info.coursetime;
                m_db.delCourseTime();
                m_db.addCourseTime(coursetimes);
                Log.Info("Global.loadSchoolInfo() Over.");
                g_SchoolInfoStr = strSchoolInfo;
            }
            else if (ret == 2)
            {
                Log.Info("getSchoolInfo error.");

                SchoolInfo  info        = JsonOper.DeserializeJsonToObject <SchoolInfo>(g_SchoolInfoStr);
                User[]      si          = info.teacherlist;
                List <User> teacherlist = new List <User>();
                foreach (User u in si)
                {
                    teacherlist.Add(u);
                }
                Global.setSchoolID(schoolid);
                Global.setSchoolname(info.schoolname);
                g_szClasses = info.classlist;
            }
            if (g_SchoolInfoStr.Length == 0)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        }
Exemplo n.º 5
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);
        }