Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15966


Ignore:
Timestamp:
06/19/18 15:51:41 (6 years ago)
Author:
jzenisek
Message:

#2839: Fixed several bugs and added project duration handling

  • fixed project duration handling (client- & service-side)
  • fixed tagging in HiveJobAdmin
  • added ProjectJobs view (under construction)
  • added necessary service methods
Location:
branches/2839_HiveProjectManagement
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj

    r15908 r15966  
    132132    </Compile>
    133133    <Compile Include="MenuItems\AdministratorMenuItem.cs" />
     134    <Compile Include="Views\ProjectJobsView.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\ProjectJobsView.Designer.cs">
     138      <DependentUpon>ProjectJobsView.cs</DependentUpon>
     139    </Compile>
    134140    <Compile Include="Views\ProjectPermissionsView.cs">
    135141      <SubType>UserControl</SubType>
     
    248254      <Private>False</Private>
    249255    </ProjectReference>
     256    <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     257      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     258      <Name>HeuristicLab.Data.Views-3.3</Name>
     259    </ProjectReference>
    250260    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    251261      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
     
    283293      <Private>False</Private>
    284294    </ProjectReference>
     295  </ItemGroup>
     296  <ItemGroup>
     297    <EmbeddedResource Include="Views\ProjectJobsView.resx">
     298      <DependentUpon>ProjectJobsView.cs</DependentUpon>
     299    </EmbeddedResource>
    285300  </ItemGroup>
    286301  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r15760 r15966  
    2828using HeuristicLab.Core.Views;
    2929using HeuristicLab.MainForm;
     30using System.Drawing;
    3031
    3132namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    3536    private readonly object locker = new object();
    3637
     38    private Guid persistedOwnerUserId;
     39
    3740    public new Project Content {
    3841      get { return (Project)base.Content; }
    39       set { base.Content = value; }
     42      set { base.Content = value; persistedOwnerUserId = Content != null ? Content.OwnerUserId : Guid.Empty; }
    4043    }
    4144
     
    8285        createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss");
    8386        startDateTimePicker.Value = Content.StartDate;
    84         if (indefiniteCheckBox.Checked = !Content.EndDate.HasValue) {
    85           endDateTimePicker.Value = startDateTimePicker.Value;
    86         } else {
    87           endDateTimePicker.Value = Content.EndDate.Value;
    88         }
     87
     88        indefiniteCheckBox.Checked = !Content.EndDate.HasValue;
     89        if(!indefiniteCheckBox.Checked) endDateTimePicker.Value = Content.EndDate.Value;
     90        else endDateTimePicker.Value = Content.StartDate;
     91        endDateTimePicker.Enabled = !indefiniteCheckBox.Checked;
    8992      }
    9093    }
     
    148151          ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
    149152          ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
    150           ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
     153          ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == persistedOwnerUserId);
    151154          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    152155          refreshButton.Enabled = true;
     
    201204      if (Content == null) return;
    202205      var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;
    203       if (Content.EndDate != newEndDate)
     206      endDateTimePicker.Enabled = !indefiniteCheckBox.Checked;
     207      if (Content.EndDate != newEndDate) {
     208        DeregisterContentEvents();
    204209        Content.EndDate = newEndDate;
     210        endDateTimePicker.Value = newEndDate.HasValue ? newEndDate.Value : Content.StartDate;
     211        RegisterContentEvents();
     212      }
    205213    }
    206214    #endregion
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs

    r15953 r15966  
    3939      this.resourcesTabPage = new System.Windows.Forms.TabPage();
    4040      this.projectResourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectResourcesView();
     41      this.jobsTabPage = new System.Windows.Forms.TabPage();
     42      this.projectJobsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectJobsView();
    4143      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    4244      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    4850      this.permissionsTabPage.SuspendLayout();
    4951      this.resourcesTabPage.SuspendLayout();
     52      this.jobsTabPage.SuspendLayout();
    5053      this.SuspendLayout();
    5154      //
     
    152155      this.tabControl.Controls.Add(this.permissionsTabPage);
    153156      this.tabControl.Controls.Add(this.resourcesTabPage);
     157      this.tabControl.Controls.Add(this.jobsTabPage);
    154158      this.tabControl.Location = new System.Drawing.Point(3, 3);
    155159      this.tabControl.Name = "tabControl";
     
    225229      this.projectResourcesView.Size = new System.Drawing.Size(571, 509);
    226230      this.projectResourcesView.TabIndex = 0;
     231      //
     232      // jobsTabPage
     233      //
     234      this.jobsTabPage.Controls.Add(this.projectJobsView);
     235      this.jobsTabPage.Location = new System.Drawing.Point(4, 22);
     236      this.jobsTabPage.Name = "jobsTabPage";
     237      this.jobsTabPage.Padding = new System.Windows.Forms.Padding(3);
     238      this.jobsTabPage.Size = new System.Drawing.Size(577, 515);
     239      this.jobsTabPage.TabIndex = 3;
     240      this.jobsTabPage.Text = "Jobs";
     241      this.jobsTabPage.UseVisualStyleBackColor = true;
     242      //
     243      // projectJobsView
     244      //
     245      this.projectJobsView.Caption = "ProjectView";
     246      this.projectJobsView.Content = null;
     247      this.projectJobsView.Dock = System.Windows.Forms.DockStyle.Fill;
     248      this.projectJobsView.Location = new System.Drawing.Point(3, 3);
     249      this.projectJobsView.Name = "projectJobsView";
     250      this.projectJobsView.ReadOnly = false;
     251      this.projectJobsView.Size = new System.Drawing.Size(571, 509);
     252      this.projectJobsView.TabIndex = 0;
    227253      //
    228254      // ProjectsView
     
    242268      this.permissionsTabPage.ResumeLayout(false);
    243269      this.resourcesTabPage.ResumeLayout(false);
     270      this.jobsTabPage.ResumeLayout(false);
    244271      this.ResumeLayout(false);
    245272
     
    260287    private System.Windows.Forms.ImageList imageList;
    261288    private System.Windows.Forms.TabPage resourcesTabPage;
     289    private System.Windows.Forms.TabPage jobsTabPage;
    262290    private ProjectResourcesView projectResourcesView;
    263291    private ProjectPermissionsView projectPermissionsView;
     292    private ProjectJobsView projectJobsView;
    264293    private System.Windows.Forms.ToolTip toolTip;
    265294  }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15953 r15966  
    100100        projectPermissionsView.Content = null;
    101101        projectResourcesView.Content = null;
     102        projectJobsView.Content = null;
    102103      } else {
    103104        BuildProjectTree(Content);
     
    115116      projectPermissionsView.Enabled = enabled;
    116117      projectResourcesView.Enabled = enabled;
     118      projectJobsView.Enabled = enabled;
    117119    }
    118120    #endregion
     
    228230        MessageBox.Show(
    229231          "Only empty projects can be deleted.",
     232          "HeuristicLab Hive Administrator",
     233          MessageBoxButtons.OK,
     234          MessageBoxIcon.Error);
     235        return;
     236      }
     237
     238      if (HiveAdminClient.Instance.Jobs.ContainsKey(selectedProject.Id)
     239        && HiveAdminClient.Instance.Jobs[selectedProject.Id] != null
     240        && HiveAdminClient.Instance.Jobs[selectedProject.Id].Any()) {
     241        MessageBox.Show(
     242          "There are " + HiveAdminClient.Instance.Jobs[selectedProject.Id].Count + " jobs using this project and/or child-projects. It is necessary to delete them before the project.",
    230243          "HeuristicLab Hive Administrator",
    231244          MessageBoxButtons.OK,
     
    442455      projectPermissionsView.Content = project;
    443456      projectResourcesView.Content = project;
     457      projectJobsView.Content = project;
    444458
    445459      bool projectIsNew = project != null && project.Id == Guid.Empty;
     
    454468      projectPermissionsView.Locked = locked;
    455469      projectResourcesView.Locked = locked;
     470      projectJobsView.Locked = locked;
    456471      selectedProject = project;
    457472    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15956 r15966  
    4848    private const string ADDED_SELECTION_TAG = " [added selection]";
    4949    private const string REMOVED_SELECTION_TAG = " [removed selection]";
     50    private const string SELECTED_TAG = " [selected]";
    5051    private const string INCLUDED_TAG = " [included]";
    5152    private const string ADDED_INCLUDE_TAG = " [added include]";
     
    537538        if (newAssignedResources.Select(x => x.Id).Contains(newResource.Id)) {
    538539          newNode.Checked = true;
     540          if(!addedAssignments.Select(x => x.Id).Contains(newResource.Id) && !removedAssignments.Select(x => x.Id).Contains(newResource.Id)) {
     541            newNode.Text += SELECTED_TAG;
     542          }
    539543        } else if (newIncludedResources.Select(x => x.Id).Contains(newResource.Id)) {
    540544          newNode.Checked = true;
     
    702706          if (newAssignedResources.Select(x => x.Id).Contains(resource.Id)) {
    703707            n.Checked = true;
     708            if (!addedAssignments.Select(x => x.Id).Contains(resource.Id) && !removedAssignments.Select(x => x.Id).Contains(resource.Id)) {
     709              n.Text += SELECTED_TAG;
     710            }
    704711          } else if (newIncludedResources.Select(x => x.Id).Contains(resource.Id)) {
    705712            n.Checked = true;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15920 r15966  
    479479
    480480    private void updateButton_Click(object sender, EventArgs e) {
     481      if (Content.ExecutionState == ExecutionState.Stopped) {
     482        MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     483        return;
     484      }
     485
    481486      HiveClient.UpdateJob(
    482487        (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r15922 r15966  
    7070    }
    7171
     72    private Dictionary<Guid, HiveItemCollection<Job>> jobs;
     73    public Dictionary<Guid, HiveItemCollection<Job>> Jobs {
     74      get { return jobs; }
     75      set {
     76        if (value != jobs)
     77          jobs = value;
     78        }
     79    }
     80
     81
    7282    //private Dictionary<Guid, HashSet<Project>> projectAncestors;
    7383    //public Dictionary<Guid, HashSet<Project>> ProjectAncestors {
     
    134144        projects = new ItemList<Project>();
    135145        projectResourceAssignments = new ItemList<AssignedProjectResource>();
    136 
    137         //projectAncestors = new Dictionary<Guid, HashSet<Project>>();
    138         //projectDescendants = new Dictionary<Guid, HashSet<Project>>();
    139         //resourceAncestors = new Dictionary<Guid, HashSet<Resource>>();
    140         //resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();
     146        jobs = new Dictionary<Guid, HiveItemCollection<Job>>();
     147
    141148        projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
    142149        projectDescendants = new Dictionary<Guid, HashSet<Guid>>();
     
    149156          service.GetProjectsForAdministration().ForEach(p => projects.Add(p));
    150157          var projectIds = projects.Select(p => p.Id).ToList();
    151           if(projectIds.Any())
     158          if (projectIds.Any()) {
    152159            service.GetAssignedResourcesForProjectsAdministration(projectIds)
    153             .ForEach(a => projectResourceAssignments.Add(a));
     160              .ForEach(a => projectResourceAssignments.Add(a));
     161            projectIds.ForEach(p => jobs.Add(p, new HiveItemCollection<Job>()));
     162            service.GetJobsByProjectIds(projectIds)
     163              .ForEach(j => jobs[j.ProjectId].Add(j));
     164          }
    154165        });
    155166
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r15913 r15966  
    23852385        System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobs();
    23862386       
     2387        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetJobsByProjectId", ReplyAction="http://tempuri.org/IHiveService/GetJobsByProjectIdResponse")]
     2388        System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobsByProjectId(System.Guid projectId);
     2389       
     2390        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetJobsByProjectIds", ReplyAction="http://tempuri.org/IHiveService/GetJobsByProjectIdsResponse")]
     2391        System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobsByProjectIds(System.Collections.Generic.List<System.Guid> projectIds);
     2392       
    23872393        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddJob", ReplyAction="http://tempuri.org/IHiveService/AddJobResponse")]
    23882394        System.Guid AddJob(HeuristicLab.Clients.Hive.Job jobDto, System.Collections.Generic.List<System.Guid> resourceIds);
     
    26552661        }
    26562662       
     2663        public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobsByProjectId(System.Guid projectId)
     2664        {
     2665            return base.Channel.GetJobsByProjectId(projectId);
     2666        }
     2667       
     2668        public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobsByProjectIds(System.Collections.Generic.List<System.Guid> projectIds)
     2669        {
     2670            return base.Channel.GetJobsByProjectIds(projectIds);
     2671        }
     2672       
    26572673        public System.Guid AddJob(HeuristicLab.Clients.Hive.Job jobDto, System.Collections.Generic.List<System.Guid> resourceIds)
    26582674        {
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs

    r15908 r15966  
    3232      return GetByIdQuery(DataContext, id);
    3333    }
    34    
     34
    3535    public void DeleteByState(JobState state) {
    3636      DataContext.ExecuteCommand(DeleteByStateQueryString, Enum.GetName(typeof(JobState), state));
     37    }
     38
     39    public IEnumerable<Job> GetByProjectId(Guid id) {
     40      return GetByProjectIdQuery(DataContext, id);
     41    }
     42
     43    public IEnumerable<Job> GetByProjectIds(IEnumerable<Guid> projectIds) {
     44      string paramProjectIds = string.Join(",", projectIds.ToList().Select(x => string.Format("'{0}'", x)));
     45      if(!string.IsNullOrWhiteSpace(paramProjectIds)) {
     46        string queryString = string.Format(GetByProjectIdsQueryString, paramProjectIds);
     47        return DataContext.ExecuteQuery<Job>(queryString);
     48      }
     49      return Enumerable.Empty<Job>();
    3750    }
    3851
     
    5669         where job.JobId == jobId
    5770         select job).SingleOrDefault());
     71    private static readonly Func<DataContext, Guid, IEnumerable<Job>> GetByProjectIdQuery =
     72      CompiledQuery.Compile((DataContext db, Guid projectId) =>
     73        (from job in db.GetTable<Job>()
     74         where job.ProjectId == projectId
     75         select job));
    5876    private static readonly Func<DataContext, JobState, IEnumerable<Job>> GetByStateQuery =
    5977      CompiledQuery.Compile((DataContext db, JobState jobState) =>
     
    92110        WHERE t.JobId = j.JobId)
    93111    ";
     112    private const string GetByProjectIdsQueryString = @"
     113      SELECT DISTINCT j.*
     114      FROM [Job] j
     115      WHERE j.ProjectId IN ({0})
     116    ";
    94117    #endregion
    95118  }
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15954 r15966  
    366366    }
    367367
     368    public IEnumerable<DT.Job> GetJobsByProjectId(Guid projectId) {
     369      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     370      var pm = PersistenceManager;
     371      using (new PerformanceLogger("GetJobsByProjectId")) {
     372        var currentUserId = UserManager.CurrentUserId;
     373        var projectDao = pm.ProjectDao;
     374        var jobDao = pm.JobDao;
     375
     376        return pm.UseTransaction(() => {
     377          // check if user is granted to administer the requested projectId
     378          var administrationGrantedProjects = projectDao
     379            .GetAdministrationGrantedProjectsForUser(currentUserId)
     380            .ToList();
     381
     382          if(administrationGrantedProjects.Select(x => x.ProjectId).Contains(projectId)) {
     383            return jobDao.GetByProjectId(projectId)
     384            .Select(x => x.ToDto())
     385            .ToList();
     386          } else {
     387            return Enumerable.Empty<DT.Job>();
     388          }
     389        });
     390      }
     391    }
     392
     393    public IEnumerable<DT.Job> GetJobsByProjectIds(IEnumerable<Guid> projectIds) {
     394      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     395      var pm = PersistenceManager;
     396      using (new PerformanceLogger("GetJobsByProjectIds")) {
     397        var currentUserId = UserManager.CurrentUserId;
     398        var projectDao = pm.ProjectDao;
     399        var jobDao = pm.JobDao;
     400        return pm.UseTransaction(() => {
     401          // check for which of requested projectIds the user is granted to administer
     402          var administrationGrantedProjectIds = projectDao
     403            .GetAdministrationGrantedProjectsForUser(currentUserId)
     404            .Select(x => x.ProjectId)
     405            .ToList();
     406          var requestedAndGrantedProjectIds = projectIds.Intersect(administrationGrantedProjectIds);
     407
     408          if(requestedAndGrantedProjectIds.Any()) {
     409            return jobDao.GetByProjectIds(requestedAndGrantedProjectIds)
     410              .Select(x => x.ToDto())
     411              .ToList();
     412          } else {
     413            return Enumerable.Empty<DT.Job>();
     414          }
     415        });
     416      }
     417    }
     418
    368419    public Guid AddJob(DT.Job jobDto, IEnumerable<Guid> resourceIds) {
    369420      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     421      var dateCreated = DateTime.Now;
     422      var pm = PersistenceManager;
     423
     424      // check project availability (cf. duration)
     425      CheckProjectAvailability(pm, jobDto.ProjectId, dateCreated);
     426
    370427      // check user - project
    371428      AuthorizationManager.AuthorizeUserForProjectUse(UserManager.CurrentUserId, jobDto.ProjectId);
     429
    372430      // check project - resources
    373431      AuthorizationManager.AuthorizeProjectForResourcesUse(jobDto.ProjectId, resourceIds);
    374       var pm = PersistenceManager;
     432     
    375433      using (new PerformanceLogger("AddJob")) {
    376434        var jobDao = pm.JobDao;
     
    380438          var newJob = jobDto.ToEntity();
    381439          newJob.OwnerUserId = UserManager.CurrentUserId;
    382           newJob.DateCreated = DateTime.Now;
     440          newJob.DateCreated = dateCreated;
    383441
    384442          // add resource assignments
     
    406464      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    407465      AuthorizationManager.AuthorizeForJob(jobDto.Id, DT.Permission.Full);
     466      var pm = PersistenceManager;
     467      var dateUpdated = DateTime.Now;
     468
     469      // check project availability
     470      CheckProjectAvailability(pm, jobDto.ProjectId, dateUpdated);
    408471      // check user - project permission
    409472      AuthorizationManager.AuthorizeUserForProjectUse(UserManager.CurrentUserId, jobDto.ProjectId);
     
    411474      AuthorizationManager.AuthorizeProjectForResourcesUse(jobDto.ProjectId, resourceIds);
    412475
    413       var pm = PersistenceManager;
    414476      using (new PerformanceLogger("UpdateJob")) {
    415477        bool exists = true;
     
    466528          if(job != null) {
    467529            var jobStateEntity = jobState.ToEntity();
    468             // note: allow solely state changes from "Online" to "StatisticsPending"
    469             // and from "StatisticsPending" to "DeletionPending"
     530            // note: allow solely state changes from "Online" to "StatisticsPending" = deletion request by user for HiveStatisticGenerator
     531            // and from "StatisticsPending" to "DeletionPending" = deletion request by HiveStatisticGenerator for EventManager
    470532            if (job.State == DA.JobState.Online && jobStateEntity == DA.JobState.StatisticsPending) {
    471533              job.State = jobStateEntity;
     
    774836      using (new PerformanceLogger("DeleteProject")) {
    775837        var projectDao = pm.ProjectDao;
     838        var jobDao = pm.JobDao;
    776839        var assignedJobResourceDao = pm.AssignedJobResourceDao;
    777840        pm.UseTransaction(() => {
     
    779842          projectIds.Union(projectDao.GetChildProjectIdsById(projectId));
    780843
    781           assignedJobResourceDao.DeleteByProjectIds(projectIds);
    782           projectDao.DeleteByIds(projectIds);
    783           pm.SubmitChanges();
     844          var jobs = jobDao.GetByProjectIds(projectIds)
     845            .Select(x => x.ToDto())
     846            .ToList();
     847
     848          if(jobs.Count > 0) {
     849            throw new InvalidOperationException("There are " + jobs.Count + " job(s) using this project and/or child-projects. It is necessary to delete them before the project.");
     850          } else {
     851            assignedJobResourceDao.DeleteByProjectIds(projectIds);
     852            projectDao.DeleteByIds(projectIds);
     853            pm.SubmitChanges();
     854          }
    784855        });
    785856      }
     
    814885        userAndGroupIds.AddRange(UserManager.GetUserGroupIdsOfUser(currentUserId));
    815886        return pm.UseTransaction(() => {
    816           return projectDao.GetUsageGrantedProjectsForUser(userAndGroupIds)
     887          var projects = projectDao.GetUsageGrantedProjectsForUser(userAndGroupIds)
    817888            .Select(x => x.ToDto()).ToList();
     889          var now = DateTime.Now;
     890          return projects.Where(x => x.StartDate <= now && x.EndDate >= now).ToList();
    818891        });
    819892      }
     
    16501723    }
    16511724
     1725    private void CheckProjectAvailability(IPersistenceManager pm, Guid projectId, DateTime date) {
     1726      var projectDao = pm.ProjectDao;
     1727      using (new PerformanceLogger("UpdateJob")) {
     1728        var project = pm.UseTransaction(() => {
     1729          return projectDao.GetById(projectId);
     1730        });
     1731        if (project != null) {
     1732          if (project.StartDate > date) throw new ArgumentException("Cannot add job to specified project. The start date of the project is still in the future.");
     1733          else if (project.EndDate < date) throw new ArgumentException("Cannot add job to specified project. The end date of the project is already in the past.");
     1734        } else {
     1735          throw new ArgumentException("Cannot add job to specified project. The project seems not to be available anymore.");
     1736        }
     1737      }
     1738    }
     1739
    16521740    #endregion
    16531741  }
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r15913 r15966  
    7979
    8080    [OperationContract]
     81    IEnumerable<Job> GetJobsByProjectId(Guid projectId);
     82
     83    [OperationContract]
     84    IEnumerable<Job> GetJobsByProjectIds(IEnumerable<Guid> projectIds);
     85
     86    [OperationContract]
    8187    Guid AddJob(Job jobDto, IEnumerable<Guid> resourceIds);
    8288
Note: See TracChangeset for help on using the changeset viewer.