private void EnterButton_Click(object sender, RoutedEventArgs e) { LoginResult lr = af.Login(this.number.Text, this.password.Password); if (lr != null) { if (lr.code == "200") { if (AccountUtil.IsRole(AccountUtil.ADMIN, lr.data.roles)) { CacheService.Instance.AdminToken = lr.token; ConfigWindow configWindow = new ConfigWindow(); configWindow.Show(); configWindow.Owner = this.Owner; this.Close(); } else { LSMessageBox.Show("登录异常", "当前角色不是管理员"); } } else { LSMessageBox.Show("登录错误", lr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } }
private void StartButton_Click(object sender, RoutedEventArgs e) { if (CacheService.Instance.LaunchPath == null || CacheService.Instance.LaunchPath.Equals("")) { LSMessageBox.Show("启动异常", "没配置启动路径"); return; } List <UserRecord> records = new List <UserRecord>(); foreach (Student s in CacheService.Instance.GetStudentList()) { UserRecord ur = new UserRecord { clazzId = s.ClassId, experimentId = CacheService.Instance.ExperimentId, studentId = s.Id, labId = CacheService.Instance.Lab.id, machineId = CacheService.Instance.MachineId, slotId = 1 }; records.Add(ur); } rcf.GetRecord(CacheService.Instance.ExperimentId, records, CacheService.Instance.GetStuToken()); launch(CacheService.Instance.LaunchPath); ProcessingWindow processingWindow = new ProcessingWindow(); processingWindow.Show(); processingWindow.Owner = this; this.Hide(); }
private void initData() { rtc.SetLabel(this.netInfo); rtc.SetImage(this.netState); rtc.SetVedioImage(this.videoState); rtc.SetVedioLabel(this.videoInfo); rtc.Start(); List <Lab> lablist = lf.AllLab(); if (lablist != null) { labs = lablist; } else { LSMessageBox.Show("网络错误", "网络异常"); } this.labList.ItemsSource = labs; this.labList.DisplayMemberPath = "Name"; this.labList.SelectedValuePath = "Id"; this.pathList.ItemsSource = paths; if (CacheService.Instance.Lab != null) { int labindex = -1; int labid = CacheService.Instance.Lab.id; foreach (Lab lab in labs) { labindex++; if (lab.Id == labid) { break; } } if (labindex == -1) { labindex = 0; } this.labList.SelectedIndex = labindex; } if (CacheService.Instance.LaunchPath != null) { this.pathText.Text = CacheService.Instance.LaunchPath; } if (CacheService.Instance.GetListenPath().Count != 0) { foreach (ListenPath lp in CacheService.Instance.GetListenPath()) { this.paths.Add(lp); } this.pathList.Items.Refresh(); } }
private void StartButton_Click(object sender, RoutedEventArgs e) { if (CacheService.Instance.LaunchPath == null || CacheService.Instance.LaunchPath.Equals("")) { LSMessageBox.Show("启动异常", "没配置启动路径"); return; } List <UserRecord> records = new List <UserRecord>(); foreach (Student s in CacheService.Instance.GetStudentList()) { UserRecord ur = new UserRecord { clazzId = s.ClassId, experimentId = CacheService.Instance.ExperimentId, studentId = s.Id, labId = CacheService.Instance.Lab.id, machineId = CacheService.Instance.MachineId, slotId = 1 }; records.Add(ur); } RecordResult rr = rcf.GetRecord(CacheService.Instance.ExperimentId, records, CacheService.Instance.GetStuToken()); if (rr != null) { if (rr.code == "200") { foreach (RecordResult.Record r in rr.data) { try { CacheService.Instance.GetStudent(r.studentId).RecordId = r.id; } catch (Exception) { LSMessageBox.Show("实验异常", "获取学生异常"); } } } else { LSMessageBox.Show("实验异常", rr.message); return; } } else { LSMessageBox.Show("网络错误", "网络异常"); return; } launch(CacheService.Instance.LaunchPath); ProcessingWindow processingWindow = new ProcessingWindow(); processingWindow.Show(); processingWindow.Owner = this; this.Hide(); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (CacheService.Instance.MachineId == -1) { List <String> lpath = new List <String>(); foreach (ListenPath lp in paths) { lpath.Add(lp.Path); } MachineResult mr = mf.AddMachine(MachineUtil.GetMac(), (int)this.labList.SelectedValue, this.pathText.Text.ToString(), lpath); if (mr != null) { if (mr.code == "200") { LSMessageBox.Show("提示", "配置成功"); CacheService.Instance.SetMachineConf(mr); this.Close(); this.Owner.Show(); } else { LSMessageBox.Show("配置异常", mr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } } else { List <String> lpath = new List <String>(); foreach (ListenPath lp in paths) { lpath.Add(lp.Path); } MachineResult mr = mf.UpdateMachine(CacheService.Instance.MachineId, MachineUtil.GetMac(), (int)this.labList.SelectedValue, this.pathText.Text.ToString(), lpath); if (mr != null) { if (mr.code == "200") { LSMessageBox.Show("提示", "更新成功"); CacheService.Instance.SetMachineConf(mr); this.Close(); this.Owner.Show(); } else { LSMessageBox.Show("配置异常", mr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } } }
/// <summary> /// 静态方法 模拟MESSAGEBOX.Show方法 /// </summary> /// <param name="title">标题</param> /// <param name="msg">消息</param> /// <returns></returns> public static bool?Show(string title, string msg) { var msgBox = new LSMessageBox(); msgBox.Title = title; msgBox.Message = msg; return(msgBox.ShowDialog()); }
private void ExitButton_Click(object sender, System.Windows.RoutedEventArgs e) { bool?result = LSMessageBox.YNShow("退出", "确认完成实验?"); if (result == true) { int count = 0; foreach (UploadFile uf in upfiles) { if (uf.Status.Equals(UploadFile.FAIL)) { count++; } } if (count != 0) { LSMessageBox.Show("退出", "检测到您还有" + count + "个实验数据未提交成功,请全部重新上传后再点击完成实验"); return; } List <int> ids = new List <int>(); foreach (Student s in CacheService.Instance.GetStudentList()) { ids.Add(s.RecordId); } AttachResult ar = rf.FinishExperiment(CacheService.Instance.ExperimentId, ids, CacheService.Instance.GetStuToken()); if (ar != null) { if (ar.code == "200") { if (device != null) { device.SignalToStop(); device.WaitForStop(); } if (device2 != null) { device2.SignalToStop(); device2.WaitForStop(); } Application.Current.Shutdown(); } else { LSMessageBox.Show("完成实验异常", ar.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } } }
private void RefreshButton_Click(object sender, RoutedEventArgs e) { FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { LSMessageBox.Show("摄像头异常", "没检测到摄像头,请确保摄像头安装正常"); } else { initVideo1(); } }
private void launch(String path) { Process p = new Process(); p.StartInfo.FileName = path; try { p.Start(); } catch (Win32Exception err) { LSMessageBox.Show("启动异常", err.Message); } }
private void EnterNotLogin_MouseDown(object sender, MouseButtonEventArgs e) { if (CacheService.Instance.LaunchPath == null || CacheService.Instance.LaunchPath.Equals("")) { LSMessageBox.Show("启动异常", "没配置启动路径"); return; } launch(CacheService.Instance.LaunchPath); CacheService.Instance.ClearStudentList(); ProcessingWindow processingWindow = new ProcessingWindow(); processingWindow.Show(); processingWindow.Owner = this; this.Hide(); }
public static bool?YNShow(string title, string msg) { var msgBox = new LSMessageBox(); msgBox.yes.Visibility = Visibility.Visible; msgBox.no.Visibility = Visibility.Visible; msgBox.ok.Visibility = Visibility.Collapsed; msgBox.Title = title; msgBox.Message = msg; return(msgBox.ShowDialog()); }
protected override void OnStartup(StartupEventArgs e) { MachineResult mr = mf.GetMachine(MachineUtil.GetMac()); if (mr != null) { if (mr.code == "200") { if (mr.data != null) { CacheService.Instance.SetMachineConf(mr); } MainWindow mainWindow = new MainWindow(); mainWindow.Show(); } else if (mr.code == "402") { LSMessageBox.Show("提示", "当前机器没有配置"); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); } else { LSMessageBox.Show("获取配置错误", "网络异常,请确认网络连接并重新打开"); this.Shutdown(); } } else { LSMessageBox.Show("网络错误", "获取机器配置错误,请确认网络连接并重新打开"); this.Shutdown(); //MainWindow mainWindow = new MainWindow(); //mainWindow.Show(); } base.OnStartup(e); }
private void UploadButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { String token = CacheService.Instance.GetStuToken(); FileResult fr = rf.UploadFile(openFileDialog.FileName, token); //获取文件名字 String file_name = openFileDialog.FileName.Split('\\')[openFileDialog.FileName.Split('\\').Length - 1]; if (fr != null) { if (fr.code == "200") { //关联文件与记录 List <Attach> attaches = new List <Attach>(); foreach (Student s in CacheService.Instance.GetStudentList()) { Attach a = new Attach { subjectId = s.RecordId, ownerId = s.Id, type = "EXPERIMENT_RECORD_FILE" }; attaches.Add(a); } AttachResult ar = rf.AttachRecordWithFile(CacheService.Instance.ExperimentId, fr.data.id, attaches, CacheService.Instance.GetStuToken()); if (ar != null) { if (ar.code == "200") { UploadFile up = new UploadFile() { FileName = file_name, FileType = UploadFile.EXPERIMENT, Status = UploadFile.SUCCESS, FilePath = openFileDialog.FileName, Id = fr.data.id, Color = "#FF979797", Operation = UploadFile.OPENDOC }; upfiles.Add(up); fileList.Items.Refresh(); } else { LSMessageBox.Show("关联文件错误", ar.message); UploadFile up = new UploadFile() { FileName = file_name, FileType = UploadFile.EXPERIMENT, Status = UploadFile.FAIL, FilePath = openFileDialog.FileName, Id = -1, Color = "Red", Operation = UploadFile.REUPLOAD }; upfiles.Add(up); fileList.Items.Refresh(); } } else { LSMessageBox.Show("网络错误", "网络异常"); UploadFile up = new UploadFile() { FileName = file_name, FileType = UploadFile.EXPERIMENT, Status = UploadFile.FAIL, FilePath = openFileDialog.FileName, Id = -1, Color = "Red", Operation = UploadFile.REUPLOAD }; upfiles.Add(up); fileList.Items.Refresh(); } } else { LSMessageBox.Show("上传文件错误", fr.message); UploadFile up = new UploadFile() { FileName = file_name, FileType = UploadFile.EXPERIMENT, Status = UploadFile.FAIL, FilePath = openFileDialog.FileName, Id = -1, Color = "Red", Operation = UploadFile.REUPLOAD }; upfiles.Add(up); fileList.Items.Refresh(); } } else { LSMessageBox.Show("网络错误", "网络异常"); UploadFile up = new UploadFile() { FileName = file_name, FileType = UploadFile.EXPERIMENT, Status = UploadFile.FAIL, FilePath = openFileDialog.FileName, Id = -1, Color = "Red", Operation = UploadFile.REUPLOAD }; upfiles.Add(up); fileList.Items.Refresh(); } } }
private void OpenLabel_MouseDown(object sender, MouseButtonEventArgs e) { Label label = sender as Label; UploadFile uploadFile = null; foreach (UploadFile uf in this.upfiles) { if (uf.FilePath.Equals(label.Tag.ToString())) { uploadFile = uf; } } if (uploadFile != null) { if (label.Content.Equals(UploadFile.OPENDOC)) { String doc = uploadFile.FilePath.Substring(0, uploadFile.FilePath.Length - uploadFile.FilePath.Split('\\')[uploadFile.FilePath.Split('\\').Length - 1].Length); System.Diagnostics.Process.Start("explorer.exe ", doc); } else if (label.Content.Equals(UploadFile.REUPLOAD)) { String token = CacheService.Instance.GetStuToken(); FileResult fr = rf.UploadFile(uploadFile.FilePath, token); //获取文件名字 String file_name = uploadFile.FilePath.Split('\\')[uploadFile.FilePath.Split('\\').Length - 1]; if (fr != null) { if (fr.code == "200") { //关联文件与记录 List <Attach> attaches = new List <Attach>(); foreach (Student s in CacheService.Instance.GetStudentList()) { Attach a = new Attach { subjectId = s.RecordId, ownerId = s.Id, type = "EXPERIMENT_RECORD_FILE" }; attaches.Add(a); } AttachResult ar = rf.AttachRecordWithFile(CacheService.Instance.ExperimentId, fr.data.id, attaches, CacheService.Instance.GetStuToken()); if (ar != null) { if (ar.code == "200") { uploadFile.Status = UploadFile.SUCCESS; uploadFile.Color = "#FF979797"; uploadFile.Operation = UploadFile.OPENDOC; fileList.Items.Refresh(); } else { LSMessageBox.Show("关联文件错误", ar.message); uploadFile.Status = UploadFile.FAIL; uploadFile.Color = "Red"; uploadFile.Operation = UploadFile.REUPLOAD; fileList.Items.Refresh(); } } else { LSMessageBox.Show("网络错误", "网络异常"); uploadFile.Status = UploadFile.FAIL; uploadFile.Color = "Red"; uploadFile.Operation = UploadFile.REUPLOAD; fileList.Items.Refresh(); } } else { LSMessageBox.Show("上传文件错误", fr.message); uploadFile.Status = UploadFile.FAIL; uploadFile.Color = "Red"; uploadFile.Operation = UploadFile.REUPLOAD; fileList.Items.Refresh(); } } else { LSMessageBox.Show("网络错误", "网络异常"); uploadFile.Status = UploadFile.FAIL; uploadFile.Color = "Red"; uploadFile.Operation = UploadFile.REUPLOAD; fileList.Items.Refresh(); } } } }
private void AddButton_Click(object sender, RoutedEventArgs e) { LoginResult lr = af.Login(this.number.Text, this.password.Password); if (lr != null) { if (lr.code == "200") { if (AccountUtil.IsRole(AccountUtil.STUDENT, lr.data.roles)) { Student student = new Student() { Number = lr.data.account, Name = lr.data.name, Token = lr.token, Id = lr.data.id }; ReservationResult rr = rf.GetValidity(CacheService.Instance.Lab.id, student.Token); if (rr != null) { if (rr.code == "200") { try { if (rr.data.clazz == null) { student.ClassId = -1; CacheService.Instance.AddStuList(student); students.Add(student); this.studentList.Items.Refresh(); } else { student.ClassId = rr.data.clazz.id; //LSMessageBox.Show("班级ID", rr.data.clazz.id+""); CacheService.Instance.AddStuList(student); students.Add(student); this.studentList.Items.Refresh(); } } catch (ArgumentException) { LSMessageBox.Show("登陆异常", "已经存在该学生"); } this.experiment.Content = rr.data.experiment.name; CacheService.Instance.ExperimentId = rr.data.experiment.id; this.virtualExp = rr.data.experiment.virtual_exp_link; if (rr.data.experiment.virtual_exp_link == null || rr.data.experiment.virtual_exp_link == "") { this.virtualexp.IsEnabled = false; } else { this.virtualexp.IsEnabled = true; } } else { LSMessageBox.Show("登陆异常", rr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } } else { LSMessageBox.Show("登录异常", "当前角色不是学生"); } this.number.Clear(); this.password.Clear(); } else { LSMessageBox.Show("登录错误", lr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } }