Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/JobItemView.cs @ 4368

Last change on this file since 4368 was 4368, checked in by cneumuel, 14 years ago
  • created HiveClient which shows an overview over all submitted HiveExperiments
  • its possible to download all submitted HiveExperiments including results
  • Experiments are now sent as a whole to the Hive and the Hive-Slaves take care of creating child-jobs (if necessary). The parent job is then paused and will be reactivated when all child-jobs are finished
  • WcfService-Clients are now consistently managed by WcfServicePool which allows to use IDisposable-Pattern and always keeps exactly one proxy-object until all callers disposed them.
  • created ProgressView which is able to lock a View and display progress of an action. It also allows to simulate progress if no progress-information is available so that users don't get too nervous while waiting.
File size: 4.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core.Views;
10using HeuristicLab.MainForm;
11using HeuristicLab.Hive.JobBase;
12using HeuristicLab.Persistence.Default.Xml;
13using System.IO;
14using HeuristicLab.Hive.Experiment.Jobs;
15
16namespace HeuristicLab.Hive.Experiment.Views {
17  [View("JobItem View")]
18  [Content(typeof(JobItem), true)]
19  public partial class JobItemView : ItemView {
20    public new JobItem Content {
21      get { return (JobItem)base.Content; }
22      set {
23        if (base.Content != value) {
24          base.Content = value;
25        }
26      }
27    }
28
29    public JobItemView() {
30      InitializeComponent();
31    }
32
33    protected override void OnContentChanged() {
34      base.OnContentChanged();
35      if (Content != null) {
36        Content_JobChanged(this, EventArgs.Empty);
37        Content_ChildJobAdded(this, EventArgs.Empty);
38      }
39    }
40
41    void Content_JobChanged(object sender, EventArgs e) {
42      if (Content.Job != null) {
43        logView.Content = Content.Job.Log;
44        Content_JobDtoChanged(this, EventArgs.Empty);
45        Content_JobStateChanged(this, EventArgs.Empty);
46      }
47    }
48
49    protected override void RegisterContentEvents() {
50      base.RegisterContentEvents();
51      Content.JobChanged += new EventHandler(Content_JobChanged);
52      Content.JobDtoChanged += new EventHandler(Content_JobDtoChanged);
53      Content.JobStateChanged += new EventHandler(Content_JobStateChanged);
54      Content.ChildJobAdded += new EventHandler(Content_ChildJobAdded);
55    }
56
57    protected override void DeregisterContentEvents() {
58      Content.JobChanged -= new EventHandler(Content_JobChanged);
59      Content.JobDtoChanged -= new EventHandler(Content_JobDtoChanged);
60      Content.JobStateChanged -= new EventHandler(Content_JobStateChanged);
61      Content.ChildJobAdded -= new EventHandler(Content_ChildJobAdded);
62      base.DeregisterContentEvents();
63    }
64
65    private void Content_JobDtoChanged(object sender, EventArgs e) {
66      if (InvokeRequired) {
67        Invoke(new EventHandler(Content_JobDtoChanged), sender, e);
68      } else {
69        this.jobIdTextBox.Text = Content.JobDto.Id.ToString();
70        this.dateCreatedTextBox.Text = Content.JobDto.DateCreated.ToString();
71        this.priorityTextBox.Text = Content.JobDto.Priority.ToString();
72        this.coresNeededTextBox.Text = Content.JobDto.CoresNeeded.ToString();
73        this.memoryNeededTextBox.Text = Content.JobDto.MemoryNeeded.ToString();
74        this.projectTextBox.Text = Content.JobDto.Project != null ? Content.JobDto.Project.Name : "-";
75      }
76    }
77
78    private void Content_JobStateChanged(object sender, EventArgs e) {
79      if (InvokeRequired) {
80        Invoke(new EventHandler(Content_JobStateChanged), sender, e);
81      } else {
82        this.stateTextBox.Text = Content.JobDto.State.ToString();
83        this.percentageTextBox.Text = (Content.JobDto.Percentage * 100).ToString() + "%";
84        this.percentageProgressBar.Value = Convert.ToInt32(Content.JobDto.Percentage * percentageProgressBar.Maximum);
85        this.dateCalculatedText.Text = Content.JobDto.DateCalculated.ToString();
86        this.dateFinishedTextBox.Text = Content.JobDto.DateFinished.ToString();
87        this.exceptionTextBox.Text = Content.JobDto.Exception;
88      }
89    }
90
91    void Content_ChildJobAdded(object sender, EventArgs e) {
92      if (InvokeRequired) {
93        Invoke(new EventHandler(Content_ChildJobAdded), sender, e);
94      } else {
95        childJobItemListView.Content = new JobItemList(Content.ChildJobItems);
96      }
97    }
98
99    protected override void SetEnabledStateOfControls() {
100      if (InvokeRequired) {
101        this.InvokeIfRequired(c => { SetEnabledStateOfControls(); });
102      } else {
103        base.SetEnabledStateOfControls();
104        this.jobIdTextBox.ReadOnly = this.ReadOnly;
105        this.stateTextBox.ReadOnly = this.ReadOnly;
106        this.userIdTextBox.ReadOnly = this.ReadOnly;
107        this.percentageTextBox.ReadOnly = this.ReadOnly;
108        this.dateCreatedTextBox.ReadOnly = this.ReadOnly;
109        this.dateCalculatedText.ReadOnly = this.ReadOnly;
110        this.dateFinishedTextBox.ReadOnly = this.ReadOnly;
111        this.priorityTextBox.ReadOnly = this.ReadOnly;
112        this.coresNeededTextBox.ReadOnly = this.ReadOnly;
113        this.memoryNeededTextBox.ReadOnly = this.ReadOnly;
114        this.exceptionTextBox.ReadOnly = this.ReadOnly;
115        this.projectTextBox.ReadOnly = this.ReadOnly;
116      }
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.