Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/15 12:42:13 (8 years ago)
Author:
abeham
Message:

#2457:

  • fixed bugs in iterated sampling view
  • worked on download runs from okb feature
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs

    r13475 r13485  
    2323using System.Collections;
    2424using System.ComponentModel;
    25 using System.IO;
    2625using System.Linq;
    2726using System.Windows.Forms;
    28 using HeuristicLab.Clients.OKB.Administration;
    29 using HeuristicLab.Clients.OKB.Query;
    3027using HeuristicLab.Common;
    3128using HeuristicLab.Common.Resources;
    32 using HeuristicLab.Core;
    3329using HeuristicLab.Core.Views;
    3430using HeuristicLab.MainForm;
    3531using HeuristicLab.Optimization;
    36 using HeuristicLab.Persistence.Default.Xml;
    3732using HeuristicLab.PluginInfrastructure;
    3833
     
    4338    protected TypeSelectorDialog problemTypeSelectorDialog;
    4439    protected virtual bool SuppressEvents { get; set; }
     40    private bool okbDownloadInProgress;
    4541
    4642    public new ExpertSystem Content {
     
    8581      base.OnContentChanged();
    8682      SuppressEvents = true;
     83      okbDownloadInProgress = false;
    8784      try {
    8885        if (Content == null) {
     
    114111      algorithmViewHost.Enabled = Content != null && !ReadOnly && !Locked;
    115112      runsView.Enabled = Content != null;
    116       algorithmInstancesViewHost.Enabled = Content != null;
     113      algorithmInstancesViewHost.Enabled = Content != null && !okbDownloadInProgress;
    117114      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;
    119116    }
    120117
     
    293290
    294291    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;
    322307      }
    323308    }
Note: See TracChangeset for help on using the changeset viewer.