Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/03/18 15:06:21 (6 years ago)
Author:
jzenisek
Message:

#2839:

  • adapted job execution implementation at ProjectJobsView
  • prohibited resource checking for non-admins
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r16208 r16209  
    4444    private const string JOB_STATE = "State";
    4545    private const string JOB_EXECUTIONSTATE = "Execution State";
     46    private const string JOB_EXECUTIONTIME = "Execution Time";
    4647    private const string JOB_DESCRIPTION = "Description";
    4748    private const string JOB_TASKCOUNT = "Tasks";
     49    private const string JOB_WAITINGTASKCOUNT = "Waiting";
    4850    private const string JOB_CALCULATINGTASKCOUNT = "Calculating";
    4951    private const string JOB_FINISHEDTASKCOUNT = "Finished";
     
    112114        var jobs = GetSelectedJobs().ToList();
    113115        if (jobs.Any()) {
    114 
    115           // TODO: include isControllable?!
     116                   
    116117          startButton.Enabled = jobs.All(x =>
    117             !x.IsProgressing && x.HiveTasks != null && x.HiveTasks.Count > 0
    118             && x.Job.ProjectId != null && x.Job.ProjectId != Guid.Empty && x.Job.ResourceIds != null && x.Job.ResourceIds.Any()
     118            !x.IsProgressing && HiveAdminClient.Instance.Tasks.ContainsKey(x.Id) && HiveAdminClient.Instance.Tasks[x.Id].Count > 0
     119            && x.Job.ProjectId != Guid.Empty //&& x.Job.ResourceIds != null && x.Job.ResourceIds.Any()
    119120            && (x.ExecutionState == ExecutionState.Prepared || x.ExecutionState == ExecutionState.Paused));
    120121          pauseButton.Enabled = jobs.All(x => !x.IsProgressing && x.ExecutionState == ExecutionState.Started);
     
    138139
    139140    private void refreshButton_Click(object sender, EventArgs e) {
    140       var task = System.Threading.Tasks.Task.Factory.StartNew(RefreshJobsAsync);
    141141      progress.Start("Refreshing jobs...");
    142142      SetEnabledStateOfControls();
     143      var task = System.Threading.Tasks.Task.Factory.StartNew(RefreshJobsAsync);
    143144
    144145      task.ContinueWith((t) => {
    145         matrixView.DataGridView.ClearSelection();
     146        progress.Finish();       
     147        SetEnabledStateOfControls();
    146148      });
    147149    }
     
    157159          MessageBoxIcon.Question);
    158160
    159         if (result == DialogResult.Yes) {         
     161        if (result == DialogResult.Yes) {
     162          progress.Start("Removing job(s)...");
     163          SetEnabledStateOfControls();
    160164          var task = System.Threading.Tasks.Task.Factory.StartNew(RemoveJobsAsync, jobs);
    161           progress.Start();
    162           SetEnabledStateOfControls();
    163 
    164           task.ContinueWith((t) => {
    165             matrixView.DataGridView.ClearSelection();
    166             RefreshJobs();
    167             progress.Finish();
     165
     166          task.ContinueWith((t) => {
     167            RefreshJobs();
     168            progress.Finish();
     169            SetEnabledStateOfControls();
    168170          }, TaskContinuationOptions.NotOnFaulted);
    169171
    170172          task.ContinueWith((t) => {
    171             matrixView.DataGridView.ClearSelection();
    172             RefreshJobs();
    173             progress.Finish();
    174             MessageBox.Show("An error occured removing the job(s). " + t.Exception.Message, "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     173            RefreshJobs();
     174            progress.Finish();
     175            SetEnabledStateOfControls();
     176            MessageBox.Show("An error occured removing the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    175177          }, TaskContinuationOptions.OnlyOnFaulted);
    176178        }
     
    189191
    190192        if (result == DialogResult.Yes) {
     193          progress.Start("Resuming job(s)...");
     194          SetEnabledStateOfControls();
    191195          var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobsAsync, jobs);
    192           progress.Start();
    193           SetEnabledStateOfControls();
    194 
    195           task.ContinueWith((t) => {
    196             matrixView.DataGridView.ClearSelection();
    197             RefreshJobs();
    198             progress.Finish();
    199           });
    200 
    201           task.ContinueWith((t) => {
    202             matrixView.DataGridView.ClearSelection();
    203             RefreshJobs();
    204             progress.Finish();
     196
     197          task.ContinueWith((t) => {
     198            RefreshJobs();           
     199            progress.Finish();
     200            SetEnabledStateOfControls();
     201          }, TaskContinuationOptions.NotOnFaulted);
     202
     203          task.ContinueWith((t) => {
     204            RefreshJobs();
     205            progress.Finish();
     206            SetEnabledStateOfControls();
    205207            MessageBox.Show("An error occured resuming the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    206208          }, TaskContinuationOptions.OnlyOnFaulted);
     
    220222
    221223        if (result == DialogResult.Yes) {
     224          progress.Start("Pausing job(s)...");
     225          SetEnabledStateOfControls();
    222226          var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobsAsync, jobs);
    223           progress.Start();
    224           SetEnabledStateOfControls();
    225 
    226           task.ContinueWith((t) => {
    227             matrixView.DataGridView.ClearSelection();
    228             RefreshJobs();
    229             progress.Finish();
    230           });
    231 
    232           task.ContinueWith((t) => {
    233             matrixView.DataGridView.ClearSelection();
    234             RefreshJobs();
    235             progress.Finish();
     227
     228          task.ContinueWith((t) => {
     229            RefreshJobs();           
     230            progress.Finish();
     231            SetEnabledStateOfControls();
     232          }, TaskContinuationOptions.NotOnFaulted);
     233
     234          task.ContinueWith((t) => {
     235            RefreshJobs();
     236            progress.Finish();
     237            SetEnabledStateOfControls();
    236238            MessageBox.Show("An error occured pausing the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    237239          }, TaskContinuationOptions.OnlyOnFaulted);
     
    251253
    252254        if (result == DialogResult.Yes) {
     255          progress.Start("Stopping job(s)...");
     256          SetEnabledStateOfControls();
    253257          var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobsAsync, jobs);
    254           progress.Start();
    255           SetEnabledStateOfControls();
    256 
    257           task.ContinueWith((t) => {
    258             matrixView.DataGridView.ClearSelection();
    259             RefreshJobs();
    260             progress.Finish();
    261           });
    262 
    263           task.ContinueWith((t) => {
    264             matrixView.DataGridView.ClearSelection();
    265             RefreshJobs();
    266             progress.Finish();
     258
     259          task.ContinueWith((t) => {
     260            RefreshJobs();
     261            progress.Finish();
     262            SetEnabledStateOfControls();
     263          }, TaskContinuationOptions.NotOnFaulted);
     264
     265          task.ContinueWith((t) => {
     266            RefreshJobs();
     267            progress.Finish();
     268            SetEnabledStateOfControls();
    267269            MessageBox.Show("An error occured stopping the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);           
    268270          }, TaskContinuationOptions.OnlyOnFaulted);
     
    287289      foreach (DataGridViewRow r in matrixView.DataGridView.SelectedRows) {
    288290        if (((string)r.Cells[0].Value) == JobState.Online.ToString()) {
    289           jobs.Add(HiveAdminClient.Instance.Jobs[Content.Id].FirstOrDefault(x => x.Id == Guid.Parse((string) r.Cells[9].Value)));
     291          jobs.Add(HiveAdminClient.Instance.Jobs[Content.Id].FirstOrDefault(x => x.Id == Guid.Parse((string) r.Cells[11].Value)));
    290292        }
    291293      }
     
    306308      var jobs = HiveAdminClient.Instance.Jobs[Content.Id];
    307309      var resources = HiveAdminClient.Instance.Resources;
    308       string[,] values = new string[jobs.Count, 11];
     310      string[,] values = new string[jobs.Count, 13];
    309311
    310312      for(int i = 0; i < jobs.Count; i++) {
     
    312314        values[i, 0] = job.Job.State.ToString();
    313315        values[i, 1] = job.ExecutionState.ToString();
    314         values[i, 2] = job.Job.DateCreated.ToString();
    315         values[i, 3] = job.Job.OwnerUsername;
    316         values[i, 4] = job.Job.Name;
    317         values[i, 5] = job.Job.JobCount.ToString();
    318         values[i, 6] = job.Job.CalculatingCount.ToString();
    319         values[i, 7] = job.Job.FinishedCount.ToString();
    320         values[i, 8] = job.Job.Description;       
    321         values[i, 9] = job.Job.Id.ToString();
    322         values[i, 10] = job.Job.OwnerUserId.ToString();
     316        values[i, 2] = job.ExecutionTime.ToString();
     317        values[i, 3] = job.Job.DateCreated.ToString();
     318        values[i, 4] = job.Job.OwnerUsername;
     319        values[i, 5] = job.Job.Name;
     320        values[i, 6] = job.Job.JobCount.ToString();
     321        values[i, 7] = (job.Job.JobCount - job.Job.CalculatingCount - job.Job.FinishedCount).ToString();
     322        values[i, 8] = job.Job.CalculatingCount.ToString();
     323        values[i, 9] = job.Job.FinishedCount.ToString();
     324        values[i, 10] = job.Job.Description;       
     325        values[i, 11] = job.Job.Id.ToString();
     326        values[i, 12] = job.Job.OwnerUserId.ToString();
    323327      }
    324328     
    325329      var matrix = new StringMatrix(values);
    326       matrix.ColumnNames = new string[] { JOB_STATE, JOB_EXECUTIONSTATE, JOB_DATECREATED, JOB_OWNER, JOB_NAME, JOB_TASKCOUNT, JOB_CALCULATINGTASKCOUNT, JOB_FINISHEDTASKCOUNT, JOB_DESCRIPTION, JOB_ID, JOB_OWNERID };
     330      matrix.ColumnNames = new string[] { JOB_STATE, JOB_EXECUTIONSTATE, JOB_EXECUTIONTIME, JOB_DATECREATED, JOB_OWNER, JOB_NAME, JOB_TASKCOUNT, JOB_WAITINGTASKCOUNT, JOB_CALCULATINGTASKCOUNT, JOB_FINISHEDTASKCOUNT, JOB_DESCRIPTION, JOB_ID, JOB_OWNERID };
    327331      matrix.SortableView = true;
    328332      return matrix;
     
    356360
    357361    private void RefreshJobsAsync() {
    358       RefreshJobs();
     362      HiveAdminClient.Instance.RefreshJobs();
     363      UpdateJobs();
    359364    }
    360365
     
    387392      progress.Start();
    388393      foreach (var job in jobList) {
    389         progress.Status = "Deleting job \"" + job.Job.Name + "\"...";
     394        progress.Status = "Removing job \"" + job.Job.Name + "\"...";
    390395        HiveAdminClient.RemoveJob(job);
    391396      }
Note: See TracChangeset for help on using the changeset viewer.