Changeset 13485 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
- Timestamp:
- 12/18/15 12:42:13 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
r13475 r13485 23 23 using System.Collections; 24 24 using System.ComponentModel; 25 using System.IO;26 25 using System.Linq; 27 26 using System.Windows.Forms; 28 using HeuristicLab.Clients.OKB.Administration;29 using HeuristicLab.Clients.OKB.Query;30 27 using HeuristicLab.Common; 31 28 using HeuristicLab.Common.Resources; 32 using HeuristicLab.Core;33 29 using HeuristicLab.Core.Views; 34 30 using HeuristicLab.MainForm; 35 31 using HeuristicLab.Optimization; 36 using HeuristicLab.Persistence.Default.Xml;37 32 using HeuristicLab.PluginInfrastructure; 38 33 … … 43 38 protected TypeSelectorDialog problemTypeSelectorDialog; 44 39 protected virtual bool SuppressEvents { get; set; } 40 private bool okbDownloadInProgress; 45 41 46 42 public new ExpertSystem Content { … … 85 81 base.OnContentChanged(); 86 82 SuppressEvents = true; 83 okbDownloadInProgress = false; 87 84 try { 88 85 if (Content == null) { … … 114 111 algorithmViewHost.Enabled = Content != null && !ReadOnly && !Locked; 115 112 runsView.Enabled = Content != null; 116 algorithmInstancesViewHost.Enabled = Content != null ;113 algorithmInstancesViewHost.Enabled = Content != null && !okbDownloadInProgress; 117 114 refreshMapButton.Enabled = Content != null; 118 okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked ;115 okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked && !okbDownloadInProgress; 119 116 } 120 117 … … 293 290 294 291 private void okbDownloadButton_Click(object sender, EventArgs e) { 295 var queryClient = QueryClient.Instance; 296 queryClient.Refresh(); 297 298 var problemTypeFilter = (StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Data Type Name"); 299 problemTypeFilter.Value = Content.Problem.GetType().Name; 300 301 var runIds = queryClient.GetRunIds(problemTypeFilter).ToList(); 302 var count = queryClient.GetNumberOfRuns(problemTypeFilter); 303 if (count > 0) { 304 var list = new ItemList<IAlgorithm>(); 305 var adminClient = AdministrationClient.Instance; 306 adminClient.Refresh(); 307 var runs = queryClient.GetRuns(runIds, true).ToList(); 308 foreach (var rGroup in runs.GroupBy(x => x.Algorithm.Id)) { 309 var data = AdministrationClient.GetAlgorithmData(rGroup.Key); 310 if (data != null) { 311 using (var stream = new MemoryStream(data)) { 312 try { 313 var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream); 314 alg.Runs.AddRange(rGroup.Select(x => queryClient.ConvertToOptimizationRun(x))); 315 list.Add(alg); 316 } catch (Exception) { } 317 stream.Close(); 318 } 319 } 320 } 321 Content.AlgorithmInstances = list; 292 var progress = new Progress(); 293 progress.ProgressStateChanged += OkbDownloadProgressOnStateChanged; 294 Content.UpdateKnowledgeBaseAsync(progress); 295 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(progressPanel, progress); 296 progressPanel.Visible = true; 297 SetEnabledStateOfControls(); 298 } 299 300 private void OkbDownloadProgressOnStateChanged(object sender, EventArgs eventArgs) { 301 var progress = (IProgress)sender; 302 okbDownloadInProgress = progress.ProgressState == ProgressState.Started; 303 SetEnabledStateOfControls(); 304 if (!okbDownloadInProgress) { 305 progressPanel.Visible = false; 306 progress.ProgressStateChanged -= OkbDownloadProgressOnStateChanged; 322 307 } 323 308 }
Note: See TracChangeset
for help on using the changeset viewer.