private bool GetConfiguration()
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();

            ofd.Title = "Please specify the installation configuration to load...";

            ofd.Filter = "json files (*.json)|*.json";

            if (ofd.ShowDialog() == true)
            {
                DataModel.InstallationConfiguration = InstallationConfiguration.LoadConfiguration(ofd.FileName);
            }
            else
            {
                MessageBox.Show("This operation cannot be completed without loading an installation configuration file. The installer will now exit.");

                Dispatcher.BeginInvoke(new Action(() =>
                {
                    Application.Current.MainWindow.Close();
                }));

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstallerModel"/> class.
        /// </summary>
        /// <param name="mainWindow">The owning UI element.</param>
        public InstallerModel(UIElement mainWindow)
        {
            InstallationConfiguration = new InstallationConfiguration();
            Progress           = new WizardProgress();
            Page               = new WizardPage();
            OperationsProgress = new OperationsProgress();

            InstallationConfiguration.LoadConfiguration();

            ShowCrmLink = false;

            PreviousEnabled = true;
            NextEnabled     = true;

            ShowStatus   = false;
            ShowProgress = false;
            ShowPrevious = false;
            ShowNext     = true;
            ShowCancel   = true;
            ShowFinish   = false;

            InstallerAction = InstallerActionType.New;
        }
        private void QueueOperations(InstallationConfiguration installConfig)
        {
            if (installConfig.Azure.ShouldDelete)
            {
                SequentialRunner.Operations.Enqueue(new Operation()
                {
                    Name = "RemoveAzureResourceGroup",
                    OperationFunction = RemoveAzureResourceGroupAsync,
                    ValidateFunction  = (context) =>
                    {
                        return(context.LastOperationStatusCode == 0);
                    },
                    ExceptionHandler = (ex) =>
                    {
                        DataModel.StatusMessage = "Failed to remove Azure Resource Group!";
                    },
                });
            }

            if (installConfig.Azure.ShouldDeleteAppRegistration)
            {
                SequentialRunner.Operations.Enqueue(new Operation()
                {
                    Name = "RemoveApplicationRegistration",
                    OperationFunction = RemoveApplicationRegistrationAsync,
                    ValidateFunction  = (context) =>
                    {
                        return(context.LastOperationStatusCode == 0);
                    },
                    ExceptionHandler = (ex) =>
                    {
                        DataModel.StatusMessage = "Failed to remove registered application from Azure AD!";
                    },
                });
            }

            if (installConfig.Azure.Luis.ShouldDelete)
            {
                SequentialRunner.Operations.Enqueue(new Operation()
                {
                    Name = "RemoveLuisApplication",
                    OperationFunction = RemoveLuisApplicationAsync,
                    ValidateFunction  = (context) =>
                    {
                        return(context.LastOperationStatusCode == 0);
                    },
                    ExceptionHandler = (ex) =>
                    {
                        DataModel.StatusMessage = "Failed to remove LUIS application!";
                    },
                });
            }

            if (installConfig.PowerApps.ShouldDelete)
            {
                if (installConfig.PowerApps.ShouldOnlyDeleteSolution)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "RemoveDynamicsCRMSolution",
                        OperationFunction = RemoveDynamicsCRMSolutionAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to remove Dynamics 365 CRM solution!";
                        },
                    });
                }
                else
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "RemovePowerAppsEnvironment",
                        OperationFunction = RemovePowerAppsEnvironmentAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to remove PowerApps environment!";
                        },
                    });
                }
            }

            DataModel.OperationsProgress.Operations = SequentialRunner.Operations
                                                      .Select(x => new OperationStatus()
            {
                Id         = x.Id,
                Name       = x.Name,
                StatusCode = OperationStatusCode.NotStarted,
            })
                                                      .ToList();
        }
        private void QueueOperations(InstallationConfiguration installConfig)
        {
            Feature apiAzure = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}"];

            if (apiAzure.ShouldInstall)
            {
                Feature apiFunctions = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.APIFunctions}"];

                if (apiFunctions != null &&
                    apiFunctions.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "UpdateAzureFunctions",
                        OperationFunction = UpdateAzureFunctionsAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to update Azure Function App!";
                        },
                    });
                }

                Feature apiLogicApps = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.LogicApps}"];

                if (apiLogicApps != null &&
                    apiLogicApps.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "UpdateAPIAzureResources",
                        OperationFunction = (context) =>
                        {
                            ResourceGroupDeploymentStatus status = (ResourceGroupDeploymentStatus)UpdateAPIAzureResourcesAsync(context);

                            if (string.Compare("Succeeded", status.Status, true) != 0)
                            {
                                throw new Exception("Resource group deployment failed!");
                            }

                            return(status);
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy Azure resources for API!";
                        },
                    });
                }

                Feature apiLuis = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureLanguageUnderstandingModel}"];

                if (apiLuis != null &&
                    apiLuis.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "UpdateLuisApplication",
                        OperationFunction = UpdateLuisApplicationAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to update LUIS application!";
                        },
                    });
                }
            }

            Feature uiAzure = DataModel.InstallationConfiguration.Features[$"{FeatureNames.UIComponents}\\{FeatureNames.AzureResources}"];

            if (uiAzure.ShouldInstall)
            {
                Feature uiLogicApps = DataModel.InstallationConfiguration.Features[$"{FeatureNames.UIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.LogicApps}"];

                if (uiLogicApps != null &&
                    uiLogicApps.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "UpdateUIAzureResources",
                        OperationFunction = (context) =>
                        {
                            ResourceGroupDeploymentStatus status = (ResourceGroupDeploymentStatus)UpdateUIAzureLogicAppsResourcesAsync(context);

                            if (string.Compare("Succeeded", status.Status, true) != 0)
                            {
                                throw new Exception("Resource group deployment failed!");
                            }

                            return(status);
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy Azure resource updates for UI!";
                        },
                    });
                }
            }

            DataModel.OperationsProgress.Operations = SequentialRunner.Operations
                                                      .Select(x => new OperationStatus()
            {
                Id         = x.Id,
                Name       = x.Name,
                StatusCode = OperationStatusCode.NotStarted,
            })
                                                      .ToList();
        }
