private async void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(pwbOld.Password) || string.IsNullOrEmpty(pwbNew1.Password) || string.IsNullOrEmpty(pwbNew2.Password)) { TaskDialog.ShowError(this, "请填写所有密码框"); return; } if (pwbNew1.Password != pwbNew2.Password) { TaskDialog.ShowError(this, "两次密码不完全相同"); return; } Hash hash = new Hash(); string OldPassword = hash.GetString("MD5", pwbOld.Password); string NewPassword = hash.GetString("MD5", pwbNew1.Password); JObject json = await NetHelper.Send(new { Command = ApiCommands.ChangePassword, ID = person.Id, OldPassword, NewPassword }); string message = json[ApiCommands.Message].Value <string>(); if (json[ApiCommands.OK].Value <bool>()) { TaskDialog.Show(this, message); DialogResult = true; Close(); } else { TaskDialog.ShowError(this, message); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(Course.Name)) { TaskDialog.ShowError(this, "课程名不可为空"); return; } DialogResult = true; Close(); }
private void FileSystemPrepareForUploadingReceived(object sender, Common.Telnet.DataReceivedEventArgs e) { var feedback = e.Content.Data as FileFolderFeedback; if (feedback.HasError) { Application.Current.Dispatcher.Invoke(() => { TaskDialog.ShowError(feedback.Message); }); return; } Debug.Assert((e.Content.Data as FileFolderFeedback).ID == currentUpload.ID); StartUploadingToB(currentUpload, ControlledClient); }
private async void Button_Click(object sender, RoutedEventArgs e) { Config.Save(); if (string.IsNullOrWhiteSpace(Config.DbConnectionString)) { TaskDialog.ShowError("数据库连接字符串为空!"); return; } grdControl.IsEnabled = false; btnStart.Content = "正在启动服务"; try { DatabaseHelper.Instance.Model = new SCMSModel(Config.DbConnectionString); DatabaseHelper.Instance.Model.Database.CommandTimeout = 2; bool exist = false; await Task.Run(() => { exist = DatabaseHelper.Instance.Model.Database.Exists(); }); if (!exist) { TaskDialog.ShowError("数据库连接失败"); grdControl.IsEnabled = true; btnStart.Content = "启动"; return; } //model.Database.Exists(); NetHelper.SocketServie(); btnStart.Content = "服务已启动"; } catch (Exception ex) { TaskDialog.ShowException(ex, "启动失败"); try { DatabaseHelper.Instance.Model.Dispose(); } catch { } grdControl.IsEnabled = true; btnStart.Content = "启动"; } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { JObject json = await NetHelper.Send(new { Command = Student_Courses, ID = Student.Id }); if (!json[OK].Value <bool>()) { TaskDialog.ShowError("获取失败:" + json[Message].Value <string>()); return; } JArray array = json[Data] as JArray; foreach (JObject item in array) { UIStudentCourse course = item.ToObject <UIStudentCourse>(); StudentCourses.Add(course); } //if(StudentCourses.Count>0) //{ // SelectedStudentCourse = TeacherCourses[0]; //} }
/// <summary> /// 单击登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LoginButtonClick(object sender, RoutedEventArgs e) { btnLogin.IsEnabled = false; //使用MD5加密密码 Config.Instance.UserPassword = pswd.Password.Length == 32 ? pswd.Password : md5.GetString("MD5", pswd.Password); JObject jsonRecv = await NetHelper.Send(new { Command = ApiCommands.Login, ID = Config.UserId, Password = Config.UserPassword }) as JObject; if (jsonRecv[ApiCommands.OK].Value <bool>()) { //登录界面渐隐 DoubleAnimation ani = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.Stop); ani.Completed += (p1, p2) => { grd.Opacity = 0; grd.Children.Clear(); //向grd添加“登陆成功”的标签 TextBlock tbk = new TextBlock() { FontSize = 28, Text = "登录成功", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; grd.Children.Add(tbk); Grid.SetColumnSpan(tbk, 1000); Grid.SetRowSpan(tbk, 1000); //登陆成功渐显 DoubleAnimation ani2 = new DoubleAnimation(1, TimeSpan.FromSeconds(0.3), FillBehavior.Stop); ani2.Completed += async(p3, p4) => { grd.Opacity = 1; await Task.Delay(1000); //登陆成功渐隐 DoubleAnimation ani3 = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.HoldEnd); ani3.Completed += (p5, p6) => { Person person = jsonRecv[ApiCommands.Person].ToObject <Person>(); switch (person.Role) { case "学生": var page1 = new PageStudent(person); (Window.GetWindow(this) as MainWindow).CurrentPage = page1; NavigationService.Navigate(page1); break; case "管理员": var page2 = new PageAdmin(person); (Window.GetWindow(this) as MainWindow).CurrentPage = page2; NavigationService.Navigate(page2); break; case "教师": var page3 = new PageTeacher(person); (Window.GetWindow(this) as MainWindow).CurrentPage = page3; NavigationService.Navigate(page3); break; default: TaskDialog.Show("未知角色"); break; } (Window.GetWindow(this) as MainWindow).CurrentUser = person; }; grd.BeginAnimation(OpacityProperty, ani3); }; grd.BeginAnimation(OpacityProperty, ani2); }; grd.BeginAnimation(OpacityProperty, ani); } else { //登陆失败,显示错误信息 TaskDialog.ShowError(jsonRecv[ApiCommands.Message].Value <string>()); btnLogin.IsEnabled = true; } Config.Save(); }
private void LoginFeedback(object sender, Common.Telnet.DataReceivedEventArgs e) { LoginFeedback result = e.Content.Data as LoginFeedback; Dispatcher.Invoke(() => { if (result.Success) { Global.CurrentClient = result.Client; #if DEBUG NavigationService.Navigate(new Uri($"UI/{nameof(PageComputerList)}.xaml", UriKind.Relative)); return; #endif //登录界面渐隐 DoubleAnimation ani = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.Stop); ani.Completed += (p1, p2) => { grd.Opacity = 0; grd.Children.Clear(); //向grd添加“登陆成功”的标签 TextBlock tbk = new TextBlock() { FontSize = 28, Text = "登录成功", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; grd.Children.Add(tbk); Grid.SetColumnSpan(tbk, 1000); Grid.SetRowSpan(tbk, 1000); //登陆成功渐显 DoubleAnimation ani2 = new DoubleAnimation(1, TimeSpan.FromSeconds(0.3), FillBehavior.Stop); ani2.Completed += async(p3, p4) => { grd.Opacity = 1; await Task.Delay(1000); //登陆成功渐隐 DoubleAnimation ani3 = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.HoldEnd); ani3.Completed += (p5, p6) => { User user = result.User; switch (user.Role) { case "用户": NavigationService.Navigate(new Uri($"UI/{nameof(PageComputerList)}.xaml", UriKind.Relative)); break; case "管理员": break; default: TaskDialog.Show("未知角色"); break; } }; grd.BeginAnimation(OpacityProperty, ani3); }; grd.BeginAnimation(OpacityProperty, ani2); }; grd.BeginAnimation(OpacityProperty, ani); } else { //登陆失败,显示错误信息 TaskDialog.ShowError(result.Message); btnLogin.IsEnabled = true; } }); }