Changeset 15643
- Timestamp:
- 01/23/18 15:42:13 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs
r15630 r15643 45 45 } 46 46 47 public IEnumerable<Job> GetJobsReadyForDeletion() { 48 return GetJobsReadyForDeletionQuery(DataContext); 49 } 50 47 51 48 52 #region Compiled queries … … 62 66 where job.State == jobState 63 67 select job.JobId).ToList()); 68 private static readonly Func<DataContext, IEnumerable<Job>> GetJobsReadyForDeletionQuery = 69 CompiledQuery.Compile((DataContext db) => 70 (from job in db.GetTable<Job>() 71 where job.State == JobState.StatisticsPending 72 && (from task in db.GetTable<Task>() 73 where task.JobId == job.JobId 74 select task.State == TaskState.Finished 75 || task.State == TaskState.Aborted 76 || task.State == TaskState.Failed).All(x => x) 77 select job).ToList()); 64 78 #endregion 65 79 … … 69 83 WHERE JobState = {0} 70 84 "; 85 private const string GetStatisticsPendingJobs = @" 86 SELECT DISTINCT j.* 87 FROM [Job] j 88 WHERE j.JobState = 'StatisticsPending' 89 AND 'Calculating' NOT IN ( 90 SELECT t.TaskState 91 FROM [Task] t 92 WHERE t.JobId = j.JobId) 93 "; 71 94 #endregion 72 95 } -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r15630 r15643 390 390 } 391 391 392 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE" )]392 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 393 393 public Resource Resource 394 394 { … … 424 424 } 425 425 426 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE" )]426 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 427 427 public Project Project 428 428 { … … 1098 1098 } 1099 1099 1100 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ResourceId", OtherKey="ResourceId" )]1100 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ResourceId", OtherKey="ResourceId", DeleteRule="CASCADE")] 1101 1101 public EntitySet<AssignedProjectResource> AssignedProjectResources 1102 1102 { … … 1163 1163 } 1164 1164 1165 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="ResourceId", OtherKey="ResourceId" )]1165 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="ResourceId", OtherKey="ResourceId", DeleteRule="CASCADE")] 1166 1166 public EntitySet<AssignedJobResource> AssignedJobResources 1167 1167 { … … 2669 2669 } 2670 2670 2671 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_Task", Storage="_Jobs", ThisKey="JobId", OtherKey="JobId" )]2671 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_Task", Storage="_Jobs", ThisKey="JobId", OtherKey="JobId", DeleteRule="CASCADE")] 2672 2672 public EntitySet<Task> Tasks 2673 2673 { … … 2682 2682 } 2683 2683 2684 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperimentPermissions", ThisKey="JobId", OtherKey="JobId" )]2684 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperimentPermissions", ThisKey="JobId", OtherKey="JobId", DeleteRule="CASCADE")] 2685 2685 public EntitySet<JobPermission> JobPermissions 2686 2686 { … … 2695 2695 } 2696 2696 2697 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="JobId", OtherKey="JobId" )]2697 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="JobId", OtherKey="JobId", DeleteRule="CASCADE")] 2698 2698 public EntitySet<AssignedJobResource> AssignedJobResources 2699 2699 { … … 3533 3533 } 3534 3534 3535 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true )]3535 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 3536 3536 public Job Job 3537 3537 { … … 5833 5833 } 5834 5834 5835 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ProjectId", OtherKey="ProjectId" )]5835 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ProjectId", OtherKey="ProjectId", DeleteRule="CASCADE")] 5836 5836 public EntitySet<AssignedProjectResource> AssignedProjectResources 5837 5837 { … … 5872 5872 } 5873 5873 5874 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_ProjectPermissions", ThisKey="ProjectId", OtherKey="ProjectId" )]5874 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_ProjectPermissions", ThisKey="ProjectId", OtherKey="ProjectId", DeleteRule="CASCADE")] 5875 5875 public EntitySet<ProjectPermission> ProjectPermissions 5876 5876 { … … 6084 6084 } 6085 6085 6086 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true )]6086 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 6087 6087 public Project Project 6088 6088 { … … 6386 6386 } 6387 6387 6388 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true )]6388 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 6389 6389 public Resource Resource 6390 6390 { … … 6420 6420 } 6421 6421 6422 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true )]6422 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteRule="CASCADE", DeleteOnNull=true)] 6423 6423 public Job Job 6424 6424 { -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15630 r15643 507 507 } else { 508 508 var addedJobResourceIds = resourceIds.Except(job.AssignedJobResources.Select(x => x.ResourceId)); 509 var removedJobResourceIds = job.AssignedJobResources.Select(x => x.ResourceId).Except(resourceIds); 509 var removedJobResourceIds = job.AssignedJobResources 510 .Select(x => x.ResourceId) 511 .Except(resourceIds) 512 .ToArray(); 510 513 511 514 // remove resource assignments … … 855 858 AuthorizationManager.AuthorizeForProjectAdministration(projectId); 856 859 var pm = PersistenceManager; 857 using (new PerformanceLogger(" GrantProjectPermissions")) {860 using (new PerformanceLogger("SaveProjectPermissions")) { 858 861 var projectDao = pm.ProjectDao; 859 862 var projectPermissionDao = pm.ProjectPermissionDao; … … 863 866 var project = projectDao.GetById(projectId); 864 867 if (project == null) return; 865 //if (project.ProjectPermissions == null) project.ProjectPermissions = new System.Data.Linq.EntitySet<DA.ProjectPermission>(); 866 var projectPermissions = project.ProjectPermissions.Select(x => x.GrantedUserId); 867 var addedPermissions = grantedUserIds.Except(projectPermissions); 868 var projectPermissions = project.ProjectPermissions.Select(x => x.GrantedUserId).ToArray(); 869 //var addedPermissions = grantedUserIds.Except(projectPermissions); 868 870 var removedPermissions = projectPermissions.Except(grantedUserIds); 869 871 … … 874 876 } else { 875 877 assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, removedPermissions); 876 foreach(var item in project.ProjectPermissions.ToList().Where(x => removedPermissions.Contains(x.GrantedUserId))) { 878 foreach(var item in project.ProjectPermissions 879 .Where(x => removedPermissions.Contains(x.GrantedUserId)) 880 .ToList()) { 877 881 project.ProjectPermissions.Remove(item); 878 882 } … … 907 911 p.ProjectPermissions.Clear(); 908 912 } else { 909 foreach(var item in p.ProjectPermissions.ToList().Where(x => removedPermissions.Contains(x.GrantedUserId))) { 913 foreach(var item in p.ProjectPermissions 914 .Where(x => removedPermissions.Contains(x.GrantedUserId)) 915 .ToList()) { 910 916 p.ProjectPermissions.Remove(item); 911 917 } … … 979 985 AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds); 980 986 var pm = PersistenceManager; 981 using (new PerformanceLogger(" AssignProjectResources")) {987 using (new PerformanceLogger("SaveProjectResourceAssignments")) { 982 988 var projectDao = pm.ProjectDao; 983 989 var assignedProjectResourceDao = pm.AssignedProjectResourceDao; … … 985 991 pm.UseTransaction(() => { 986 992 var project = projectDao.GetById(projectId); 987 var assignedResources = project.AssignedProjectResources.Select(x => x.ResourceId) ;988 var addedAssignments = resourceIds.Except(assignedResources);993 var assignedResources = project.AssignedProjectResources.Select(x => x.ResourceId).ToArray(); 994 //var addedAssignments = resourceIds.Except(assignedResources); 989 995 var removedAssignments = assignedResources.Except(resourceIds); 990 996 … … 992 998 if (reassign) { 993 999 assignedJobResourceDao.DeleteByProjectId(project.ProjectId); 994 //assignedProjectResourceDao.DeleteByProjectIds(new List<Guid> { projectId });995 1000 project.AssignedProjectResources.Clear(); 996 1001 } else { 997 1002 assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, removedAssignments); 998 //assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, removedAssignments); 999 foreach (var item in project.AssignedProjectResources.ToList().Where(x => removedAssignments.Contains(x.ResourceId))) { 1003 foreach (var item in project.AssignedProjectResources 1004 .Where(x => removedAssignments.Contains(x.ResourceId)) 1005 .ToList()) { 1000 1006 project.AssignedProjectResources.Remove(item); 1001 1007 } … … 1030 1036 } else { 1031 1037 //assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(p.ProjectId, removedAssignments); 1032 foreach (var item in p.AssignedProjectResources.ToList().Where(x => removedAssignments.Contains(x.ResourceId))) { 1038 //for(int i = p.AssignedProjectResources.Count -1; i >= 0; i--) { 1039 // if(removedAssignments.Contains(p.AssignedProjectResources[i].ResourceId)) { 1040 // p.AssignedProjectResources.RemoveAt(i); 1041 // } 1042 //} 1043 foreach (var item in p.AssignedProjectResources 1044 .Where(x => removedAssignments.Contains(x.ResourceId)) 1045 .ToList()) { 1033 1046 p.AssignedProjectResources.Remove(item); 1034 1047 }
Note: See TracChangeset
for help on using the changeset viewer.