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 | } else {
|
---|
51 | userNameTextBox.Text = Content.UserName;
|
---|
52 | fullNameTextBox.Text = Content.FullName;
|
---|
53 | emailTextBox.Text = Content.Email;
|
---|
54 | idTextBox.Text = Content.Id.ToString();
|
---|
55 | lastActivityTextBox.Text = Content.LastActivityDate.ToString();
|
---|
56 | lastLoginTextBox.Text = Content.LastLoginDate.ToString();
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | private void fullNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
61 | if (Content.FullName != fullNameTextBox.Text)
|
---|
62 | Content.FullName = fullNameTextBox.Text;
|
---|
63 | }
|
---|
64 |
|
---|
65 | private void userNameTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
66 | if (Content.UserName != userNameTextBox.Text)
|
---|
67 | Content.UserName = userNameTextBox.Text;
|
---|
68 | }
|
---|
69 |
|
---|
70 | private void emailTextBox_TextChanged(object sender, System.EventArgs e) {
|
---|
71 | if (Content.Email != emailTextBox.Text)
|
---|
72 | Content.Email = emailTextBox.Text;
|
---|
73 | }
|
---|
74 |
|
---|
75 | private void resetPasswordButton_Click(object sender, System.EventArgs e) {
|
---|
76 | Action a = new Action(delegate {
|
---|
77 | string result = AccessAdministrationClient.CallAccessService<string>(s => s.ResetPassword(Content.Id));
|
---|
78 | ShowPassword(result);
|
---|
79 | });
|
---|
80 |
|
---|
81 | AccessAdministrationClient.Instance.ExecuteActionAsync(a, PluginInfrastructure.ErrorHandling.ShowErrorDialog); ;
|
---|
82 | }
|
---|
83 |
|
---|
84 | private void ShowPassword(string result) {
|
---|
85 | if (InvokeRequired) {
|
---|
86 | Invoke(new Action<string>(ShowPassword), result);
|
---|
87 | } else {
|
---|
88 | MessageBox.Show("The new password is: " + result, "Password Reset", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 | }
|
---|