Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7584


Ignore:
Timestamp:
03/07/12 22:16:01 (12 years ago)
Author:
ascheibe
Message:

#1174 added displaying of progress when uploading runs

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r7580 r7584  
    383383    <None Include="HeuristicLab.snk" />
    384384  </ItemGroup>
    385   <ItemGroup>
    386     <EmbeddedResource Include="RunCreation\Views\OKBExperimentUploadView.resx">
    387       <DependentUpon>OKBExperimentUploadView.cs</DependentUpon>
    388     </EmbeddedResource>
    389     <EmbeddedResource Include="RunCreation\Views\OKBRunConfigSelectionView.resx">
    390       <DependentUpon>OKBRunConfigSelectionView.cs</DependentUpon>
    391     </EmbeddedResource>
    392   </ItemGroup>
    393385  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    394386  <PropertyGroup>
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.cs

    r7580 r7584  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading.Tasks;
    2526using System.Windows.Forms;
    2627using HeuristicLab.Clients.Access;
    2728using HeuristicLab.Core.Views;
    2829using HeuristicLab.MainForm;
     30using HeuristicLab.MainForm.WindowsForms;
    2931using HeuristicLab.Optimization;
    3032
     
    3840    }
    3941
     42    private ProgressView progressView;
    4043    List<OKBRunConfigSelectionView> runConfigViews = new List<OKBRunConfigSelectionView>();
    4144    private List<Problem> problems = new List<Problem>();
     
    104107        Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e);
    105108      } else {
    106         //TODO: display loading dialog
    107         Cursor = Cursors.AppStarting;
    108         Enabled = false;
     109        IProgress prog = new Progress();
     110        prog.Status = "Refreshing algorithms and problems...";
     111        SetProgressView(prog);
    109112      }
    110113    }
     114
    111115    private void RunCreationClient_Refreshed(object sender, EventArgs e) {
    112116      if (InvokeRequired) {
    113117        Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e);
    114118      } else {
     119        FinishProgressView();
     120
    115121        CreateUI();
    116 
    117         Enabled = true;
    118122        SetEnabledStateOfControls();
    119         Cursor = Cursors.Default;
    120123      }
    121124    }
    122125
    123126    private void btnUpload_Click(object sender, EventArgs e) {
     127      var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync);
     128      task.ContinueWith((t) => {
     129        FinishProgressView();
     130        PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception);
     131      }, TaskContinuationOptions.OnlyOnFaulted);
     132    }
     133
     134    private void UploadAsync() {
     135      IProgress prog = new Progress();
     136      prog.Status = "Uploading runs to OKB...";
     137      prog.ProgressValue = 0;
     138      double count = runConfigViews.Count(x => x.UploadToOKB());
     139      int i = 0;
     140
     141      SetProgressView(prog);
    124142      foreach (var runConfigView in runConfigViews) {
    125143        if (runConfigView.UploadToOKB()) {
    126           //TODO: show progress
    127144          OKBRun run = new OKBRun(runConfigView.GetSelectedAlgorithm().Id, runConfigView.GetSelectedProblem().Id, runConfigView.ExperimentRun, UserInformation.Instance.User.Id);
    128           try { run.Store(); }
    129           catch (Exception ex) {
    130             PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", ex);
    131           }
     145          run.Store();
     146          i++;
     147          prog.ProgressValue = ((double)i) / count;
     148        }
     149      }
     150      FinishProgressView();
     151    }
     152
     153    private void SetProgressView(IProgress progress) {
     154      if (InvokeRequired) {
     155        Invoke(new Action<IProgress>(SetProgressView), progress);
     156      } else {
     157        if (progressView == null) {
     158          progressView = new ProgressView(this, progress);
     159        } else {
     160          progressView.Progress = progress;
     161        }
     162      }
     163    }
     164
     165    private void FinishProgressView() {
     166      if (InvokeRequired) {
     167        Invoke(new Action(FinishProgressView));
     168      } else {
     169        if (progressView != null) {
     170          progressView.Finish();
     171          progressView = null;
     172          SetEnabledStateOfControls();
    132173        }
    133174      }
Note: See TracChangeset for help on using the changeset viewer.