Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB/HeuristicLab.OKB.AlgorithmHost/AlgorithmContainerView.cs @ 5219

Last change on this file since 5219 was 4311, checked in by swagner, 14 years ago

Integrated OKB clients for HL 3.3 (#1166)

File size: 2.4 KB
RevLine 
[4311]1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Linq;
8using System.Windows.Forms;
9using HeuristicLab.OKB.Client;
10using HeuristicLab.MainForm;
11
12namespace HeuristicLab.OKB.AlgorithmHost {
13
14  [ViewAttribute("AlgorithmContainer View")]
15  [Content(typeof(AlgorithmContainer), true)]
16  public partial class AlgorithmContainerView : ParameterizedNamedItemContainerView {
17
18    private Mapping resultMapping;
19
20    public AlgorithmContainerView() {
21      resultMapping = new Mapping();
22      InitializeComponent();
23    }
24
25    public new AlgorithmContainer Content {
26      get { return (AlgorithmContainer)base.Content; }
27      set { base.Content = value; }
28    }
29
30    protected override void OnContentChanged() {
31      base.OnContentChanged();
32      if (Content == null) {
33        resultMapping.Map = null;
34      } else {
35        resultMapping.Map = Content.ResultMapping;
36        resultMappingView.Content = resultMapping;
37      }
38    }
39
40    private DataTable backgroundLoadedResults = null;
41
42    protected override void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
43      backgroundWorker.ReportProgress(0);
44      var client = ClientFactory.Create<OKBTables.TableServiceClient, OKBTables.ITableService>();
45      int count;
46      DataTable results = client.PrepareDataTable(out count, "Result");
47      results.BeginLoadData();
48      DataTable newRows;
49      do {
50        newRows = client.GetNextRows(100);
51        results.Merge(newRows);
52      } while (newRows != null && newRows.Rows.Count > 0);
53      client.FinishFetchingRows();
54      client.Close();
55      results.EndLoadData();
56      backgroundLoadedResults = results;
57      base.backgroundWorker_DoWork(sender, e);
58    }
59
60    protected override void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
61      base.backgroundWorker_RunWorkerCompleted(sender, e);
62      resultMappingView.Enabled = false;
63      if (backgroundLoadedParameters != null) {
64        resultMapping.Values.Clear();
65        resultMapping.Values.Add(null);
66        resultMapping.Values.AddRange(backgroundLoadedResults.Rows.Cast<DataRow>().Select(r => (string)r["Name"]));
67        resultMappingView.Enabled = true;
68      }
69    }
70
71    private void stripButton_Click(object sender, EventArgs e) {
72      Content.Strip();
73      this.Enabled = false;
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.