1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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 = AccessAdministrationClient.Instance;
|
---|
60 | refreshableRoleSelectionListView.CurrentUser = Content;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | private void fullNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
65 | if (Content.FullName != fullNameTextBox.Text)
|
---|
66 | Content.FullName = fullNameTextBox.Text;
|
---|
67 | }
|
---|
68 |
|
---|
69 | private void userNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
70 | if (Content.UserName != userNameTextBox.Text)
|
---|
71 | Content.UserName = userNameTextBox.Text;
|
---|
72 | }
|
---|
73 |
|
---|
74 | private void emailTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
75 | if (Content.Email != emailTextBox.Text)
|
---|
76 | Content.Email = emailTextBox.Text;
|
---|
77 | }
|
---|
78 |
|
---|
79 | private void resetPasswordButton_Click(object sender, System.EventArgs e) {
|
---|
80 | Action a = new Action(delegate {
|
---|
81 | string result = AccessAdministrationClient.CallAccessService<string>(s => s.ResetPassword(Content.Id));
|
---|
82 | ShowPassword(result);
|
---|
83 | });
|
---|
84 |
|
---|
85 | AccessAdministrationClient.Instance.ExecuteActionAsync(a, PluginInfrastructure.ErrorHandling.ShowErrorDialog); ;
|
---|
86 | }
|
---|
87 |
|
---|
88 | private void ShowPassword(string result) {
|
---|
89 | if (InvokeRequired) {
|
---|
90 | Invoke(new Action<string>(ShowPassword), result);
|
---|
91 | } else {
|
---|
92 | using (PasswordDisplayDialog dlg = new PasswordDisplayDialog()) {
|
---|
93 | dlg.Password = result;
|
---|
94 | dlg.ShowDialog(this);
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | }
|
---|