Changeset 15412 for branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
- Timestamp:
- 10/07/17 10:32:07 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r15401 r15412 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Clients.Access; 27 using HeuristicLab.Clients.Hive.Views; 27 28 using HeuristicLab.Core.Views; 28 29 using HeuristicLab.MainForm; 29 using Tasks = System.Threading.Tasks;30 30 31 31 namespace HeuristicLab.Clients.Hive.Administrator.Views { … … 48 48 } 49 49 50 #region Overrides 50 51 protected override void OnClosing(FormClosingEventArgs e) { 51 52 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed; … … 62 63 Content.PropertyChanged -= Content_PropertyChanged; 63 64 base.DeregisterContentEvents(); 64 }65 66 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {67 OnContentChanged();68 65 } 69 66 … … 73 70 nameTextBox.Clear(); 74 71 descriptionTextBox.Clear(); 75 ownerComboBox.DataSource = null;76 72 ownerComboBox.SelectedItem = null; 77 73 createdTextBox.Clear(); … … 82 78 nameTextBox.Text = Content.Name; 83 79 descriptionTextBox.Text = Content.Description; 84 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();85 80 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 86 81 createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss"); … … 99 94 nameTextBox.Enabled = enabled; 100 95 descriptionTextBox.Enabled = enabled; 96 refreshButton.Enabled = enabled; 101 97 ownerComboBox.Enabled = enabled; 102 98 createdTextBox.Enabled = enabled; … … 104 100 endDateTimePicker.Enabled = enabled && Content.EndDate.HasValue; 105 101 indefiniteCheckBox.Enabled = enabled; 102 } 103 #endregion 104 105 #region Event Handlers 106 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 107 OnContentChanged(); 106 108 } 107 109 … … 125 127 126 128 private async void ProjectView_Load(object sender, EventArgs e) { 127 lock (locker) { 128 if (updatingUsers) return; 129 updatingUsers = true; 130 } 131 try { 132 await Tasks.Task.Run(() => UpdateUsers()); 133 } finally { 134 updatingUsers = false; 135 } 129 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 130 action: () => UpdateUsers(), 131 finallyCallback: () => { 132 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 133 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 134 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 135 }); 136 136 } 137 137 … … 141 141 updatingUsers = true; 142 142 } 143 try { 144 await Tasks.Task.Run(() => UpdateUsers()); 145 } finally { 146 updatingUsers = false; 147 } 148 } 149 150 private void UpdateUsers() { 151 ownerComboBox.DataSource = null; 152 AccessClient.Instance.Refresh(); 153 if (Content != null) { 154 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 155 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 156 } 143 144 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 145 action: () => UpdateUsers(), 146 finallyCallback: () => { 147 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 148 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 149 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 150 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 151 updatingUsers = false; 152 }); 157 153 } 158 154 … … 192 188 Content.EndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate; 193 189 } 190 #endregion 191 192 #region Helpers 193 private void UpdateUsers() { 194 try { 195 AccessClient.Instance.Refresh(); 196 } catch (AnonymousUserException) { 197 ShowHiveInformationDialog(); 198 } 199 } 200 201 private void ShowHiveInformationDialog() { 202 if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog); 203 else { 204 using (HiveInformationDialog dialog = new HiveInformationDialog()) { 205 dialog.ShowDialog(this); 206 } 207 } 208 } 209 #endregion 194 210 } 195 211 }
Note: See TracChangeset
for help on using the changeset viewer.