Changeset 7387 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views
- Timestamp:
- 01/20/12 16:54:16 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
r7374 r7387 108 108 } 109 109 } 110 } 111 112 private bool ValidateInput() { 113 bool valid = true; 114 // TODO: input validation 115 // see http://stackoverflow.com/questions/769184/winform-ui-validation 116 return valid; 110 117 } 111 118 … … 159 166 if (cmbChooseSubscription.SelectedItem != null) { 160 167 Subscription sub = (Subscription)cmbChooseSubscription.SelectedItem; 161 bool newHostedServiceChecked = cbNewHostedService.Checked; 162 bool regionChecked = rbRegion.Checked; 163 string certFile = certificateFile; 164 string certPw = certificatePassword; 165 int instanceCount = Convert.ToInt32(tbInstanceCount.Text); 166 HostedService hostedService = new HostedService(); 167 hostedService.ServiceName = tbServiceName.Text; 168 HostedServiceProperties properties = new HostedServiceProperties(); 169 if (regionChecked) { 170 properties.AffinityGroup = string.Empty; 168 if (ValidateInput()) { 169 bool newHostedServiceChecked = cbNewHostedService.Checked; 170 bool regionChecked = rbRegion.Checked; 171 string certFile = certificateFile; 172 string certPw = certificatePassword; 173 int instanceCount = Convert.ToInt32(tbInstanceCount.Text); 174 HostedService hostedService = new HostedService(); 175 hostedService.ServiceName = tbServiceName.Text; 176 HostedServiceProperties properties = new HostedServiceProperties(); 177 if (regionChecked) { 178 properties.AffinityGroup = string.Empty; 179 properties.Location = (string)cmbLocation.SelectedItem; 180 } else { 181 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 182 properties.Location = string.Empty; 183 } 184 185 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 186 properties.Label = tbLabel.Text; 171 187 properties.Location = (string)cmbLocation.SelectedItem; 172 } else { 173 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 174 properties.Location = string.Empty; 175 } 176 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 177 properties.Label = tbLabel.Text; 178 properties.Location = (string)cmbLocation.SelectedItem; 179 hostedService.HostedServiceProperties = properties; 180 181 var parameters = Tuple.Create<Subscription, bool, bool, string, string, HostedService, int>(sub, newHostedServiceChecked, regionChecked, certificateFile, certificatePassword, hostedService, instanceCount); 182 183 bwCompleted = false; 184 progressBar.Visible = true; 185 SetAllControlsEnabled(this, false); 186 workerCreate.RunWorkerAsync(parameters); 188 hostedService.HostedServiceProperties = properties; 189 190 var parameters = Tuple.Create<Subscription, bool, bool, string, string, HostedService, int>(sub, newHostedServiceChecked, regionChecked, certificateFile, certificatePassword, hostedService, instanceCount); 191 192 bwCompleted = false; 193 progressBar.Visible = true; 194 SetAllControlsEnabled(this, false); 195 workerCreate.RunWorkerAsync(parameters); 196 } 187 197 } 188 198 } … … 218 228 219 229 private void CreateDoploymentTask(object sender, DoWorkEventArgs e) { 230 bool errorOccured = false; 220 231 Tuple<Subscription, bool, bool, string, string, HostedService, int> parameters = (Tuple<Subscription, bool, bool, string, string, HostedService, int>)e.Argument; 221 232 … … 229 240 230 241 // STEP 1 - Create Hosted Service 231 if (newHostedServiceChecked) { 232 if (regionChecked) { 233 CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, hostedService.ServiceName, hostedService.HostedServiceProperties.Label, hostedService.HostedServiceProperties.Description, hostedService.HostedServiceProperties.Location); 234 } else { 235 CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, hostedService.ServiceName, hostedService.HostedServiceProperties.Label, hostedService.HostedServiceProperties.Description, new AffinityGroup() { Name = hostedService.HostedServiceProperties.AffinityGroup }); 236 } 242 try { 243 if (newHostedServiceChecked) { 244 if (regionChecked) { 245 CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, hostedService.ServiceName, hostedService.HostedServiceProperties.Label, hostedService.HostedServiceProperties.Description, hostedService.HostedServiceProperties.Location); 246 } else { 247 CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, hostedService.ServiceName, hostedService.HostedServiceProperties.Label, hostedService.HostedServiceProperties.Description, new AffinityGroup() { Name = hostedService.HostedServiceProperties.AffinityGroup }); 248 } 249 } 250 } 251 catch (Exception ex) { 252 errorOccured = true; 253 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 237 254 } 238 255 239 256 // STEP 2 - Add Certificate 240 if (certFile != string.Empty) { 241 CloudManagerClient.Instance.AzureProvider.AddCertificate(sub, hostedService, certFile, certPw); 257 try { 258 if ((!errorOccured) && (certFile != string.Empty)) { 259 CloudManagerClient.Instance.AzureProvider.AddCertificate(sub, hostedService, certFile, certPw); 260 } 261 } 262 catch (Exception ex) { 263 errorOccured = true; 264 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 265 if (newHostedServiceChecked) { 266 CloudManagerClient.Instance.AzureProvider.DeleteHostedService(sub, hostedService.ServiceName); 267 } 268 242 269 } 243 270 244 271 // STEP 3 - Create Deployment 245 CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), Constants.DeploymentSlotStaging, Constants.DeploymentPackageUrl, Constants.DeploymentConfigurationUrl, Constants.DeploymentLabel, instanceCount); 246 272 try { 273 if (!errorOccured) { 274 CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), Constants.DeploymentSlotStaging, Constants.DeploymentPackageUrl, Constants.DeploymentConfigurationUrl, Constants.DeploymentLabel, instanceCount); 275 } 276 } 277 catch (Exception ex) { 278 errorOccured = true; 279 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 280 if (newHostedServiceChecked) { 281 CloudManagerClient.Instance.AzureProvider.DeleteHostedService(sub, hostedService.ServiceName); 282 } 283 } 284 285 e.Result = errorOccured; 247 286 } 248 287 … … 251 290 progressBar.Visible = false; 252 291 bwCompleted = true; 292 bool errorOccured = (bool)e.Result; 253 293 if (closePending) { 254 294 this.Close(); 295 } else if (!errorOccured) { 296 this.Close(); 297 } else { 298 this.Show(); 255 299 } 256 300 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.cs
r7362 r7387 24 24 } 25 25 26 private void SetAllControlsEnabled(Form frm, bool isEnabled) { 27 foreach (Control ctrl in frm.Controls) { 28 if (!(ctrl is ProgressBar)) { 29 ctrl.Enabled = isEnabled; 30 } 31 } 32 } 33 26 34 private void btnOk_Click(object sender, System.EventArgs e) { 27 35 this.progressBar.Visible = true; 36 SetAllControlsEnabled(this, false); 28 37 worker.RunWorkerAsync(); 29 38 } … … 38 47 39 48 private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 49 SetAllControlsEnabled(this, true); 40 50 progressBar.Visible = false; 41 51 if (e.Error == null) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/CloudResourcesView.Designer.cs
r7339 r7387 5 5 /// </summary> 6 6 private System.ComponentModel.IContainer components = null; 7 8 /// <summary>9 /// Clean up any resources being used.10 /// </summary>11 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>12 protected override void Dispose(bool disposing) {13 if (disposing && (components != null)) {14 components.Dispose();15 }16 base.Dispose(disposing);17 }18 7 19 8 #region Component Designer generated code … … 106 95 // treeCloudResources 107 96 // 108 this.treeCloudResources.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 109 | System.Windows.Forms.AnchorStyles.Left) 97 this.treeCloudResources.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 98 | System.Windows.Forms.AnchorStyles.Left) 110 99 | System.Windows.Forms.AnchorStyles.Right))); 111 100 this.treeCloudResources.ImageIndex = 0; -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/CloudResourcesView.cs
r7339 r7387 1 1 using System; 2 2 using System.Diagnostics; 3 using System.Threading;4 3 using System.Timers; 5 4 using System.Windows.Forms; … … 16 15 private int updateInterval = 15000; 17 16 private DateTime dueTime; 17 18 18 private const int subscriptionImageIndex = 0; 19 19 private const int serviceImageIndex = 1; 20 private const int deploymentImageIndex = 2; 20 21 21 22 public new IItemList<Subscription> Content { … … 24 25 } 25 26 27 private IItemList<HostedService> hostedServices; 28 public IItemList<HostedService> HostedServices { 29 get { return hostedServices; } 30 set { hostedServices = value; } 31 } 32 26 33 public CloudResourcesView() { 27 34 InitializeComponent(); 28 35 36 treeCloudResources.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NewFolder); 29 37 treeCloudResources.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge); 30 38 treeCloudResources.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge); 31 39 40 HostedServices = CloudManagerClient.Instance.HostedServices; 32 41 Content = CloudManagerClient.Instance.Subscriptions; 42 43 33 44 CloudManagerClient.Instance.Refreshing += new EventHandler(Instance_Refreshing); 34 45 CloudManagerClient.Instance.Refreshed += new EventHandler(Instance_Refreshed); … … 41 52 } 42 53 43 public new void Dispose() {44 CloudManagerClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing);45 CloudManagerClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed);46 timer.Dispose();47 Debug.WriteLine("Dispose");48 }49 50 54 #region Register Content Events 51 55 protected override void DeregisterContentEvents() { … … 60 64 } 61 65 #endregion 66 67 /// <summary> 68 /// Clean up any resources being used. 69 /// </summary> 70 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 71 protected override void Dispose(bool disposing) { 72 if (disposing && (components != null)) { 73 components.Dispose(); 74 CloudManagerClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing); 75 CloudManagerClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed); 76 timer.Stop(); 77 timer.Dispose(); 78 timer = null; 79 } 80 base.Dispose(disposing); 81 } 62 82 63 83 protected override void SetEnabledStateOfControls() { … … 81 101 treeCloudResources.Nodes.Clear(); 82 102 } else { 103 treeCloudResources.BeginUpdate(); 83 104 treeCloudResources.Nodes.Clear(); 84 105 foreach (Subscription sub in Content) { 85 TreeNode tn = new TreeNode(); 86 tn.Tag = sub; 87 tn.Text = sub.SubscriptionName; 88 tn.ImageIndex = subscriptionImageIndex; 89 tn.SelectedImageIndex = tn.ImageIndex; 90 treeCloudResources.Nodes.Add(tn); 106 TreeNode nodeSub = new TreeNode(); 107 nodeSub.Tag = sub; 108 nodeSub.Text = sub.SubscriptionName; 109 nodeSub.ImageIndex = subscriptionImageIndex; 110 nodeSub.SelectedImageIndex = nodeSub.ImageIndex; 111 112 foreach (HostedService s in HostedServices) { 113 if (s.SubscriptionId == sub.SubscriptionID) { 114 TreeNode nodeServ = new TreeNode(); 115 nodeServ.Tag = s; 116 nodeServ.Text = s.HostedServiceProperties.Label; 117 nodeServ.ImageIndex = serviceImageIndex; 118 nodeServ.SelectedImageIndex = nodeServ.ImageIndex; 119 120 foreach (Deployment d in s.Deployments) { 121 TreeNode nodeDepl = new TreeNode(); 122 nodeDepl.Tag = d; 123 nodeDepl.Text = d.Label + " (" + d.DeploymentSlot + ")"; 124 nodeDepl.ImageIndex = deploymentImageIndex; 125 nodeDepl.SelectedImageIndex = nodeDepl.ImageIndex; 126 nodeServ.Nodes.Add(nodeDepl); 127 } 128 nodeSub.Nodes.Add(nodeServ); 129 } 130 } 131 treeCloudResources.Nodes.Add(nodeSub); 91 132 } 133 treeCloudResources.EndUpdate(); 92 134 } 93 135 } … … 95 137 private void Instance_Refreshing(object sender, EventArgs e) { 96 138 Debug.WriteLine("Instance_Refreshing"); 139 //if (treeCloudResources.InvokeRequired) { 140 // treeCloudResources.Invoke((MethodInvoker)delegate { OnContentChanged(); }); 141 //} else { 142 // OnContentChanged(); 143 //} 97 144 } 98 145 99 146 private void Instance_Refreshed(object sender, EventArgs e) { 100 147 Debug.WriteLine("Instance_Refreshed"); 148 if (treeCloudResources.InvokeRequired) { 149 treeCloudResources.Invoke((MethodInvoker)delegate { OnContentChanged(); }); 150 } else { 151 OnContentChanged(); 152 } 101 153 } 102 154 … … 120 172 // statistics 121 173 Debug.WriteLine("perform update"); 122 Thread.Sleep(1000);174 CloudManagerClient.Instance.Refresh(); 123 175 124 176 dueTime = DateTime.Now.AddMilliseconds(updateInterval); 125 timer.Start(); 177 if (timer != null) { 178 timer.Start(); 179 } 126 180 } 127 181 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/HiveCloudManagerView.cs
r7324 r7387 39 39 InitializeComponent(); 40 40 cloudResourcesView.Content = CloudManagerClient.Instance.Subscriptions; 41 cloudResourcesView.HostedServices = CloudManagerClient.Instance.HostedServices; 41 42 } 42 43
Note: See TracChangeset
for help on using the changeset viewer.