Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/25/17 15:22:47 (7 years ago)
Author:
gkronber
Message:

#2547 merged r13474 from trunk to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/QueryView.cs

    r14186 r15055  
    2323using System.Collections;
    2424using System.Collections.Generic;
    25 using System.IO;
    2625using System.Linq;
    2726using System.Threading;
    2827using System.Threading.Tasks;
    2928using System.Windows.Forms;
    30 using HeuristicLab.Core;
    3129using HeuristicLab.MainForm;
    3230using HeuristicLab.MainForm.WindowsForms;
    3331using HeuristicLab.Optimization;
    34 using HeuristicLab.Persistence.Default.Xml;
    3532using HeuristicLab.PluginInfrastructure;
    3633
     
    103100          cancellationToken.ThrowIfCancellationRequested();
    104101          if (AllValueNamesChecked()) {
    105             runs.AddRange(QueryClient.Instance.GetRuns(ids.Take(batchSize), includeBinaryValues).Select(x => ConvertToOptimizationRun(x)));
     102            runs.AddRange(QueryClient.Instance.GetRuns(ids.Take(batchSize), includeBinaryValues).Select(x => QueryClient.Instance.ConvertToOptimizationRun(x)));
    106103          } else {
    107             runs.AddRange(QueryClient.Instance.GetRunsWithValues(ids.Take(batchSize), includeBinaryValues, valueNames).Select(x => ConvertToOptimizationRun(x)));
     104            runs.AddRange(QueryClient.Instance.GetRunsWithValues(ids.Take(batchSize), includeBinaryValues, valueNames).Select(x => QueryClient.Instance.ConvertToOptimizationRun(x)));
    108105          }
    109106          ids = ids.Skip(batchSize);
     
    124121          try {
    125122            t.Wait();
    126           }
    127           catch (AggregateException ex) {
     123          } catch (AggregateException ex) {
    128124            try {
    129125              ex.Flatten().Handle(x => x is OperationCanceledException);
    130             }
    131             catch (AggregateException remaining) {
     126            } catch (AggregateException remaining) {
    132127              if (remaining.InnerExceptions.Count == 1) ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining.InnerExceptions[0]);
    133128              else ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining);
     
    195190    }
    196191
    197     private Optimization.IRun ConvertToOptimizationRun(Run run) {
    198       Optimization.Run optRun = new Optimization.Run();
    199       foreach (Value value in run.ParameterValues)
    200         optRun.Parameters.Add(value.Name, ConvertToItem(value));
    201       foreach (Value value in run.ResultValues)
    202         optRun.Results.Add(value.Name, ConvertToItem(value));
    203       return optRun;
    204     }
    205 
    206     private IItem ConvertToItem(Value value) {
    207       if (value is BinaryValue) {
    208         IItem item = null;
    209         BinaryValue binaryValue = (BinaryValue)value;
    210         if (binaryValue.Value != null) {
    211           using (MemoryStream stream = new MemoryStream(binaryValue.Value)) {
    212             try {
    213               item = XmlParser.Deserialize<IItem>(stream);
    214             }
    215             catch (Exception) { }
    216             stream.Close();
    217           }
    218         }
    219         return item != null ? item : new Data.StringValue(value.DataType.Name);
    220       } else if (value is BoolValue) {
    221         return new Data.BoolValue(((BoolValue)value).Value);
    222       } else if (value is FloatValue) {
    223         return new Data.DoubleValue(((FloatValue)value).Value);
    224       } else if (value is PercentValue) {
    225         return new Data.PercentValue(((PercentValue)value).Value);
    226       } else if (value is DoubleValue) {
    227         return new Data.DoubleValue(((DoubleValue)value).Value);
    228       } else if (value is IntValue) {
    229         return new Data.IntValue((int)((IntValue)value).Value);
    230       } else if (value is LongValue) {
    231         return new Data.IntValue((int)((LongValue)value).Value);
    232       } else if (value is StringValue) {
    233         return new Data.StringValue(((StringValue)value).Value);
    234       } else if (value is TimeSpanValue) {
    235         return new Data.TimeSpanValue(TimeSpan.FromSeconds((long)((TimeSpanValue)value).Value));
    236       }
    237       return null;
    238     }
    239 
    240192    private void SetCheckedState(bool val) {
    241193      for (int i = 0; i < constraintsCheckedListBox.Items.Count; i++) {
Note: See TracChangeset for help on using the changeset viewer.