Exemplo n.º 5
0
        private void QueueOperations(InstallationConfiguration installConfig)
        {
            Feature apiAzure = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}"];

            if (apiAzure.ShouldInstall)
            {
                Feature azureADAppRegistration = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureADAppRegistration}"];

                if (azureADAppRegistration != null &&
                    azureADAppRegistration.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployAzureADFunctionAppRegistration",
                        OperationFunction         = DeployAzureADFunctionAppRegistrationAsync,
                        OperationCompletedHandler = (result) =>
                        {
                            AzureApplication response = (AzureApplication)result;

                            DataModel.InstallationConfiguration.Azure.FunctionApp.ApplicationId = response.AppId;
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to create application registration in Azure AD for Azure Function App!";
                        },
                    });
                }

                Feature azureRGDeployment = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureRGDeployment}"];

                if (azureRGDeployment != null &&
                    azureRGDeployment.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployAPIAzureResources",
                        OperationFunction = (context) =>
                        {
                            ResourceGroupDeploymentStatus status = (ResourceGroupDeploymentStatus)DeployAPIAzureResourcesAsync(context);

                            if (string.Compare("Succeeded", status.Status, true) != 0)
                            {
                                throw new Exception("Resource group deployment failed!");
                            }

                            return(status);
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy Azure resources for API!";
                        },
                    });
                }

                Feature azureFunctionAppAuth = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureFunctionAppAuthentication}"];

                if (azureFunctionAppAuth != null &&
                    azureFunctionAppAuth.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "SetAzureFunctionAppAuthentication",
                        OperationFunction = SetFunctionAppAuthenticationAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to set authentication settings for Azure Function App!";
                        },
                    });
                }

                Feature azureKeyVaultAccessPolicies = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureKeyVault}"];

                if (azureKeyVaultAccessPolicies != null &&
                    azureKeyVaultAccessPolicies.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployAzureKeyVaultAccessPolicies",
                        OperationFunction = SetKeyVaultAccessPoliciesAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to create access policies on Azure Key Vault!";
                        },
                    });
                }

                Feature azureStorageAccessPolicies = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureStorageAccessPolicies}"];

                if (azureStorageAccessPolicies != null &&
                    azureStorageAccessPolicies.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployAzureStorageStoredAccessPolicies",
                        OperationFunction = DeployStorageAccessPoliciesAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to create stored access policies on Azure Blob container!";
                        },
                    });
                }

                Feature languageUnderstanding = DataModel.InstallationConfiguration.Features[$"{FeatureNames.APIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.AzureLanguageUnderstandingModel}"];

                if (languageUnderstanding != null &&
                    languageUnderstanding.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployLuisApplication",
                        OperationFunction = DeployLuisApplicationAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy LUIS application!";
                        },
                    });
                }
            }

            Feature uiAzure = DataModel.InstallationConfiguration.Features[$"{FeatureNames.UIComponents}\\{FeatureNames.AzureResources}"];

            if (uiAzure.ShouldInstall)
            {
                Feature uiLogicApps = DataModel.InstallationConfiguration.Features[$"{FeatureNames.UIComponents}\\{FeatureNames.AzureResources}\\{FeatureNames.LogicApps}"];

                if (uiLogicApps != null &&
                    uiLogicApps.ShouldInstall)
                {
                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployUIAzureCdsResources",
                        OperationFunction = (context) =>
                        {
                            ResourceGroupDeploymentStatus status = (ResourceGroupDeploymentStatus)DeployUIAzureCdsResourcesAsync(context);

                            if (string.Compare("Succeeded", status.Status, true) != 0)
                            {
                                throw new Exception("Resource group deployment failed!");
                            }

                            return(status);
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy Azure resources for UI (CDS)!";
                        },
                    });

                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "AuthenticateLogicAppsCDSConnection",
                        OperationFunction = AuthorizeCDSConnectionAsync,
                        ValidateFunction  = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to authenticate CDS!";
                        },
                    });

                    SequentialRunner.Operations.Enqueue(new Operation()
                    {
                        Name = "DeployUIAzureResources",
                        OperationFunction = (context) =>
                        {
                            ResourceGroupDeploymentStatus status = (ResourceGroupDeploymentStatus)DeployUIAzureResourcesAsync(context);

                            if (string.Compare("Succeeded", status.Status, true) != 0)
                            {
                                throw new Exception("Resource group deployment failed!");
                            }

                            return(status);
                        },
                        ValidateFunction = (context) =>
                        {
                            return(context.LastOperationStatusCode == 0);
                        },
                        ExceptionHandler = (ex) =>
                        {
                            DataModel.StatusMessage = "Failed to deploy Azure resources for UI!";
                        },
                    });
                }
            }

            DataModel.OperationsProgress.Operations = SequentialRunner.Operations
                                                      .Select(x => new OperationStatus()
            {
                Id         = x.Id,
                Name       = x.Name,
                StatusCode = OperationStatusCode.NotStarted,
            })
                                                      .ToList();
        }