Changeset 4587 for branches/OKB
- Timestamp:
- 10/09/10 13:27:57 (14 years ago)
- Location:
- branches/OKB/HeuristicLab.Clients.OKB-3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB/HeuristicLab.Clients.OKB-3.3/OKBClient.cs
r4566 r4587 171 171 } 172 172 } 173 public bool Store(long algorithmId, long problemId, Run run) { 174 try { 175 IAlgorithm algorithm = run.Algorithm; 176 IProblem problem = algorithm.Problem; 177 178 ItemCollection<AlgorithmParameter> algorithmParameters = GetAlgorithmParameters(algorithmId); 179 AddAlgorithmParamters(algorithmId, algorithmParameters, algorithm, ""); 180 ItemCollection<ProblemParameter> problemParameters = GetProblemParameters(problemId); 181 AddProblemParamters(problemId, problemParameters, problem, ""); 182 183 return true; 184 } 185 catch (Exception ex) { 186 ErrorHandling.ShowErrorDialog("Store run failed.", ex); 187 return false; 188 } 189 } 190 191 private void AddAlgorithmParamters(long algorithmId, ItemCollection<AlgorithmParameter> parameters, IParameterizedItem item, string prefix) { 192 foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) { 193 if (param.GetsCollected && (param.Value != null) && (parameters.FirstOrDefault(x => x.Name == param.Name) == null)) { 194 AlgorithmParameter p = new AlgorithmParameter(); 195 p.Name = prefix + param.Name; 196 p.Alias = prefix + param.Name; 197 p.Description = param.Description; 198 p.AlgorithmId = algorithmId; 199 p.DataTypeId = GetDataType(param.DataType).Id; 200 p.Store(); 201 parameters.Add(p); 202 } 203 if (param.Value is IParameterizedItem) 204 AddAlgorithmParamters(algorithmId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."); 205 } 206 } 207 private void AddProblemParamters(long problemId, ItemCollection<ProblemParameter> parameters, IParameterizedItem item, string prefix) { 208 foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) { 209 if (param.GetsCollected && (param.Value != null) && (parameters.FirstOrDefault(x => x.Name == param.Name) == null)) { 210 ProblemParameter p = new ProblemParameter(); 211 p.Name = prefix + param.Name; 212 p.Alias = prefix + param.Name; 213 p.Description = param.Description; 214 p.ProblemId = problemId; 215 p.DataTypeId = GetDataType(param.DataType).Id; 216 p.Store(); 217 parameters.Add(p); 218 } 219 if (param.Value is IParameterizedItem) 220 AddProblemParamters(problemId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."); 221 } 222 } 223 224 public DataType GetDataType(Type type) { 173 #endregion 174 175 #region DataType Methods 176 public DataType ConvertToDataType(Type type) { 225 177 DataType dataType = DataTypes.FirstOrDefault(x => x.Name == type.AssemblyQualifiedName); 226 178 if (dataType == null) { … … 245 197 return dataType; 246 198 } 247 248 199 #endregion 249 200 … … 359 310 ErrorHandling.ShowErrorDialog("Refresh problem parameters failed.", ex); 360 311 return null; 312 } 313 } 314 #endregion 315 316 #region Run Methods 317 public bool AddRun(long algorithmId, long problemId, Run run) { 318 try { 319 IAlgorithm algorithm = run.Algorithm; 320 IProblem problem = algorithm.Problem; 321 322 ItemCollection<AlgorithmParameter> algorithmParameters = GetAlgorithmParameters(algorithmId); 323 AddAlgorithmParamters(algorithmId, algorithmParameters, algorithm, ""); 324 ItemCollection<ProblemParameter> problemParameters = GetProblemParameters(problemId); 325 AddProblemParamters(problemId, problemParameters, problem, ""); 326 327 return true; 328 } 329 catch (Exception ex) { 330 ErrorHandling.ShowErrorDialog("Store run failed.", ex); 331 return false; 332 } 333 } 334 335 private void AddAlgorithmParamters(long algorithmId, ItemCollection<AlgorithmParameter> parameters, IParameterizedItem item, string prefix) { 336 foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) { 337 if (param.GetsCollected && (param.Value != null) && (parameters.FirstOrDefault(x => x.Name == prefix + param.Name) == null)) { 338 AlgorithmParameter p = new AlgorithmParameter(); 339 p.Name = prefix + param.Name; 340 p.Alias = prefix + param.Name; 341 p.Description = param.Description; 342 p.AlgorithmId = algorithmId; 343 p.DataTypeId = ConvertToDataType(param.DataType).Id; 344 p.Store(); 345 parameters.Add(p); 346 } 347 if (param.Value is IParameterizedItem) 348 AddAlgorithmParamters(algorithmId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."); 349 } 350 } 351 private void AddProblemParamters(long problemId, ItemCollection<ProblemParameter> parameters, IParameterizedItem item, string prefix) { 352 foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) { 353 if (param.GetsCollected && (param.Value != null) && (parameters.FirstOrDefault(x => x.Name == prefix + param.Name) == null)) { 354 ProblemParameter p = new ProblemParameter(); 355 p.Name = prefix + param.Name; 356 p.Alias = prefix + param.Name; 357 p.Description = param.Description; 358 p.ProblemId = problemId; 359 p.DataTypeId = ConvertToDataType(param.DataType).Id; 360 p.Store(); 361 parameters.Add(p); 362 } 363 if (param.Value is IParameterizedItem) 364 AddProblemParamters(problemId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."); 361 365 } 362 366 } -
branches/OKB/HeuristicLab.Clients.OKB-3.3/OKBExperiment.cs
r4566 r4587 321 321 try { 322 322 foreach (Run run in e.Items) 323 OKBClient.Instance. Store(AlgorithmId, ProblemId, run);323 OKBClient.Instance.AddRun(AlgorithmId, ProblemId, run); 324 324 } 325 325 catch (Exception ex) { -
branches/OKB/HeuristicLab.Clients.OKB-3.3/ServiceClients/OKBServiceClient.cs
r4566 r4587 10 10 11 11 namespace HeuristicLab.Clients.OKB { 12 using System.Runtime.Serialization;13 12 14 13 -
branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/AlgorithmDataView.cs
r4558 r4587 157 157 if (Content == null) Content = new AlgorithmData { AlgorithmId = AlgorithmId }; 158 158 viewHost.Content = (IContent)dialog.TypeSelector.CreateInstanceOfSelectedType(); 159 DataType dataType = OKBClient.Instance.DataTypes.FirstOrDefault(d => d.Name == viewHost.Content.GetType().AssemblyQualifiedName); 160 if (dataType == null) { 161 dataType = new DataType { Name = viewHost.Content.GetType().AssemblyQualifiedName, SqlName = "varbinary" }; 162 dataType.PlatformId = OKBClient.Instance.Platforms.FirstOrDefault(p => p.Name == "HeuristicLab 3.3").Id; 163 dataType.Store(); 164 OKBClient.Instance.DataTypes.Add(dataType); 165 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 166 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 167 } 159 DataType dataType = OKBClient.Instance.ConvertToDataType(viewHost.Content.GetType()); 160 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 161 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 168 162 dataTypeComboBox.SelectedItem = dataType; 169 163 fileTextBox.Text = "-"; … … 190 184 viewHost.Content = algorithm; 191 185 noViewAvailableLabel.Visible = false; 192 DataType dataType = OKBClient.Instance.DataTypes.FirstOrDefault(d => d.Name == viewHost.Content.GetType().AssemblyQualifiedName); 193 if (dataType == null) { 194 dataType = new DataType { Name = viewHost.Content.GetType().AssemblyQualifiedName, SqlName = "varbinary" }; 195 dataType.PlatformId = OKBClient.Instance.Platforms.FirstOrDefault(p => p.Name == "HeuristicLab 3.3").Id; 196 dataType.Store(); 197 OKBClient.Instance.DataTypes.Add(dataType); 198 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 199 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 200 } 186 DataType dataType = OKBClient.Instance.ConvertToDataType(viewHost.Content.GetType()); 187 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 188 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 201 189 dataTypeComboBox.SelectedItem = dataType; 202 190 } else { -
branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/ProblemDataView.cs
r4558 r4587 156 156 if (Content == null) Content = new ProblemData { ProblemId = ProblemId }; 157 157 viewHost.Content = (IContent)dialog.TypeSelector.CreateInstanceOfSelectedType(); 158 DataType dataType = OKBClient.Instance.DataTypes.FirstOrDefault(d => d.Name == viewHost.Content.GetType().AssemblyQualifiedName); 159 if (dataType == null) { 160 dataType = new DataType { Name = viewHost.Content.GetType().AssemblyQualifiedName, SqlName = "varbinary" }; 161 dataType.PlatformId = OKBClient.Instance.Platforms.FirstOrDefault(p => p.Name == "HeuristicLab 3.3").Id; 162 dataType.Store(); 163 OKBClient.Instance.DataTypes.Add(dataType); 164 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 165 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 166 } 158 DataType dataType = OKBClient.Instance.ConvertToDataType(viewHost.Content.GetType()); 159 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 160 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 167 161 dataTypeComboBox.SelectedItem = dataType; 168 162 fileTextBox.Text = "-"; … … 189 183 viewHost.Content = problem; 190 184 noViewAvailableLabel.Visible = false; 191 DataType dataType = OKBClient.Instance.DataTypes.FirstOrDefault(d => d.Name == viewHost.Content.GetType().AssemblyQualifiedName); 192 if (dataType == null) { 193 dataType = new DataType { Name = viewHost.Content.GetType().AssemblyQualifiedName, SqlName = "varbinary" }; 194 dataType.PlatformId = OKBClient.Instance.Platforms.FirstOrDefault(p => p.Name == "HeuristicLab 3.3").Id; 195 dataType.Store(); 196 OKBClient.Instance.DataTypes.Add(dataType); 197 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 198 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 199 } 185 DataType dataType = OKBClient.Instance.ConvertToDataType(viewHost.Content.GetType()); 186 dataTypeComboBoxValues = OKBClient.Instance.DataTypes.OrderBy(d => d.Name).ToList(); 187 dataTypeComboBox.DataSource = dataTypeComboBoxValues; 200 188 dataTypeComboBox.SelectedItem = dataType; 201 189 } else {
Note: See TracChangeset
for help on using the changeset viewer.