public void ThreadGo()
 {
     HTTPReq.HttpGet(url, "action=handon.upload&lessonid=" + lessonid + "&courseid=" + courseid + "&classid=" + classid + "&result=" + data + "");
 }
Esempio n. 2
0
        public static int uploadOfflineData(LessonEvents le)
        {
            string _lessonid  = "0";
            int    _classid   = le.classid;
            int    _courseid  = le.courseid;
            int    _teacherid = le.teacherid;

            int nRet = 0;

            foreach (LessonEvent ev in le.eventlist)
            {
                string tm  = ev.tm;
                string url = ev.request;
                if (tm == null)
                {
                    tm = url.Substring(url.IndexOf("&t=") + 3, 14);
                }
                string data = ev.filepath + "&offline=1";

                string src     = tm + "_" + Global.getSchoolID() + "_" + _classid + "_" + KEY;
                string sign    = GetMD5(src);
                string keyTemp = sign.Substring(4, 16);
                if (_lessonid != "0")
                {
                    data = data.Replace("lessonid=0", "lessonid=" + _lessonid);
                }

                if (_lessonid == "0" && ev.type != LessonEventType.ClassOn)
                {
                    continue;
                }

                if (ev.type == LessonEventType.UploadFile && _lessonid != "0")
                {
                    string ret = HTTPReq.UploadFile(url, ev.filepath);
                }
                else
                {
                    string dataEncrypt = AesEncrypt(data, keyTemp);//跟java的substring不一样
                    Log.Info("OfflineUpload. url=" + url + ", " + data);
                    string retCrypt = HTTPReq.HttpPost(url, dataEncrypt);
                    string ret      = AesDecrypt(retCrypt, keyTemp);
                    if (ev.type == LessonEventType.ClassOn && ret.Length > 0)
                    {
                        JObject jo = (JObject)JsonConvert.DeserializeObject(ret);
                        _lessonid = jo["data"]["lessonid"].ToString();
                        string _index      = jo["data"]["index"].ToString();
                        string _coursename = jo["data"]["coursename"].ToString();
                        nRet++;
                    }
                    else
                    {
                        if (ret.Length > 0)
                        {
                            nRet++;
                        }

                        if (ev.type == LessonEventType.ClassOff)
                        {
                        }
                        else
                        {
                        }
                    }
                }
            }
            return(nRet);
        }
Esempio n. 3
0
        /// <summary>
        /// 采集器----GetXiti
        /// </summary>
        public static string GetXitiResult(bool bClear = false)
        {
            Log.Debug("GetXitiResult()_1 ");
            string ret = "";

            if (Global.isHDPassive())
            {
                Log.Info("GetXitiResult()_2 ");
                string url       = Global.url_recv;
                string url_param = "action=xiti.get";
                url_param += "&classid=0";
                url_param += "&courseid=0";
                url_param += "&lessonid=0";
                if (bClear)
                {
                    Thread thread = new Thread(delegate()
                    {
                        ret = HTTPReq.HttpGet(url + url_param);
                        Log.Info("HD_Async_Xiti: " + url + url_param + ", ret=" + ret);
                    });
                    thread.Start();
                }
                else
                {
                    string json = HTTPReq.HttpGet(url + url_param);
                    Log.Info("HD_Xiti_Passive: " + url + url_param + ", json=" + json);

                    CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(json.Replace("(", "").Replace(")", ""));
                    if (cb != null && cb.data.Length > 0)
                    {
                        string data = cb.data;

                        for (int i = 0; i < data.Split('|').Length - 1; i++)
                        {
                            int    num    = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", ""));
                            string answer = data.Split('|')[i].Split(':')[1];
                            //57A299E5,A;57A299E5,B;57A299E6,C;57A299E6,D;57A299E6,S
                            string[]           szKey  = answer.Split(';');
                            SortedSet <string> keySet = new SortedSet <string>();
                            for (int k = 0; k < szKey.Length; k++)
                            {
                                string _answer = szKey[k].Split(',')[1];
                                if (_answer == "S")
                                {
                                    continue;
                                }
                                if (!keySet.Contains(_answer))
                                {
                                    keySet.Add(_answer);
                                }
                            }
                            string keys = "";
                            foreach (string key in keySet)
                            {
                                keys += key;
                            }
                            if (keys.Length == 0)
                            {
                                continue;
                            }
                            string context = num + ":" + keys;
                            ret += (ret.Length > 0 ? "|" : "") + context;
                        }
                    }
                }
            }
            else
            {
                if (bClear)
                {
                    Log.Debug("GetXitiResult()_2, Clear...");
                    string data = Httpd.ClearMQ_Xiti();
                    if (data.Length > 0)
                    {
                        Common.uploadInvalidXitiResult(data);
                    }
                }
                else
                {
                    Log.Debug("GetXitiResult()_3_1, Pop...");
                    ret = Httpd.PopMQ_Xiti();
                    Log.Debug("GetXitiResult()_3_2, Pop..." + ret);
                }
            }
            return(ret);
        }
Esempio n. 4
0
        private static void Update()
        {
            string versionC = Global.getVersion();
            string versionS = "";
            string url      = "http://" + Global.HOST + "/user.do?action=update&schoolid=" + Global.getSchoolID() + "&classid=" + Global.getClassID() + "&version=" + Global.getVersion();
            //string json = HTTPReq.doGet(url,1000);
            string json = HTTPReq.HttpGet(url);

            if (json.Length == 0)
            {
                return;
            }
            Log.Info("Update, ret=" + json);
            try
            {
                UpdateInfo resp = JsonOper.DeserializeJsonToObject <UpdateInfo>(json.Replace("(", "").Replace(")", ""));
                if (resp == null)
                {
                    return;
                }


                foreach (UpdateItem item in resp.updateinfolist)
                {
                    Log.Info(item.toJson());
                    if (item.type == 1)//
                    {
                        versionS = item.version;
                        Log.Info("versionC=" + versionC + ", versionS=" + versionS);
                        string[] szVerS  = versionS.Split('.');
                        string[] szVerC  = versionC.Split('.');
                        string   zipurl  = item.path;
                        bool     bUpdate = false;
                        for (int i = 0; i < szVerS.Length; i++)
                        {
                            int nS = Util.toInt(szVerS[i]);
                            int nC = Util.toInt(szVerC[i]);
                            if (nS > nC)
                            {
                                bUpdate = true;
                                break;
                            }
                            else if (nS < nC)
                            {
                                return;
                            }
                            else
                            {
                                continue;
                            }
                        }

                        if (bUpdate)
                        {
                            string update  = Application.StartupPath + "\\RueUpdate.exe";
                            string update2 = Application.StartupPath + "\\RueUpdate2.exe";
                            Log.Info(update);
                            Log.Info(update2);
                            if (File.Exists(update2))
                            {
                                Log.Info("copy...");
                                KillProcess("RueUpdate.exe");
                                try
                                {
                                    File.Delete(update);
                                    File.Copy(update2, update, true);
                                    Log.Info("delete update2...");
                                    File.Delete(update2);
                                }
                                catch (Exception e)
                                {
                                    Log.Info("File.copy(update2,update) and File.Delete exception. " + e.Message);
                                }
                            }
                            else if (File.Exists(update))
                            {
                                string param = versionS + " " + zipurl;
                                Log.Info("run update.exe now..." + param);
                                Process.Start(update, param);
                            }
                        }
                    }
                    else if (item.type == 2)
                    {
                        Global.setRyktUpdateInfo(item);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }
        }