Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs @ 1595

Last change on this file since 1595 was 1595, checked in by aleitner, 15 years ago

bugfix on showing a client if changes on status and capacity (#585)

File size: 24.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Data;
26using System.Drawing;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30using HeuristicLab.Hive.Contracts.Interfaces;
31using HeuristicLab.Hive.Contracts.BusinessObjects;
32using HeuristicLab.Hive.Contracts;
33
34namespace HeuristicLab.Hive.Server.ServerConsole {
35
36  public delegate void closeForm(bool cf, bool error);
37
38  public partial class HiveServerManagementConsole : Form {
39
40    public event closeForm closeFormEvent;
41
42    #region private variables
43    private ResponseList<ClientGroup> clients = null;
44    private ResponseList<ClientInfo> clientInfo = null;
45    private ResponseList<Job> jobs = null;
46
47    private Dictionary<Guid, ListViewGroup> clientObjects;
48    private Dictionary<Guid, ListViewItem> clientInfoObjects;
49    private Dictionary<Guid, ListViewItem> jobObjects;
50
51    private Job currentJob = null;
52    private ClientInfo currentClient = null;
53    private string nameCurrentJob = "";
54    private string nameCurrentClient = "";
55    private bool flagJob = false;
56    private bool flagClient = false;
57
58    private List<Changes> changes = new List<Changes>();
59
60    private ToolTip tt = new ToolTip();
61    #endregion
62
63    public HiveServerManagementConsole() {
64      InitializeComponent();
65      AddClients();
66      AddJobs();
67      timerSyncronize.Start();
68    }
69
70
71    #region Backgroundworker
72    /// <summary>
73    /// event on Ticker
74    /// </summary>
75    /// <param name="obj"></param>
76    /// <param name="e"></param>
77    private void TickSync(object obj, EventArgs e) {
78      if (!updaterWoker.IsBusy) {
79        updaterWoker.RunWorkerAsync();
80      }
81    }
82
83    private void updaterWoker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
84      Refresh();
85    }
86
87    #endregion
88
89    /// <summary>
90    /// Adds clients to ListView and TreeView
91    /// </summary>
92    private void AddClients() {
93      try {
94        clientObjects = new Dictionary<Guid, ListViewGroup>();
95        clientInfoObjects = new Dictionary<Guid, ListViewItem>();
96        IClientManager clientManager =
97          ServiceLocator.GetClientManager();
98
99        clients = clientManager.GetAllClientGroups();
100        lvClientControl.Items.Clear();
101        List<Guid> inGroup = new List<Guid>();
102        foreach (ClientGroup cg in clients.List) {
103          ListViewGroup lvg = new ListViewGroup(cg.Name, HorizontalAlignment.Left);
104          foreach (ClientInfo ci in cg.Resources) {
105            ListViewItem item = null;
106            if ((ci.State == State.offline) || (ci.State == State.nullState)) {
107              item = new ListViewItem(ci.Name, 3, lvg);
108            } else {
109              int percentageUsage = CapacityRam(ci.NrOfCores, ci.NrOfFreeCores);
110              int usage = 0;
111              if ((percentageUsage >= 0) && (percentageUsage <= 25)) {
112                usage = 0;
113              } else if ((percentageUsage > 25) && (percentageUsage <= 75)) {
114                usage = 1;
115              } else if ((percentageUsage > 75) && (percentageUsage <= 100)) {
116                usage = 2;
117              }
118
119              item = new ListViewItem(ci.Name, usage, lvg);
120            }
121            item.Tag = ci.Id;
122            lvClientControl.Items.Add(item);
123            clientInfoObjects.Add(ci.Id, item);
124            inGroup.Add(ci.Id);
125
126          }
127          lvClientControl.BeginUpdate();
128          lvClientControl.Groups.Add(lvg);
129          lvClientControl.EndUpdate();
130          clientObjects.Add(cg.Id, lvg);
131        } // Groups
132
133        clientInfo = clientManager.GetAllClients();
134        ListViewGroup lvunsorted = new ListViewGroup("no group", HorizontalAlignment.Left);
135        foreach (ClientInfo ci in clientInfo.List) {
136          bool help = false;
137          foreach (Guid client in inGroup) {
138            if (client == ci.Id) {
139              help = true;
140              break;
141            }
142          }
143          if (!help) {
144            ListViewItem item = null;
145            if ((ci.State == State.offline) || (ci.State == State.nullState)) {
146              item = new ListViewItem(ci.Name, 3, lvunsorted);
147            } else {
148              int percentageUsage = CapacityRam(ci.NrOfCores, ci.NrOfFreeCores);
149              int usage = 0;
150              if ((percentageUsage >= 0) && (percentageUsage <= 25)) {
151                usage = 0;
152              } else if ((percentageUsage > 25) && (percentageUsage <= 75)) {
153                usage = 1;
154              } else if ((percentageUsage > 75) && (percentageUsage <= 100)) {
155                usage = 2;
156              }
157              item = new ListViewItem(ci.Name, usage, lvunsorted);
158            }
159            item.Tag = ci.Id;
160            lvClientControl.Items.Add(item);
161          }
162        }
163        lvClientControl.BeginUpdate();
164        lvClientControl.Groups.Add(lvunsorted);
165        lvClientControl.EndUpdate();
166        if (flagClient) {
167          ClientClicked();
168        }
169      }
170      catch (Exception ex) {
171        closeFormEvent(true, true);
172        this.Close();
173      }
174    }
175
176
177    List<ListViewGroup> jobGroup;
178    /// <summary>
179    /// Adds jobs to ListView and TreeView
180    /// </summary>
181    private void AddJobs() {
182      try {
183        jobObjects = new Dictionary<Guid, ListViewItem>();
184        IJobManager jobManager =
185          ServiceLocator.GetJobManager();
186        jobs = jobManager.GetAllJobs();
187
188        lvJobControl.Items.Clear();
189
190        ListViewGroup lvJobCalculating = new ListViewGroup("calculating", HorizontalAlignment.Left);
191        ListViewGroup lvJobFinished = new ListViewGroup("finished", HorizontalAlignment.Left);
192        ListViewGroup lvJobPending = new ListViewGroup("pending", HorizontalAlignment.Left);
193
194        jobGroup = new List<ListViewGroup>();
195        jobGroup.Add(lvJobCalculating);
196        jobGroup.Add(lvJobFinished);
197        jobGroup.Add(lvJobPending);
198
199        foreach (Job job in jobs.List) {
200          if (job.State == State.calculating) {
201            ListViewItem lvi = new ListViewItem(job.Id.ToString(), 0, lvJobCalculating);
202            jobObjects.Add(job.Id, lvi);
203
204            //lvJobControl.Items.Add(lvi);
205
206            lvi.ToolTipText = (job.Percentage * 100) + "% of job calculated";
207          } else if (job.State == State.finished) {
208            ListViewItem lvi = new ListViewItem(job.Id.ToString(), 0, lvJobFinished);
209            jobObjects.Add(job.Id, lvi);
210            //lvJobControl.Items.Add(lvi);
211          } else if (job.State == State.offline) {
212            ListViewItem lvi = new ListViewItem(job.Id.ToString(), 0, lvJobPending);
213            jobObjects.Add(job.Id, lvi);
214            //lvJobControl.Items.Add(lvi);
215          }
216        } // Jobs
217        lvJobControl.BeginUpdate();
218        foreach (ListViewItem lvi in jobObjects.Values) {
219          lvJobControl.Items.Add(lvi);
220        }
221        lvJobControl.Groups.Add(lvJobCalculating);
222        lvJobControl.Groups.Add(lvJobFinished);
223        lvJobControl.Groups.Add(lvJobPending);
224        lvJobControl.EndUpdate();
225        if (flagJob) {
226          JobClicked();
227        }
228      }
229      catch (Exception ex) {
230        closeFormEvent(true, true);
231        this.Close();
232      }
233    }
234
235    /// <summary>
236    /// if one client is clicked, the details for the clicked client are shown
237    /// in the second panel
238    /// </summary>
239    private void ClientClicked() {
240      plClientDetails.Visible = true;
241      int i = 0;
242      while (clientInfo.List[i].Id.ToString() != nameCurrentClient) {
243        i++;
244      }
245      currentClient = clientInfo.List[i];
246      int percentageUsage = CapacityRam(currentClient.NrOfCores, currentClient.NrOfFreeCores);
247      int usage = 3;
248      if ((currentClient.State != State.offline) && (currentClient.State != State.nullState)) {
249        if ((percentageUsage >= 0) && (percentageUsage <= 25)) {
250          usage = 0;
251        } else if ((percentageUsage > 25) && (percentageUsage <= 75)) {
252          usage = 1;
253        } else if ((percentageUsage > 75) && (percentageUsage <= 100)) {
254          usage = 2;
255        }
256      }
257      pbClientControl.Image = ilClientControl.Images[usage];
258      lblClientName.Text = currentClient.Name;
259      lblLogin.Text = currentClient.Login.ToString();
260      lblState.Text = currentClient.State.ToString();
261    }
262
263    /// <summary>
264    /// if one job is clicked, the details for the clicked job are shown
265    /// in the second panel
266    /// </summary>
267    private void JobClicked() {
268      plJobDetails.Visible = true;
269      int i = 0;
270      while (jobs.List[i].Id.ToString() != nameCurrentJob) {
271        i++;
272      }
273      lvSnapshots.Enabled = true;
274      currentJob = jobs.List[i];
275      pbJobControl.Image = ilJobControl.Images[0];
276      lblJobName.Text = currentJob.Id.ToString();
277      progressJob.Value = (int)(currentJob.Percentage * 100);
278      lblProgress.Text = (int)(currentJob.Percentage * 100) + "% calculated";
279      lblUserCreatedJob.Text = currentJob.UserId.ToString() + /* currentJob.User.Name + */ " created Job";
280      lblJobCreated.Text = "Created at " + currentJob.DateCreated;
281      if (currentJob.ParentJob != null) {
282        lblParentJob.Text = currentJob.ParentJob.Id + " is parent job";
283      } else {
284        lblParentJob.Text = "";
285      }
286      lblPriorityJob.Text = "Priority of job is " + currentJob.Priority;
287      if (currentJob.Client != null) {
288        lblClientCalculating.Text = currentJob.Client.Name + " calculated Job";
289        lblJobCalculationBegin.Text = "Startet calculation at " + currentJob.DateCalculated;
290
291        if (currentJob.State == State.finished) {
292          IJobManager jobManager =
293            ServiceLocator.GetJobManager();
294          ResponseObject<JobResult> jobRes = jobManager.GetLastJobResultOf(currentJob.Id, false);
295          lblJobCalculationEnd.Text = "Calculation ended at " + jobRes.Obj.DateFinished;
296        }
297      } else {
298        lblClientCalculating.Text = "";
299        lblJobCalculationBegin.Text = "";
300        lblJobCalculationEnd.Text = "";
301      }
302      if (currentJob.State != State.offline) {
303        lvSnapshots.Items.Clear();
304        if (currentJob.State == State.finished)
305          GetSnapshotList();
306        lvSnapshots.Visible = true;
307      } else {
308        lvSnapshots.Visible = false;
309      }
310    }
311
312    private void Refresh() {
313      foreach (Changes change in changes) {
314        if (change.Types == Type.Job) {
315          RefreshJob(change);
316        } else if (change.Types == Type.Client) {
317          RefreshClient(change);
318        } else if (change.Types == Type.ClientGroup) {
319          RefreshClientGroup(change);
320        }
321      }
322    }
323
324    private void RefreshJob(Changes change) {
325      if (change.ChangeType == Change.Update) {
326        for (int i = 0; i < lvJobControl.Items.Count; i++) {
327          if (lvJobControl.Items[i].Text == change.ID.ToString()) {
328            if (nameCurrentJob == change.ID.ToString()) {
329              JobClicked();
330            }
331            State state = jobs.List[change.Position].State;
332            System.Diagnostics.Debug.WriteLine(lvJobControl.Items[i].Text.ToString());
333            if (state == State.finished) {
334              lvJobControl.Items[i].Group = jobGroup[1];
335              System.Diagnostics.Debug.WriteLine("finished");
336            } else if (state == State.calculating) {
337              lvJobControl.Items[i].Group = jobGroup[0];
338              System.Diagnostics.Debug.WriteLine("calculating");
339            } else if (state == State.offline) {
340              lvJobControl.Items[i].Group = jobGroup[2];
341              System.Diagnostics.Debug.WriteLine("offline");
342
343            }
344            lvJobControl.Refresh();
345          }
346        }
347      } else if (change.ChangeType == Change.Create) {
348        ListViewItem lvi = new ListViewItem(
349          change.ID.ToString(), 0, jobGroup[2]);
350        jobObjects.Add(change.ID, lvi);
351        lvJobControl.Items.Add(lvi);
352
353      } else if (change.ChangeType == Change.Delete) {
354        jobObjects.Remove(change.ID);
355        for (int i = 0; i < lvJobControl.Items.Count; i++) {
356          if (change.ID.ToString() == lvJobControl.Items[i].Text.ToString()) {
357            lvJobControl.Items[i].Remove();
358            break;
359          }
360        }
361      }
362    }
363
364    private void RefreshClient(Changes change) {
365      if (change.ChangeType == Change.Update) {
366        for (int i = 0; i < lvClientControl.Items.Count; i++) {
367          if (lvClientControl.Items[i].Tag.ToString() == change.ID.ToString()) {
368            if (nameCurrentClient == change.ID.ToString()) {
369              ClientClicked();
370            }
371            State state = clientInfo.List[change.Position].State;
372            System.Diagnostics.Debug.WriteLine(lvClientControl.Items[i].Text.ToString());
373
374            ClientInfo ci = null;
375
376            foreach (ClientInfo c in clientInfo.List) {
377              if (c.Id == change.ID) {
378                ci = c;
379              }
380            }
381
382            int percentageUsage = CapacityRam(ci.NrOfCores, ci.NrOfFreeCores);
383            if ((state == State.offline) || (state == State.nullState)) {
384              lvClientControl.Items[i].ImageIndex = 3;
385            } else {
386              if ((percentageUsage >= 0) && (percentageUsage <= 25)) {
387                lvClientControl.Items[i].ImageIndex = 0;
388              } else if ((percentageUsage > 25) && (percentageUsage <= 75)) {
389                lvClientControl.Items[i].ImageIndex = 1;
390              } else if ((percentageUsage > 75) && (percentageUsage <= 100)) {
391                lvClientControl.Items[i].ImageIndex = 2;
392              }
393
394            }
395            lvClientControl.Refresh();
396          }
397        }
398
399
400      } else if (change.ChangeType == Change.Create) {
401
402      } else if (change.ChangeType == Change.Delete) {
403        clientInfoObjects.Remove(change.ID);
404        for (int i = 0; i < lvClientControl.Items.Count; i++) {
405          if (change.ID.ToString() == lvClientControl.Items[i].Text.ToString()) {
406            lvClientControl.Items[i].Remove();
407            break;
408          }
409        }
410
411      }
412    }
413
414    private void RefreshClientGroup(Changes change) {
415
416    }
417
418    #region Eventhandlers
419    /// <summary>
420    /// Send event to Login-GUI when closing
421    /// </summary>
422    /// <param name="sender"></param>
423    /// <param name="e"></param>
424    private void Close_Click(object sender, EventArgs e) {
425      if (closeFormEvent != null) {
426        closeFormEvent(true, false);
427      }
428      this.Close();
429    }
430
431    /// <summary>
432    /// Send evnt to Login-GUI when closing
433    /// </summary>
434    /// <param name="sender"></param>
435    /// <param name="e"></param>
436    private void HiveServerConsoleInformation_FormClosing(object sender, FormClosingEventArgs e) {
437      if (closeFormEvent != null) {
438        closeFormEvent(true, false);
439      }
440    }
441
442    private void AddJob_Click(object sender, EventArgs e) {
443      AddJobForm newForm = new AddJobForm();
444      newForm.Show();
445      newForm.addJobEvent += new addDelegate(updaterWoker.RunWorkerAsync);
446    }
447
448    private void OnLVClientClicked(object sender, EventArgs e) {
449      nameCurrentClient = lvClientControl.SelectedItems[0].Tag.ToString();
450      flagClient = true;
451      ClientClicked();
452    }
453
454    private void OnLVJobControlClicked(object sender, EventArgs e) {
455      nameCurrentJob = lvJobControl.SelectedItems[0].Text;
456      flagJob = true;
457      JobClicked();
458    }
459
460    private void lvJobControl_MouseMove(object sender, MouseEventArgs e) {
461      if ((lvJobControl.GetItemAt(e.X, e.Y) != null) &&
462        (lvJobControl.GetItemAt(e.X, e.Y).ToolTipText != null)) {
463        tt.SetToolTip(lvJobControl, lvJobControl.GetItemAt(e.X, e.Y).ToolTipText);
464      }
465    }
466
467    private void updaterWoker_DoWork(object sender, DoWorkEventArgs e) {
468
469      changes.Clear();
470      IClientManager clientManager =
471          ServiceLocator.GetClientManager();
472
473      #region ClientInfo
474      ResponseList<ClientInfo> clientInfoOld = clientInfo;
475      clientInfo = clientManager.GetAllClients();
476
477      IDictionary<int, ClientInfo> clientInfoOldHelp;
478
479      CloneList(clientInfoOld, out clientInfoOldHelp);
480
481      GetDelta(clientInfoOld.List, clientInfoOldHelp);
482      #endregion
483
484      #region Clients
485      ResponseList<ClientGroup> clientsOld = clients;
486
487      clients = clientManager.GetAllClientGroups();
488
489      IDictionary<int, ClientGroup> clientsOldHelp;
490
491      CloneList(clientsOld, out clientsOldHelp);
492
493      GetDelta(clientsOld.List, clientsOldHelp);
494      #endregion
495
496      #region Job
497      ResponseList<Job> jobsOld = jobs;
498      IJobManager jobManager =
499          ServiceLocator.GetJobManager();
500
501      jobs = jobManager.GetAllJobs();
502
503      IDictionary<int, Job> jobsOldHelp;
504      CloneList(jobsOld, out jobsOldHelp);
505
506      GetDelta(jobsOld.List, jobsOldHelp);
507
508      #endregion
509
510      foreach (Changes change in changes) {
511        System.Diagnostics.Debug.WriteLine(change.ID + " " + change.ChangeType);
512      }
513
514    }
515    #endregion
516
517    #region Helper methods
518
519    private void CloneList(ResponseList<Job> oldList, out IDictionary<int, Job> newList) {
520      newList = new Dictionary<int, Job>();
521      for (int i = 0; i < oldList.List.Count; i++) {
522        newList.Add(i, oldList.List[i]);
523      }
524    }
525
526    private void CloneList(ResponseList<ClientInfo> oldList, out IDictionary<int, ClientInfo> newList) {
527      newList = new Dictionary<int, ClientInfo>();
528      for (int i = 0; i < oldList.List.Count; i++) {
529        newList.Add(i, oldList.List[i]);
530      }
531    }
532
533    private void CloneList(ResponseList<ClientGroup> oldList, out IDictionary<int, ClientGroup> newList) {
534      newList = new Dictionary<int, ClientGroup>();
535      for (int i = 0; i < oldList.List.Count; i++) {
536        newList.Add(i, oldList.List[i]);
537      }
538    }
539
540    private bool IsEqual(ClientInfo ci1, ClientInfo ci2) {
541      if (ci2 == null) {
542        return false;
543      }
544      if (ci1.Id.Equals(ci2.Id)) {
545        return true;
546      } else return false;
547    }
548
549    private int CapacityRam(int noCores, int freeCores) {
550      int capacity = ((noCores - freeCores) / noCores) * 100;
551      System.Diagnostics.Debug.WriteLine(capacity);
552      return capacity;
553    }
554
555    private void GetDelta(IList<ClientInfo> oldClient, IDictionary<int, ClientInfo> helpClients) {
556      bool found = false;
557
558      for (int i = 0; i < clientInfo.List.Count; i++) {
559        ClientInfo ci = clientInfo.List[i];
560        for (int j = 0; j < oldClient.Count; j++) {
561          ClientInfo cio = oldClient[j];
562          if (ci.Id.Equals(cio.Id)) {
563            found = true;
564            if ((ci.State != cio.State) || (ci.NrOfFreeCores != cio.NrOfFreeCores)) {
565              changes.Add(new Changes { Types = Type.Client, ID = ci.Id, ChangeType = Change.Update, Position = i });
566            }
567            int removeAt = -1;
568            foreach (KeyValuePair<int, ClientInfo> kvp in helpClients) {
569              if (cio.Id.Equals(kvp.Value.Id)) {
570                removeAt = kvp.Key;
571                break;
572              }
573            }
574            if (removeAt >= 0) {
575              helpClients.Remove(removeAt);
576            }
577            break;
578          }
579        }
580        if (found == false) {
581          changes.Add(new Changes { Types = Type.Client, ID = ci.Id, ChangeType = Change.Create });
582        }
583        found = false;
584      }
585      foreach (KeyValuePair<int, ClientInfo> kvp in helpClients) {
586        changes.Add(new Changes { Types = Type.Client, ID = kvp.Value.Id, ChangeType = Change.Delete, Position = kvp.Key });
587      }
588
589    }
590
591    private void GetDelta(IList<ClientGroup> oldClient, IDictionary<int, ClientGroup> helpClients) {
592
593      bool found = false;
594      for (int i = 0; i < clients.List.Count; i++) {
595        ClientGroup cg = clients.List[i];
596        for (int j = 0; j < oldClient.Count; i++) {
597          ClientGroup cgo = oldClient[j];
598          if (cg.Id.Equals(cgo.Id)) {
599            found = true;
600            foreach (Resource resource in cg.Resources) {
601              foreach (Resource resourceold in cgo.Resources) {
602                if (resource.Id.Equals(resourceold.Id)) {
603                  if (resourceold.Name != resource.Name) {
604                    changes.Add(new Changes { Types = Type.Client, ID = cg.Id, ChangeType = Change.Update, Position = i });
605                  }
606                }
607              }
608            }
609            for (int k = 0; k < helpClients.Count; k++) {
610              if (cgo.Id.Equals(helpClients[k].Id)) {
611                helpClients.Remove(k);
612                break;
613              }
614            }
615            break;
616          }
617        }
618        if (found == false) {
619          changes.Add(new Changes { Types = Type.ClientGroup, ID = cg.Id, ChangeType = Change.Create });
620        }
621        found = false;
622      }
623      foreach (KeyValuePair<int, ClientGroup> kvp in helpClients) {
624        changes.Add(new Changes { Types = Type.ClientGroup, ID = kvp.Value.Id, ChangeType = Change.Delete, Position = kvp.Key });
625      }
626    }
627
628    private void GetDelta(IList<Job> oldJobs, IDictionary<int, Job> helpJobs) {
629      bool found = false;
630      for (int i = 0; i < jobs.List.Count; i++) {
631        Job job = jobs.List[i];
632        for (int j = 0; j < oldJobs.Count; j++) {
633
634          Job jobold = oldJobs[j];
635
636          if (job.Id.Equals(jobold.Id)) {
637
638            found = true;
639            if (job.State != State.offline) {
640              if ((!IsEqual(job.Client, jobold.Client)) || (job.State != jobold.State)
641                   || (job.Percentage != jobold.Percentage)) {
642                changes.Add(new Changes { Types = Type.Job, ID = job.Id, ChangeType = Change.Update, Position = i });
643              }
644            } else if (job.DateCalculated != jobold.DateCalculated) {
645              changes.Add(new Changes { Types = Type.Job, ID = job.Id, ChangeType = Change.Update, Position = i });
646            }
647
648            int removeAt = -1;
649            foreach (KeyValuePair<int, Job> kvp in helpJobs) {
650              if (job.Id.Equals(kvp.Value.Id)) {
651                removeAt = kvp.Key;
652                break;
653              }
654            }
655            if (removeAt >= 0) {
656              helpJobs.Remove(removeAt);
657            }
658            break;
659          }
660
661        }
662        if (found == false) {
663          changes.Add(new Changes { Types = Type.Job, ID = job.Id, ChangeType = Change.Create });
664          System.Diagnostics.Debug.WriteLine("new Job: " + job.Id);
665        }
666        found = false;
667      }
668      foreach (KeyValuePair<int, Job> kvp in helpJobs) {
669        changes.Add(new Changes { Types = Type.Job, ID = kvp.Value.Id, ChangeType = Change.Delete, Position = kvp.Key });
670        System.Diagnostics.Debug.WriteLine("delete Job: " + kvp.Value.Id);
671      }
672    }
673
674    private void GetSnapshotList() {
675
676      lvSnapshots.Items.Clear();
677      IJobManager jobManager = ServiceLocator.GetJobManager();
678
679      ResponseObject<JobResult> jobRes = jobManager.GetLastJobResultOf(currentJob.Id, false);
680
681      // iterate threw all snapshots if method is implemented
682
683      ListViewItem curSnapshot = new ListViewItem(jobRes.Obj.Client.Name);
684      double percentage = jobRes.Obj.Percentage * 100;
685      curSnapshot.SubItems.Add(percentage.ToString() + " %");
686      curSnapshot.SubItems.Add(jobRes.Obj.timestamp.ToString());
687      lvSnapshots.Items.Add(curSnapshot);
688    }
689
690    #endregion
691
692  }
693}
Note: See TracBrowser for help on using the repository browser.