public static string ClearHandon(bool bUpload = true) { string ret = ""; if (Global.isHDPassive()) { string url = Global.url_recv; string url_param = "action=handon"; url_param += "&classid=0"; url_param += "&courseid=0"; url_param += "&lessonid=0"; if (bUpload) { Thread thread = new Thread(delegate() { ret = HTTPReq.HttpGet(url + url_param); Log.Info("HD_Async_Handon: " + url + url_param + ", ret=" + ret); }); thread.Start(); } } else { string data = Httpd.ClearMQ_Handon(); if (bUpload) { Common.uploadInvalidHandon(data); } } return(ret); }
/// <summary> /// 采集器----清空之前的按键信息 /// </summary> public static int HD_Test() { //if (Global.isHDPassive()) { string url = Global.url_recv; string url_param = "action=classroom.get"; url_param += "&callback=CB"; //&callback=CB&tm=5755587A string ret1 = HTTPReq.HttpGet(url + url_param, 3000); string ret2 = HTTPReq.HttpGet(url + url_param, 3000); int nRet1 = 0; int nRet2 = 0; if (ret1.Length > 0 && ret1.IndexOf("classroom.get") > 0) { nRet1 = 1; } if (ret2.Length > 0 && ret2.IndexOf("classroom.get") > 0) { nRet2 = 1; } if (nRet1 == 1 || nRet2 == 1) { return(1); } else { return(0); } } }
public static string GetHandon() { string result = ""; if (Global.isHDPassive()) { string url = Global.url_recv; string url_param = "action=handon"; url_param += "&classid=0"; url_param += "&courseid=0"; url_param += "&lessonid=0"; string ret = HTTPReq.HttpGet(url + url_param); Log.Debug("HD_Handon: " + url + url_param + ", ret=" + ret); CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(ret.Replace("(", "").Replace(")", "")); if (cb != null && cb.data.Length > 0) { result = cb.data.Replace("-", ""); if (result.EndsWith("|")) { result = result.Substring(0, result.Length - 1); } } } else { result = Httpd.PopMQ_Handon(); } return(result); }
private void SaveInfo() { string ip = GetLocalIPAddress(); string sid = Global.getSchoolID() + ""; string cid = Global.getClassID() + ""; string apiurl = Global.url_hd; string str = HTTPReq.HttpGet(apiurl + "action=appsync&ip=" + ip + "&classid=" + cid + "&schoolid=" + sid + ""); }
/// <summary> /// 异步同步文件列表到云端 /// </summary> public void AsnycSubmit() { int classid = Global.getClassID(); int schoolid = Global.getSchoolID(); string apiurl = Global.url_assistant; string url_param = "action=assfilenamebyclassroomid.set&filenames=" + submitStr + "&classid=" + classid + "&schoolid=" + schoolid + ""; HTTPReq.HttpGet(apiurl + url_param); Log.Info(apiurl + url_param); }
// 根据移动登录后返回的uid获取老师信息 public static string verifyTheTeacher(string uid) { string url = "http://api.skyeducation.cn/EduApi_Test/pcgroupnet?action=verifyTheTeacher&uid=" + uid; string ret = HTTPReq.HttpGet(url); if (ret.Length > 0) { JObject jo = (JObject)JsonConvert.DeserializeObject(ret); string _data = jo["data"].ToString(); string _ret = jo["ret"].ToString(); string _msg = jo["msg"].ToString(); return(_data); } else { return(""); } }
private void setHD_PcIp() { string ips = GetInternalIPList(); string[] iplist = ips.Split(','); string pcip = ""; foreach (string ip in iplist) { if (ip.StartsWith("172.18.20")) { pcip = ip; break; } } if (pcip.Length == 0) { return; } pcip = "172.18.201.3"; string host = Global.getHDIP(); String url = "http://P1/EduApi/hd.do?action=pcip.get&callback=CB&tm=P2";// String utctime = getUTC(); url = url.Replace("P1", host); url = url.Replace("P2", utctime); url = url.Replace("P3", pcip); string resp = HTTPReq.HttpGet(url); Log.Info(url + ", ret=" + resp); if (resp.IndexOf(pcip) < 0) { String url_set = "http://P1/EduApi/hd.do?action=pcip.set&callback=CB&ip=P2&tm=P3";// url_set = url_set.Replace("P1", host); url_set = url_set.Replace("P2", pcip); url_set = url_set.Replace("P3", utctime); string resp2 = HTTPReq.HttpGet(url_set); Log.Info(url_set + ", ret=" + resp2); } }
private void Theout(object sender, System.Timers.ElapsedEventArgs e) { if (Interlocked.Exchange(ref inTimer, 1) == 0) { string json = HTTPReq.HttpGet(Global.url_recv + "action=xiti.get&classid=0&lessonid=0&xitiid=0"); if (json.Length > 55) { log.Info("Theout() xiti.get=" + json); } CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(json.Replace("(", "").Replace(")", "")); if (cb != null && cb.data.Length > 0) { string data = cb.data; string context = ""; 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]; int _answerLen = answer.Split(';').Length; string getAnswer = ""; if (_answerLen == 1) { getAnswer = answer.Split(';')[_answerLen - 1].Split(',')[1]; } else { getAnswer = answer.Split(';')[_answerLen - 2].Split(',')[1]; } context = num + ":" + getAnswer; for (int j = 0; j < al.Count; j++) { PictureBox lb = (PictureBox)al[j]; PictureBox text = (PictureBox)alText[j]; if ((num - 1) == j && (int)clickstate[j] == 0) { LabelStateEvent(context, lb, text, j + 1); clickstate[j] = 1; } } } } Interlocked.Exchange(ref inTimer, 0); } }
private void button2_Click(object sender, EventArgs e) { //测试采集器 String url = "http://P1/EduApi/hd.do?action=handon&classid=0";//&callback=CB String utctime = getUTC(); url = url.Replace("P2", utctime); String ret = HTTPReq.HttpGet(url, false); if (ret.Length == 0) { MessageBox.Show("测试失败,请确认IP地址和网络连接!", "警告"); } else { MessageBox.Show("测试成功!", "提示"); } //ThreadStart starter = delegate { HTTPReq.HttpGet(url, true); }; //new Thread(starter).Start(); }
public static string getHDID() { string url = Global.url_recv + "/EduApi/hd.do?action=serialid.get&tm=" + Util.getUTC(); string resp = HTTPReq.HttpGet(url).Replace("\"", ""); int pos1 = resp.IndexOf("deviceid"); if (pos1 > 0) { try { string tmp1 = resp.Substring(pos1 + 9);//"deviceid:" int pos2 = tmp1.IndexOf(","); string tmp2 = tmp1.Substring(0, pos2); if (tmp2.Length > 0) { Global.setHDID(tmp2); } return(tmp2); }catch (Exception e) {} } return(""); }
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); } }
/// <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); }
public void ThreadGo() { HTTPReq.HttpGet(url, "action=handon.upload&lessonid=" + lessonid + "&courseid=" + courseid + "&classid=" + classid + "&result=" + data + ""); }