Changeset 7584
- Timestamp:
- 03/07/12 22:16:01 (13 years ago)
- 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 383 383 <None Include="HeuristicLab.snk" /> 384 384 </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>393 385 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 394 386 <PropertyGroup> -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r7580 r7584 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading.Tasks; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.Clients.Access; 27 28 using HeuristicLab.Core.Views; 28 29 using HeuristicLab.MainForm; 30 using HeuristicLab.MainForm.WindowsForms; 29 31 using HeuristicLab.Optimization; 30 32 … … 38 40 } 39 41 42 private ProgressView progressView; 40 43 List<OKBRunConfigSelectionView> runConfigViews = new List<OKBRunConfigSelectionView>(); 41 44 private List<Problem> problems = new List<Problem>(); … … 104 107 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 105 108 } else { 106 //TODO: display loading dialog107 Cursor = Cursors.AppStarting;108 Enabled = false;109 IProgress prog = new Progress(); 110 prog.Status = "Refreshing algorithms and problems..."; 111 SetProgressView(prog); 109 112 } 110 113 } 114 111 115 private void RunCreationClient_Refreshed(object sender, EventArgs e) { 112 116 if (InvokeRequired) { 113 117 Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e); 114 118 } else { 119 FinishProgressView(); 120 115 121 CreateUI(); 116 117 Enabled = true;118 122 SetEnabledStateOfControls(); 119 Cursor = Cursors.Default;120 123 } 121 124 } 122 125 123 126 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); 124 142 foreach (var runConfigView in runConfigViews) { 125 143 if (runConfigView.UploadToOKB()) { 126 //TODO: show progress127 144 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(); 132 173 } 133 174 }
Note: See TracChangeset
for help on using the changeset viewer.