Beispiel #1
0
        private async void HandleDownloadPackageClicked(object sender, EventArgs e)
        {
            LogMethodEntry();
            _parent.ColorTab(_id, null);
            await PerformWorkAsync(null, async() =>
            {
                var subscription   = cbSubscriptions.SelectedItem as SubscriptionListOperationResponse.Subscription;
                var service        = cbCloudservices.SelectedItem as HostedServiceListResponse.HostedService;
                var packageStorage = cbPackageStorage.SelectedItem as StorageAccount;
                var slot           = (DeploymentSlot)cbSlot.SelectedItem;

                try
                {
                    if (!CheckAndChoosePackageDownloadLocation())
                    {
                        throw new ApplicationException("A download location for packages must be selected");
                    }
                    if (subscription == null)
                    {
                        throw new ApplicationException("Subscription must be selectered");
                    }
                    if (service == null)
                    {
                        throw new ApplicationException("Cloudservice must be selected");
                    }
                    if (packageStorage == null)
                    {
                        throw new ApplicationException("Package storage account must be selected");
                    }

                    try
                    {
                        await AzureHelper.DownloadDeploymentAsync(_id, subscription, service, slot, packageStorage, Configuration.Instance.PackageDownloadPath);

                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Package downloaded", ToolTipIcon.Info);
                        _parent.ColorTab(_id, Color.LightGreen);
                    }
                    catch (CloudException cex)
                    {
                        Logger.Error("[" + _id + "] " + cex.Message);
                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed downloading package", ToolTipIcon.Error);
                        _parent.ColorTab(_id, Color.LightPink);
                    }
                    catch (StorageException sex)
                    {
                        Logger.Error("[" + _id + "] " + sex.Message);
                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed downloading package", ToolTipIcon.Error);
                        _parent.ColorTab(_id, Color.LightPink);
                    }
                }
                catch (ApplicationException aex)
                {
                    // We use ApplicationExceptions to indicate a custom error. All other errors will result in a ReportBug dialog.
                    MessageBox.Show(this, "[" + _id + "] " + "Package download failed: " + aex.Message);
                }
            });
        }
Beispiel #2
0
        private async void HandleDeployClicked(object sender, EventArgs e)
        {
            Logger.Debug("[" + _id + "] " + "HandleDeployClicked");
            _parent.ColorTab(_id, null);
            await PerformWorkAsync(bgwork : null, fgwork : async() =>
            {
                try
                {
                    var subscription     = cbSubscriptions.SelectedItem as SubscriptionListOperationResponse.Subscription;
                    var service          = cbCloudservices.SelectedItem as HostedServiceListResponse.HostedService;
                    var packageStorage   = cbPackageStorage.SelectedItem as StorageAccount;
                    var slot             = (DeploymentSlot)cbSlot.SelectedItem;
                    var pref             = ((KeyValuePair <UpgradePreference, string>)cbUpgradePreference.SelectedItem).Key;
                    var diagstorage      = cbDiagStorage.SelectedItem as StorageAccount;
                    lblLabelPreview.Text = GetRenderedLabel();
                    var deploymentLabel  = GetRenderedLabel();

                    if (Configuration.Instance.AutoDownloadPackageBeforeDeploy && !CheckAndChoosePackageDownloadLocation())
                    {
                        throw new ApplicationException("A download location for packages must be selected");
                    }
                    if (subscription == null)
                    {
                        throw new ApplicationException("Subscription must be selected");
                    }
                    if (service == null)
                    {
                        throw new ApplicationException("Cloudservice must be selected");
                    }
                    if (packageStorage == null)
                    {
                        throw new ApplicationException("Package storage account must be selected");
                    }
                    if (_selectedPackage == null)
                    {
                        throw new ApplicationException("A .cspkg file must be selected");
                    }
                    if (_selectedConfig == null)
                    {
                        throw new ApplicationException("A .cscfg file must be selected");
                    }
                    if (_selectedDiag == null)
                    {
                        if (MessageBox.Show("Diagnostics configuration is not selected. Are you sure you want to continue?", "Diagnostics Configuration", MessageBoxButtons.YesNo) != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                    if (!File.Exists(_selectedPackage))
                    {
                        throw new ApplicationException("The specified .cspkg no longer exists on the filesystem: " + _selectedPackage);
                    }
                    if (!File.Exists(_selectedConfig))
                    {
                        throw new ApplicationException("The specified .cscfg no longer exists on the filesystem:" + _selectedConfig);
                    }
                    if (_selectedDiag != null && !File.Exists(_selectedDiag))
                    {
                        throw new ApplicationException("The specified diagnostics configuration file no longer exists on the filesystem: " + _selectedDiag);
                    }

                    try
                    {
                        if (Configuration.Instance.AutoDownloadPackageBeforeDeploy)
                        {
                            await AzureHelper.DownloadDeploymentAsync(_id, subscription, service, slot, packageStorage, Configuration.Instance.PackageDownloadPath, true);
                        }

                        await AzureHelper.DeployAsync(_id, subscription, service, packageStorage, slot, pref, _selectedPackage, _selectedConfig, _selectedDiag, diagstorage, deploymentLabel, Configuration.Instance.CleanupUnusedExtensions, cbForceUpgrade.Checked);

                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Successfully deployed", ToolTipIcon.Info);
                        _parent.ColorTab(_id, Color.LightGreen);
                    }
                    catch (CloudException cex)
                    {
                        Logger.Error("[" + _id + "] " + cex.Message);
                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed deployment", ToolTipIcon.Error);
                        _parent.ColorTab(_id, Color.LightPink);
                    }
                    catch (StorageException sex)
                    {
                        Logger.Error("[" + _id + "] " + sex.Message);
                        _parent.ActionCompleted("ACD: " + service.ServiceName + "/" + slot, "Failed deployment", ToolTipIcon.Error);
                        _parent.ColorTab(_id, Color.LightPink);
                    }
                }
                catch (ApplicationException aex)
                {
                    // We use ApplicationExceptions to indicate a custom error. All other errors will result in a ReportBug dialog.
                    MessageBox.Show(this, "[" + _id + "] " + "Deployment failed: " + aex.Message);
                }
            });
        }