Ejemplo n.º 1
0
        public async Task SetSubscriptionContext(AzureSubscription azureSubscription)
        {
            if (BeforeAzureSubscriptionChange != null)
            {
                await BeforeAzureSubscriptionChange?.Invoke(this);
            }

            if (azureSubscription != null)
            {
                if (azureSubscription.Parent != null)
                {
                    if (azureSubscription.Parent != this._AzureTenant)
                    {
                        await SetTenantContext(azureSubscription.Parent);
                    }
                }
            }

            _AzureSubscription = azureSubscription;

            if (_AzureSubscription != null)
            {
                if (_TokenProvider != null)
                {
                    await _TokenProvider.GetToken(_AzureSubscription);
                }

                await _AzureRetriever.SetSubscriptionContext(_AzureSubscription);
            }

            if (AfterAzureSubscriptionChange != null)
            {
                await AfterAzureSubscriptionChange?.Invoke(this);
            }
        }
Ejemplo n.º 2
0
        public async Task SetSubscriptionContext(AzureSubscription azureSubscription)
        {
            if (azureSubscription != _AzureSubscription)
            {
                if (BeforeAzureSubscriptionChange != null)
                {
                    await BeforeAzureSubscriptionChange?.Invoke(this);
                }

                if (azureSubscription != null)
                {
                    if (azureSubscription.AzureTenant != this.AzureTenant)
                    {
                        await SetTenantContext(azureSubscription.AzureTenant);
                    }
                }

                _AzureSubscription = azureSubscription;

                if (AfterAzureSubscriptionChange != null)
                {
                    await AfterAzureSubscriptionChange?.Invoke(this);
                }
            }
        }
Ejemplo n.º 3
0
        public async Task SetSubscriptionContext(AzureSubscription azureSubscription)
        {
            if (azureSubscription != _AzureSubscription)
            {
                if (BeforeAzureSubscriptionChange != null)
                {
                    await BeforeAzureSubscriptionChange?.Invoke(this);
                }

                if (azureSubscription != null)
                {
                    if (azureSubscription.AzureTenant != this.AzureTenant)
                    {
                        await SetTenantContext(azureSubscription.AzureTenant);
                    }

                    await azureSubscription.InitializeChildrenAsync();

                    await azureSubscription.BindArmResources(_TargetSettings);
                }

                _AzureSubscription = azureSubscription;

                if (AfterAzureSubscriptionChange != null)
                {
                    await AfterAzureSubscriptionChange?.Invoke(this);
                }
            }
        }
Ejemplo n.º 4
0
        public async Task SetSubscriptionContext(AzureSubscription azureSubscription)
        {
            if (BeforeAzureSubscriptionChange != null)
            {
                await BeforeAzureSubscriptionChange?.Invoke(this);
            }

            _AzureSubscription = azureSubscription;

            if (_AzureSubscription != null)
            {
                if (_TokenProvider != null)
                {
                    await _TokenProvider.GetToken(_AzureSubscription);
                }

                if (_AzureRetriever == null)
                {
                    _AzureRetriever = new AzureRetriever(this);
                }

                await _AzureRetriever.SetSubscriptionContext(_AzureSubscription);
            }

            if (AfterAzureSubscriptionChange != null)
            {
                await AfterAzureSubscriptionChange?.Invoke(this);
            }
        }
Ejemplo n.º 5
0
        private async Task _AzureContext_AfterAzureSubscriptionChange(AzureContext sender)
        {
            try
            {
                ResetForm();

                if (sender.AzureSubscription != null)
                {
                    switch (cmbAzureResourceTypeSource.SelectedItem.ToString())
                    {
                    case "Azure Service Management (ASM / Classic)":
                        await BindAsmResources(sender, _TargetSettings);

                        break;

                    case "Azure Resource Manager (ARM)":
                        treeViewSourceResourceManager1.Enabled = true;
                        treeViewSourceResourceManager1.Visible = true;
                        await sender.AzureSubscription.InitializeChildrenAsync();

                        await sender.AzureSubscription.BindArmResources(_TargetSettings);

                        await treeViewSourceResourceManager1.BindArmResources(sender, sender.AzureSubscription, _TargetSettings);

                        break;

                    default:
                        throw new ArgumentException("Unexpected Source Resource Tab: " + cmbAzureResourceTypeSource.SelectedValue);
                    }

                    _AzureContextSource.AzureRetriever.SaveRestCache();
                }
            }
            catch (Exception exc)
            {
                UnhandledExceptionDialog unhandledException = new UnhandledExceptionDialog(_AzureContextSource.LogProvider, exc);
                unhandledException.ShowDialog();
            }

            _AzureContextSource.StatusProvider.UpdateStatus("Ready");

            AfterAzureSubscriptionChange?.Invoke(sender);
        }