Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/07/17 10:32:07 (7 years ago)
Author:
jkarder
Message:

#2839:

  • worked on resources and projects views
  • changed resource selector to be able to select projects and assigned resources
  • updated service clients
File:
1 edited

Legend:

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

    r15401 r15412  
    2525using System.Windows.Forms;
    2626using HeuristicLab.Clients.Access;
     27using HeuristicLab.Clients.Hive.Views;
    2728using HeuristicLab.Core.Views;
    2829using HeuristicLab.MainForm;
    29 using Tasks = System.Threading.Tasks;
    3030
    3131namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    4848    }
    4949
     50    #region Overrides
    5051    protected override void OnClosing(FormClosingEventArgs e) {
    5152      AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
     
    6263      Content.PropertyChanged -= Content_PropertyChanged;
    6364      base.DeregisterContentEvents();
    64     }
    65 
    66     private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    67       OnContentChanged();
    6865    }
    6966
     
    7370        nameTextBox.Clear();
    7471        descriptionTextBox.Clear();
    75         ownerComboBox.DataSource = null;
    7672        ownerComboBox.SelectedItem = null;
    7773        createdTextBox.Clear();
     
    8278        nameTextBox.Text = Content.Name;
    8379        descriptionTextBox.Text = Content.Description;
    84         ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
    8580        ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
    8681        createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss");
     
    9994      nameTextBox.Enabled = enabled;
    10095      descriptionTextBox.Enabled = enabled;
     96      refreshButton.Enabled = enabled;
    10197      ownerComboBox.Enabled = enabled;
    10298      createdTextBox.Enabled = enabled;
     
    104100      endDateTimePicker.Enabled = enabled && Content.EndDate.HasValue;
    105101      indefiniteCheckBox.Enabled = enabled;
     102    }
     103    #endregion
     104
     105    #region Event Handlers
     106    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     107      OnContentChanged();
    106108    }
    107109
     
    125127
    126128    private async void ProjectView_Load(object sender, EventArgs e) {
    127       lock (locker) {
    128         if (updatingUsers) return;
    129         updatingUsers = true;
    130       }
    131       try {
    132         await Tasks.Task.Run(() => UpdateUsers());
    133       } finally {
    134         updatingUsers = false;
    135       }
     129      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     130        action: () => UpdateUsers(),
     131        finallyCallback: () => {
     132          ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
     133          ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
     134          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
     135        });
    136136    }
    137137
     
    141141        updatingUsers = true;
    142142      }
    143       try {
    144         await Tasks.Task.Run(() => UpdateUsers());
    145       } finally {
    146         updatingUsers = false;
    147       }
    148     }
    149 
    150     private void UpdateUsers() {
    151       ownerComboBox.DataSource = null;
    152       AccessClient.Instance.Refresh();
    153       if (Content != null) {
    154         ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
    155         ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
    156       }
     143
     144      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     145        action: () => UpdateUsers(),
     146        finallyCallback: () => {
     147          ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;
     148          ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();
     149          ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
     150          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
     151          updatingUsers = false;
     152        });
    157153    }
    158154
     
    192188      Content.EndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;
    193189    }
     190    #endregion
     191
     192    #region Helpers
     193    private void UpdateUsers() {
     194      try {
     195        AccessClient.Instance.Refresh();
     196      } catch (AnonymousUserException) {
     197        ShowHiveInformationDialog();
     198      }
     199    }
     200
     201    private void ShowHiveInformationDialog() {
     202      if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog);
     203      else {
     204        using (HiveInformationDialog dialog = new HiveInformationDialog()) {
     205          dialog.ShowDialog(this);
     206        }
     207      }
     208    }
     209    #endregion
    194210  }
    195211}
Note: See TracChangeset for help on using the changeset viewer.