1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Core.Views;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Clients.Access.Administration {
|
---|
28 | [View("User View")]
|
---|
29 | [Content(typeof(User), true)]
|
---|
30 | public partial class UserView : ItemView {
|
---|
31 | public new User Content {
|
---|
32 | get { return (User)base.Content; }
|
---|
33 | set { base.Content = value; }
|
---|
34 | }
|
---|
35 |
|
---|
36 | public UserView() {
|
---|
37 | InitializeComponent();
|
---|
38 | }
|
---|
39 |
|
---|
40 | protected override void OnContentChanged() {
|
---|
41 | base.OnContentChanged();
|
---|
42 |
|
---|
43 | if (Content == null) {
|
---|
44 | userNameTextBox.Clear();
|
---|
45 | fullNameTextBox.Clear();
|
---|
46 | emailTextBox.Clear();
|
---|
47 | idTextBox.Clear();
|
---|
48 | lastActivityTextBox.Clear();
|
---|
49 | lastLoginTextBox.Clear();
|
---|
50 | refreshableRoleSelectionListView.Content = null;
|
---|
51 | refreshableRoleSelectionListView.CurrentUser = null;
|
---|
52 | } else {
|
---|
53 | userNameTextBox.Text = Content.UserName;
|
---|
54 | fullNameTextBox.Text = Content.FullName;
|
---|
55 | emailTextBox.Text = Content.Email;
|
---|
56 | idTextBox.Text = Content.Id.ToString();
|
---|
57 | lastActivityTextBox.Text = Content.LastActivityDate.ToString();
|
---|
58 | lastLoginTextBox.Text = Content.LastLoginDate.ToString();
|
---|
59 | refreshableRoleSelectionListView.Content = Content.Id != Guid.Empty ? AccessAdministrationClient.Instance : null;
|
---|
60 | refreshableRoleSelectionListView.CurrentUser = Content;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected override void SetEnabledStateOfControls() {
|
---|
65 | base.SetEnabledStateOfControls();
|
---|
66 | if (Content == null) {
|
---|
67 | resetPasswordButton.Enabled = false;
|
---|
68 | } else {
|
---|
69 | resetPasswordButton.Enabled = Content.Id != Guid.Empty;
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | private void fullNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
74 | if (Content.FullName != fullNameTextBox.Text)
|
---|
75 | Content.FullName = fullNameTextBox.Text;
|
---|
76 | }
|
---|
77 |
|
---|
78 | private void userNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
79 | if (Content.UserName != userNameTextBox.Text)
|
---|
80 | Content.UserName = userNameTextBox.Text;
|
---|
81 | }
|
---|
82 |
|
---|
83 | private void emailTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
84 | if (Content.Email != emailTextBox.Text)
|
---|
85 | Content.Email = emailTextBox.Text;
|
---|
86 | }
|
---|
87 |
|
---|
88 | private void resetPasswordButton_Click(object sender, System.EventArgs e) {
|
---|
89 | Action a = new Action(delegate {
|
---|
90 | string result = AccessAdministrationClient.CallAccessService<string>(s => s.ResetPassword(Content.Id));
|
---|
91 | ShowPassword(result);
|
---|
92 | });
|
---|
93 |
|
---|
94 | AccessAdministrationClient.Instance.ExecuteActionAsync(a, PluginInfrastructure.ErrorHandling.ShowErrorDialog); ;
|
---|
95 | }
|
---|
96 |
|
---|
97 | private void ShowPassword(string result) {
|
---|
98 | if (InvokeRequired) {
|
---|
99 | Invoke(new Action<string>(ShowPassword), result);
|
---|
100 | } else {
|
---|
101 | using (PasswordDisplayDialog dlg = new PasswordDisplayDialog()) {
|
---|
102 | dlg.Password = result;
|
---|
103 | dlg.ShowDialog(this);
|
---|
104 | }
|
---|
105 | }
|
---|
106 | }
|
---|
107 | }
|
---|
108 | }
|
---|