protected override IConfiguration GetConfiguration() { if (this.Configuration == null) { Httpd httpd = new Httpd(this.ConfigurationFile, this.AlpheusEnvironment); if (httpd.ParseSucceded) { this.Configuration = httpd; this.ConfigurationInitialised = true; } else { this.AuditEnvironment.Error("Could not parse configuration from {0}.", httpd.FullFilePath); if (httpd.LastParseException != null) { this.AuditEnvironment.Error(httpd.LastParseException); } if (httpd.LastIOException != null) { this.AuditEnvironment.Error(httpd.LastIOException); } this.Configuration = null; this.ConfigurationInitialised = false; } } return(this.Configuration); }
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); }
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); }
private void Theout(object sender, System.Timers.ElapsedEventArgs e) { if (Interlocked.Exchange(ref inTimer, 1) == 0) { string data = Common.GetXitiResult();//FormPPTPractise if (data.Length > 0) { Log.Info("xiti.get=" + data); DateTime tm_now = DateTime.Now; TimeSpan createtimespan = new TimeSpan(tm_create.Ticks); TimeSpan nowtimespan = new TimeSpan(tm_now.Ticks); TimeSpan timespan = nowtimespan.Subtract(createtimespan).Duration(); int timeDiff = timespan.Minutes * 60 + timespan.Seconds; for (int i = 0; i < data.Split('|').Length; i++) { int num = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", "")); string answer = data.Split('|')[i].Split(':')[1]; string context = num + ":" + answer + ":" + timeDiff; Log.Info("vote.item=" + context); if (answer.Length > 1) { answer = answer.Substring(answer.Length - 1); } statisticABCD(num, answer); VoteColumnEvent(answer, pictureBox_A); } Httpd.NotifyVoteEvent(); } Interlocked.Exchange(ref inTimer, 0); } }
private void Form1_Load(object sender, EventArgs e) { try { EService service = new EService(); m_Host = new ServiceHost(service); m_Host.Open(); m_HttpdComet = new Httpd(); thread_comet = new Thread(m_HttpdComet.run); thread_comet.Start(); ////////////////////////////////////////////////////////////// // 系统管理 发现IP地址变更后自动重启服务 ////////////////////////////////////////////////////////////// thread_Manage = new Thread(delegate() { string ip1 = GetInternalIPList(); while (true) { string ip2 = GetInternalIPList(); if (ip1 != ip2) { Log.Info("ip1=" + ip1 + ". ip2=" + ip2); ip1 = ip2; restartHttpd(); } Thread.Sleep(8000); } }); thread_Manage.Start(); ////////////////////////////////////////////////////////////// // 系统管理 发现IP地址变更后自动重启服务 ////////////////////////////////////////////////////////////// thread_DeviceStatusCheck = new Thread(Thread_CheckDeviceStatus); thread_DeviceStatusCheck.Start(); } catch (Exception ex) { Log.Error(ex.Message); MessageBox.Show("小助手启动异常,请联系管理员", "Warning!!!"); } }
private void restartHttpd() { Log.Info("restartHttpd_8989 now..."); { if (m_HttpdComet != null) { m_HttpdComet.stop(); m_HttpdComet = null; } if (thread_comet != null) { thread_comet.Abort(); thread_comet.Interrupt(); } m_HttpdComet = new Httpd(); thread_comet = new Thread(m_HttpdComet.run); thread_comet.Start(); } Log.Info("restartHttpd_8989 over..."); }
//点击选择老师 public void pictureBox_SelectTeacher_Click(object sender, EventArgs e) { //http://172.18.201.3:8989/user.do?action=login&courseid=12&callback=angular.callbacks._8 PictureBox box = (PictureBox)sender; string name = box.Name; int courseid = int.Parse(name); foreach (User u in Global.g_TeacherArray) { if (u.courseid == courseid) { Dictionary <String, String> pList = new Dictionary <String, String>(); pList.Add("courseid", "" + courseid); Httpd.handleLogin(pList, ""); //TODO:WQ 开始上课 EService.ShowSelectTeacher(false, 1); //调用控制栏 Form1.ShowController(true); } } }
private void Theout(object sender, System.Timers.ElapsedEventArgs e) { if (Interlocked.Exchange(ref inTimer, 1) == 0) { string json = ""; if (mode == 1) { json = Common.GetHandon(); } else { json = Common.GetXitiResult(); } Log.Debug("Theout. " + json); string data = json; if (data.Length > 0) { DateTime tm_now = DateTime.Now; TimeSpan createtimespan = new TimeSpan(tm_create.Ticks); TimeSpan nowtimespan = new TimeSpan(tm_now.Ticks); TimeSpan timespan = nowtimespan.Subtract(createtimespan).Duration(); int timeDiff = timespan.Minutes * 60 + timespan.Seconds; Log.Info("Theout. handon=" + data + ", timediff=" + timeDiff); //0-3:56AAA549,H|0-4:56AAA54A,H| string context = ""; string[] szItem = data.Split('|'); for (int i = 0; i < szItem.Length; i++) { string item = szItem[i]; int num = Convert.ToInt16(item.Split(':')[0].ToString()); string answer = ""; if (mode == 1) { answer = "H"; } else { answer = item.Split(':')[1]; } string groupname = getGroup(num); context = groupname + ":" + answer + ":" + timeDiff; Httpd.setGroupResult(context); int _count = 1; if (stuPushCount.Contains(num)) { _count = (int)stuPushCount[num] + 1; stuPushCount.Remove(num); } stuPushCount.Add(num, _count); if (_resutlSet.Contains(num)) { ;//重复按 } else { //_resutlSet.Add(num);//20160520 不缓存,因为经常导致不通知PAD。 Log.Debug("LabelStateEvent id=" + num + ",group=" + groupname + ", al.Count=" + al.Count); if (Global.m_grouplist != null) { int groupsize = Global.m_grouplist.grouplist.Length; Group[] szGroup = Global.m_grouplist.grouplist; for (int j = 0; j < groupsize; j++) { PictureBox lb = (PictureBox)al[j]; PictureBox text = (PictureBox)alText[j]; if (szGroup[j].name == groupname && (int)clickstate[j] == 0) { LabelStateEvent(context, lb, text, j + 1); clickstate[j] = 1; Log.Debug("LabelStateEvent id=" + num + ",group=" + groupname + ", al.Count=" + al.Count + ", ok."); } } } } } } Interlocked.Exchange(ref inTimer, 0); } }
private void ReadFilePath(string diskPath, int field, bool bNotify = false) { currentdir = diskPath; if (diskPath.LastIndexOf("\\") == diskPath.Length - 1) { diskPath = diskPath.Substring(0, diskPath.Length - 1); } ArrayList autoAddedFileList = new ArrayList(); ArrayList al = Disk.MergrObj(diskPath.Replace("\r\n", "")); btnList = new ArrayList(); if (field == 1) { Button backBtn = CreateBackBtn(); btnList.Add(backBtn); } bool bAutoSync = false; string[] szType = { "ppt", "pptx", "doc", "docx", "pdf", "mp3", "wma", "wmv", "mp4", "swf" }; ArrayList filelist0 = Disk.getFilelist(diskPath.Replace("\r\n", ""), szType); if (filelist0.Count <= 5) { bAutoSync = true; } else { Httpd.pushFilelistTips("U盘课件文件超过5个!\r\n请手动选择课件文件,并使用鼠标\"右键\"选择\"添加到如e小助手\""); } bAutoSync = false; for (int k = 0; k < al.Count; k++) { string value = al[k].ToString(); Button btn = new Button(); btn.Size = new System.Drawing.Size(70, 70); btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(153, 209, 255); btn.FlatAppearance.BorderSize = 0; btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255); btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255); btn.TextAlign = ContentAlignment.BottomCenter; btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.AllowDrop = true; if (value.Split('|')[0].ToString() == "0") { btn.BackgroundImage = global::RueHelper.Properties.Resources.wenjianjia; btn.Name = "0|" + diskPath + "|" + value.Split('|')[2].ToString(); } else { string filename = value.Split('|')[2].ToString(); string extName = filename.Substring(filename.LastIndexOf(".") + 1, (filename.Length - filename.LastIndexOf(".") - 1)); btn.BackgroundImage = FileICON(extName);//load if (btn.BackgroundImage == null) { continue; } btn.Name = "1|" + diskPath + "|" + value.Split('|')[2].ToString(); if (filename.StartsWith("~$")) { continue; } if (field == 0 && bAutoSync) { //仅仅在插上U盘时自动加载 string _filepath = diskPath + "\\" + filename; autoAddedFileList.Add(_filepath); continue; } } this.label6.Text = diskPath + "\\" + value.Split('|')[2].ToString(); btn.Text = value.Split('|')[1].ToString(); string tooltipStr = value.Split('|')[2].ToString() + "\r\n类型:" + value.Split('|')[3].ToString() + "\r\n修改日期:" + value.Split('|')[5].ToString() + "\r\n大小:" + value.Split('|')[4].ToString() + ""; this.toolTip1.SetToolTip(btn, tooltipStr); addButtonlist_Left(btn); } try { for (int i = 0; i < autoAddedFileList.Count; i++) { string _path = (string)autoAddedFileList.ToArray()[i]; string _name = Path.GetFileName(_path); EService.selectFile(_name, _path); this.AddFile(_path, false); } }catch (Exception e1) { ;// } Thread thread = new Thread(delegate() { if (autoAddedFileList.Count == 0) { return; } bExporting = true; try { string title = Global.getSchoolname() + " - " + Global.getClassname() + ""; if (bNotify) { if (fNotify == null) { fNotify = new FormNotify(title, "\r\n 课件导入中,请稍后!", 30); } this.Invoke(new System.EventHandler(this.showForm), new object[] { fNotify, null }); fNotify.InvokeUpdate(title, "\r\n 课件导入中,请稍后!"); } for (int i = 0; i < autoAddedFileList.Count; i++) { string filepathSrc = (string)autoAddedFileList.ToArray()[i]; Log.Info("copy ppt......0:" + filepathSrc); string _fname = Path.GetFileName(filepathSrc); if (_fname.IndexOf("ppt") > 0 || _fname.IndexOf("PPT") > 0) { Log.Info("copy ppt......3"); MyPPT.exportImg(filepathSrc); Log.Info("copy ppt......4"); } Log.Info("copy ppt......5"); } bExporting = false; if (bNotify && fNotify != null) { fNotify.InvokeUpdate(title, "\r\n 课件导入完毕!"); Thread.Sleep(5000); fNotify.InvokeClose(); fNotify = null; } }catch (Exception e1) { Log.Error("Err!!! " + e1.Message); bExporting = false; try { if (fNotify != null) { fNotify.InvokeClose(); fNotify = null; } } catch (Exception e2) { Log.Error("Err!!! " + e2.Message); } } }); thread.Start(); RefreshControls(); }
/// <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 CallbackFun(int iDevice, AnswersCollection.CALLBACK_MSG msg, int param1, string param2) { if (msg == AnswersCollection.CALLBACK_MSG.MSG_PULLEDOUT) { MessageBox.Show("设备拔出"); } if (msg == AnswersCollection.CALLBACK_MSG.MSG_TEST_DATA) { string[] s = param2.ToString().Split(new char[] { '"' }); if (Global.AnswerStu == "") { if (s[7].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; Global.AnswerStu = s[3] + ":" + Global.judgeAnsewer; } else if (s[7].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; Global.AnswerStu = s[3] + ":" + Global.judgeAnsewer; } else { Global.AnswerStu = s[3] + ":" + s[7].Replace(" ", ""); } } else { if (Global.AnswerStu.IndexOf(s[3]) >= 0) { //有的话去重 string[] stringArray = Global.AnswerStu.Split('|'); List <string> listString = new List <string>(stringArray); int count = listString.Count; for (int t = 0; t < count; t++) { if (listString[t].IndexOf(s[3]) >= 0) { listString.Remove(listString[t]); if (s[7].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; listString.Add(s[3] + ":" + Global.judgeAnsewer); } else if (s[7].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; listString.Add(s[3] + ":" + Global.judgeAnsewer); } else { listString.Add(s[3] + ":" + s[7].Replace(" ", "")); } } } Global.AnswerStu = string.Join("|", listString); } else { //没有 if (s[7].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; Global.AnswerStu += "|" + s[3] + ":" + Global.judgeAnsewer; } else if (s[7].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; Global.AnswerStu += "|" + s[3] + ":" + Global.judgeAnsewer; } else { Global.AnswerStu += "|" + s[3] + ":" + s[7].Replace(" ", ""); } } } Httpd.setPracticeResult(Global.AnswerStu); } }
private void Exit() { try { MyPPT.clearImg(); } catch (Exception e) { Log.Error(e.Message); } isExit = true; //2016-04-09 Log.Info("From1.exit now..."); try { if (m_db != null) { m_db.Close(); m_db = null; } } catch (Exception e) { Log.Error(e.Message); } this.timer_lessonOff.Enabled = false; this.ShowInTaskbar = false; this.notifyIcon1.Visible = false; try { Process p = Process.GetCurrentProcess(); if (p != null) { Log.Info("From1 KillProcess now. pid=" + p.Id); Thread.Sleep(1000); p.Kill(); } } catch (Exception e) { Log.Error(e.Message); } try { if (m_Host != null) { m_Host.Close(); m_Host = null; } } catch (Exception e) { Log.Error(e.Message); } try { if (m_HttpdComet != null) { m_HttpdComet.stop(); m_HttpdComet = null; } } catch (Exception e) { Log.Error(e.Message); } try { if (thread_comet != null) { thread_comet.Abort(); thread_comet.Interrupt(); } } catch (Exception e) { Log.Error(e.Message); } try { if (thread_Manage != null) { thread_Manage.Abort(); thread_Manage.Interrupt(); } } catch (Exception e) { Log.Error(e.Message); } try { if (thread_DeviceStatusCheck != null) { thread_DeviceStatusCheck.Abort(); thread_DeviceStatusCheck.Interrupt(); } } catch (Exception e) { Log.Error(e.Message); } try { if (fNotify != null) { fNotify.Close(); fNotify = null; } } catch (Exception e) { Log.Error(e.Message); } try { if (f12 != null) { f12.Close(); f12 = null; } Application.Exit(); } catch (Exception e) { Log.Error(e.Message); } Log.Info("From1 exit over."); }
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { switch (e.newState) { case 0: // Undefined state = "Undefined"; break; case 1: // Stopped state = "Stopped"; Httpd.OnPublicMsg("Video|Stopped"); break; case 2: // Paused state = "Paused"; break; case 3: // Playing state = "Playing"; duration = axWindowsMediaPlayer2.currentMedia.duration; break; case 4: // ScanForward state = "ScanForward"; break; case 5: // ScanReverse state = "ScanReverse"; break; case 6: // Buffering state = "Buffering"; break; case 7: // Waiting state = "Waiting"; break; case 8: // MediaEnded state = "MediaEnded"; break; case 9: // Transitioning state = "Transitioning"; break; case 10: // Ready state = "Ready"; break; case 11: // Reconnecting state = "Reconnecting"; break; case 12: // Last state = "Last"; break; default: state = ("Unknown State: " + e.newState.ToString()); break; } }
public void CallbackFun(int iDevice, AnswersCollection.CALLBACK_MSG msg, int param1, string param2) { if (msg == AnswersCollection.CALLBACK_MSG.MSG_PULLEDOUT) { MessageBox.Show("设备拔出"); } if (msg == AnswersCollection.CALLBACK_MSG.MSG_ANSWER_DATA) { for (int i = 0; i < param1; i++) { Console.WriteLine(param2); string[] s = param2.ToString().Split(new char[] { '"' }); //this.BeginInvoke((MethodInvoker)delegate //{ // textBox1.AppendText("StudentID:" + s[3] + " " + "CardID:" + s[7] + " " + "answer:" + s[11] + "\r\n"); //}); if (answer_card.Raise) { } else { if (Global.AnswerStu == "") { if (s[11].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; Global.AnswerStu = s[7] + ":" + Global.judgeAnsewer; } else if (s[11].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; Global.AnswerStu = s[7] + ":" + Global.judgeAnsewer; } else { Global.AnswerStu = s[7] + ":" + s[11].Replace(" ", ""); } } else { if (Global.AnswerStu.IndexOf(s[7]) >= 0) { //有的话去重 string[] stringArray = Global.AnswerStu.Split('|'); List <string> listString = new List <string>(stringArray); int count = listString.Count; for (int t = 0; t < count; t++) { if (listString[t].IndexOf(s[7]) >= 0) { listString.Remove(listString[t]); if (s[11].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; listString.Add(s[7] + ":" + Global.judgeAnsewer); } else if (s[11].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; listString.Add(s[7] + ":" + Global.judgeAnsewer); } else { listString.Add(s[7] + ":" + s[11].Replace(" ", "")); } } } //foreach (string eachString in listString) //{ // if (eachString.IndexOf(s[3]) >= 0) // { // listString.Remove(eachString); // listString.Add(s[3] + ":" + s[11].Replace(" ", "")); // } //} Global.AnswerStu = string.Join("|", listString); } else { //没有 if (s[11].Replace(" ", "") == "√") { Global.judgeAnsewer = "R"; Global.AnswerStu += "|" + s[7] + ":" + Global.judgeAnsewer; } else if (s[11].Replace(" ", "") == "×") { Global.judgeAnsewer = "W"; Global.AnswerStu += "|" + s[7] + ":" + Global.judgeAnsewer; } else { Global.AnswerStu += "|" + s[7] + ":" + s[11].Replace(" ", ""); } } } Httpd.setPracticeResult(Global.AnswerStu); } } } else if (msg == AnswersCollection.CALLBACK_MSG.MSG_DOUTE_DATA) { Console.WriteLine(param2); string[] s2 = param2.ToString().Split(new char[] { '"' }); //this.BeginInvoke((MethodInvoker)delegate //{ // textBox1.AppendText("StudentID:" + s2[3] + " " + "CardID:" + s2[7] + "\r\n"); //}); } if (msg == AnswersCollection.CALLBACK_MSG.MSG_ERROR) { Console.Write("ErrCode:{0:D} ", param1); Console.WriteLine("Description:" + param2); } }