Changeset 7670
- Timestamp:
- 03/28/12 17:22:34 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/CloudManagerClient.cs
r7668 r7670 227 227 } 228 228 229 public void RestoreSubscriptionsFromUserConfig() { 229 public List<Subscription> RestoreSubscriptionsFromUserConfig() { 230 List<Subscription> result = new List<Subscription>(); 230 231 StringCollection strCol = Settings.Default.AzureSubscriptions; 231 232 foreach (string azureSub in strCol) { 232 233 string setting = CryptoService.ToInsecureString(CryptoService.DecryptString(azureSub)); 233 Subscription s = Subscription.ParseSettingString(setting); 234 Subscription tmp = Subscription.ParseSettingString(setting); 235 Subscription s = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(tmp.SubscriptionID, tmp.CertificateThumbprint); 234 236 s.SaveToConfig = true; 235 237 s.DiscoverServices = true; 236 Add(s); 237 } 238 result.Add(s); 239 } 240 return result; 238 241 } 239 242 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/CloudResourcesView.cs
r7668 r7670 1 1 using System; 2 using System.Collections.Generic; 2 3 using System.Diagnostics; 4 using System.Threading.Tasks; 3 5 using System.Timers; 4 6 using System.Windows.Forms; … … 8 10 using HeuristicLab.Core.Views; 9 11 using HeuristicLab.MainForm; 12 using HeuristicLab.MainForm.WindowsForms; 13 using HeuristicLab.PluginInfrastructure; 10 14 11 15 namespace HeuristicLab.Clients.Hive.CloudManager.Views { … … 13 17 [Content(typeof(IItemList<Subscription>), IsDefaultView = true)] 14 18 public partial class CloudResourcesView : ItemView, IDisposable { 19 ProgressView progressView; 15 20 private System.Timers.Timer timer = new System.Timers.Timer(); 16 21 private int updateInterval = 15000; … … 52 57 dueTime = DateTime.Now.AddMilliseconds(updateInterval); 53 58 54 CloudManagerClient.Instance.RestoreSubscriptionsFromUserConfig(); 59 //IProgress progress = new Progress(); 60 //progress.Status = "Restore Subscriptions"; 61 //progressView = new ProgressView(this, progress); 62 //CloudManagerClient.Instance.RestoreSubscriptionsFromUserConfig(); 63 //progressView.Finish(); 55 64 } 56 65 … … 85 94 } 86 95 96 private void SetProgressView(IProgress progress) { 97 if (InvokeRequired) { 98 Invoke(new Action<IProgress>(SetProgressView), progress); 99 } else { 100 if (progressView == null) { 101 progressView = new ProgressView(this, progress); 102 } else { 103 progressView.Progress = progress; 104 } 105 } 106 } 107 108 private void FinishProgressView() { 109 if (InvokeRequired) { 110 Invoke(new Action(FinishProgressView)); 111 } else { 112 if (progressView != null) { 113 progressView.Finish(); 114 progressView = null; 115 SetEnabledStateOfControls(); 116 } 117 } 118 } 119 120 public void Restore() { 121 var task = System.Threading.Tasks.Task.Factory.StartNew(RestoreAsync); 122 task.ContinueWith((t) => { 123 FinishProgressView(); 124 ErrorHandling.ShowErrorDialog(this, "An error occured while restoring Azure Subscriptions.", t.Exception); 125 }, TaskContinuationOptions.OnlyOnFaulted); 126 FinishProgressView(); 127 } 128 129 private void RestoreAsync() { 130 IProgress progress = new Progress(); 131 progress.Status = "Restoring Azure Subscriptions"; 132 SetProgressView(progress); 133 List<Subscription> result = CloudManagerClient.Instance.RestoreSubscriptionsFromUserConfig(); 134 FinishProgressView(); 135 foreach (Subscription s in result) this.BeginInvoke((MethodInvoker)delegate() { CloudManagerClient.Instance.Add(s); }); 136 } 137 87 138 protected override void SetEnabledStateOfControls() { 88 139 base.SetEnabledStateOfControls(); 89 140 if (Content == null || Content.Count == 0) { 90 btnAddSlaveService.Enabled = false; 91 btnDelete.Enabled = false; 92 btnSave.Enabled = false; 93 } else { 94 btnAddSlaveService.Enabled = true; 95 btnDelete.Enabled = true; 96 btnSave.Enabled = true; 97 } 141 if (this.InvokeRequired) { 142 this.BeginInvoke((MethodInvoker)delegate() { SetBtnControlsEnabled(false); }); 143 } else { 144 SetBtnControlsEnabled(false); 145 } 146 } else { 147 if (this.InvokeRequired) { 148 this.BeginInvoke((MethodInvoker)delegate() { SetBtnControlsEnabled(true); }); 149 } else { 150 SetBtnControlsEnabled(true); 151 } 152 } 153 } 154 155 private void SetBtnControlsEnabled(bool enabled) { 156 btnAddSlaveService.Enabled = enabled; 157 btnDelete.Enabled = enabled; 158 btnSave.Enabled = enabled; 98 159 } 99 160 -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/HiveCloudManagerView.cs
r7387 r7670 40 40 cloudResourcesView.Content = CloudManagerClient.Instance.Subscriptions; 41 41 cloudResourcesView.HostedServices = CloudManagerClient.Instance.HostedServices; 42 43 cloudResourcesView.Restore(); 42 44 } 43 45
Note: See TracChangeset
for help on using the changeset viewer.