[4311] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.ComponentModel;
|
---|
| 4 | using System.Data;
|
---|
| 5 | using System.Drawing;
|
---|
| 6 | using System.Text;
|
---|
| 7 | using System.Linq;
|
---|
| 8 | using System.Windows.Forms;
|
---|
| 9 | using HeuristicLab.OKB.Client;
|
---|
| 10 | using HeuristicLab.MainForm;
|
---|
| 11 |
|
---|
| 12 | namespace 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 | }
|
---|