Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15992


Ignore:
Timestamp:
07/10/18 23:06:00 (6 years ago)
Author:
jzenisek
Message:

#2839: fixed couple of minor issues

  • changed tags in resource selector
  • added project information in job list and adapted sortation
  • fixed hand-down save by withdrawing additional offset-rights (permissions, resources),...
Location:
branches/2839_HiveProjectManagement
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r15966 r15992  
    8282        nameTextBox.Text = Content.Name;
    8383        descriptionTextBox.Text = Content.Description;
    84         ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
     84
     85        ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
     86        var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>();
     87        if (!Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator));
     88        ownerComboBox.DataSource = users.ToList();
     89        ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == Content.OwnerUserId);
     90        ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
     91
    8592        createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss");
    8693        startDateTimePicker.Value = Content.StartDate;
     
    135142        finallyCallback: () => {
    136143          ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
    137           ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
     144          var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>();
     145          if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator));
     146          ownerComboBox.DataSource = users.ToList();
    138147          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    139148        });
     
    150159        finallyCallback: () => {
    151160          ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
    152           ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
    153           ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == persistedOwnerUserId);
     161          var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>();
     162          if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator));
     163          ownerComboBox.DataSource = users.ToList();
     164          ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == persistedOwnerUserId);
    154165          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    155166          refreshButton.Enabled = true;
     
    203214    private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) {
    204215      if (Content == null) return;
    205       var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;
     216      var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : endDateTimePicker.Value;
    206217      endDateTimePicker.Enabled = !indefiniteCheckBox.Checked;
    207218      if (Content.EndDate != newEndDate) {
    208219        DeregisterContentEvents();
    209220        Content.EndDate = newEndDate;
    210         endDateTimePicker.Value = newEndDate.HasValue ? newEndDate.Value : Content.StartDate;
    211221        RegisterContentEvents();
    212222      }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15966 r15992  
    110110      bool enabled = Content != null && !Locked && !ReadOnly;
    111111      refreshButton.Enabled = enabled;
    112       addButton.Enabled = enabled;
    113       removeButton.Enabled = enabled;
    114       saveProjectButton.Enabled = enabled;
     112      //addButton.Enabled = enabled;
     113      //removeButton.Enabled = enabled;
     114      //saveProjectButton.Enabled = enabled;
    115115      projectView.Enabled = enabled;
    116116      projectPermissionsView.Enabled = enabled;
     
    199199      Guid? parentProjectId = null;
    200200
     201      if(selectedProject == null && !IsAdmin()) {
     202        MessageBox.Show(
     203          "You are not allowed to add a root project - please select a parent project.",
     204          "HeuristicLab Hive Administrator",
     205          MessageBoxButtons.OK,
     206          MessageBoxIcon.Information);
     207        return;
     208      }
     209     
    201210      if (selectedProject != null && selectedProject.Id == Guid.Empty) {
    202211        MessageBox.Show(
     
    459468      bool projectIsNew = project != null && project.Id == Guid.Empty;
    460469      bool locked = project == null || projectIsNew;
     470
     471      // if the project is new, or:
     472      // the project does have any descendant projects and
     473      // the user is an admin or owner of a parent project
    461474      bool deleteEnabled = project != null && (
    462475        projectIsNew
    463         || HiveAdminClient.Instance.CheckOwnershipOfParentProject(project, UserInformation.Instance.User.Id)
    464         || !HiveAdminClient.Instance.ProjectDescendants[project.Id].Any());
    465 
    466       addButton.Enabled = !locked;
     476        ||  (!HiveAdminClient.Instance.ProjectDescendants[project.Id].Any()
     477              && (HiveAdminClient.Instance.CheckOwnershipOfParentProject(project, UserInformation.Instance.User.Id)
     478              || IsAdmin())
     479            )
     480      );
     481
     482      bool addEnabled = !locked;
     483      if (!IsAdmin() && project == null) addEnabled = false;
     484
     485      bool saveEnabled = project != null;
     486      if (!IsAdmin() && !project.ParentProjectId.HasValue) saveEnabled = false;
     487
     488      addButton.Enabled = addEnabled;
    467489      removeButton.Enabled = deleteEnabled;
     490      saveProjectButton.Enabled = saveEnabled;
    468491      projectPermissionsView.Locked = locked;
    469492      projectResourcesView.Locked = locked;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj

    r15412 r15992  
    105105    <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" />
    106106    <Compile Include="ListViewItemDateComparer.cs" />
     107    <Compile Include="ListViewItemComparer.cs" />
    107108    <Compile Include="MenuItems\CreateHiveJobMenuItem.cs" />
    108109    <Compile Include="MenuItems\RunInHiveMenuItem.cs" />
     
    244245      <Private>False</Private>
    245246    </ProjectReference>
     247  </ItemGroup>
     248  <ItemGroup>
     249    <EmbeddedResource Include="Views\RefreshableHiveJobView.resx">
     250      <DependentUpon>RefreshableHiveJobView.cs</DependentUpon>
     251    </EmbeddedResource>
    246252  </ItemGroup>
    247253  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15978 r15992  
    4343    public const string additionalSlavesGroupDescription = "Contains additional slaves which are either ungrouped or the parenting slave group is not assigned to the selected project.";
    4444
    45     private const string CURRENT_SELECTION_TAG = " [current selection]";
    46     private const string NEW_SELECTION_TAG = " [new selection]";
    47     private const string CHANGED_SELECTION_TAG = " [changed selection]";
    48     private const string ADDED_SELECTION_TAG = " [added selection]";
    49     private const string REMOVED_SELECTION_TAG = " [removed selection]";
    50     private const string SELECTED_TAG = " [selected]";
     45    private const string CURRENT_SELECTION_TAG = " [current assignment]";
     46    private const string NEW_SELECTION_TAG = " [new assignment]";
     47    private const string CHANGED_SELECTION_TAG = " [changed assignment]";
     48    private const string ADDED_SELECTION_TAG = " [added assignment]";
     49    private const string REMOVED_SELECTION_TAG = " [removed assignment]";
     50    private const string SELECTED_TAG = " [assigned]";
    5151    private const string INCLUDED_TAG = " [included]";
    5252    private const string ADDED_INCLUDE_TAG = " [added include]";
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r14185 r15992  
    4141      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
    4242      this.itemsListView.Columns.Add(new ColumnHeader("Name") { Text = "Name" });
     43      this.itemsListView.Columns.Add(new ColumnHeader("Project") { Text = "Project" });
    4344
    4445      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
    4546      this.itemsListView.FullRowSelect = true;
    4647
    47       this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending);
     48      this.itemsListView.ListViewItemSorter = new ListViewItemComparer(new int[] { 2, 0 }, new SortOrder[] { SortOrder.Ascending, SortOrder.Ascending });
     49
     50      foreach (ColumnHeader c in this.itemsListView.Columns) {
     51        c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     52        int w = c.Width;
     53        c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     54        if(w > c.Width) {
     55          c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     56        }
     57      }
    4858    }
    4959
    5060    protected override void SortItemsListView(SortOrder sortOrder) {
    5161      if (itemsListView.Sorting == sortOrder || sortOrder == SortOrder.None) return;
    52       ((ListViewItemDateComparer)itemsListView.ListViewItemSorter).Order = sortOrder;
     62      ((ListViewItemComparer)itemsListView.ListViewItemSorter).Orders[1] = sortOrder;
    5363      itemsListView.Sorting = sortOrder;
    5464      itemsListView.Sort();
    55       AdjustListViewColumnSizes();
     65      //AdjustListViewColumnSizes();
    5666    }
    5767
     
    133143        base.Content_ItemsAdded(sender, e);
    134144        foreach (ColumnHeader c in this.itemsListView.Columns) {
     145          c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     146          int w = c.Width;
    135147          c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     148          if (w > c.Width) {
     149            c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     150          }
    136151        }
    137152        foreach (var item in e.Items) {
     
    180195      listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.Job.DateCreated.ToString()));
    181196      listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.Job.Name));
     197      listViewItem.SubItems.Insert(2, new ListViewItem.ListViewSubItem(listViewItem, HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId)));
     198     
    182199      listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername);
    183200      return listViewItem;
     
    189206      listViewItem.SubItems[0].Text = item == null ? "null" : item.Job.DateCreated.ToString("dd.MM.yyyy HH:mm");
    190207      listViewItem.SubItems[1].Text = item == null ? "null" : item.Job.Name;
     208      listViewItem.SubItems[2].Text = item == null ? "null" : HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId);
    191209      listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername);
    192210      listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r15953 r15992  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RefreshableHiveJobView));
    4849      this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl();
    4950      this.tasksTabPage = new System.Windows.Forms.TabPage();
     
    5152      this.permissionTabPage = new System.Windows.Forms.TabPage();
    5253      this.refreshPermissionsButton = new System.Windows.Forms.Button();
     54      this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.JobManager.Views.HiveJobPermissionListView();
    5355      this.runsTabPage = new System.Windows.Forms.TabPage();
    5456      this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    6668      this.nameLabel = new System.Windows.Forms.Label();
    6769      this.nameTextBox = new System.Windows.Forms.TextBox();
     70      this.descriptionLabel = new System.Windows.Forms.Label();
     71      this.descriptionTextBox = new System.Windows.Forms.TextBox();
    6872      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    6973      this.refreshButton = new System.Windows.Forms.Button();
    7074      this.updateButton = new System.Windows.Forms.Button();
    7175      this.UnloadButton = new System.Windows.Forms.Button();
     76      this.searchButton = new System.Windows.Forms.Button();
    7277      this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
    7378      this.infoGroupBox = new System.Windows.Forms.GroupBox();
     
    7883      this.calculatingLabel = new System.Windows.Forms.Label();
    7984      this.jobsLabel = new System.Windows.Forms.Label();
    80       this.searchButton = new System.Windows.Forms.Button();
    81       this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.JobManager.Views.HiveJobPermissionListView();
    8285      this.tabControl.SuspendLayout();
    8386      this.tasksTabPage.SuspendLayout();
     
    100103      this.tabControl.Controls.Add(this.stateTabPage);
    101104      this.tabControl.Controls.Add(this.logTabPage);
    102       this.tabControl.Location = new System.Drawing.Point(0, 78);
     105      this.tabControl.Location = new System.Drawing.Point(0, 106);
    103106      this.tabControl.Name = "tabControl";
    104107      this.tabControl.SelectedIndex = 0;
     
    147150      // refreshPermissionsButton
    148151      //
    149       this.refreshPermissionsButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
     152      this.refreshPermissionsButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshPermissionsButton.Image")));
    150153      this.refreshPermissionsButton.Location = new System.Drawing.Point(3, 3);
    151154      this.refreshPermissionsButton.Name = "refreshPermissionsButton";
     
    155158      this.refreshPermissionsButton.UseVisualStyleBackColor = true;
    156159      this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click);
     160      //
     161      // hiveExperimentPermissionListView
     162      //
     163      this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     164            | System.Windows.Forms.AnchorStyles.Left)
     165            | System.Windows.Forms.AnchorStyles.Right)));
     166      this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";
     167      this.hiveExperimentPermissionListView.Content = null;
     168      this.hiveExperimentPermissionListView.HiveExperimentId = new System.Guid("00000000-0000-0000-0000-000000000000");
     169      this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33);
     170      this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView";
     171      this.hiveExperimentPermissionListView.ReadOnly = false;
     172      this.hiveExperimentPermissionListView.ShowDetails = true;
     173      this.hiveExperimentPermissionListView.Size = new System.Drawing.Size(703, 390);
     174      this.hiveExperimentPermissionListView.TabIndex = 0;
    157175      //
    158176      // runsTabPage
     
    235253      //
    236254      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    237       this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
    238       this.startButton.Location = new System.Drawing.Point(0, 536);
     255      this.startButton.Image = ((System.Drawing.Image)(resources.GetObject("startButton.Image")));
     256      this.startButton.Location = new System.Drawing.Point(0, 564);
    239257      this.startButton.Name = "startButton";
    240258      this.startButton.Size = new System.Drawing.Size(24, 24);
    241       this.startButton.TabIndex = 5;
     259      this.startButton.TabIndex = 4;
    242260      this.toolTip.SetToolTip(this.startButton, "Start/Resume Experiment");
    243261      this.startButton.UseVisualStyleBackColor = true;
     
    247265      //
    248266      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    249       this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop;
    250       this.stopButton.Location = new System.Drawing.Point(60, 536);
     267      this.stopButton.Image = ((System.Drawing.Image)(resources.GetObject("stopButton.Image")));
     268      this.stopButton.Location = new System.Drawing.Point(60, 564);
    251269      this.stopButton.Name = "stopButton";
    252270      this.stopButton.Size = new System.Drawing.Size(24, 24);
    253       this.stopButton.TabIndex = 7;
     271      this.stopButton.TabIndex = 6;
    254272      this.toolTip.SetToolTip(this.stopButton, "Stop Experiment");
    255273      this.stopButton.UseVisualStyleBackColor = true;
     
    260278      this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    261279      this.executionTimeLabel.AutoSize = true;
    262       this.executionTimeLabel.Location = new System.Drawing.Point(491, 543);
     280      this.executionTimeLabel.Location = new System.Drawing.Point(491, 571);
    263281      this.executionTimeLabel.Name = "executionTimeLabel";
    264282      this.executionTimeLabel.Size = new System.Drawing.Size(83, 13);
    265       this.executionTimeLabel.TabIndex = 9;
     283      this.executionTimeLabel.TabIndex = 100;
    266284      this.executionTimeLabel.Text = "&Execution Time:";
    267285      //
     
    269287      //
    270288      this.executionTimeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    271       this.executionTimeTextBox.Location = new System.Drawing.Point(580, 540);
     289      this.executionTimeTextBox.Location = new System.Drawing.Point(580, 568);
    272290      this.executionTimeTextBox.Name = "executionTimeTextBox";
    273291      this.executionTimeTextBox.ReadOnly = true;
    274292      this.executionTimeTextBox.Size = new System.Drawing.Size(137, 20);
    275       this.executionTimeTextBox.TabIndex = 10;
     293      this.executionTimeTextBox.TabIndex = 100;
    276294      //
    277295      // pauseButton
     
    279297      this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    280298      this.pauseButton.Enabled = false;
    281       this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause;
    282       this.pauseButton.Location = new System.Drawing.Point(30, 536);
     299      this.pauseButton.Image = ((System.Drawing.Image)(resources.GetObject("pauseButton.Image")));
     300      this.pauseButton.Location = new System.Drawing.Point(30, 564);
    283301      this.pauseButton.Name = "pauseButton";
    284302      this.pauseButton.Size = new System.Drawing.Size(24, 24);
    285       this.pauseButton.TabIndex = 6;
     303      this.pauseButton.TabIndex = 5;
    286304      this.toolTip.SetToolTip(this.pauseButton, "Pause Experiment");
    287305      this.pauseButton.UseVisualStyleBackColor = true;
     
    291309      //
    292310      this.projectLabel.AutoSize = true;
    293       this.projectLabel.Location = new System.Drawing.Point(3, 56);
     311      this.projectLabel.Location = new System.Drawing.Point(3, 83);
    294312      this.projectLabel.Name = "projectLabel";
    295313      this.projectLabel.Size = new System.Drawing.Size(43, 13);
    296       this.projectLabel.TabIndex = 12;
     314      this.projectLabel.TabIndex = 100;
    297315      this.projectLabel.Text = "Project:";
    298316      //
     
    301319      this.projectNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    302320            | System.Windows.Forms.AnchorStyles.Right)));
    303       this.projectNameTextBox.Location = new System.Drawing.Point(82, 52);
     321      this.projectNameTextBox.Location = new System.Drawing.Point(100, 80);
    304322      this.projectNameTextBox.Name = "projectNameTextBox";
    305323      this.projectNameTextBox.ReadOnly = true;
    306       this.projectNameTextBox.Size = new System.Drawing.Size(489, 20);
    307       this.projectNameTextBox.TabIndex = 2;
     324      this.projectNameTextBox.Size = new System.Drawing.Size(471, 20);
     325      this.projectNameTextBox.TabIndex = 100;
    308326      this.projectNameTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated);
    309327      //
     
    311329      //
    312330      this.nameLabel.AutoSize = true;
    313       this.nameLabel.Location = new System.Drawing.Point(3, 30);
     331      this.nameLabel.Location = new System.Drawing.Point(3, 35);
    314332      this.nameLabel.Name = "nameLabel";
    315333      this.nameLabel.Size = new System.Drawing.Size(38, 13);
    316       this.nameLabel.TabIndex = 20;
     334      this.nameLabel.TabIndex = 100;
    317335      this.nameLabel.Text = "Name:";
    318336      //
     
    321339      this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    322340            | System.Windows.Forms.AnchorStyles.Right)));
    323       this.nameTextBox.Location = new System.Drawing.Point(52, 27);
     341      this.nameTextBox.Location = new System.Drawing.Point(71, 32);
    324342      this.nameTextBox.Name = "nameTextBox";
    325       this.nameTextBox.Size = new System.Drawing.Size(519, 20);
     343      this.nameTextBox.Size = new System.Drawing.Size(500, 20);
    326344      this.nameTextBox.TabIndex = 1;
    327345      this.nameTextBox.Validated += new System.EventHandler(this.nameTextBox_Validated);
    328346      //
     347      // descriptionLabel
     348      //
     349      this.descriptionLabel.AutoSize = true;
     350      this.descriptionLabel.Location = new System.Drawing.Point(3, 59);
     351      this.descriptionLabel.Name = "descriptionLabel";
     352      this.descriptionLabel.Size = new System.Drawing.Size(63, 13);
     353      this.descriptionLabel.TabIndex = 100;
     354      this.descriptionLabel.Text = "Description:";
     355      //
     356      // descriptionTextBox
     357      //
     358      this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     359            | System.Windows.Forms.AnchorStyles.Right)));
     360      this.descriptionTextBox.Location = new System.Drawing.Point(71, 56);
     361      this.descriptionTextBox.Name = "descriptionTextBox";
     362      this.descriptionTextBox.Size = new System.Drawing.Size(500, 20);
     363      this.descriptionTextBox.TabIndex = 2;
     364      this.descriptionTextBox.Validated += new System.EventHandler(this.descriptionTextBox_Validated);
     365      //
    329366      // refreshButton
    330367      //
    331       this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
     368      this.refreshButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshButton.Image")));
    332369      this.refreshButton.Location = new System.Drawing.Point(3, 0);
    333370      this.refreshButton.Name = "refreshButton";
    334371      this.refreshButton.Size = new System.Drawing.Size(24, 24);
    335       this.refreshButton.TabIndex = 22;
     372      this.refreshButton.TabIndex = 7;
    336373      this.toolTip.SetToolTip(this.refreshButton, "Refresh Data");
    337374      this.refreshButton.UseVisualStyleBackColor = true;
     
    340377      // updateButton
    341378      //
    342       this.updateButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
     379      this.updateButton.Image = ((System.Drawing.Image)(resources.GetObject("updateButton.Image")));
    343380      this.updateButton.Location = new System.Drawing.Point(30, 0);
    344381      this.updateButton.Name = "updateButton";
    345382      this.updateButton.Size = new System.Drawing.Size(24, 24);
    346       this.updateButton.TabIndex = 23;
     383      this.updateButton.TabIndex = 8;
    347384      this.toolTip.SetToolTip(this.updateButton, "Update Job (Name, Project, Resources)");
    348385      this.updateButton.UseVisualStyleBackColor = true;
     
    351388      // UnloadButton
    352389      //
    353       this.UnloadButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Disconnect;
     390      this.UnloadButton.Image = ((System.Drawing.Image)(resources.GetObject("UnloadButton.Image")));
    354391      this.UnloadButton.Location = new System.Drawing.Point(57, 0);
    355392      this.UnloadButton.Name = "UnloadButton";
    356393      this.UnloadButton.Size = new System.Drawing.Size(24, 24);
    357       this.UnloadButton.TabIndex = 27;
     394      this.UnloadButton.TabIndex = 9;
    358395      this.toolTip.SetToolTip(this.UnloadButton, "Unload Job");
    359396      this.UnloadButton.UseVisualStyleBackColor = true;
    360397      this.UnloadButton.Click += new System.EventHandler(this.UnloadButton_Click);
     398      //
     399      // searchButton
     400      //
     401      this.searchButton.Image = ((System.Drawing.Image)(resources.GetObject("searchButton.Image")));
     402      this.searchButton.Location = new System.Drawing.Point(71, 79);
     403      this.searchButton.Name = "searchButton";
     404      this.searchButton.Size = new System.Drawing.Size(24, 24);
     405      this.searchButton.TabIndex = 3;
     406      this.toolTip.SetToolTip(this.searchButton, "Select project and resources");
     407      this.searchButton.UseVisualStyleBackColor = true;
     408      this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
    361409      //
    362410      // refreshAutomaticallyCheckBox
     
    366414      this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox";
    367415      this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17);
    368       this.refreshAutomaticallyCheckBox.TabIndex = 24;
     416      this.refreshAutomaticallyCheckBox.TabIndex = 100;
    369417      this.refreshAutomaticallyCheckBox.Text = "&Refresh automatically";
    370418      this.refreshAutomaticallyCheckBox.UseVisualStyleBackColor = true;
     
    380428      this.infoGroupBox.Controls.Add(this.calculatingLabel);
    381429      this.infoGroupBox.Controls.Add(this.jobsLabel);
    382       this.infoGroupBox.Location = new System.Drawing.Point(580, 5);
     430      this.infoGroupBox.Location = new System.Drawing.Point(578, 16);
    383431      this.infoGroupBox.Name = "infoGroupBox";
    384432      this.infoGroupBox.Size = new System.Drawing.Size(133, 89);
     
    394442      this.finishedTextBox.Name = "finishedTextBox";
    395443      this.finishedTextBox.Size = new System.Drawing.Size(53, 20);
    396       this.finishedTextBox.TabIndex = 5;
     444      this.finishedTextBox.TabIndex = 100;
    397445      //
    398446      // calculatingTextBox
     
    403451      this.calculatingTextBox.Name = "calculatingTextBox";
    404452      this.calculatingTextBox.Size = new System.Drawing.Size(53, 20);
    405       this.calculatingTextBox.TabIndex = 4;
     453      this.calculatingTextBox.TabIndex = 100;
    406454      //
    407455      // jobsTextBox
     
    412460      this.jobsTextBox.Name = "jobsTextBox";
    413461      this.jobsTextBox.Size = new System.Drawing.Size(53, 20);
    414       this.jobsTextBox.TabIndex = 3;
     462      this.jobsTextBox.TabIndex = 100;
    415463      //
    416464      // finishedLabel
     
    420468      this.finishedLabel.Name = "finishedLabel";
    421469      this.finishedLabel.Size = new System.Drawing.Size(49, 13);
    422       this.finishedLabel.TabIndex = 2;
     470      this.finishedLabel.TabIndex = 100;
    423471      this.finishedLabel.Text = "Finished:";
    424472      //
     
    429477      this.calculatingLabel.Name = "calculatingLabel";
    430478      this.calculatingLabel.Size = new System.Drawing.Size(62, 13);
    431       this.calculatingLabel.TabIndex = 1;
     479      this.calculatingLabel.TabIndex = 100;
    432480      this.calculatingLabel.Text = "Calculating:";
    433481      //
     
    438486      this.jobsLabel.Name = "jobsLabel";
    439487      this.jobsLabel.Size = new System.Drawing.Size(46, 13);
    440       this.jobsLabel.TabIndex = 0;
     488      this.jobsLabel.TabIndex = 100;
    441489      this.jobsLabel.Text = "Waiting:";
    442       //
    443       // searchButton
    444       //
    445       this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
    446       this.searchButton.Location = new System.Drawing.Point(52, 50);
    447       this.searchButton.Name = "searchButton";
    448       this.searchButton.Size = new System.Drawing.Size(24, 24);
    449       this.searchButton.TabIndex = 26;
    450       this.toolTip.SetToolTip(this.searchButton, "Select project and resources");
    451       this.searchButton.UseVisualStyleBackColor = true;
    452       this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
    453       //
    454       // hiveExperimentPermissionListView
    455       //
    456       this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    457             | System.Windows.Forms.AnchorStyles.Left)
    458             | System.Windows.Forms.AnchorStyles.Right)));
    459       this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";
    460       this.hiveExperimentPermissionListView.Content = null;
    461       this.hiveExperimentPermissionListView.HiveExperimentId = new System.Guid("00000000-0000-0000-0000-000000000000");
    462       this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33);
    463       this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView";
    464       this.hiveExperimentPermissionListView.ReadOnly = false;
    465       this.hiveExperimentPermissionListView.ShowDetails = true;
    466       this.hiveExperimentPermissionListView.Size = new System.Drawing.Size(703, 390);
    467       this.hiveExperimentPermissionListView.TabIndex = 0;
    468490      //
    469491      // RefreshableHiveJobView
     
    478500      this.Controls.Add(this.nameTextBox);
    479501      this.Controls.Add(this.nameLabel);
     502      this.Controls.Add(this.descriptionTextBox);
     503      this.Controls.Add(this.descriptionLabel);
    480504      this.Controls.Add(this.tabControl);
    481505      this.Controls.Add(this.startButton);
     
    487511      this.Controls.Add(this.stopButton);
    488512      this.Name = "RefreshableHiveJobView";
    489       this.Size = new System.Drawing.Size(717, 560);
     513      this.Size = new System.Drawing.Size(717, 588);
    490514      this.tabControl.ResumeLayout(false);
    491515      this.tasksTabPage.ResumeLayout(false);
     
    515539    private System.Windows.Forms.Label nameLabel;
    516540    private System.Windows.Forms.TextBox nameTextBox;
     541    private System.Windows.Forms.Label descriptionLabel;
     542    private System.Windows.Forms.TextBox descriptionTextBox;
    517543    private System.Windows.Forms.ToolTip toolTip;
    518544    private System.Windows.Forms.Button refreshButton;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15966 r15992  
    121121        if (Content == null) {
    122122          nameTextBox.Text = string.Empty;
     123          descriptionTextBox.Text = string.Empty;
    123124          executionTimeTextBox.Text = string.Empty;
    124125          projectNameTextBox.Text = string.Empty;
     
    139140
    140141          nameTextBox.Text = Content.Job.Name;
     142          descriptionTextBox.Text = Content.Job.Description;
    141143          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    142144          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
     
    183185      tabControl.Enabled = !Locked;
    184186      nameTextBox.Enabled = !Locked;
     187      descriptionTextBox.Enabled = !Locked;
    185188      projectNameTextBox.Enabled = !Locked;
    186189      searchButton.Enabled = !Locked;
     
    208211
    209212          this.nameTextBox.ReadOnly = Content.IsProgressing;
     213          this.descriptionTextBox.ReadOnly = Content.IsProgressing;
    210214          this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped;
    211215          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     
    457461    }
    458462
     463    private void descriptionTextBox_Validated(object sender, EventArgs e) {
     464      if (!SuppressEvents && Content.Job != null && Content.Job.Description != descriptionTextBox.Text)
     465        Content.Job.Description = descriptionTextBox.Text;
     466    }
     467
    459468    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
    460469      //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
     
    478487    }
    479488
     489    private void updateButton_Click2(object sender, EventArgs e) {
     490      if (Content.ExecutionState == ExecutionState.Stopped) {
     491        MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     492        return;
     493      }
     494
     495      HiveClient.UpdateJob(
     496        (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
     497        Content,
     498        new CancellationToken());
     499      UpdateSelectorDialog();
     500    }
     501
    480502    private void updateButton_Click(object sender, EventArgs e) {
    481503      if (Content.ExecutionState == ExecutionState.Stopped) {
     
    484506      }
    485507
    486       HiveClient.UpdateJob(
    487         (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
    488         Content,
    489         new CancellationToken());
     508      var invoker = new Action<RefreshableJob>(HiveClient.UpdateJob);
     509      invoker.BeginInvoke(Content, (ar) => {
     510        try {
     511          invoker.EndInvoke(ar);
     512        } catch (Exception ex) {
     513          ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
     514        }
     515      }, null);
    490516      UpdateSelectorDialog();
    491517    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15978 r15992  
    151151        });
    152152
    153         UpdateResourceGenealogy();
    154         UpdateProjectGenealogy();
    155         UpdateDisabledParentProjects();
     153        RefreshResourceGenealogy();
     154        RefreshProjectGenealogy();
     155        RefreshDisabledParentProjects();
    156156      }
    157157      catch {
     
    186186        });
    187187
    188         UpdateResourceGenealogy();
    189         UpdateProjectGenealogy();
    190         UpdateDisabledParentProjects();
     188        RefreshResourceGenealogy();
     189        RefreshProjectGenealogy();
     190        RefreshDisabledParentProjects();
    191191      } catch {
    192192        projects = null;
     
    214214    }
    215215
    216     private void UpdateResourceGenealogy() {
     216    private void RefreshResourceGenealogy() {
    217217      resourceAncestors.Clear();
    218218      resourceDescendants.Clear();
     
    234234    }
    235235
    236     private void UpdateProjectGenealogy() {
     236    private void RefreshProjectGenealogy() {
    237237      projectAncestors.Clear();
    238238      projectDescendants.Clear();
     
    254254    }
    255255
    256     private void UpdateDisabledParentProjects() {
     256    private void RefreshDisabledParentProjects() {
    257257      disabledParentProjects = new HashSet<Project>();
    258258
     
    414414
    415415    public static void UpdateJob(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
    416       HiveServiceLocator.Instance.CallHiveService(service => {
    417         HiveClient.StoreAsync(
    418           new Action<Exception>((Exception ex) => {
    419             //refreshableJob.ExecutionState = ExecutionState.Prepared;
    420             exceptionCallback(ex);
    421           }), refreshableJob.Job, cancellationToken);
    422       });
    423     }
     416      refreshableJob.IsProgressing = true;
     417      refreshableJob.Progress.Status = "Saving Job...";
     418      HiveClient.StoreAsync(
     419        new Action<Exception>((Exception ex) => {
     420          exceptionCallback(ex);
     421        }), refreshableJob.Job, cancellationToken);
     422      refreshableJob.IsProgressing = false;
     423      refreshableJob.Progress.Finish();
     424    }
     425
     426    public static void UpdateJob(RefreshableJob refreshableJob) {
     427      refreshableJob.IsProgressing = true;
     428
     429      try {
     430        refreshableJob.Progress.Start("Saving Job...");
     431        HiveClient.StoreAsync(new Action<Exception>((Exception ex) => {
     432          throw new Exception("Update failed.", ex);
     433        }), refreshableJob.Job, new CancellationToken());
     434      } finally {
     435        refreshableJob.IsProgressing = false;
     436        refreshableJob.Progress.Finish();
     437      }
     438    }
     439
     440
    424441
    425442    #region Upload Job
     
    687704      });
    688705    }
     706
     707    public string GetProjectAncestry(Guid projectId) {
     708      if (projectId == null || projectId == Guid.Empty) return "";
     709      var projects = projectAncestors[projectId].Reverse().ToList();
     710      projects.Add(projectId);
     711      return string.Join(" » ", projects.Select(x => ProjectNames[x]).ToArray());
     712    }
    689713  }
    690714}
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Access/3.3/Interfaces/IRoleVerifier.cs

    r14185 r15992  
    2323  public interface IRoleVerifier {
    2424    bool IsInRole(string role);
     25    bool IsUserInRole(string username, string role);
    2526    bool IsInAnyRole(params string[] roles);
    2627    bool IsInAllRoles(params string[] roles);
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Access/3.3/RoleVerifier.cs

    r14185 r15992  
    2929      return Roles.IsUserInRole(role);
    3030    }
     31    public bool IsUserInRole(string username, string role) {
     32      return Roles.IsUserInRole(username, role);
     33    }
    3134    public bool IsInAnyRole(params string[] roles) {
    3235      return roles.Any(x => Roles.IsUserInRole(x));
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15978 r15992  
    4343    private const string NOT_AUTHORIZED_PROJECTRESOURCE = "Selected project is not authorized to access the requested resource";
    4444    private const string NOT_AUTHORIZED_USERPROJECT = "Current user is not authorized to access the requested project";
     45    private const string NOT_AUTHORIZED_PROJECTOWNER = "The set user is not authorized to own the project";
    4546    private const string NO_JOB_UPDATE_POSSIBLE = "This job has already been flagged for deletion, thus, it can not be updated anymore.";
    4647
     
    768769      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    769770      // check if current (non-admin) user is owner of one of projectDto's-parents
     771      // note: non-admin users are not allowed to administer root projects (i.e. projects without parental entry)
    770772      if (!RoleVerifier.IsInRole(HiveRoles.Administrator)) {
    771         if(projectDto.ParentProjectId.HasValue) {
     773        if(projectDto != null && projectDto.ParentProjectId.HasValue) {
    772774          AuthorizationManager.AuthorizeForProjectAdministration(projectDto.ParentProjectId.Value, false);
    773775        } else {
     
    775777        }
    776778      }
    777      
     779
     780      // check that non-admins can not be set as owner of root projects
     781      if (projectDto != null && !projectDto.ParentProjectId.HasValue) {
     782        var owner = UserManager.GetUserById(projectDto.OwnerUserId);
     783        if (owner == null || !RoleVerifier.IsUserInRole(owner.UserName, HiveRoles.Administrator)) {
     784          throw new SecurityException(NOT_AUTHORIZED_PROJECTOWNER);
     785        }
     786      }
     787
    778788      var pm = PersistenceManager;
    779789      using (new PerformanceLogger("AddProject")) {
     
    797807      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    798808      // check if current (non-admin) user is owner of the project or the projectDto's-parents
     809      // note: non-admin users are not allowed to administer root projects (i.e. projects without parental entry)
    799810      if (!RoleVerifier.IsInRole(HiveRoles.Administrator)) {
    800         AuthorizationManager.AuthorizeForProjectAdministration(projectDto.Id, false);
    801       }
    802 
     811        if (projectDto != null && projectDto.ParentProjectId.HasValue) {
     812          AuthorizationManager.AuthorizeForProjectAdministration(projectDto.Id, false);
     813        } else {
     814          throw new SecurityException(NOT_AUTHORIZED_USERPROJECT);
     815        }
     816      }
     817
     818      // check that non-admins can not be set as owner of root projects
     819      if(projectDto != null && !projectDto.ParentProjectId.HasValue) {
     820        var owner = UserManager.GetUserById(projectDto.OwnerUserId);
     821        if(owner == null || !RoleVerifier.IsUserInRole(owner.UserName, HiveRoles.Administrator)) {
     822          throw new SecurityException(NOT_AUTHORIZED_PROJECTOWNER);
     823        }
     824      }
     825     
    803826      var pm = PersistenceManager;
    804827      using (new PerformanceLogger("UpdateProject")) {
     
    863886      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    864887      // check if current (non-admin) user is owner of one of the projectDto's-parents
    865       if (!RoleVerifier.IsInRole(HiveRoles.Administrator)) {
     888      // note: non-admin users are not allowed to administer root projects (i.e. projects without parental entry)
     889      if (!RoleVerifier.IsInRole(HiveRoles.Administrator)) {       
    866890        AuthorizationManager.AuthorizeForProjectAdministration(projectId, true);
    867891      }
     
    922946            .Select(x => x.ToDto()).ToList();
    923947          var now = DateTime.Now;
    924           return projects.Where(x => x.StartDate <= now && x.EndDate >= now).ToList();
     948          return projects.Where(x => x.StartDate <= now && (x.EndDate == null || x.EndDate >= now)).ToList();
    925949        });
    926950      }
     
    9991023          if (project == null) return;
    10001024          var projectPermissions = project.ProjectPermissions.Select(x => x.GrantedUserId).ToArray();
     1025
     1026          // guarantee that project owner is always permitted
     1027          if(!grantedUserIds.Contains(project.OwnerUserId)) {
     1028            grantedUserIds.Add(project.OwnerUserId);
     1029          }
     1030
    10011031          //var addedPermissions = grantedUserIds.Except(projectPermissions);
    10021032          var removedPermissions = projectPermissions.Except(grantedUserIds);
     
    10301060
    10311061            // (3) get all Guids which are in removedPermissions but not in grantedUserIds
    1032             var definatelyNotPermittedGuids = notpermittedGuids.Except(permittedGuids);
     1062            var definitelyNotPermittedGuids = notpermittedGuids.Except(permittedGuids);
    10331063
    10341064            // (4) delete jobs of those
    1035             assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, definatelyNotPermittedGuids);
     1065            assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, definitelyNotPermittedGuids);
    10361066
    10371067
     
    10681098
    10691099            foreach(var p in childProjects) {
     1100              var cpAssignedPermissions = p.ProjectPermissions.Select(x => x.GrantedUserId).ToList();
     1101              // guarantee that project owner is always permitted
     1102              if (!cpAssignedPermissions.Contains(p.OwnerUserId)) {
     1103                cpAssignedPermissions.Add(p.OwnerUserId);
     1104              }
     1105              var cpRemovedPermissions = cpAssignedPermissions.Where(x => x != p.OwnerUserId).Except(grantedUserIds);
     1106
     1107              // remove left-over job assignments (for non-reassignments)
     1108              if(!reassignCascading) {
     1109                assignedJobResourceDao.DeleteByProjectIdAndUserIds(p.ProjectId, cpRemovedPermissions);
     1110              }
     1111
    10701112              // remove project permissions
    1071               if(reassignCascading) {
     1113              if (reassignCascading) {
    10721114                p.ProjectPermissions.Clear();
    10731115              } else {
    10741116                foreach(var item in p.ProjectPermissions
    1075                   .Where(x => removedPermissions.Contains(x.GrantedUserId))
     1117                  .Where(x => x.GrantedUserId != p.OwnerUserId
     1118                    && (removedPermissions.Contains(x.GrantedUserId) || cpRemovedPermissions.Contains(x.GrantedUserId)))
    10761119                  .ToList()) {
    10771120                  p.ProjectPermissions.Remove(item);
     
    10811124
    10821125              // add project permissions
    1083               foreach (var id in grantedUserIds) {
     1126              var cpGrantedUserIds = new HashSet<Guid>(grantedUserIds);
     1127              cpGrantedUserIds.Add(p.OwnerUserId);
     1128
     1129              foreach (var id in cpGrantedUserIds) {
    10841130                if (p.ProjectPermissions.All(x => x.GrantedUserId != id)) {
    10851131                  p.ProjectPermissions.Add(new DA.ProjectPermission {
     
    11811227          if (cascading) {
    11821228            var childProjects = projectDao.GetChildProjectsById(projectId).ToList();
     1229            var childProjectIds = childProjects.Select(x => x.ProjectId).ToList();
    11831230
    11841231            // remove job assignments
    11851232            if (reassignCascading) {
    1186               assignedJobResourceDao.DeleteByProjectIds(childProjects.Select(x => x.ProjectId).ToList());
     1233              assignedJobResourceDao.DeleteByProjectIds(childProjectIds);
    11871234            } else {
    1188               var childProjectIds = childProjects.Select(x => x.ProjectId).ToList();
    11891235              assignedJobResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, removedAssignments);
    11901236            }
    11911237            foreach (var p in childProjects) {
     1238              var cpAssignedResources = p.AssignedProjectResources.Select(x => x.ResourceId).ToArray();
     1239              var cpRemovedAssignments = cpAssignedResources.Except(resourceIds);
     1240
     1241              // remove left-over job assignments (for non-reassignments)
     1242              if(!reassignCascading) {
     1243                assignedJobResourceDao.DeleteByProjectIdAndResourceIds(p.ProjectId, cpRemovedAssignments);
     1244              }
     1245
    11921246              // remove project assignments
    11931247              if (reassignCascading) {
     
    11951249              } else {
    11961250                foreach (var item in p.AssignedProjectResources
    1197                   .Where(x => removedAssignments.Contains(x.ResourceId))
     1251                  .Where(x => removedAssignments.Contains(x.ResourceId) || cpRemovedAssignments.Contains(x.ResourceId))
    11981252                  .ToList()) {
    11991253                  p.AssignedProjectResources.Remove(item);
     
    17801834        if (project != null) {
    17811835          if (project.StartDate > date) throw new ArgumentException("Cannot add job to specified project. The start date of the project is still in the future.");
    1782           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.");
     1836          else if (project.EndDate != null && project.EndDate < date) throw new ArgumentException("Cannot add job to specified project. The end date of the project is already reached.");
    17831837        } else {
    17841838          throw new ArgumentException("Cannot add job to specified project. The project seems not to be available anymore.");
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r15813 r15992  
    3939    private const string USER_NOT_IDENTIFIED = "User could not be identified";
    4040    private const string TASK_NOT_EXISTENT = "Queried task could not be found";
     41    private const string PROJECT_NOT_EXISTENT = "Queried project could not be found";
    4142
    4243    private IPersistenceManager PersistenceManager {
     
    9899      var projectDao = pm.ProjectDao;
    99100      pm.UseTransaction(() => {
     101        var project = projectDao.GetById(projectId);
     102        if (project == null) throw new ArgumentException(PROJECT_NOT_EXISTENT);
     103        if(!RoleVerifier.IsInRole(HiveRoles.Administrator)
     104          && !project.ParentProjectId.HasValue) {
     105          throw new SecurityException(NOT_AUTHORIZED_USERPROJECT);
     106        }
     107
    100108        List<Project> projectBranch = null;
    101109        if(parentalOwnership) projectBranch = projectDao.GetParentProjectsById(projectId).ToList();
Note: See TracChangeset for help on using the changeset viewer.