Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15760


Ignore:
Timestamp:
02/12/18 18:10:42 (7 years ago)
Author:
jzenisek
Message:

#2839

  • minor changes regarding project- & resource selection
  • adapted DeleteOnNull rules in dbml
Location:
branches/HiveProjectManagement
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs

    r15642 r15760  
    8181      }
    8282    }
     83
     84    protected override void SetEnabledStateOfControls() {
     85      base.SetEnabledStateOfControls();
     86      bool enabled = Content != null && !Locked && !ReadOnly;
     87
     88      inheritButton.Enabled = enabled;
     89      saveButton.Enabled = enabled;
     90      treeView.Enabled = enabled;
     91    }
    8392    #endregion
    8493
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15658 r15760  
    5050    private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();
    5151
    52     //private readonly Color addedAssignmentColor = Color.FromArgb(255, 0, 174, 179); // #00aeb3
    5352    private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1
    5453    private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48
     
    8483        var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
    8584        detailsViewHost.Content = top;
    86         detailsViewHost.ActiveView.Locked = true;
    87       }
    88     }
    89 
     85      }
     86    }
     87
     88    protected override void SetEnabledStateOfControls() {
     89      base.SetEnabledStateOfControls();
     90      bool enabled = Content != null && !Locked && !ReadOnly;
     91
     92      inheritButton.Enabled = enabled;
     93      saveButton.Enabled = enabled;
     94      treeView.Enabled = enabled;
     95    }
    9096    #endregion
    9197
     
    208214      var resources = HiveAdminClient.Instance.Resources;
    209215
    210       foreach(var r in resources) {
     216      foreach(var r in resources.Where(x => x.Id != Guid.Empty)) {
    211217        resourceAncestors.Add(r.Id, new HashSet<Resource>());
    212218        resourceDescendants.Add(r.Id, new HashSet<Resource>());
    213219      }
    214220
    215       foreach(var r in resources) {
     221      foreach(var r in resources.Where(x => x.Id != Guid.Empty)) {
    216222        var parentResourceId = r.ParentResourceId;
    217223        while(parentResourceId != null) {
     
    253259      treeView.AfterCheck -= treeView_AfterCheck;
    254260
     261      resources = resources.Where(x => x.Id != Guid.Empty);
    255262      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
    256263      var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     
    379386      var projects = HiveAdminClient.Instance.Projects;
    380387
    381       foreach(var p in projects) {
     388      foreach(var p in projects.Where(x => x.Id != Guid.Empty)) {
    382389        projectAncestors.Add(p.Id, new HashSet<Project>());
    383390        projectDescendants.Add(p.Id, new HashSet<Project>());
    384391      }
    385392
    386       foreach (var p in projects) {
     393      foreach (var p in projects.Where(x => x.Id != Guid.Empty)) {
    387394        var parentProjectId = p.ParentProjectId;
    388395        while (parentProjectId != null) {
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r15576 r15760  
    9292    protected override void SetEnabledStateOfControls() {
    9393      base.SetEnabledStateOfControls();
    94       bool enabled = Content != null && !ReadOnly;
     94      bool enabled = Content != null && !Locked && !ReadOnly;
    9595      nameTextBox.Enabled = enabled;
    9696      descriptionTextBox.Enabled = enabled;
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15742 r15760  
    9797        projectPermissionsView.Content = top;
    9898        projectResourcesView.Content = top;
     99
     100        if(top != null && top.Id == Guid.Empty) {
     101          projectPermissionsView.Locked = true;
     102          projectResourcesView.Locked = true;
     103        }
    99104      }
    100105    }
     
    390395      var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name));
    391396      if (selectedProject != null) selectedProject = projects.Where(x => x.Id == selectedProject.Id).FirstOrDefault();
     397      bool nodeSelected = false;
    392398
    393399      TreeNode currentNode = null;
     
    406412          selectedProject = newProject;
    407413        }
    408         if (newProject.Id == selectedProject.Id) {
     414        if (newProject.Id == selectedProject.Id && !nodeSelected) {
    409415          newNode.BackColor = selectedColor;
    410416          newNode.Text += " [selected]";
     417          nodeSelected = true;
    411418        }
    412419
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15742 r15760  
    9595      } else {
    9696        var top = BuildResourceTree(Content);
     97        SetEnabledStateOfControlsForSelectedResource();
     98
    9799        viewHost.Content = top;
     100        bool locked = !IsAdmin();
     101        viewHost.Locked = locked;
     102        scheduleView.Locked = locked;
     103
     104        if (top != null && top.Id == Guid.Empty) {
     105          scheduleView.SetEnabledStateOfSchedule(false);
     106        }
    98107      }
    99108    }
     
    105114      btnRemoveGroup.Enabled = enabled;
    106115      btnSave.Enabled = enabled;
    107       scheduleView.SetEnabledStateOfSchedule(enabled && IsAdmin()); // IsAuthorized((Resource)viewHost.Content));
     116      scheduleView.SetEnabledStateOfSchedule(enabled && IsAdmin());
    108117    }
    109118    #endregion
     
    415424      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
    416425      if (selectedResource != null) selectedResource = resources.Where(x => x.Id == selectedResource.Id).FirstOrDefault();
    417       //bool nodeSelected = false;
     426      bool nodeSelected = false;
    418427
    419428      TreeNode currentNode = null;
     
    432441          selectedResource = newResource;
    433442        }
    434         if (newResource.Id == selectedResource.Id) {
     443        if (newResource.Id == selectedResource.Id && !nodeSelected) {
    435444          newNode.BackColor = selectedColor;
    436445          newNode.Text += " [selected]";
     446          nodeSelected = true;
    437447        }
    438448
     
    490500          slaveNode.Text += " [changes not stored]";
    491501        }
    492         if (slave.Id == selectedResource.Id) {
     502        if (slave.Id == selectedResource.Id && !nodeSelected) {
    493503          slaveNode.BackColor = selectedColor;
    494504          slaveNode.Text += " [selected]";
     505          nodeSelected = true;
    495506        }
    496507      }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r15742 r15760  
    234234        Invoke(new Action(() => SetEnabledStateOfSchedule(state)));
    235235      } else {
    236         if (Content == null) state = false;
     236        if (Content == null || Locked || ReadOnly) state = false;
    237237        groupBox1.Enabled = state;
    238238        btnClearCal.Enabled = state;
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/AssignedJobResourceDao.cs

    r15737 r15760  
    105105          SELECT j.JobId
    106106          FROM [Job] j
    107           WHERE j.ProjectId = {0}
     107          WHERE j.ProjectId = '{0}'
    108108          AND j.OwnerUserId IN ({1})
    109109        )
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectPermissionDao.cs

    r15628 r15760  
    7474    private const string DeleteByProjectIdAndGrantedUserIdsQueryString = @"
    7575      DELETE FROM [ProjectPermission]
    76       WHERE ProjectId = {0}
     76      WHERE ProjectId = '{0}'
    7777      AND GrantedUserId IN ({1});
    7878    ";
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs

    r15671 r15760  
    401401    }
    402402   
    403     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE")]
     403    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteOnNull=true)]
    404404    public Resource Resource
    405405    {
     
    435435    }
    436436   
    437     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE")]
     437    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteOnNull=true)]
    438438    public Project Project
    439439    {
     
    28502850    }
    28512851   
    2852     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_TaskData", Storage="_Job", ThisKey="TaskId", OtherKey="TaskId", IsForeignKey=true)]
     2852    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_TaskData", Storage="_Job", ThisKey="TaskId", OtherKey="TaskId", IsForeignKey=true, DeleteOnNull=true)]
    28532853    public Task Task
    28542854    {
     
    34883488    }
    34893489   
    3490     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true)]
     3490    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteOnNull=true)]
    34913491    public Job Job
    34923492    {
     
    61086108    }
    61096109   
    6110     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)]
     6110    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteOnNull=true)]
    61116111    public Project Project
    61126112    {
     
    62426242    }
    62436243   
    6244     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]
     6244    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteOnNull=true)]
    62456245    public Resource Resource
    62466246    {
     
    62766276    }
    62776277   
    6278     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true)]
     6278    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteOnNull=true)]
    62796279    public Job Job
    62806280    {
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15737 r15760  
    880880    }
    881881
    882     private void GrantProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {
    883       throw new NotImplementedException();
    884     }
    885 
    886     private void RevokeProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {
    887       RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    888       if (projectId == null || grantedUserIds == null || !grantedUserIds.Any()) return;
    889       AuthorizationManager.AuthorizeForProjectAdministration(projectId, false);
    890       var pm = PersistenceManager;
    891       using (new PerformanceLogger("RevokeProjectPermissions")) {
    892         var projectPermissionDao = pm.ProjectPermissionDao;
    893         var projectDao = pm.ProjectDao;
    894         var assignedJobResourceDao = pm.AssignedJobResourceDao;
    895         pm.UseTransaction(() => {
    896           if (cascading) {
    897             var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList();
    898             projectPermissionDao.DeleteByProjectIdsAndGrantedUserIds(childProjectIds, grantedUserIds);
    899             assignedJobResourceDao.DeleteByProjectIdsAndUserIds(childProjectIds, grantedUserIds);
    900           }
    901           projectPermissionDao.DeleteByProjectIdAndGrantedUserIds(projectId, grantedUserIds);
    902           assignedJobResourceDao.DeleteByProjectIdAndUserIds(projectId, grantedUserIds);
    903           pm.SubmitChanges();
    904         });
    905       }
    906     }
     882    //private void GrantProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {
     883    //  throw new NotImplementedException();
     884    //}
     885
     886    //private void RevokeProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {
     887    //  RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     888    //  if (projectId == null || grantedUserIds == null || !grantedUserIds.Any()) return;
     889    //  AuthorizationManager.AuthorizeForProjectAdministration(projectId, false);
     890    //  var pm = PersistenceManager;
     891    //  using (new PerformanceLogger("RevokeProjectPermissions")) {
     892    //    var projectPermissionDao = pm.ProjectPermissionDao;
     893    //    var projectDao = pm.ProjectDao;
     894    //    var assignedJobResourceDao = pm.AssignedJobResourceDao;
     895    //    pm.UseTransaction(() => {
     896    //      if (cascading) {
     897    //        var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList();
     898    //        projectPermissionDao.DeleteByProjectIdsAndGrantedUserIds(childProjectIds, grantedUserIds);
     899    //        assignedJobResourceDao.DeleteByProjectIdsAndUserIds(childProjectIds, grantedUserIds);
     900    //      }
     901    //      projectPermissionDao.DeleteByProjectIdAndGrantedUserIds(projectId, grantedUserIds);
     902    //      assignedJobResourceDao.DeleteByProjectIdAndUserIds(projectId, grantedUserIds);
     903    //      pm.SubmitChanges();
     904    //    });
     905    //  }
     906    //}
    907907
    908908    public IEnumerable<DT.ProjectPermission> GetProjectPermissions(Guid projectId) {
     
    10011001    }
    10021002
    1003     private void AssignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) {
    1004       throw new NotImplementedException();
    1005     }
    1006 
    1007     // basic: unassign resourceIds from project and depending jobs
    1008     // cascading: unassign resourceIds from all child-projects and their depending jobs
    1009     private void UnassignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) {
    1010       RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    1011       if (projectId == null || resourceIds == null || !resourceIds.Any()) return;
    1012       AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds);
    1013       var pm = PersistenceManager;
    1014       using (new PerformanceLogger("UnassignProjectResources")) {
    1015         var assignedProjectResourceDao = pm.AssignedProjectResourceDao;
    1016         var assignedJobResourceDao = pm.AssignedJobResourceDao;
    1017         var projectDao = pm.ProjectDao;
    1018         pm.UseTransaction(() => {
    1019           if (cascading) {
    1020             var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList();
    1021             assignedProjectResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds);
    1022             assignedJobResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds);
    1023           }
    1024           assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds);
    1025           assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds);
    1026           pm.SubmitChanges();
    1027         });
    1028       }
    1029     }
     1003    //private void AssignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) {
     1004    //  throw new NotImplementedException();
     1005    //}
     1006
     1007    //private void UnassignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) {
     1008    //  RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     1009    //  if (projectId == null || resourceIds == null || !resourceIds.Any()) return;
     1010    //  AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds);
     1011    //  var pm = PersistenceManager;
     1012    //  using (new PerformanceLogger("UnassignProjectResources")) {
     1013    //    var assignedProjectResourceDao = pm.AssignedProjectResourceDao;
     1014    //    var assignedJobResourceDao = pm.AssignedJobResourceDao;
     1015    //    var projectDao = pm.ProjectDao;
     1016    //    pm.UseTransaction(() => {
     1017    //      if (cascading) {
     1018    //        var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList();
     1019    //        assignedProjectResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds);
     1020    //        assignedJobResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds);
     1021    //      }
     1022    //      assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds);
     1023    //      assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds);
     1024    //      pm.SubmitChanges();
     1025    //    });
     1026    //  }
     1027    //}
    10301028
    10311029    public IEnumerable<DT.AssignedProjectResource> GetAssignedResourcesForProject(Guid projectId) {
Note: See TracChangeset for help on using the changeset viewer.