Changeset 15055 for stable/HeuristicLab.Clients.OKB/3.3/Query
- Timestamp:
- 06/25/17 15:22:47 (8 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13474
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.OKB/3.3/Query/QueryClient.cs
r14186 r15055 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using HeuristicLab.Clients.Common; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 29 using HeuristicLab.Persistence.Default.Xml; 28 30 29 31 namespace HeuristicLab.Clients.OKB.Query { … … 61 63 filters.AddRange(CallQueryService<List<Filter>>(s => s.GetFilters())); 62 64 valueNames.AddRange(CallQueryService<List<ValueName>>(s => s.GetValueNames())); 63 } 64 finally { 65 } finally { 65 66 OnRefreshed(); 66 67 } … … 70 71 try { 71 72 Refresh(); 72 } 73 catch (Exception ex) { 73 } catch (Exception ex) { 74 74 return ex; 75 75 } … … 98 98 #endregion 99 99 100 #region OKB-Item Conversion 101 public Optimization.IRun ConvertToOptimizationRun(Run run) { 102 Optimization.Run optRun = new Optimization.Run(); 103 foreach (Value value in run.ParameterValues) 104 optRun.Parameters.Add(value.Name, ConvertToItem(value)); 105 foreach (Value value in run.ResultValues) 106 optRun.Results.Add(value.Name, ConvertToItem(value)); 107 return optRun; 108 } 109 110 public IItem ConvertToItem(Value value) { 111 if (value is BinaryValue) { 112 IItem item = null; 113 var binaryValue = (BinaryValue)value; 114 if (binaryValue.Value != null) { 115 using (var stream = new MemoryStream(binaryValue.Value)) { 116 try { 117 item = XmlParser.Deserialize<IItem>(stream); 118 } catch (Exception) { } 119 stream.Close(); 120 } 121 } 122 return item ?? new Data.StringValue(value.DataType.Name); 123 } else if (value is BoolValue) { 124 return new Data.BoolValue(((BoolValue)value).Value); 125 } else if (value is FloatValue) { 126 return new Data.DoubleValue(((FloatValue)value).Value); 127 } else if (value is PercentValue) { 128 return new Data.PercentValue(((PercentValue)value).Value); 129 } else if (value is DoubleValue) { 130 return new Data.DoubleValue(((DoubleValue)value).Value); 131 } else if (value is IntValue) { 132 return new Data.IntValue((int)((IntValue)value).Value); 133 } else if (value is LongValue) { 134 return new Data.IntValue((int)((LongValue)value).Value); 135 } else if (value is StringValue) { 136 return new Data.StringValue(((StringValue)value).Value); 137 } else if (value is TimeSpanValue) { 138 return new Data.TimeSpanValue(TimeSpan.FromSeconds((long)((TimeSpanValue)value).Value)); 139 } 140 return null; 141 } 142 #endregion 143 100 144 #region Events 101 145 public event EventHandler Refreshing; … … 116 160 try { 117 161 return call(client); 118 } 119 finally { 162 } finally { 120 163 try { 121 164 client.Close(); 122 } 123 catch (Exception) { 165 } catch (Exception) { 124 166 client.Abort(); 125 167 }
Note: See TracChangeset
for help on using the changeset viewer.