Changeset 15412 for branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.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/ResourcesView.cs
r15401 r15412 27 27 using HeuristicLab.Clients.Access; 28 28 using HeuristicLab.Clients.Hive.Views; 29 using HeuristicLab.Collections; 29 30 using HeuristicLab.Common.Resources; 30 31 using HeuristicLab.Core; … … 144 145 145 146 #region Event Handlers 146 private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 147 OnContentChanged(); 148 } 149 150 private void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 151 OnContentChanged(); 147 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 148 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsAdded, sender, e); 149 else { 150 OnContentChanged(); 151 } 152 } 153 154 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 155 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsRemoved, sender, e); 156 else { 157 OnContentChanged(); 158 } 152 159 } 153 160 154 161 private void SlaveViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) { 155 OnContentChanged(); 156 if (e.PropertyName == "HbInterval") { 157 UpdateChildHbIntervall(slaveView.Content); 162 if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)SlaveViewContent_PropertyChanged, sender, e); 163 else { 164 OnContentChanged(); 165 if (e.PropertyName == "HbInterval") { 166 UpdateChildHbIntervall(slaveView.Content); 167 } 158 168 } 159 169 } … … 196 206 197 207 private async void ResourcesView_Load(object sender, EventArgs e) { 198 lock (locker) {199 if (updatingResources) return;200 updatingResources = true;201 }202 203 208 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 204 action: () => UpdateResources(), 205 finallyCallback: () => updatingResources = false); 209 action: () => UpdateResources()); 206 210 } 207 211 … … 259 263 slaveView.Content = selectedResource; 260 264 261 if (selectedResource is SlaveGroup) 262 slaveView.Content.PropertyChanged += SlaveViewContent_PropertyChanged; 263 264 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 265 action: () => UpdateSchedule()); 265 if (selectedResource != null && selectedResource is SlaveGroup) 266 selectedResource.PropertyChanged += SlaveViewContent_PropertyChanged; 267 268 if (IsAuthorized(selectedResource)) { 269 if (!tabSlaveGroup.TabPages.Contains(tabSchedule)) 270 tabSlaveGroup.TabPages.Add(tabSchedule); 271 272 HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id; 273 274 if (tabSlaveGroup.SelectedIndex == 1) { 275 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 276 action: () => UpdateSchedule(), 277 finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes); 278 } 279 } else { 280 if (tabSlaveGroup.TabPages.Contains(tabSchedule)) 281 tabSlaveGroup.TabPages.Remove(tabSchedule); 282 HiveAdminClient.Instance.DowntimeForResourceId = Guid.Empty; 283 } 266 284 } 267 285 … … 412 430 413 431 private void UpdateResources() { 414 try { 415 ResetView(); 416 HiveAdminClient.Instance.Refresh(); 417 Content = HiveAdminClient.Instance.Resources; 418 } catch (AnonymousUserException) { 419 ShowHiveInformationDialog(); 420 } 432 HiveAdminClient.Instance.Refresh(); 433 Content = HiveAdminClient.Instance.Resources; 421 434 } 422 435 … … 452 465 453 466 private void UpdateSchedule() { 454 var selectedNode = treeSlaveGroup.SelectedNode; 455 var resource = (Resource)selectedNode?.Tag; 456 457 if (IsAuthorized(resource)) { 458 if (!tabSlaveGroup.TabPages.Contains(tabSchedule)) 459 tabSlaveGroup.TabPages.Add(tabSchedule); 460 461 if (tabSlaveGroup.SelectedIndex == 1) { 462 HiveAdminClient.Instance.DowntimeForResourceId = resource.Id; 463 HiveAdminClient.Instance.RefreshCalendar(); 464 scheduleView.Invoke((Action)(() => { 465 scheduleView.Content = HiveAdminClient.Instance.Downtimes; 466 SetEnabledStateOfControls(); 467 })); 468 } 469 } else { 470 if (tabSlaveGroup.TabPages.Contains(tabSchedule)) 471 tabSlaveGroup.TabPages.Remove(tabSchedule); 467 try { 468 HiveAdminClient.Instance.RefreshCalendar(); 469 } catch (AnonymousUserException) { 470 ShowHiveInformationDialog(); 472 471 } 473 472 }
Note: See TracChangeset
for help on using the changeset viewer.