Changeset 15401


Ignore:
Timestamp:
10/04/17 13:56:38 (4 years ago)
Author:
jkarder
Message:

#2839:

  • worked on hive administrator view
  • updated service clients
Location:
branches/HiveProjectManagement
Files:
6 added
21 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Access/3.3/HeuristicLab.Clients.Access-3.3.csproj

    r11623 r15401  
    106106    <Compile Include="ClientInformation.cs" />
    107107    <Compile Include="ClientInformationUtils.cs" />
     108    <Compile Include="HiveRoles.cs" />
    108109    <Compile Include="Plugin.cs" />
    109110    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/HiveProjectManagement/HeuristicLab.Clients.Access/3.3/HiveRoles.cs

    r15392 r15401  
    2121
    2222using System.Linq;
    23 using HeuristicLab.Clients.Access;
    2423
    25 namespace HeuristicLab.Clients.Hive.Administrator {
     24namespace HeuristicLab.Clients.Access {
    2625  public static class HiveRoles {
    2726    public const string Administrator = "Hive Administrator";
     
    3029
    3130    public static bool CheckAdminUserPermissions() {
    32       return UserInformation.Instance.UserExists && UserInformation.Instance.User.Roles.Any(x => x.Name == HiveRoles.Administrator);
     31      return UserInformation.Instance.UserExists && UserInformation.Instance.User.Roles.Any(x => x.Name == Administrator);
     32    }
     33
     34    public static bool CheckHiveUserPermissions() {
     35      return UserInformation.Instance.UserExists && UserInformation.Instance.User.Roles.Any(x => x.Name == User);
    3336    }
    3437  }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Common/3.3/HeuristicLab.Clients.Common-3.3.csproj

    r11623 r15401  
    139139      <DependentUpon>Settings.settings</DependentUpon>
    140140    </Compile>
     141    <Compile Include="SecurityExceptionUtil.cs" />
    141142    <None Include="app.config" />
    142143    <None Include="Properties\AssemblyInfo.cs.frame" />
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj

    r14125 r15401  
    110110  </ItemGroup>
    111111  <ItemGroup>
    112     <Compile Include="HiveRoles.cs" />
    113112    <Compile Include="Views\DowntimeTypeDialog.cs">
    114113      <SubType>Form</SubType>
     
    133132    </Compile>
    134133    <Compile Include="MenuItems\AdministratorMenuItem.cs" />
     134    <Compile Include="Views\ProjectsView.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\ProjectsView.Designer.cs">
     138      <DependentUpon>ProjectsView.cs</DependentUpon>
     139    </Compile>
     140    <Compile Include="Views\ProjectView.cs">
     141      <SubType>UserControl</SubType>
     142    </Compile>
     143    <Compile Include="Views\ProjectView.Designer.cs">
     144      <DependentUpon>ProjectView.cs</DependentUpon>
     145    </Compile>
    135146    <Compile Include="Views\Recurrence.cs">
    136147      <SubType>Form</SubType>
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/MenuItems/AdministratorMenuItem.cs

    r14185 r15401  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    23 using HeuristicLab.Clients.Hive;
     24using System.Windows.Forms;
     25using HeuristicLab.Clients.Access;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.Optimizer;
    2528
    26 namespace HeuristicLab.Optimizer.MenuItems {
    27   public class AdministratorMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     29namespace HeuristicLab.Clients.Hive.Administrator {
     30  public class AdministratorMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2831    public override string Name {
    2932      get { return "&Administrator"; }
    3033    }
     34
    3135    public override IEnumerable<string> Structure {
    3236      get { return new string[] { "&Services", "&Hive" }; }
    3337    }
     38
    3439    public override void Execute() {
    35       MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance);
     40      if (HiveRoles.CheckAdminUserPermissions()) {
     41        MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance);
     42      } else if (!UserInformation.Instance.UserExists) {
     43        MessageBox.Show(
     44          "Couldn't fetch user information from the server." + Environment.NewLine +
     45          "Please verify that you have an existing user and that your user name and password is correct.",
     46          "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     47      } else {
     48        MessageBox.Show(
     49          "You do not seem to have the permissions to use the Hive Administrator." + Environment.NewLine +
     50          "If that's not the case or you have any questions please write an email to support@heuristiclab.com",
     51          "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     52      }
    3653    }
     54
    3755    public override int Position {
    38       get { return 10000; }
     56      get { return 8000; }
     57    }
     58
     59    public override Keys ShortCutKeys {
     60      get { return Keys.Control | Keys.Shift | Keys.H; }
    3961    }
    4062  }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.Designer.cs

    r14185 r15401  
    3030      this.tabAdmin = new System.Windows.Forms.TabControl();
    3131      this.tabSlaves = new System.Windows.Forms.TabPage();
     32      this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();
     33      this.tabPage1 = new System.Windows.Forms.TabPage();
    3234      this.imageListUsers = new System.Windows.Forms.ImageList(this.components);
    33       this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();
     35      this.projectsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectsView();
    3436      this.tabAdmin.SuspendLayout();
    3537      this.tabSlaves.SuspendLayout();
     38      this.tabPage1.SuspendLayout();
    3639      this.SuspendLayout();
    3740      //
    3841      // tabAdmin
    3942      //
    40       this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    41                   | System.Windows.Forms.AnchorStyles.Left)
    42                   | System.Windows.Forms.AnchorStyles.Right)));
     43      this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     44            | System.Windows.Forms.AnchorStyles.Left)
     45            | System.Windows.Forms.AnchorStyles.Right)));
    4346      this.tabAdmin.Controls.Add(this.tabSlaves);
     47      this.tabAdmin.Controls.Add(this.tabPage1);
    4448      this.tabAdmin.Location = new System.Drawing.Point(3, 0);
    4549      this.tabAdmin.Name = "tabAdmin";
     
    5963      this.tabSlaves.UseVisualStyleBackColor = true;
    6064      //
    61       // imageListUsers
    62       //
    63       this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
    64       this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16);
    65       this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent;
    66       //
    6765      // resourcesView
    6866      //
    69       this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    70                   | System.Windows.Forms.AnchorStyles.Left)
    71                   | System.Windows.Forms.AnchorStyles.Right)));
     67      this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     68            | System.Windows.Forms.AnchorStyles.Left)
     69            | System.Windows.Forms.AnchorStyles.Right)));
    7270      this.resourcesView.Caption = "ResourcesView";
    7371      this.resourcesView.Content = null;
     
    7876      this.resourcesView.TabIndex = 0;
    7977      //
    80       // HiveAdministrationView
     78      // tabPage1
    8179      //
    82       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     80      this.tabPage1.Controls.Add(this.projectsView);
     81      this.tabPage1.Location = new System.Drawing.Point(4, 22);
     82      this.tabPage1.Name = "tabPage1";
     83      this.tabPage1.Size = new System.Drawing.Size(734, 520);
     84      this.tabPage1.TabIndex = 4;
     85      this.tabPage1.Text = "Projects";
     86      this.tabPage1.UseVisualStyleBackColor = true;
     87      //
     88      // imageListUsers
     89      //
     90      this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
     91      this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16);
     92      this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent;
     93      //
     94      // projectsView
     95      //
     96      this.projectsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     97            | System.Windows.Forms.AnchorStyles.Left)
     98            | System.Windows.Forms.AnchorStyles.Right)));
     99      this.projectsView.Caption = "Resources View";
     100      this.projectsView.Content = null;
     101      this.projectsView.Location = new System.Drawing.Point(0, 0);
     102      this.projectsView.Name = "projectsView";
     103      this.projectsView.ReadOnly = false;
     104      this.projectsView.Size = new System.Drawing.Size(734, 520);
     105      this.projectsView.TabIndex = 0;
     106      //
     107      // HiveAdministratorView
     108      //
    83109      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    84110      this.Controls.Add(this.tabAdmin);
    85       this.Name = "HiveAdministrationView";
     111      this.Name = "HiveAdministratorView";
    86112      this.Size = new System.Drawing.Size(745, 546);
    87113      this.tabAdmin.ResumeLayout(false);
    88114      this.tabSlaves.ResumeLayout(false);
     115      this.tabPage1.ResumeLayout(false);
    89116      this.ResumeLayout(false);
    90117
     
    96123    private System.Windows.Forms.ImageList imageListUsers;
    97124    private System.Windows.Forms.TabPage tabSlaves;
    98 
     125    private System.Windows.Forms.TabPage tabPage1;
     126    private ProjectsView projectsView;
    99127  }
    100128}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r14185 r15401  
    3737        components.Dispose();
    3838      }
    39       HiveAdminClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing);
    40       HiveAdminClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed);
    41 
    42       Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Refreshing);
    43       Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Refreshed);
     39      HiveAdminClient.Instance.Refreshing -= new EventHandler(HiveAdminClient_Instance_Refreshing);
     40      HiveAdminClient.Instance.Refreshed -= new EventHandler(HiveAdminClient_Instance_Refreshed);
     41
     42      Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Instance_Refreshing);
     43      Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Instance_Refreshed);
    4444      base.Dispose(disposing);
    4545    }
     
    5353    private void InitializeComponent() {
    5454      this.components = new System.ComponentModel.Container();
     55      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ResourcesView));
    5556      this.imageListSlaveGroups = new System.Windows.Forms.ImageList(this.components);
    5657      this.splitSlaves = new System.Windows.Forms.SplitContainer();
    5758      this.btnRefresh = new System.Windows.Forms.Button();
    58       this.progressBar = new System.Windows.Forms.ProgressBar();
    5959      this.btnSave = new System.Windows.Forms.Button();
    6060      this.btnRemoveGroup = new System.Windows.Forms.Button();
    6161      this.btnAddGroup = new System.Windows.Forms.Button();
    62       this.btnPermissionsSave = new System.Windows.Forms.Button();
    6362      this.treeSlaveGroup = new System.Windows.Forms.TreeView();
    6463      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
     
    6867      this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();
    6968      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    70       this.tabPermissions = new System.Windows.Forms.TabPage();
    71       this.permissionView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView();
    7269      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit();
    7370      this.splitSlaves.Panel1.SuspendLayout();
     
    7774      this.tabDetails.SuspendLayout();
    7875      this.tabSchedule.SuspendLayout();
    79       this.tabPermissions.SuspendLayout();
    8076      this.SuspendLayout();
    8177      //
     
    8884      // splitSlaves
    8985      //
    90       this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    91             | System.Windows.Forms.AnchorStyles.Left)
     86      this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     87            | System.Windows.Forms.AnchorStyles.Left) 
    9288            | System.Windows.Forms.AnchorStyles.Right)));
    9389      this.splitSlaves.Location = new System.Drawing.Point(3, 3);
     
    9793      //
    9894      this.splitSlaves.Panel1.Controls.Add(this.btnRefresh);
    99       this.splitSlaves.Panel1.Controls.Add(this.progressBar);
    10095      this.splitSlaves.Panel1.Controls.Add(this.btnSave);
    10196      this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup);
     
    121116      this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
    122117      //
    123       // progressBar
    124       //
    125       this.progressBar.Location = new System.Drawing.Point(123, 4);
    126       this.progressBar.Name = "progressBar";
    127       this.progressBar.Size = new System.Drawing.Size(123, 23);
    128       this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
    129       this.progressBar.TabIndex = 7;
    130       //
    131118      // btnSave
    132119      //
     
    165152      //
    166153      this.treeSlaveGroup.AllowDrop = true;
    167       this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    168             | System.Windows.Forms.AnchorStyles.Left)
     154      this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     155            | System.Windows.Forms.AnchorStyles.Left) 
    169156            | System.Windows.Forms.AnchorStyles.Right)));
    170157      this.treeSlaveGroup.ImageIndex = 0;
     
    184171      // tabSlaveGroup
    185172      //
    186       this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    187             | System.Windows.Forms.AnchorStyles.Left)
     173      this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     174            | System.Windows.Forms.AnchorStyles.Left) 
    188175            | System.Windows.Forms.AnchorStyles.Right)));
    189176      this.tabSlaveGroup.Controls.Add(this.tabDetails);
    190177      this.tabSlaveGroup.Controls.Add(this.tabSchedule);
    191       this.tabSlaveGroup.Controls.Add(this.tabPermissions);
    192178      this.tabSlaveGroup.Location = new System.Drawing.Point(3, 3);
    193179      this.tabSlaveGroup.Name = "tabSlaveGroup";
     
    210196      // slaveView
    211197      //
    212       this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    213             | System.Windows.Forms.AnchorStyles.Left)
     198      this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     199            | System.Windows.Forms.AnchorStyles.Left) 
    214200            | System.Windows.Forms.AnchorStyles.Right)));
    215201      this.slaveView.Caption = "SlaveView";
     
    234220      // scheduleView
    235221      //
    236       this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    237             | System.Windows.Forms.AnchorStyles.Left)
     222      this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     223            | System.Windows.Forms.AnchorStyles.Left) 
    238224            | System.Windows.Forms.AnchorStyles.Right)));
    239225      this.scheduleView.Caption = "ScheduleView";
     
    244230      this.scheduleView.Size = new System.Drawing.Size(565, 503);
    245231      this.scheduleView.TabIndex = 0;
    246       //
    247       // tabPermissions
    248       //
    249       this.tabPermissions.Controls.Add(this.btnPermissionsSave);
    250       this.tabPermissions.Controls.Add(this.permissionView);
    251       this.tabPermissions.Location = new System.Drawing.Point(4, 22);
    252       this.tabPermissions.Name = "tabPermissions";
    253       this.tabPermissions.Padding = new System.Windows.Forms.Padding(3);
    254       this.tabPermissions.Size = new System.Drawing.Size(577, 515);
    255       this.tabPermissions.TabIndex = 2;
    256       this.tabPermissions.Text = "Permissions";
    257       this.tabPermissions.UseVisualStyleBackColor = true;
    258       //
    259       // btnPermissionsSave
    260       //
    261       this.btnPermissionsSave.Enabled = false;
    262       this.btnPermissionsSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
    263       this.btnPermissionsSave.Location = new System.Drawing.Point(39, 9);
    264       this.btnPermissionsSave.Name = "btnPermissionsSave";
    265       this.btnPermissionsSave.Size = new System.Drawing.Size(24, 24);
    266       this.btnPermissionsSave.TabIndex = 1;
    267       this.toolTip.SetToolTip(this.btnPermissionsSave, "Store slave and group sharing permissions on the server");
    268       this.btnPermissionsSave.UseVisualStyleBackColor = true;
    269       this.btnPermissionsSave.Click += new System.EventHandler(this.btnPermissionsSave_Click);
    270       //
    271       // permissionView
    272       //
    273       this.permissionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    274             | System.Windows.Forms.AnchorStyles.Left)
    275             | System.Windows.Forms.AnchorStyles.Right)));
    276       this.permissionView.Caption = "RefreshableLightweightUser View";
    277       this.permissionView.Content = null;
    278       this.permissionView.FetchSelectedUsers = null;
    279       this.permissionView.Location = new System.Drawing.Point(6, 6);
    280       this.permissionView.Name = "permissionView";
    281       this.permissionView.ReadOnly = false;
    282       this.permissionView.Size = new System.Drawing.Size(565, 503);
    283       this.permissionView.TabIndex = 0;
    284232      //
    285233      // ResourcesView
     
    297245      this.tabDetails.ResumeLayout(false);
    298246      this.tabSchedule.ResumeLayout(false);
    299       this.tabPermissions.ResumeLayout(false);
    300247      this.ResumeLayout(false);
    301248
     
    315262    private ScheduleView scheduleView;
    316263    private System.Windows.Forms.Button btnSave;
    317     private System.Windows.Forms.ProgressBar progressBar;
    318264    private System.Windows.Forms.Button btnRefresh;
    319265    private System.Windows.Forms.ToolTip toolTip;
    320     private System.Windows.Forms.TabPage tabPermissions;
    321     private Access.Views.RefreshableLightweightUserView permissionView;
    322     private System.Windows.Forms.Button btnPermissionsSave;
    323266  }
    324267}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r14185 r15401  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using System.Collections.Generic;
     23using System.ComponentModel;
    2424using System.Drawing;
    2525using System.Linq;
    26 using System.ServiceModel.Security;
    27 using System.Threading;
    28 using System.Threading.Tasks;
    2926using System.Windows.Forms;
    3027using HeuristicLab.Clients.Access;
    3128using HeuristicLab.Clients.Hive.Views;
     29using HeuristicLab.Common.Resources;
    3230using HeuristicLab.Core;
    3331using HeuristicLab.Core.Views;
    3432using HeuristicLab.MainForm;
    35 using TS = System.Threading.Tasks;
    3633
    3734namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    3936  [Content(typeof(IItemList<Resource>), false)]
    4037  public partial class ResourcesView : ItemView, IDisposable {
     38    private const string UngroupedGroupName = "UNGROUPED";
     39    private const int slaveImageIndex = 0;
     40    private const int slaveGroupImageIndex = 1;
     41
     42    private readonly Color ownedResourceColor = Color.LightGreen;
     43    private readonly object locker = new object();
     44    private bool updatingResources = false;
     45    private bool removingResources = false;
     46    private bool savingResources = false;
     47
    4148    public new IItemList<Resource> Content {
    4249      get { return (IItemList<Resource>)base.Content; }
     
    4451    }
    4552
    46     public const string UngroupedGroupName = "UNGROUPED";
    47     private const int slaveImageIndex = 0;
    48     private const int slaveGroupImageIndex = 1;
    49     private readonly Color ownedResourceColor = Color.LightGreen;
    50     private TS.Task progressTask;
    51     private bool stopProgressTask;
    52     private bool currentlyAuthorized;
    53 
    54 
    5553    public ResourcesView() {
    5654      InitializeComponent();
    57       treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    58       treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
    59 
    60       HiveAdminClient.Instance.Refreshing += new EventHandler(Instance_Refreshing);
    61       HiveAdminClient.Instance.Refreshed += new EventHandler(Instance_Refreshed);
    62 
    63       Access.AccessClient.Instance.Refreshing += new EventHandler(AccessClient_Refreshing);
    64       Access.AccessClient.Instance.Refreshed += new EventHandler(AccessClient_Refreshed);
    65     }
    66 
    67     private void UpdateProgress() {
    68       while (!stopProgressTask) {
    69         int diff = (progressBar.Maximum - progressBar.Minimum) / 10;
    70 
    71         if (progressBar.InvokeRequired) {
    72           progressBar.Invoke(new Action(delegate() { progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum; }));
    73         } else {
    74           progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum;
    75         }
    76 
    77         //ok, this is not very clever...
    78         Thread.Sleep(500);
    79       }
    80       if (progressBar.InvokeRequired) {
    81         progressBar.Invoke(new Action(delegate() { progressBar.Value = progressBar.Minimum; }));
    82       } else {
    83         progressBar.Value = progressBar.Minimum;
    84       }
    85     }
    86 
    87     void Instance_Refreshing(object sender, EventArgs e) {
    88       stopProgressTask = false;
    89       progressTask = new TS.Task(UpdateProgress);
    90       progressTask.Start();
    91       SetEnabledStateOfControls();
    92     }
    93 
    94     void Instance_Refreshed(object sender, EventArgs e) {
    95       stopProgressTask = true;
    96       SetEnabledStateOfControls();
    97     }
    98 
    99     void AccessClient_Refreshing(object sender, EventArgs e) {
    100       stopProgressTask = false;
    101       progressTask = new TS.Task(UpdateProgress);
    102       progressTask.Start();
    103       SetEnabledStateOfControls();
    104       btnPermissionsSave.Enabled = false;
    105     }
    106 
    107     void AccessClient_Refreshed(object sender, EventArgs e) {
    108       stopProgressTask = true;
    109       SetEnabledStateOfControls();
    110     }
    111 
    112     #region Register Content Events
    113     protected override void DeregisterContentEvents() {
    114       Content.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded);
    115       Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved);
    116       base.DeregisterContentEvents();
    117     }
     55
     56      treeSlaveGroup.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
     57      treeSlaveGroup.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
     58
     59      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
     60      HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
     61      AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;
     62      AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;
     63    }
     64
     65    #region Overrides
     66    protected override void OnClosing(FormClosingEventArgs e) {
     67      AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
     68      AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
     69      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     70      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
     71      base.OnClosing(e);
     72    }
     73
    11874    protected override void RegisterContentEvents() {
    11975      base.RegisterContentEvents();
    120       Content.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded);
    121       Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved);
    122     }
    123     #endregion
     76      Content.ItemsAdded += Content_ItemsAdded;
     77      Content.ItemsRemoved += Content_ItemsRemoved;
     78    }
     79
     80    protected override void DeregisterContentEvents() {
     81      Content.ItemsRemoved -= Content_ItemsRemoved;
     82      Content.ItemsAdded -= Content_ItemsAdded;
     83      base.DeregisterContentEvents();
     84    }
    12485
    12586    protected override void OnContentChanged() {
     
    12889        slaveView.Content = null;
    12990        scheduleView.Content = null;
    130         permissionView.Content = null;
    131         permissionView.FetchSelectedUsers = null;
    13291        treeSlaveGroup.Nodes.Clear();
    13392      } else {
    134         permissionView.Content = Access.AccessClient.Instance;
    13593        treeSlaveGroup.Nodes.Clear();
    13694
     
    145103        ungrp.Tag = newGroup;
    146104
    147         foreach (Resource g in Content) {
     105        foreach (Resource g in Content.OrderBy(x => x.Name)) {
    148106          if (g.GetType() == typeof(SlaveGroup)) {
    149107            //root node
     
    175133    }
    176134
    177     private void BuildSlaveGroupTree(Resource g, TreeNode tn) {
    178       foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id)) {
    179         TreeNode stn = new TreeNode(r.Name);
    180         if (r is Slave) {
    181           stn.ImageIndex = slaveImageIndex;
    182         } else if (r is SlaveGroup) {
    183           stn.ImageIndex = slaveGroupImageIndex;
    184         }
    185         stn.SelectedImageIndex = stn.ImageIndex;
    186         stn.Tag = r;
    187         if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    188         tn.Nodes.Add(stn);
    189 
    190         BuildSlaveGroupTree(r, stn);
    191       }
    192     }
    193 
    194135    protected override void SetEnabledStateOfControls() {
    195136      base.SetEnabledStateOfControls();
    196       if (Content == null) {
    197         btnAddGroup.Enabled = false;
    198         btnRemoveGroup.Enabled = false;
    199         btnSave.Enabled = false;
    200         btnPermissionsSave.Enabled = false;
    201         permissionView.Enabled = false;
    202         scheduleView.SetEnabledStateOfSchedule(false);
    203         btnPermissionsSave.Enabled = false;
    204         permissionView.Enabled = false;
    205       } else {
    206         btnAddGroup.Enabled = true;
    207         btnRemoveGroup.Enabled = true;
    208         btnSave.Enabled = true;
    209         scheduleView.SetEnabledStateOfSchedule(IsAuthorized(slaveView.Content));
    210         btnPermissionsSave.Enabled = permissionView.FetchSelectedUsers != null;
    211         permissionView.Enabled = permissionView.FetchSelectedUsers != null;
    212       }
    213     }
    214 
    215     private bool IsAuthorized(Resource resource) {
    216       return resource != null
    217           && resource.Name != UngroupedGroupName
    218           && resource.Id != Guid.Empty
    219           && UserInformation.Instance.UserExists
    220           && (resource.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());
    221     }
    222 
    223     private void treeSlaveGroup_AfterSelect(object sender, TreeViewEventArgs e) {
    224       if (e.Action != TreeViewAction.Unknown) {
    225         Resource selectedResource = ((Resource)e.Node.Tag);
    226         currentlyAuthorized = IsAuthorized(selectedResource);
    227         if (currentlyAuthorized) {
    228           permissionView.FetchSelectedUsers = new Func<List<Guid>>(() => {
    229             return HiveServiceLocator.Instance.CallHiveService<List<ResourcePermission>>(service => {
    230               return service.GetResourcePermissions(selectedResource.Id);
    231             }).Select(x => x.GrantedUserId).ToList();
    232           });
    233           if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
    234         } else {
    235           permissionView.FetchSelectedUsers = null;
    236           btnPermissionsSave.Enabled = false;
    237           if (selectedResource.Id == Guid.Empty) {
    238             if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
    239           } else tabSlaveGroup.TabPages.Remove(tabPermissions);
    240         }
    241 
    242         if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    243           slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    244         }
    245 
    246         slaveView.Content = selectedResource;
    247         HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id;
    248 
    249         if (selectedResource is SlaveGroup) {
    250           slaveView.Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    251         }
    252 
    253         if (tabSlaveGroup.SelectedIndex == 1) {
    254           UpdateScheduleAsync();
    255         } else if (tabSlaveGroup.SelectedIndex == 2) {
    256           UpdatePermissionsAsync();
    257         }
    258       }
    259     }
    260 
    261     void SlaveViewContent_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
     137      bool enabled = Content != null;
     138      btnAddGroup.Enabled = enabled;
     139      btnRemoveGroup.Enabled = enabled;
     140      btnSave.Enabled = enabled;
     141      scheduleView.SetEnabledStateOfSchedule(enabled && IsAuthorized(slaveView.Content));
     142    }
     143    #endregion
     144
     145    #region Event Handlers
     146    private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
     147      OnContentChanged();
     148    }
     149
     150    private void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
     151      OnContentChanged();
     152    }
     153
     154    private void SlaveViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    262155      OnContentChanged();
    263156      if (e.PropertyName == "HbInterval") {
     
    266159    }
    267160
    268     private void UpdateChildHbIntervall(Resource resource) {
    269       foreach (Resource r in Content.Where(x => x.ParentResourceId == resource.Id)) {
    270         r.HbInterval = resource.HbInterval;
    271         if (r is SlaveGroup) {
    272           UpdateChildHbIntervall(r);
    273         }
    274       }
     161    private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) {
     162      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
     163      else {
     164        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     165        mainForm.AddOperationProgressToView(this, "Refreshing ...");
     166        SetEnabledStateOfControls();
     167      }
     168    }
     169
     170    private void HiveAdminClient_Instance_Refreshed(object sender, EventArgs e) {
     171      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
     172      else {
     173        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     174        mainForm.RemoveOperationProgressFromView(this);
     175        SetEnabledStateOfControls();
     176      }
     177    }
     178
     179    private void AccessClient_Instance_Refreshing(object sender, EventArgs e) {
     180      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
     181      else {
     182        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     183        mainForm.AddOperationProgressToView(this, "Refreshing ...");
     184        SetEnabledStateOfControls();
     185      }
     186    }
     187
     188    private void AccessClient_Instance_Refreshed(object sender, EventArgs e) {
     189      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
     190      else {
     191        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     192        mainForm.RemoveOperationProgressFromView(this);
     193        SetEnabledStateOfControls();
     194      }
     195    }
     196
     197    private async void ResourcesView_Load(object sender, EventArgs e) {
     198      lock (locker) {
     199        if (updatingResources) return;
     200        updatingResources = true;
     201      }
     202
     203      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     204        action: () => UpdateResources(),
     205        finallyCallback: () => updatingResources = false);
     206    }
     207
     208    private async void btnRefresh_Click(object sender, EventArgs e) {
     209      lock (locker) {
     210        if (updatingResources) return;
     211        updatingResources = true;
     212      }
     213
     214      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     215        action: () => UpdateResources(),
     216        finallyCallback: () => updatingResources = false);
    275217    }
    276218
    277219    private void btnAddGroup_Click(object sender, EventArgs e) {
    278       SlaveGroup newGroup = new SlaveGroup();
    279       newGroup.Name = "New Group";
    280       newGroup.OwnerUserId = UserInformation.Instance.User.Id;
    281       Content.Add(newGroup);
    282     }
    283 
    284     void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
    285       OnContentChanged();
    286     }
    287 
    288     void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
    289       OnContentChanged();
    290     }
    291 
    292     private void btnRemoveGroup_Click(object sender, EventArgs e) {
    293       if (treeSlaveGroup.SelectedNode != null && treeSlaveGroup.SelectedNode.Tag != null) {
    294         Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag;
    295 
    296         DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrator", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    297         if (diagRes == DialogResult.Yes) {
    298           if (res is Slave) {
    299             Content.Remove(res);
    300             HiveAdminClient.Delete(res);
    301           } else if (res is SlaveGroup) {
    302             //only delete empty groups
    303             if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) {
    304               Content.Remove(res);
    305               HiveAdminClient.Delete(res);
    306             } else {
    307               MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    308             }
    309           }
    310         }
    311       }
    312     }
    313 
    314     private void btnSave_Click(object sender, EventArgs e) {
    315       foreach (Resource res in Content) {
    316         if (res is SlaveGroup && res.Id == Guid.Empty) {
    317           SlaveGroup slaveGroup = (SlaveGroup)res;
    318           slaveGroup.Store();
    319         } else if (res.Id != Guid.Empty && res.Modified) {
    320           res.Store();
    321         }
    322       }
     220      var group = new SlaveGroup {
     221        Name = "New Group",
     222        OwnerUserId = UserInformation.Instance.User.Id
     223      };
     224      Content.Add(group);
     225    }
     226
     227    private async void btnRemoveGroup_Click(object sender, EventArgs e) {
     228      lock (locker) {
     229        if (removingResources) return;
     230        removingResources = true;
     231      }
     232
     233      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     234        action: () => RemoveResource(),
     235        finallyCallback: () => removingResources = false);
     236    }
     237
     238    private async void btnSave_Click(object sender, EventArgs e) {
     239      lock (locker) {
     240        if (savingResources) return;
     241        savingResources = true;
     242      }
     243
     244      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     245        action: () => {
     246          var resourcesToSave = Content.Where(x => x.Id == Guid.Empty || x.Modified);
     247          foreach (var resource in resourcesToSave)
     248            resource.Store();
     249        },
     250        finallyCallback: () => savingResources = false);
     251    }
     252
     253    private async void treeSlaveGroup_AfterSelect(object sender, TreeViewEventArgs e) {
     254      var selectedResource = (Resource)e.Node.Tag;
     255
     256      if (slaveView.Content != null && slaveView.Content is SlaveGroup)
     257        slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged;
     258
     259      slaveView.Content = selectedResource;
     260
     261      if (selectedResource is SlaveGroup)
     262        slaveView.Content.PropertyChanged += SlaveViewContent_PropertyChanged;
     263
     264      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     265        action: () => UpdateSchedule());
    323266    }
    324267
     
    386329    }
    387330
    388     private bool CheckParentsEqualsMovedNode(TreeNode dest, TreeNode movedNode) {
    389       TreeNode tmp = dest;
    390 
    391       while (tmp != null) {
    392         if (tmp == movedNode) {
    393           return true;
    394         }
    395         tmp = tmp.Parent;
    396       }
    397       return false;
    398     }
    399 
    400331    private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) {
    401332      TreeNode sourceNode = (TreeNode)e.Item;
     
    416347    }
    417348
    418     void ResetView() {
    419       if (this.InvokeRequired) {
    420         Invoke(new Action(ResetView));
    421       } else {
     349    private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) {
     350      if (tabSlaveGroup.SelectedIndex == 1) {
     351        UpdateSchedule();
     352      }
     353    }
     354    #endregion
     355
     356    #region Helpers
     357    private void BuildSlaveGroupTree(Resource g, TreeNode tn) {
     358      foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id).OrderBy(x => x.Name)) {
     359        TreeNode stn = new TreeNode(r.Name);
     360        if (r is Slave) {
     361          stn.ImageIndex = slaveImageIndex;
     362        } else if (r is SlaveGroup) {
     363          stn.ImageIndex = slaveGroupImageIndex;
     364        }
     365        stn.SelectedImageIndex = stn.ImageIndex;
     366        stn.Tag = r;
     367        if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
     368        tn.Nodes.Add(stn);
     369
     370        BuildSlaveGroupTree(r, stn);
     371      }
     372    }
     373
     374    private void UpdateChildHbIntervall(Resource resource) {
     375      foreach (Resource r in Content.Where(x => x.ParentResourceId == resource.Id)) {
     376        r.HbInterval = resource.HbInterval;
     377        if (r is SlaveGroup) {
     378          UpdateChildHbIntervall(r);
     379        }
     380      }
     381    }
     382
     383    private bool CheckParentsEqualsMovedNode(TreeNode dest, TreeNode movedNode) {
     384      TreeNode tmp = dest;
     385
     386      while (tmp != null) {
     387        if (tmp == movedNode) {
     388          return true;
     389        }
     390        tmp = tmp.Parent;
     391      }
     392      return false;
     393    }
     394
     395    private void ResetView() {
     396      if (InvokeRequired) Invoke((Action)ResetView);
     397      else {
    422398        treeSlaveGroup.Nodes.Clear();
    423399
    424400        if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    425           slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    426         }
     401          slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged;
     402        }
     403
    427404        slaveView.Content = null;
    428405        if (scheduleView.Content != null) {
    429406          scheduleView.Content.Clear();
    430407        }
     408
    431409        HiveAdminClient.Instance.ResetDowntime();
    432410      }
     
    434412
    435413    private void UpdateResources() {
    436       ResetView();
    437 
    438414      try {
    439         if (!Access.UserInformation.Instance.UserExists) {
    440           //do a refresh just in case that the user has changed his usr and pwd in between
    441           Access.UserInformation.Instance.Refresh();
    442         }
     415        ResetView();
    443416        HiveAdminClient.Instance.Refresh();
    444417        Content = HiveAdminClient.Instance.Resources;
    445       }
    446       catch (MessageSecurityException) {
    447         ShowMessageSecurityException();
    448       }
    449       catch (AnonymousUserException) {
     418      } catch (AnonymousUserException) {
    450419        ShowHiveInformationDialog();
    451420      }
    452421    }
    453422
    454     private void ShowMessageSecurityException() {
    455       if (this.InvokeRequired) {
    456         Invoke(new Action(ShowMessageSecurityException));
     423    private void RemoveResource() {
     424      var selectedNode = treeSlaveGroup.SelectedNode;
     425      if (selectedNode == null || selectedNode.Tag == null) return;
     426
     427      var resource = (Resource)selectedNode.Tag;
     428      var result = MessageBox.Show(
     429        "Do you really want to delete " + resource.Name + "?",
     430        "HeuristicLab Hive Administrator",
     431        MessageBoxButtons.YesNo,
     432        MessageBoxIcon.Question);
     433
     434      if (result == DialogResult.Yes) {
     435        if (resource is Slave) {
     436          Content.Remove(resource);
     437          HiveAdminClient.Delete(resource);
     438        } else if (resource is SlaveGroup) {
     439          if (Content.Any(x => x.ParentResourceId == resource.Id)) {
     440            MessageBox.Show(
     441              "Only empty resources can be deleted.",
     442              "HeuristicLab Hive Administrator",
     443              MessageBoxButtons.OK,
     444              MessageBoxIcon.Error);
     445          } else {
     446            Content.Remove(resource);
     447            HiveAdminClient.Delete(resource);
     448          }
     449        }
     450      }
     451    }
     452
     453    private void UpdateSchedule() {
     454      var selectedNode = treeSlaveGroup.SelectedNode;
     455      var resource = (Resource)selectedNode?.Tag;
     456
     457      if (IsAuthorized(resource)) {
     458        if (!tabSlaveGroup.TabPages.Contains(tabSchedule))
     459          tabSlaveGroup.TabPages.Add(tabSchedule);
     460
     461        if (tabSlaveGroup.SelectedIndex == 1) {
     462          HiveAdminClient.Instance.DowntimeForResourceId = resource.Id;
     463          HiveAdminClient.Instance.RefreshCalendar();
     464          scheduleView.Invoke((Action)(() => {
     465            scheduleView.Content = HiveAdminClient.Instance.Downtimes;
     466            SetEnabledStateOfControls();
     467          }));
     468        }
    457469      } else {
    458         MessageBox.Show("A Message Security error has occured. This normally means that your user name or password is wrong.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    459       }
     470        if (tabSlaveGroup.TabPages.Contains(tabSchedule))
     471          tabSlaveGroup.TabPages.Remove(tabSchedule);
     472      }
     473    }
     474
     475    private bool IsAuthorized(Resource resource) {
     476      return resource != null
     477          && resource.Name != UngroupedGroupName
     478          && resource.Id != Guid.Empty
     479          && UserInformation.Instance.UserExists
     480          && (resource.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());
    460481    }
    461482
    462483    private void ShowHiveInformationDialog() {
    463       if (this.InvokeRequired) {
    464         Invoke(new Action(ShowHiveInformationDialog));
    465       } else {
     484      if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog);
     485      else {
    466486        using (HiveInformationDialog dialog = new HiveInformationDialog()) {
    467487          dialog.ShowDialog(this);
     
    469489      }
    470490    }
    471 
    472     private void UpdateResourcesAsync() {
    473       TS.Task.Factory.StartNew(UpdateResources).ContinueWith((t) => {
    474         DisplayError(t.Exception);
    475       }, TaskContinuationOptions.OnlyOnFaulted);
    476     }
    477 
    478     private void UpdateSchedule() {
    479       HiveAdminClient.Instance.RefreshCalendar();
    480       scheduleView.Invoke(new Action(() => {
    481         scheduleView.Content = HiveAdminClient.Instance.Downtimes;
    482         SetEnabledStateOfControls();
    483       }));
    484     }
    485 
    486     private void UpdateScheduleAsync() {
    487       TS.Task.Factory.StartNew(UpdateSchedule).ContinueWith((t) => {
    488         DisplayError(t.Exception);
    489       }, TaskContinuationOptions.OnlyOnFaulted);
    490     }
    491 
    492     private void UpdatePermissions() {
    493       if (permissionView.Content != null && permissionView.FetchSelectedUsers != null)
    494         permissionView.Invoke(new Action(() => permissionView.ManualRefresh()));
    495     }
    496 
    497     private void UpdatePermissionsAsync() {
    498       TS.Task.Factory.StartNew(UpdatePermissions).ContinueWith((t) => {
    499         DisplayError(t.Exception);
    500       }, TaskContinuationOptions.OnlyOnFaulted);
    501     }
    502 
    503 
    504     private void DisplayError(Exception ex) {
    505       MessageBox.Show(string.Format("An error occured while updating: {0} {1}", Environment.NewLine, ex.Message), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    506     }
    507 
    508     private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) {
    509       if (tabSlaveGroup.SelectedIndex == 1) {
    510         UpdateScheduleAsync();
    511       } else if (tabSlaveGroup.SelectedIndex == 2) {
    512         UpdatePermissionsAsync();
    513       }
    514     }
    515 
    516     private void btnRefresh_Click(object sender, EventArgs e) {
    517       UpdateResourcesAsync();
    518     }
    519 
    520     private void ResourcesView_Load(object sender, EventArgs e) {
    521       UpdateResourcesAsync();
    522     }
    523 
    524     private void btnPermissionsSave_Click(object sender, EventArgs e) {
    525       SetEnabledStateOfControls();
    526       HiveServiceLocator.Instance.CallHiveService(service => {
    527         service.GrantResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetAddedUsers().Select(x => x.Id).ToList());
    528         service.RevokeResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetDeletedUsers().Select(x => x.Id).ToList());
    529       });
    530       SetEnabledStateOfControls();
    531     }
     491    #endregion
    532492  }
    533493}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj

    r14125 r15401  
    159159  </ItemGroup>
    160160  <ItemGroup>
     161    <ProjectReference Include="..\..\HeuristicLab.Clients.Access\3.3\HeuristicLab.Clients.Access-3.3.csproj">
     162      <Project>{494f87f4-0f25-4d33-a382-10cdb2174d48}</Project>
     163      <Name>HeuristicLab.Clients.Access-3.3</Name>
     164      <Private>False</Private>
     165    </ProjectReference>
    161166    <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Views\3.3\HeuristicLab.Clients.Hive.Views-3.3.csproj">
    162167      <Project>{E1D6C801-892A-406A-B606-F158E36DD3C3}</Project>
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/JobManagerMenuItem.cs

    r14185 r15401  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Windows.Forms;
     25using HeuristicLab.Clients.Access;
    2426using HeuristicLab.MainForm;
    2527using HeuristicLab.Optimizer;
    2628
    2729namespace HeuristicLab.Clients.Hive.JobManager {
    28   public class JobManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     30  public class JobManagerMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2931    public override string Name {
    3032      get { return "&Job Manager"; }
    3133    }
     34
    3235    public override IEnumerable<string> Structure {
    3336      get { return new string[] { "&Services", "&Hive" }; }
    3437    }
     38
    3539    public override void Execute() {
    36       MainFormManager.MainForm.ShowContent(HiveClient.Instance);
     40      if (HiveRoles.CheckHiveUserPermissions()) {
     41        MainFormManager.MainForm.ShowContent(HiveClient.Instance);
     42      } else if (!UserInformation.Instance.UserExists) {
     43        MessageBox.Show(
     44          "Couldn't fetch user information from the server." + Environment.NewLine +
     45          "Please verify that you have an existing user and that your user name and password is correct.",
     46          "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     47      } else {
     48        MessageBox.Show(
     49          "You do not seem to have the permissions to use the Hive Job Manager." + Environment.NewLine +
     50          "If that's not the case or you have any questions please write an email to support@heuristiclab.com",
     51          "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     52      }
    3753    }
     54
    3855    public override int Position {
    3956      get { return 10000; }
    4057    }
     58
    4159    public override Keys ShortCutKeys {
    4260      get { return Keys.Control | Keys.H; }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs

    r14185 r15401  
    2121
    2222namespace HeuristicLab.Clients.Hive.JobManager.Views {
    23   partial class HiveResourceSelector {
     23  partial class HiveProjectSelector {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveResourceSelector));
    4948      this.resourcesGroupBox = new System.Windows.Forms.GroupBox();
    5049      this.splitContainer = new System.Windows.Forms.SplitContainer();
     
    7170      this.resourcesGroupBox.TabIndex = 0;
    7271      this.resourcesGroupBox.TabStop = false;
    73       this.resourcesGroupBox.Text = "Available Resources";
     72      this.resourcesGroupBox.Text = "Available Projects";
    7473      //
    7574      // splitContainer
     
    9594      // resourcesTreeView
    9695      //
    97       this.resourcesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    98             | System.Windows.Forms.AnchorStyles.Left)
     96      this.resourcesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     97            | System.Windows.Forms.AnchorStyles.Left) 
    9998            | System.Windows.Forms.AnchorStyles.Right)));
    10099      this.resourcesTreeView.CheckBoxes = true;
     
    128127      // searchTextBox
    129128      //
    130       this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     129      this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    131130            | System.Windows.Forms.AnchorStyles.Right)));
    132131      this.searchTextBox.Location = new System.Drawing.Point(29, 3);
     
    139138      // descriptionTextBox
    140139      //
    141       this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    142             | System.Windows.Forms.AnchorStyles.Left)
     140      this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     141            | System.Windows.Forms.AnchorStyles.Left) 
    143142            | System.Windows.Forms.AnchorStyles.Right)));
    144143      this.descriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F);
     
    154153      // HiveResourceSelector
    155154      //
    156       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    157155      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    158156      this.Controls.Add(this.resourcesGroupBox);
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r14185 r15401  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using System.Drawing;
    2525using System.Linq;
    26 using System.Text;
    2726using System.Windows.Forms;
    28 using HeuristicLab.Clients.Hive.JobManager.ExtensionMethods;
    2927using HeuristicLab.Core;
    3028using HeuristicLab.Core.Views;
     
    3331
    3432namespace HeuristicLab.Clients.Hive.JobManager.Views {
    35   [View("Hive Resource Selector View")]
    36   [Content(typeof(IItemList<Resource>), true)]
    37   public partial class HiveResourceSelector : ItemView, IDisposable {
    38     private const int slaveImageIndex = 0;
    39     private const int slaveGroupImageIndex = 1;
     33  [View("Hive Project Selector View")]
     34  [Content(typeof(IItemList<Project>), true)]
     35  public partial class HiveProjectSelector : ItemView, IDisposable {
     36    private const int greenFlagImageIndex = 0;
     37    private const int redFlagImageIndex = 1;
    4038    private string currentSearchString;
    4139    private ISet<TreeNode> mainTreeNodes;
    4240    private ISet<TreeNode> filteredTreeNodes;
    4341    private ISet<TreeNode> nodeStore;
    44    
    45     private ISet<Resource> selectedResources;
    46     public ISet<Resource> SelectedResources {
     42
     43    private ISet<Project> selectedResources;
     44    public ISet<Project> SelectedResources {
    4745      get { return selectedResources; }
    4846      set { selectedResources = value; }
    4947    }
    5048
    51     public new IItemList<Resource> Content {
    52       get { return (IItemList<Resource>)base.Content; }
     49    public Project SelectedProject {
     50      get { return (Project)resourcesTreeView.SelectedNode.Tag; }
     51    }
     52
     53    public new IItemList<Project> Content {
     54      get { return (IItemList<Project>)base.Content; }
    5355      set { base.Content = value; }
    5456    }
    5557
    56     public HiveResourceSelector() {
     58    public HiveProjectSelector() {
    5759      InitializeComponent();
    5860      mainTreeNodes = new HashSet<TreeNode>();
    5961      filteredTreeNodes = new HashSet<TreeNode>();
    6062      nodeStore = new HashSet<TreeNode>();
    61       selectedResources = new HashSet<Resource>();
    62       imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    63       imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
    64     }
    65  
     63      selectedResources = new HashSet<Project>();
     64      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.FlagGreen);
     65      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.FlagRed);
     66    }
     67
    6668    public void StartProgressView() {
    6769      if (InvokeRequired) {
    6870        Invoke(new Action(StartProgressView));
    6971      } else {
    70         var message = "Downloading resources. Please be patient.";
     72        var message = "Downloading projects. Please be patient.";
    7173        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    7274      }
     
    8587
    8688      if (Content != null) {
    87         selectedResources = new HashSet<Resource>(Content.Where(x => selectedResources.Any(y => x.Id == y.Id)));
     89        selectedResources = new HashSet<Project>(Content.Where(x => selectedResources.Any(y => x.Id == y.Id)));
    8890        UpdateMainTree();
    8991        ExtractStatistics();
     
    98100      mainTreeNodes.Clear();
    99101
    100       foreach (Resource g in Content) {
    101         if (g.GetType() == typeof(SlaveGroup)) {
    102           //root node
    103           if (g.ParentResourceId == null) {
    104             TreeNode tn = new TreeNode();
    105             tn.ImageIndex = slaveGroupImageIndex;
    106             tn.SelectedImageIndex = tn.ImageIndex;
    107 
    108             tn.Tag = g;
    109             tn.Text = g.Name;
    110             tn.Checked = selectedResources.Any(x => x.Id == g.Id);
    111 
    112             BuildMainTree(tn);
    113             mainTreeNodes.Add(tn);
    114           }
     102      foreach (Project g in Content.OrderBy(x => x.Name)) {
     103        //root node
     104        if (g.ParentProjectId == null) {
     105          TreeNode tn = new TreeNode();
     106          tn.ImageIndex = greenFlagImageIndex;
     107          tn.SelectedImageIndex = tn.ImageIndex;
     108
     109          tn.Tag = g;
     110          tn.Text = g.Name;
     111          tn.Checked = selectedResources.Any(x => x.Id == g.Id);
     112
     113          BuildMainTree(tn);
     114          mainTreeNodes.Add(tn);
    115115        }
    116116      }
     
    119119
    120120    private void BuildMainTree(TreeNode tn) {
    121       foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == ((Resource)tn.Tag).Id)) {
     121      foreach (Project r in Content.Where(s => s.ParentProjectId != null && s.ParentProjectId == ((Project)tn.Tag).Id).OrderBy(x => x.Name)) {
    122122        TreeNode stn = new TreeNode(r.Name);
    123         if (r is Slave) stn.ImageIndex = slaveImageIndex;
    124         else if (r is SlaveGroup) stn.ImageIndex = slaveGroupImageIndex;
     123        stn.ImageIndex = redFlagImageIndex;
    125124        stn.SelectedImageIndex = stn.ImageIndex;
    126125        stn.Tag = r;
     
    139138      foreach (TreeNode n in mainTreeNodes) {
    140139        n.BackColor = SystemColors.Window;
    141         if (currentSearchString == null || ((Resource)n.Tag).Name.ToLower().Contains(currentSearchString)) {
     140        if (currentSearchString == null || ((Project)n.Tag).Name.ToLower().Contains(currentSearchString)) {
    142141          n.BackColor = string.IsNullOrEmpty(currentSearchString) ? SystemColors.Window : Color.LightBlue;
    143142          filteredTreeNodes.Add(n);
     
    162161
    163162      foreach (TreeNode node in filteredTreeNodes) {
    164         var clone = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
     163        var clone = nodeStore.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)node.Tag).Id);
    165164        if (clone == null) {
    166165          clone = (TreeNode)node.Clone();
     
    169168        }
    170169        foreach (TreeNode child in node.Nodes)
    171           if (filteredTreeNodes.Any(x => ((Resource)x.Tag).Id == ((Resource)child.Tag).Id)) {
    172             var childClone = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)child.Tag).Id);
     170          if (filteredTreeNodes.Any(x => ((Project)x.Tag).Id == ((Project)child.Tag).Id)) {
     171            var childClone = nodeStore.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)child.Tag).Id);
    173172            if (childClone == null) {
    174173              childClone = (TreeNode)child.Clone();
     
    179178          }
    180179      }
    181       resourcesTreeView.Nodes.AddRange(nodeStore.Where(x => ((Resource)x.Tag).ParentResourceId == null).ToArray());
     180      resourcesTreeView.Nodes.AddRange(nodeStore.Where(x => ((Project)x.Tag).ParentProjectId == null).ToArray());
    182181      if (string.IsNullOrEmpty(currentSearchString)) ExpandSlaveGroupNodes();
    183182      else resourcesTreeView.ExpandAll();
     
    187186    #region Events
    188187    private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
    189       if (e.Action != TreeViewAction.Unknown) {
    190         if (e.Node.Checked) {
    191           IncludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    192           IncludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    193         } else {
    194           ExcludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    195           ExcludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    196         }
    197         ExtractStatistics();
    198       }
     188      //if (e.Action != TreeViewAction.Unknown) {
     189      //  if (e.Node.Checked) {
     190      //    IncludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id));
     191      //    IncludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id));
     192      //  } else {
     193      //    ExcludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id));
     194      //    ExcludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id));
     195      //  }
     196      //  ExtractStatistics();
     197      //}
    199198    }
    200199
     
    212211
    213212    #region Helpers
    214     private void IncludeChildNodes(TreeNode node) {
    215       if (node != null) {
    216         node.Checked = true;
    217         selectedResources.Add((Resource)node.Tag);
    218         AdjustNodeCheckedState(node);
    219         foreach (TreeNode n in node.Nodes) IncludeChildNodes(n);
    220       }
    221     }
    222 
    223     private void IncludeParentNodes(TreeNode node) {
    224       if (node != null && node.Parent != null) {
    225         TreeNode parent = node.Parent;
    226         if (parent.Nodes.OfType<TreeNode>().All(x => x.Checked)) {
    227           parent.Checked = true;
    228           selectedResources.Add((Resource)parent.Tag);
    229           AdjustNodeCheckedState(parent);
    230           IncludeParentNodes(parent);
    231         }
    232       }
    233     }
    234 
    235     private void ExcludeChildNodes(TreeNode node) {
    236       if (node != null) {
    237         node.Checked = false;
    238         selectedResources.Remove((Resource)node.Tag);
    239         AdjustNodeCheckedState(node);
    240         foreach (TreeNode n in node.Nodes) ExcludeChildNodes(n);
    241       }
    242     }
    243 
    244     private void ExcludeParentNodes(TreeNode node) {
    245       if (node != null) {
    246         node.Checked = false;
    247         selectedResources.Remove((Resource)node.Tag);
    248         AdjustNodeCheckedState(node);
    249         ExcludeParentNodes(node.Parent);
    250       }
    251     }
    252 
    253     private void AdjustNodeCheckedState(TreeNode node) {
    254       var filterdNode = filteredTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
    255       var storedNode = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
    256       if (filterdNode != null) filterdNode.Checked = node.Checked;
    257       if (storedNode != null) storedNode.Checked = node.Checked;
    258     }
    259 
    260213    private void ExpandSlaveGroupNodes() {
    261214      foreach (TreeNode n in nodeStore.Where(x => x.Tag is SlaveGroup)) {
     
    267220
    268221    private void ExtractStatistics(TreeNode treeNode = null) {
    269       StringBuilder sb = new StringBuilder();
    270       Resource resource = treeNode == null ? null : treeNode.Tag as Resource;
    271       ISet<Resource> resources = treeNode == null ? selectedResources : new HashSet<Resource>(treeNode.DescendantNodes().Select(x => x.Tag as Resource)); ;
    272       IEnumerable<SlaveGroup> slaveGroups = resources.OfType<SlaveGroup>();
    273       IEnumerable<Slave> slaves = resources.OfType<Slave>();
    274       int cpuSpeed = 0, cores = 0, freeCores = 0, memory = 0, freeMemory = 0;
    275       string contextString = treeNode == null ? "Selected" : "Included";
    276 
    277       if (resources.Any() || resource != null) {
    278         foreach (Slave s in slaves) {
    279           cpuSpeed += s.CpuSpeed.GetValueOrDefault();
    280           cores += s.Cores.GetValueOrDefault();
    281           freeCores += s.FreeCores.GetValueOrDefault();
    282           memory += s.Memory.GetValueOrDefault();
    283           freeMemory += s.FreeMemory.GetValueOrDefault();
    284         }
    285         if (resource != null) {
    286           if (resource is SlaveGroup) sb.Append("Slave group: ");
    287           else if (resource is Slave) {
    288             sb.Append("Slave: ");
    289             if (!resources.Any()) {
    290               Slave s = resource as Slave;
    291               cpuSpeed = s.CpuSpeed.GetValueOrDefault();
    292               cores = s.Cores.GetValueOrDefault();
    293               freeCores = s.FreeCores.GetValueOrDefault();
    294               memory = s.Memory.GetValueOrDefault();
    295               freeMemory = s.FreeMemory.GetValueOrDefault();
    296             }
    297           }
    298           sb.AppendLine(string.Format("{0}", resource.Name));
    299         }
    300         if (resource == null || resource is SlaveGroup) {
    301           if (resources.Any()) {
    302             sb.AppendFormat("{0} slave groups ({1}): ", contextString, slaveGroups.Count());
    303             foreach (SlaveGroup sg in slaveGroups) sb.AppendFormat("{0}; ", sg.Name);
    304             sb.AppendLine();
    305             sb.AppendFormat("{0} slaves ({1}): ", contextString, slaves.Count());
    306             foreach (Slave s in slaves) sb.AppendFormat("{0}; ", s.Name);
    307             sb.AppendLine();
    308           } else {
    309             sb.Append("The selection does not inlcude any further resources.");
    310           }
    311         }
    312         sb.AppendLine();
    313         sb.AppendLine(string.Format("CPU speed: {0} MHz", cpuSpeed));
    314         if (resources.Any()) sb.AppendLine(string.Format("Avg. CPU speed: {0:0.00} MHz", (double)cpuSpeed / resources.Count()));
    315         sb.AppendLine(string.Format("Cores: {0}", cores));
    316         sb.AppendLine(string.Format("Free cores: {0}", freeCores));
    317         if (resources.Any()) sb.AppendLine(string.Format("Avg. free cores: {0:0.00}", (double)freeCores / resources.Count()));
    318         sb.AppendLine(string.Format("Memory: {0} MB", memory));
    319         sb.AppendFormat("Free memory: {0} MB", freeMemory);
    320         if (resources.Any()) sb.Append(string.Format("{0}Avg. free memory: {1:0.00} MB", Environment.NewLine, (double)freeMemory / resources.Count()));
    321       } else {
    322         sb.Append("No resources selected.");
    323       }
    324 
    325       descriptionTextBox.Text = sb.ToString();
     222      //StringBuilder sb = new StringBuilder();
     223      //Resource resource = treeNode == null ? null : treeNode.Tag as Resource;
     224      //ISet<Resource> resources = treeNode == null ? selectedResources : new HashSet<Resource>(treeNode.DescendantNodes().Select(x => x.Tag as Resource)); ;
     225      //IEnumerable<SlaveGroup> slaveGroups = resources.OfType<SlaveGroup>();
     226      //IEnumerable<Slave> slaves = resources.OfType<Slave>();
     227      //int cpuSpeed = 0, cores = 0, freeCores = 0, memory = 0, freeMemory = 0;
     228      //string contextString = treeNode == null ? "Selected" : "Included";
     229
     230      //if (resources.Any() || resource != null) {
     231      //  foreach (Slave s in slaves) {
     232      //    cpuSpeed += s.CpuSpeed.GetValueOrDefault();
     233      //    cores += s.Cores.GetValueOrDefault();
     234      //    freeCores += s.FreeCores.GetValueOrDefault();
     235      //    memory += s.Memory.GetValueOrDefault();
     236      //    freeMemory += s.FreeMemory.GetValueOrDefault();
     237      //  }
     238      //  if (resource != null) {
     239      //    if (resource is SlaveGroup) sb.Append("Slave group: ");
     240      //    else if (resource is Slave) {
     241      //      sb.Append("Slave: ");
     242      //      if (!resources.Any()) {
     243      //        Slave s = resource as Slave;
     244      //        cpuSpeed = s.CpuSpeed.GetValueOrDefault();
     245      //        cores = s.Cores.GetValueOrDefault();
     246      //        freeCores = s.FreeCores.GetValueOrDefault();
     247      //        memory = s.Memory.GetValueOrDefault();
     248      //        freeMemory = s.FreeMemory.GetValueOrDefault();
     249      //      }
     250      //    }
     251      //    sb.AppendLine(string.Format("{0}", resource.Name));
     252      //  }
     253      //  if (resource == null || resource is SlaveGroup) {
     254      //    if (resources.Any()) {
     255      //      sb.AppendFormat("{0} slave groups ({1}): ", contextString, slaveGroups.Count());
     256      //      foreach (SlaveGroup sg in slaveGroups) sb.AppendFormat("{0}; ", sg.Name);
     257      //      sb.AppendLine();
     258      //      sb.AppendFormat("{0} slaves ({1}): ", contextString, slaves.Count());
     259      //      foreach (Slave s in slaves) sb.AppendFormat("{0}; ", s.Name);
     260      //      sb.AppendLine();
     261      //    } else {
     262      //      sb.Append("The selection does not inlcude any further resources.");
     263      //    }
     264      //  }
     265      //  sb.AppendLine();
     266      //  sb.AppendLine(string.Format("CPU speed: {0} MHz", cpuSpeed));
     267      //  if (resources.Any()) sb.AppendLine(string.Format("Avg. CPU speed: {0:0.00} MHz", (double)cpuSpeed / resources.Count()));
     268      //  sb.AppendLine(string.Format("Cores: {0}", cores));
     269      //  sb.AppendLine(string.Format("Free cores: {0}", freeCores));
     270      //  if (resources.Any()) sb.AppendLine(string.Format("Avg. free cores: {0:0.00}", (double)freeCores / resources.Count()));
     271      //  sb.AppendLine(string.Format("Memory: {0} MB", memory));
     272      //  sb.AppendFormat("Free memory: {0} MB", freeMemory);
     273      //  if (resources.Any()) sb.Append(string.Format("{0}Avg. free memory: {1:0.00} MB", Environment.NewLine, (double)freeMemory / resources.Count()));
     274      //} else {
     275      //  sb.Append("No resources selected.");
     276      //}
     277
     278      //descriptionTextBox.Text = sb.ToString();
    326279    }
    327280    #endregion
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs

    r14185 r15401  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveResourceSelectorDialog));
    4847      this.okButton = new System.Windows.Forms.Button();
    4948      this.cancelButton = new System.Windows.Forms.Button();
    5049      this.refreshButton = new System.Windows.Forms.Button();
    51       this.hiveResourceSelector = new HeuristicLab.Clients.Hive.JobManager.Views.HiveResourceSelector();
     50      this.hiveResourceSelector = new HeuristicLab.Clients.Hive.JobManager.Views.HiveProjectSelector();
    5251      this.SuspendLayout();
    5352      //
     
    8786      // hiveResourceSelector
    8887      //
    89       this.hiveResourceSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    90             | System.Windows.Forms.AnchorStyles.Left)
     88      this.hiveResourceSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     89            | System.Windows.Forms.AnchorStyles.Left) 
    9190            | System.Windows.Forms.AnchorStyles.Right)));
    9291      this.hiveResourceSelector.Caption = "View";
     
    101100      //
    102101      this.AcceptButton = this.okButton;
    103       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    104102      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    105103      this.CancelButton = this.cancelButton;
     
    115113      this.ShowInTaskbar = false;
    116114      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    117       this.Text = "Select Resources";
     115      this.Text = "Select Project";
    118116      this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiveResourceSelectorDialog_FormClosing);
    119117      this.Load += new System.EventHandler(this.HiveResourceSelectorDialog_Load);
     
    126124    protected System.Windows.Forms.Button okButton;
    127125    protected System.Windows.Forms.Button cancelButton;
    128     protected HiveResourceSelector hiveResourceSelector;
     126    protected HiveProjectSelector hiveResourceSelector;
    129127    protected System.Windows.Forms.Button refreshButton;
    130128  }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs

    r14185 r15401  
    3131    }
    3232
    33     public ISet<Resource> GetSelectedResources() { return hiveResourceSelector.SelectedResources; }
     33    public ISet<Project> GetSelectedResources() { return hiveResourceSelector.SelectedResources; }
     34    public Project SelectedProject { get { return hiveResourceSelector.SelectedProject; } }
    3435
    3536    private void HiveResourceSelectorDialog_Load(object sender, System.EventArgs e) {
     
    4344
    4445    void Instance_Refreshed(object sender, System.EventArgs e) {
    45       hiveResourceSelector.Content = HiveAdminClient.Instance.Resources;
     46      hiveResourceSelector.Content = HiveAdminClient.Instance.Projects;
    4647    }
    4748
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r14901 r15401  
    130130          nameTextBox.Text = Content.Job.Name;
    131131          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    132           resourceNamesTextBox.Text = Content.Job.ResourceNames;
     132          //resourceNamesTextBox.Text = Content.Job.ResourceNames;
    133133          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    134134          logView.Content = Content.Log;
     
    337337      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    338338        StringBuilder sb = new StringBuilder();
    339         foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) {
    340           sb.Append(resource.Name);
    341           sb.Append(";");
    342         }
    343         resourceNamesTextBox.Text = sb.ToString();
    344         if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
    345           Content.Job.ResourceNames = resourceNamesTextBox.Text;
     339        //foreach (Project resource in hiveResourceSelectorDialog.GetSelectedResources()) {
     340        //  sb.Append(resource.Name);
     341        //  sb.Append(";");
     342        //}
     343        //resourceNamesTextBox.Text = sb.ToString();
     344        //if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
     345        //  Content.Job.ResourceNames = resourceNamesTextBox.Text;
     346        var selectedProject = hiveResourceSelectorDialog.SelectedProject;
     347        resourceNamesTextBox.Text = selectedProject.Name;
     348        if (Content.Job.ProjectId != selectedProject.Id)
     349          Content.Job.ProjectId = selectedProject.Id;
    346350      }
    347351    }
     
    404408
    405409    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
    406       if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
    407         Content.Job.ResourceNames = resourceNamesTextBox.Text;
     410      //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
     411      //  Content.Job.ResourceNames = resourceNamesTextBox.Text;
    408412    }
    409413
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj

    r14738 r15401  
    125125    <Compile Include="HiveAdminClient.cs" />
    126126    <Compile Include="HiveClient.cs" />
     127    <Compile Include="ServiceClients\Project.cs" />
    127128    <Compile Include="ServiceClients\UserPriority.cs" />
    128129    <Compile Include="ServiceClients\ResourcePermission.cs" />
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r14185 r15401  
    5757    }
    5858
     59    private IItemList<Project> projects;
     60    public IItemList<Project> Projects {
     61      get { return projects; }
     62    }
     63
    5964    #region Events
    6065    public event EventHandler Refreshing;
     
    7883      try {
    7984        resources = new ItemList<Resource>();
     85        projects = new ItemList<Project>();
    8086
    8187        HiveServiceLocator.Instance.CallHiveService(service => {
    8288          service.GetSlaveGroups().ForEach(g => resources.Add(g));
    8389          service.GetSlaves().ForEach(s => resources.Add(s));
     90          service.GetProjects().ForEach(p => projects.Add(p));
    8491        });
    8592      }
     
    127134          item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddDowntime((Downtime)item));
    128135        }
     136        if (item is Project) {
     137          item.Id = HiveServiceLocator.Instance.CallHiveService(s => s.AddProject((Project)item));
     138        }
    129139      } else {
    130140        if (item is SlaveGroup) {
     
    136146        if (item is Downtime) {
    137147          HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));
     148        }
     149        if (item is Project) {
     150          HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateProject((Project)item));
    138151        }
    139152      }
     
    149162      } else if (item is Downtime) {
    150163        HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));
     164      } else if (item is Project) {
     165        HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteProject(item.Id));
    151166      }
    152167    }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r14901 r15401  
    140140          HiveServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.JobId, hep.GrantedUserId, hep.Permission));
    141141        }
     142        if (item is Project) {
     143          HiveServiceLocator.Instance.CallHiveService(s => s.AddProject((Project)item));
     144        }
    142145      } else {
    143146        if (item is Job)
    144147          HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
     148        if (item is Project)
     149          HiveServiceLocator.Instance.CallHiveService(s => s.UpdateProject((Project)item));
    145150      }
    146151    }
     
    250255        refreshableJob.IsProgressing = true;
    251256        refreshableJob.Progress.Start("Connecting to server...");
    252         IEnumerable<string> resourceNames = ToResourceNameList(refreshableJob.Job.ResourceNames);
     257        IEnumerable<string> resourceNames = ToResourceNameList("");
    253258        var resourceIds = new List<Guid>();
    254259        foreach (var resourceName in resourceNames) {
     
    372377              hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));
    373378            } else {
    374               hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList()));
     379              hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData));
    375380            }
    376381          }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r14738 r15401  
    2626    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.SlaveGroup))]
    2727    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Plugin))]
     28    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Project))]
    2829    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.JobPermission))]
    2930    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))]
    30     [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.ResourcePermission))]
     31    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.ProjectPermission))]
    3132    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))]
    3233    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.UserPriority))]
     
    211212    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.SlaveGroup))]
    212213    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Plugin))]
     214    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Project))]
    213215    public partial class NamedHiveItem : HeuristicLab.Clients.Hive.HiveItem
    214216    {
     
    284286       
    285287        [System.Runtime.Serialization.OptionalFieldAttribute()]
    286         private string ResourceNamesField;
     288        private System.Guid ProjectIdField;
    287289       
    288290        [System.Runtime.Serialization.DataMemberAttribute()]
     
    406408       
    407409        [System.Runtime.Serialization.DataMemberAttribute()]
    408         public string ResourceNames
    409         {
    410             get
    411             {
    412                 return this.ResourceNamesField;
    413             }
    414             set
    415             {
    416                 if ((object.ReferenceEquals(this.ResourceNamesField, value) != true))
    417                 {
    418                     this.ResourceNamesField = value;
    419                     this.RaisePropertyChanged("ResourceNames");
     410        public System.Guid ProjectId
     411        {
     412            get
     413            {
     414                return this.ProjectIdField;
     415            }
     416            set
     417            {
     418                if ((this.ProjectIdField.Equals(value) != true))
     419                {
     420                    this.ProjectIdField = value;
     421                    this.RaisePropertyChanged("ProjectId");
    420422                }
    421423            }
     
    839841    [System.Diagnostics.DebuggerStepThroughAttribute()]
    840842    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     843    [System.Runtime.Serialization.DataContractAttribute(Name="Project", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     844    [System.SerializableAttribute()]
     845    public partial class Project : HeuristicLab.Clients.Hive.NamedHiveItem
     846    {
     847       
     848        [System.Runtime.Serialization.OptionalFieldAttribute()]
     849        private System.DateTime DateCreatedField;
     850       
     851        [System.Runtime.Serialization.OptionalFieldAttribute()]
     852        private System.Nullable<System.DateTime> EndDateField;
     853       
     854        [System.Runtime.Serialization.OptionalFieldAttribute()]
     855        private System.Guid OwnerUserIdField;
     856       
     857        [System.Runtime.Serialization.OptionalFieldAttribute()]
     858        private System.Nullable<System.Guid> ParentProjectIdField;
     859       
     860        [System.Runtime.Serialization.OptionalFieldAttribute()]
     861        private System.DateTime StartDateField;
     862       
     863        [System.Runtime.Serialization.DataMemberAttribute()]
     864        public System.DateTime DateCreated
     865        {
     866            get
     867            {
     868                return this.DateCreatedField;
     869            }
     870            set
     871            {
     872                if ((this.DateCreatedField.Equals(value) != true))
     873                {
     874                    this.DateCreatedField = value;
     875                    this.RaisePropertyChanged("DateCreated");
     876                }
     877            }
     878        }
     879       
     880        [System.Runtime.Serialization.DataMemberAttribute()]
     881        public System.Nullable<System.DateTime> EndDate
     882        {
     883            get
     884            {
     885                return this.EndDateField;
     886            }
     887            set
     888            {
     889                if ((this.EndDateField.Equals(value) != true))
     890                {
     891                    this.EndDateField = value;
     892                    this.RaisePropertyChanged("EndDate");
     893                }
     894            }
     895        }
     896       
     897        [System.Runtime.Serialization.DataMemberAttribute()]
     898        public System.Guid OwnerUserId
     899        {
     900            get
     901            {
     902                return this.OwnerUserIdField;
     903            }
     904            set
     905            {
     906                if ((this.OwnerUserIdField.Equals(value) != true))
     907                {
     908                    this.OwnerUserIdField = value;
     909                    this.RaisePropertyChanged("OwnerUserId");
     910                }
     911            }
     912        }
     913       
     914        [System.Runtime.Serialization.DataMemberAttribute()]
     915        public System.Nullable<System.Guid> ParentProjectId
     916        {
     917            get
     918            {
     919                return this.ParentProjectIdField;
     920            }
     921            set
     922            {
     923                if ((this.ParentProjectIdField.Equals(value) != true))
     924                {
     925                    this.ParentProjectIdField = value;
     926                    this.RaisePropertyChanged("ParentProjectId");
     927                }
     928            }
     929        }
     930       
     931        [System.Runtime.Serialization.DataMemberAttribute()]
     932        public System.DateTime StartDate
     933        {
     934            get
     935            {
     936                return this.StartDateField;
     937            }
     938            set
     939            {
     940                if ((this.StartDateField.Equals(value) != true))
     941                {
     942                    this.StartDateField = value;
     943                    this.RaisePropertyChanged("StartDate");
     944                }
     945            }
     946        }
     947    }
     948   
     949    [System.Diagnostics.DebuggerStepThroughAttribute()]
     950    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    841951    [System.Runtime.Serialization.DataContractAttribute(Name="JobPermission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    842952    [System.SerializableAttribute()]
     
    9951105    [System.Diagnostics.DebuggerStepThroughAttribute()]
    9961106    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    997     [System.Runtime.Serialization.DataContractAttribute(Name="ResourcePermission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
     1107    [System.Runtime.Serialization.DataContractAttribute(Name="ProjectPermission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")]
    9981108    [System.SerializableAttribute()]
    999     public partial class ResourcePermission : HeuristicLab.Clients.Hive.HiveItem
     1109    public partial class ProjectPermission : HeuristicLab.Clients.Hive.HiveItem
    10001110    {
    10011111       
     
    10071117       
    10081118        [System.Runtime.Serialization.OptionalFieldAttribute()]
    1009         private System.Guid ResourceIdField;
     1119        private System.Guid ProjectIdField;
    10101120       
    10111121        [System.Runtime.Serialization.DataMemberAttribute()]
     
    10441154       
    10451155        [System.Runtime.Serialization.DataMemberAttribute()]
    1046         public System.Guid ResourceId
    1047         {
    1048             get
    1049             {
    1050                 return this.ResourceIdField;
    1051             }
    1052             set
    1053             {
    1054                 if ((this.ResourceIdField.Equals(value) != true))
    1055                 {
    1056                     this.ResourceIdField = value;
    1057                     this.RaisePropertyChanged("ResourceId");
     1156        public System.Guid ProjectId
     1157        {
     1158            get
     1159            {
     1160                return this.ProjectIdField;
     1161            }
     1162            set
     1163            {
     1164                if ((this.ProjectIdField.Equals(value) != true))
     1165                {
     1166                    this.ProjectIdField = value;
     1167                    this.RaisePropertyChanged("ProjectId");
    10581168                }
    10591169            }
     
    21002210       
    21012211        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddTask", ReplyAction="http://tempuri.org/IHiveService/AddTaskResponse")]
    2102         System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds);
     2212        System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData);
    21032213       
    21042214        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddChildTask", ReplyAction="http://tempuri.org/IHiveService/AddChildTaskResponse")]
     
    21842294        System.Collections.Generic.List<HeuristicLab.Clients.Hive.PluginData> GetPluginDatas(System.Collections.Generic.List<System.Guid> pluginIds);
    21852295       
    2186         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GrantResourcePermissions", ReplyAction="http://tempuri.org/IHiveService/GrantResourcePermissionsResponse")]
    2187         void GrantResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds);
    2188        
    2189         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RevokeResourcePermissions", ReplyAction="http://tempuri.org/IHiveService/RevokeResourcePermissionsResponse")]
    2190         void RevokeResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds);
    2191        
    2192         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetResourcePermissions", ReplyAction="http://tempuri.org/IHiveService/GetResourcePermissionsResponse")]
    2193         System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetResourcePermissions(System.Guid resourceId);
     2296        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddProject", ReplyAction="http://tempuri.org/IHiveService/AddProjectResponse")]
     2297        System.Guid AddProject(HeuristicLab.Clients.Hive.Project projectDto);
     2298       
     2299        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateProject", ReplyAction="http://tempuri.org/IHiveService/UpdateProjectResponse")]
     2300        void UpdateProject(HeuristicLab.Clients.Hive.Project projectDto);
     2301       
     2302        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteProject", ReplyAction="http://tempuri.org/IHiveService/DeleteProjectResponse")]
     2303        void DeleteProject(System.Guid projectId);
     2304       
     2305        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProject", ReplyAction="http://tempuri.org/IHiveService/GetProjectResponse")]
     2306        HeuristicLab.Clients.Hive.Project GetProject(System.Guid projectId);
     2307       
     2308        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjects", ReplyAction="http://tempuri.org/IHiveService/GetProjectsResponse")]
     2309        System.Collections.Generic.List<HeuristicLab.Clients.Hive.Project> GetProjects();
     2310       
     2311        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GrantProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/GrantProjectPermissionsResponse")]
     2312        void GrantProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds);
     2313       
     2314        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RevokeProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/RevokeProjectPermissionsResponse")]
     2315        void RevokeProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds);
     2316       
     2317        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/GetProjectPermissionsResponse")]
     2318        System.Collections.Generic.List<HeuristicLab.Clients.Hive.ProjectPermission> GetProjectPermissions(System.Guid projectId);
    21942319       
    21952320        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddSlave", ReplyAction="http://tempuri.org/IHiveService/AddSlaveResponse")]
     
    22912416        }
    22922417       
    2293         public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds)
    2294         {
    2295             return base.Channel.AddTask(task, taskData, resourceIds);
     2418        public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData)
     2419        {
     2420            return base.Channel.AddTask(task, taskData);
    22962421        }
    22972422       
     
    24312556        }
    24322557       
    2433         public void GrantResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds)
    2434         {
    2435             base.Channel.GrantResourcePermissions(resourceId, grantedUserIds);
    2436         }
    2437        
    2438         public void RevokeResourcePermissions(System.Guid resourceId, System.Collections.Generic.List<System.Guid> grantedUserIds)
    2439         {
    2440             base.Channel.RevokeResourcePermissions(resourceId, grantedUserIds);
    2441         }
    2442        
    2443         public System.Collections.Generic.List<HeuristicLab.Clients.Hive.ResourcePermission> GetResourcePermissions(System.Guid resourceId)
    2444         {
    2445             return base.Channel.GetResourcePermissions(resourceId);
     2558        public System.Guid AddProject(HeuristicLab.Clients.Hive.Project projectDto)
     2559        {
     2560            return base.Channel.AddProject(projectDto);
     2561        }
     2562       
     2563        public void UpdateProject(HeuristicLab.Clients.Hive.Project projectDto)
     2564        {
     2565            base.Channel.UpdateProject(projectDto);
     2566        }
     2567       
     2568        public void DeleteProject(System.Guid projectId)
     2569        {
     2570            base.Channel.DeleteProject(projectId);
     2571        }
     2572       
     2573        public HeuristicLab.Clients.Hive.Project GetProject(System.Guid projectId)
     2574        {
     2575            return base.Channel.GetProject(projectId);
     2576        }
     2577       
     2578        public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Project> GetProjects()
     2579        {
     2580            return base.Channel.GetProjects();
     2581        }
     2582       
     2583        public void GrantProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds)
     2584        {
     2585            base.Channel.GrantProjectPermissions(projectId, grantedUserIds);
     2586        }
     2587       
     2588        public void RevokeProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds)
     2589        {
     2590            base.Channel.RevokeProjectPermissions(projectId, grantedUserIds);
     2591        }
     2592       
     2593        public System.Collections.Generic.List<HeuristicLab.Clients.Hive.ProjectPermission> GetProjectPermissions(System.Guid projectId)
     2594        {
     2595            return base.Channel.GetProjectPermissions(projectId);
    24462596        }
    24472597       
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/Job.cs

    r14185 r15401  
    2929    #region Constructors and Cloning
    3030    public Job() {
    31       ResourceNames = "HEAL";
     31      ProjectId = Guid.Empty;
    3232      DateCreated = DateTime.Now;
    3333      Permission = Permission.Full;
     
    3838      this.OwnerUserId = original.OwnerUserId;
    3939      this.DateCreated = original.DateCreated;
    40       this.ResourceNames = original.ResourceNames;
     40      this.ProjectId = original.ProjectId;
    4141      this.Name = original.Name;
    4242      this.Description = original.Description;
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/ResourcePermission.cs

    r14185 r15401  
    2424
    2525namespace HeuristicLab.Clients.Hive {
    26   public partial class ResourcePermission : IDeepCloneable, IContent {
     26  public partial class ProjectPermission : IDeepCloneable, IContent {
    2727
    2828    private string grantedUserName;
     
    4141    }
    4242
    43     public ResourcePermission() { }
     43    public ProjectPermission() { }
    4444
    4545    protected override void OnPropertyChanged(PropertyChangedEventArgs e) {
     
    5050    }
    5151
    52     protected ResourcePermission(ResourcePermission original, Cloner cloner)
     52    protected ProjectPermission(ProjectPermission original, Cloner cloner)
    5353      : base(original, cloner) {
    5454      this.GrantedByUserId = original.GrantedByUserId;
    5555      this.GrantedUserId = original.GrantedUserId;
    56       this.ResourceId = original.ResourceId;
     56      this.ProjectId = original.ProjectId;
    5757    }
    5858
    5959    public override IDeepCloneable Clone(Cloner cloner) {
    60       return new ResourcePermission(this, cloner);
     60      return new ProjectPermission(this, cloner);
    6161    }
    6262
  • branches/HiveProjectManagement/HeuristicLab.Optimizer/3.3/MenuItems/UsernamePasswordMenuItem.cs

    r14185 r15401  
    2222using System.Collections.Generic;
    2323using System.Windows.Forms;
     24using HeuristicLab.Clients.Access;
    2425using HeuristicLab.Clients.Common;
    2526using HeuristicLab.MainForm;
     
    4344      using (PasswordDialog dialog = new PasswordDialog()) {
    4445        dialog.ShowDialog((IWin32Window)MainFormManager.MainForm);
     46        UserInformation.Instance.Refresh();
    4547      }
    4648    }
Note: See TracChangeset for help on using the changeset viewer.