Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 14:47:01 (5 years ago)
Author:
mkommend
Message:

#2839: Merged 16446 into stable.

Location:
stable
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.Administrator

  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.cs

    r15584 r17063  
    3737    }
    3838
    39     #region Register Content Events
    40     protected override void DeregisterContentEvents() {
    41       base.DeregisterContentEvents();
    42     }
    43     protected override void RegisterContentEvents() {
    44       base.RegisterContentEvents();
    45     }
    46     #endregion
    47 
    4839    protected override void OnContentChanged() {
    4940      base.OnContentChanged();
    50     }
    51 
    52     protected override void SetEnabledStateOfControls() {
    53       base.SetEnabledStateOfControls();
     41      if (Content != null) {
     42        projectsView.Content = Content.Projects;
     43        resourcesView.Content = Content.Resources;
     44      } else {
     45        projectsView.Content = null;
     46        resourcesView.Content = null;
     47      }
    5448    }
    5549  }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.Designer.cs

    r17059 r17063  
    171171      this.Name = "ProjectResourcesView";
    172172      this.Size = new System.Drawing.Size(830, 494);
    173       this.Load += new System.EventHandler(this.ProjectResourcesView_Load);
     173      this.Disposed += new System.EventHandler(this.ProjectResourcesView_Disposed);
    174174      this.splitContainer.Panel1.ResumeLayout(false);
    175175      this.splitContainer.Panel2.ResumeLayout(false);
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r17059 r17063  
    2929using HeuristicLab.Core.Views;
    3030using HeuristicLab.MainForm;
    31 using System.Collections;
    32 using HeuristicLab.Common;
    3331
    3432namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    7977
    8078    #region Overrides
    81     protected override void OnClosing(FormClosingEventArgs e) {
    82       HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
    83       HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    84       base.OnClosing(e);
    85     }
    86 
    8779    protected override void OnContentChanged() {
    8880      base.OnContentChanged();
     
    130122    }
    131123
    132     private void ProjectResourcesView_Load(object sender, EventArgs e) {
    133 
     124    private void ProjectResourcesView_Disposed(object sender, EventArgs e) {
     125      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     126      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    134127    }
    135128
     
    165158
    166159      var selectedResource = (Resource)e.Node.Tag;
    167       if(HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource))
     160      if (HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource))
    168161        e.Cancel = true;
    169162    }
     
    179172        return;
    180173      }
    181        
     174
    182175      var checkedResource = (Resource)e.Node.Tag;
    183176      if (checkedResource == null
    184177        || checkedResource.Id == Guid.Empty
    185         || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource) 
     178        || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource)
    186179        || newIncludedResources.Contains(checkedResource)) {
    187180        e.Cancel = true;
    188181      } else if (!IsAdmin()) {
    189           if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)
    190             || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any()
    191             || projectExclusiveResources.Contains(checkedResource)) {
    192             e.Cancel = true;
    193           }
     182        if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)
     183          || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any()
     184          || projectExclusiveResources.Contains(checkedResource)) {
     185          e.Cancel = true;
     186        }
    194187      }
    195188    }
     
    232225
    233226      // get project specific assigned resources
    234       var projectResources = resources.Where(x => 
     227      var projectResources = resources.Where(x =>
    235228        HiveAdminClient.Instance.ProjectResourceAssignments
    236229          .Where(a => a.ProjectId == projectId)
     
    242235      HiveAdminClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id));
    243236
    244       var ancestorProjectResources = resources.Where(x => 
     237      var ancestorProjectResources = resources.Where(x =>
    245238        HiveAdminClient.Instance.ProjectResourceAssignments
    246239          .Where(a => projectIds.Contains(a.ProjectId))
     
    251244      HashSet<Resource> availableResources = new HashSet<Resource>(ancestorProjectResources);
    252245      foreach (var r in ancestorProjectResources) {
    253         foreach(var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {
     246        foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {
    254247          availableResources.Add(d);
    255248        }
     
    267260          foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {
    268261            projectExclusiveResources.Add(d);
    269           } 
     262          }
    270263        }
    271264      }
     
    286279      if (projectId == null || resourceIds == null) return;
    287280      HiveServiceLocator.Instance.CallHiveService(s => {
    288        s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, reassignCascading);
     281        s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, reassignCascading);
    289282      });
    290283    }
    291284
    292285    private void UpdateNewAssignedResources() {
    293       for(int i = newAssignedResources.Count -1; i >= 0; i--) {
    294         if(newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) {
     286      for (int i = newAssignedResources.Count - 1; i >= 0; i--) {
     287        if (newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) {
    295288          newAssignedResources.Remove(newAssignedResources.ElementAt(i));
    296289        }
     
    345338
    346339      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
    347      
     340
    348341      Resource top = null;
    349342      //bool nodeSelected = false;
     
    352345        top = resources.Where(x => x.Id == resourceId).FirstOrDefault();
    353346      }
    354      
     347
    355348
    356349      TreeNode currentNode = null;
     
    366359        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
    367360
    368         if(top == null && !disabledParentResources.Contains(newResource)) {
     361        if (top == null && !disabledParentResources.Contains(newResource)) {
    369362          top = newResource;
    370363        }
     
    395388        } else if (newAssignedResources.Contains(newResource)) {
    396389          newNode.Checked = true;
    397           if(!HiveRoles.CheckAdminUserPermissions()) {
    398             if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id) 
    399               || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() 
     390          if (!HiveRoles.CheckAdminUserPermissions()) {
     391            if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)
     392              || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any()
    400393              || projectExclusiveResources.Contains(newResource)) {
    401394              newNode.ForeColor = SystemColors.GrayText;
     
    452445      bool expandUngroupedGroupNode = false;
    453446      var ungroupedSlaves = subResources.OfType<Slave>().OrderBy(x => x.Name);
    454       if(ungroupedSlaves.Any()) {
     447      if (ungroupedSlaves.Any()) {
    455448        ungroupedGroupNode = new TreeNode(UNGROUPED_GROUP_NAME) {
    456449          ForeColor = SystemColors.GrayText,
     
    486479        }
    487480
    488         if(expandUngroupedGroupNode) ungroupedGroupNode.Expand();
     481        if (expandUngroupedGroupNode) ungroupedGroupNode.Expand();
    489482        treeView.Nodes.Add(ungroupedGroupNode);
    490483      } else if (ungroupedGroupNode != null) {
     
    493486
    494487      treeView.BeforeCheck += treeView_BeforeCheck;
    495       treeView.AfterCheck += treeView_AfterCheck;         
     488      treeView.AfterCheck += treeView_AfterCheck;
    496489
    497490      return top;
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs

    r17060 r17063  
    213213      this.Size = new System.Drawing.Size(539, 271);
    214214      this.Load += new System.EventHandler(this.ProjectView_Load);
     215      this.Disposed += new System.EventHandler(this.ProjectView_Disposed);
    215216      this.ResumeLayout(false);
    216217      this.PerformLayout();
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r17062 r17063  
    3535    private readonly object locker = new object();
    3636
    37     private Guid persistedOwnerUserId;
    38 
    3937    public new Project Content {
    4038      get { return (Project)base.Content; }
    41       set { base.Content = value; persistedOwnerUserId = Content != null ? Content.OwnerUserId : Guid.Empty; }
     39      set { base.Content = value; }
    4240    }
    4341
     
    5048
    5149    #region Overrides
    52     protected override void OnClosing(FormClosingEventArgs e) {
    53       AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
    54       AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
    55       base.OnClosing(e);
    56     }
    57 
    5850    protected override void RegisterContentEvents() {
    5951      base.RegisterContentEvents();
     
    10698        var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>();
    10799        if (!Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator));
    108         ownerComboBox.DataSource = users.ToList();
    109         ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == Content.OwnerUserId);
     100        var projectOwnerId = Content.OwnerUserId;
     101        ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList();
     102        ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == projectOwnerId);
    110103        ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    111104
     
    180173          var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>();
    181174          if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator));
    182           ownerComboBox.DataSource = users.ToList();
     175          ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList();
    183176          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    184177        });
     178    }
     179
     180    private void ProjectView_Disposed(object sender, EventArgs e) {
     181      AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
     182      AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
    185183    }
    186184
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs

    r17060 r17063  
    260260      this.Size = new System.Drawing.Size(853, 553);
    261261      this.Load += new System.EventHandler(this.ProjectsView_Load);
     262      this.Disposed += new System.EventHandler(this.ProjectsView_Disposed);
    262263      this.splitContainer.Panel1.ResumeLayout(false);
    263264      this.splitContainer.Panel2.ResumeLayout(false);
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r17062 r17063  
    5656
    5757    private readonly object locker = new object();
     58    private bool refreshingInternal = false;
     59    private bool refreshingExternal = false;
    5860
    5961    public new IItemList<Project> Content {
     
    7072      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
    7173      HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
    72       AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;
    73       AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;
    7474    }
    7575
    7676    #region Overrides
    77     protected override void OnClosing(FormClosingEventArgs e) {
    78       AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
    79       AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
    80       HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
    81       HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    82       base.OnClosing(e);
    83     }
    84 
    8577    protected override void RegisterContentEvents() {
    8678      base.RegisterContentEvents();
     
    183175      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
    184176      else {
     177        lock (locker) {
     178          if (refreshingExternal) return;
     179          if (!refreshingInternal) refreshingExternal = true;
     180        }
     181
    185182        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    186183        SetEnabledStateOfControls();
     
    191188      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
    192189      else {
    193         Progress.Hide(this);
    194         SetEnabledStateOfControls();
    195       }
    196     }
    197 
    198     private void AccessClient_Instance_Refreshing(object sender, EventArgs e) {
    199       if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
    200       else {
    201         Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    202         SetEnabledStateOfControls();
    203       }
    204     }
    205 
    206     private void AccessClient_Instance_Refreshed(object sender, EventArgs e) {
    207       if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
    208       else {
     190        if (refreshingExternal) refreshingExternal = false;
     191        Content = HiveAdminClient.Instance.Projects;
     192
    209193        Progress.Hide(this);
    210194        SetEnabledStateOfControls();
     
    215199      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    216200        action: () => UpdateProjects());
     201    }
     202
     203    private void ProjectsView_Disposed(object sender, EventArgs e) {
     204      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     205      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    217206    }
    218207
     
    515504
    516505    private void UpdateProjects() {
     506      lock (locker) {
     507        if (refreshingInternal || refreshingExternal) return;
     508        refreshingInternal = true;
     509      }
     510
    517511      try {
    518512        HiveAdminClient.Instance.Refresh();
    519         Content = HiveAdminClient.Instance.Projects;
    520513      } catch (AnonymousUserException) {
    521514        ShowHiveInformationDialog();
     515      } finally {
     516        refreshingInternal = false;
    522517      }
    523518    }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r17059 r17063  
    239239      this.Size = new System.Drawing.Size(853, 553);
    240240      this.Load += new System.EventHandler(this.ResourcesView_Load);
     241      this.Disposed += new System.EventHandler(this.ResourcesView_Disposed);
    241242      this.splitSlaves.Panel1.ResumeLayout(false);
    242243      this.splitSlaves.Panel2.ResumeLayout(false);
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r17062 r17063  
    5454
    5555
    56 
    5756    private TreeNode ungroupedGroupNode;
    5857
     
    6463
    6564    private readonly object locker = new object();
     65    private bool refreshingInternal = false;
     66    private bool refreshingExternal = false;
    6667
    6768    public new IItemList<Resource> Content {
     
    7879      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
    7980      HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
    80       AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;
    81       AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;
    8281    }
    8382
    8483    #region Overrides
    85     protected override void OnClosing(FormClosingEventArgs e) {
    86       AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
    87       AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
    88       HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
    89       HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    90       base.OnClosing(e);
    91     }
    92 
    9384    protected override void RegisterContentEvents() {
    9485      base.RegisterContentEvents();
     
    185176      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
    186177      else {
     178        lock (locker) {
     179          if (refreshingExternal) return;
     180          if (!refreshingInternal) refreshingExternal = true;
     181        }
     182
    187183        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    188184        SetEnabledStateOfControls();
     
    193189      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
    194190      else {
     191        if (refreshingExternal) refreshingExternal = false;
     192        Content = HiveAdminClient.Instance.Resources;
     193
    195194        Progress.Hide(this);
    196195        SetEnabledStateOfControls();
     
    198197    }
    199198
    200     private void AccessClient_Instance_Refreshing(object sender, EventArgs e) {
    201       if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
    202       else {
    203         Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    204         SetEnabledStateOfControls();
    205       }
    206     }
    207 
    208     private void AccessClient_Instance_Refreshed(object sender, EventArgs e) {
    209       if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
    210       else {
    211         Progress.Hide(this);
    212         SetEnabledStateOfControls();
    213       }
    214     }
    215 
    216199    private async void ResourcesView_Load(object sender, EventArgs e) {
    217       await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    218         action: () => UpdateResources());
     200      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(() => UpdateResources());
     201    }
     202
     203    private void ResourcesView_Disposed(object sender, EventArgs e) {
     204      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     205      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
    219206    }
    220207
     
    550537
    551538    private void UpdateResources() {
     539      lock (locker) {
     540        if (refreshingInternal || refreshingExternal) return;
     541        refreshingInternal = true;
     542      }
     543
    552544      try {
    553545        HiveAdminClient.Instance.Refresh();
    554         Content = HiveAdminClient.Instance.Resources;
    555546      } catch (AnonymousUserException) {
    556547        ShowHiveInformationDialog();
     548      } finally {
     549        refreshingInternal = false;
    557550      }
    558551    }
Note: See TracChangeset for help on using the changeset viewer.