public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == "MSMQ"),
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Does.Contain("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            // null queues will default to default names
            p = new ServiceControlQueueNameValidator(new ServiceControlNewInstance())
            {
                Instances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
            Assert.That(ex.Message, Does.Contain("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));
        }
Esempio n. 2
0
        protected override void ProcessRecord()
        {
            var details = new ServiceControlNewInstance
            {
                InstallPath             = InstallPath,
                LogPath                 = LogPath,
                DBPath                  = DBPath,
                Name                    = Name,
                DisplayName             = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName,
                ServiceDescription      = Description,
                HostName                = HostName,
                Port                    = Port,
                DatabaseMaintenancePort = DatabaseMaintenancePort,
                VirtualDirectory        = VirtualDirectory,
                AuditLogQueue           = AuditLogQueue,
                AuditQueue              = AuditQueue,
                ErrorLogQueue           = ErrorLogQueue,
                ErrorQueue              = ErrorQueue,
                ForwardAuditMessages    = ForwardAuditMessages,
                ForwardErrorMessages    = ForwardErrorMessages,
                ConnectionString        = ConnectionString,
                TransportPackage        = ServiceControlCoreTransports.All.First(t => t.Matches(Transport)),
                AuditRetentionPeriod    = AuditRetentionPeriod,
                ErrorRetentionPeriod    = ErrorRetentionPeriod
            };

            details.Save(OutputFile);
        }
        protected override void ProcessRecord()
        {
            var psPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(UnattendFile, out _, out _);

            var details = ServiceControlNewInstance.Load(psPath);

            details.ServiceAccount    = ServiceAccount;
            details.ServiceAccountPwd = Password;
            var zipfolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path);
            var logger    = new PSLogger(Host);
            var installer = new UnattendServiceControlInstaller(logger, zipfolder);

            try
            {
                logger.Info("Installing Service Control instance...");
                if (installer.Add(details, PromptToProceed))
                {
                    var instance = InstanceFinder.FindServiceControlInstance(details.Name);
                    if (instance != null)
                    {
                        WriteObject(PsServiceControl.FromInstance(instance));
                    }
                    else
                    {
                        throw new Exception("Unknown error creating instance");
                    }
                }
            }
            catch (Exception ex)
            {
                ThrowTerminatingError(new ErrorRecord(ex, null, ErrorCategory.NotSpecified, null));
            }
        }
        public void EnsureDuplicateQueueNamesAreAllowedOnSameTransportWithDifferentConnectionString()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage     = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.RabbitMQConventionalRoutingTopology),
                ErrorQueue           = "RMQerror",
                ErrorLogQueue        = "RMQerrorlog",
                ConnectionString     = "afakeconnectionstring",
                ForwardErrorMessages = true
            };

            var p = new QueueNameValidator(newInstance)
            {
                SCInstances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherServiceControlInstance());

            Assert.That(ex.Message, Does.Contain("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            newInstance.ConnectionString = "differentconnectionstring";
            p = new QueueNameValidator(newInstance)
            {
                SCInstances = instances
            };
            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherServiceControlInstance());
        }
        public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldThrow()
        {
            var expectedError = "Some queue names specified are already assigned to another ServiceControl instance - Correct the values for ErrorLogQueue, ErrorQueue";
            var newInstance   = new ServiceControlNewInstance
            {
                TransportPackage     = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
                ErrorLogQueue        = "errorlog",
                ErrorQueue           = "error",
                ForwardErrorMessages = true
            };

            var p = new QueueNameValidator(newInstance)
            {
                SCInstances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherServiceControlInstance());

            Assert.That(ex.Message, Does.Contain(expectedError));

            expectedError = "The queue name for ErrorQueue is already assigned to another ServiceControl instance";

            // with default names
            var defaultInstance = new ServiceControlNewInstance
            {
                ErrorQueue = "Error"
            };

            p = new QueueNameValidator(defaultInstance)
            {
                SCInstances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherServiceControlInstance());
            Assert.That(ex.Message, Does.Contain(expectedError));
        }
Esempio n. 6
0
        public void DuplicateQueueNamesAreAllowedOnDifferentTransports_ShouldNotThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "RabbitMQ",
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            // null queues will default to default names
            p = new ServiceControlQueueNameValidator(new ServiceControlNewInstance())
            {
                Instances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));
        }
Esempio n. 7
0
        public void EnsureDuplicateQueueNamesAreAllowedOnSameTransportWithDifferentConnectionString()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "RabbitMQ",
                AuditQueue       = "RMQaudit",
                AuditLogQueue    = "RMQauditlog",
                ErrorQueue       = "RMQerror",
                ErrorLogQueue    = "RMQerrorlog",
                ConnectionString = "afakeconnectionstring"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            newInstance.ConnectionString = "differentconnectionstring";
            p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
        }
        private async Task Add(object arg)
        {
            viewModel.SubmitAttempted = true;
            if (!viewModel.ValidationTemplate.Validate())
            {
                viewModel.NotifyOfPropertyChange(string.Empty);
                viewModel.SubmitAttempted = false;
                windowManager.ScrollFirstErrorIntoView(viewModel);

                return;
            }

            viewModel.InProgress = true;

            var instanceMetadata = new ServiceControlNewInstance
            {
                DisplayName             = viewModel.InstanceName,
                Name                    = viewModel.InstanceName.Replace(' ', '.'),
                ServiceDescription      = viewModel.Description,
                DBPath                  = viewModel.DatabasePath,
                LogPath                 = viewModel.LogPath,
                InstallPath             = viewModel.DestinationPath,
                HostName                = viewModel.HostName,
                Port                    = Convert.ToInt32(viewModel.PortNumber),
                DatabaseMaintenancePort = Convert.ToInt32(viewModel.DatabaseMaintenancePortNumber),
                VirtualDirectory        = null, // TODO
                AuditLogQueue           = viewModel.AuditForwarding.Value ? viewModel.AuditForwardingQueueName  : null,
                AuditQueue              = viewModel.AuditQueueName,
                ForwardAuditMessages    = viewModel.AuditForwarding.Value,
                ErrorQueue              = viewModel.ErrorQueueName,
                ErrorLogQueue           = viewModel.ErrorForwarding.Value ? viewModel.ErrorForwardingQueueName : null,
                TransportPackage        = viewModel.SelectedTransport.Name,
                ConnectionString        = viewModel.ConnectionString,
                ErrorRetentionPeriod    = viewModel.ErrorRetentionPeriod,
                AuditRetentionPeriod    = viewModel.AuditRetentionPeriod,
                ServiceAccount          = viewModel.ServiceAccount,
                ServiceAccountPwd       = viewModel.Password
            };

            using (var progress = viewModel.GetProgressObject("ADDING INSTANCE"))
            {
                var reportCard = await Task.Run(() => installer.Add(instanceMetadata, progress, PromptToProceed));

                if (reportCard.HasErrors || reportCard.HasWarnings)
                {
                    windowManager.ShowActionReport(reportCard, "ISSUES ADDING INSTANCE", "Could not add new instance because of the following errors:", "There were some warnings while adding the instance:");
                    return;
                }

                if (reportCard.CancelRequested)
                {
                    return;
                }
            }

            viewModel.TryClose(true);

            eventAggregator.PublishOnUIThread(new RefreshInstances());
        }
Esempio n. 9
0
        public static void Validate(ServiceControlNewInstance instance)
        {
            var validator = new ServiceControlQueueNameValidator(instance)
            {
                Instances = InstanceFinder.ServiceControlInstances().Where(p => p.Name != instance.Name & p.TransportPackage.Equals(instance.TransportPackage, StringComparison.OrdinalIgnoreCase)).AsEnumerable <IServiceControlTransportConfig>().ToList()
            };

            validator.RunValidation();
        }
        protected override void ProcessRecord()
        {
            var details = new ServiceControlNewInstance
            {
                InstallPath             = InstallPath,
                LogPath                 = LogPath,
                DBPath                  = DBPath,
                Name                    = Name,
                DisplayName             = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName,
                ServiceDescription      = Description,
                ServiceAccount          = ServiceAccount,
                ServiceAccountPwd       = ServiceAccountPassword,
                HostName                = HostName,
                Port                    = Port,
                DatabaseMaintenancePort = DatabaseMaintenancePort,
                VirtualDirectory        = VirtualDirectory,
                AuditQueue              = AuditQueue,
                ErrorQueue              = ErrorQueue,
                AuditLogQueue           = string.IsNullOrWhiteSpace(AuditLogQueue) ? null : AuditLogQueue,
                ErrorLogQueue           = string.IsNullOrWhiteSpace(ErrorLogQueue) ? null : ErrorLogQueue,
                ForwardAuditMessages    = ForwardAuditMessages.ToBool(),
                ForwardErrorMessages    = ForwardErrorMessages.ToBool(),
                AuditRetentionPeriod    = AuditRetentionPeriod,
                ErrorRetentionPeriod    = ErrorRetentionPeriod,
                ConnectionString        = ConnectionString,
                TransportPackage        = ServiceControlCoreTransports.All.First(t => t.Matches(Transport)),
                SkipQueueCreation       = SkipQueueCreation
            };

            var zipfolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path);
            var logger    = new PSLogger(Host);

            var installer = new UnattendServiceControlInstaller(logger, zipfolder);

            try
            {
                logger.Info("Installing Service Control instance...");
                if (installer.Add(details, PromptToProceed))
                {
                    var instance = InstanceFinder.FindServiceControlInstance(details.Name);
                    if (instance != null)
                    {
                        WriteObject(PsServiceControl.FromInstance(instance));
                    }
                    else
                    {
                        throw new Exception("Unknown error creating instance");
                    }
                }
            }
            catch (Exception ex)
            {
                ThrowTerminatingError(new ErrorRecord(ex, null, ErrorCategory.NotSpecified, null));
            }
        }
Esempio n. 11
0
        public void CheckPathsAreValid_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\bin",
                LogPath     = @"c:\test\1\bin",
                DBPath      = @"c:\test\1\bin"
            };

            var p = new PathsValidator(newInstance);

            Assert.DoesNotThrow(() => p.CheckPathsAreValid());
        }
Esempio n. 12
0
        public void CheckNoNestedSiblingPaths_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\servicecontrol",
                LogPath     = @"c:\test\1\servicecontrollog",
                DBPath      = @"c:\test\1\servicecontroldb"
            };

            var p = new PathsValidator(newInstance);

            Assert.DoesNotThrow(() => p.CheckNoNestedPaths());
        }
Esempio n. 13
0
        public void CheckNoNestedPaths_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1",
                LogPath     = @"c:\test\1\log",
                DBPath      = @"c:\test\1\db"
            };

            var p  = new PathsValidator(newInstance);
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckNoNestedPaths());

            Assert.That(ex.Message, Does.Contain("Nested paths are not supported"));
        }
Esempio n. 14
0
        public void CheckPathsAreUnique_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\bin",
                LogPath     = @"c:\test\1\bin",
                DBPath      = @"c:\test\1\bin"
            };

            var p = new PathsValidator(newInstance);

            var ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsAreUnique());

            Assert.That(ex.Message, Is.EqualTo("The installation path, log path and database path must be unique"));
        }
        public void CheckQueueNamesAreUniqueShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
                ErrorLogQueue    = "errorlog",
                ErrorQueue       = "error"
            };

            var p = new QueueNameValidator(newInstance)
            {
                SCInstances = new List <IServiceControlInstance>()
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreUniqueWithinInstance());
        }
        public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
                ErrorLogQueue    = "errorlog2",
                ErrorQueue       = "error2"
            };

            var p = new QueueNameValidator(newInstance)
            {
                SCInstances = instances
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherServiceControlInstance());
        }
        async Task <bool> InstallInstance(ServiceControlNewInstance instanceData, IProgressObject progress)
        {
            var reportCard = await Task.Run(() => serviceControlInstaller.Add(instanceData, progress, PromptToProceed));

            if (reportCard.HasErrors || reportCard.HasWarnings)
            {
                windowManager.ShowActionReport(reportCard, "ISSUES ADDING INSTANCE", "Could not add new instance because of the following errors:", "There were some warnings while adding the instance:");
                return(true);
            }

            if (reportCard.CancelRequested)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 18
0
        public void CheckQueueNamesAreUniqueShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = new List <IServiceControlTransportConfig>()
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreUniqueWithinInstance());
        }
Esempio n. 19
0
        public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "auditlog2",
                ErrorLogQueue    = "errorlog2",
                AuditQueue       = "audit2",
                ErrorQueue       = "error2"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
        }
        public void CheckQueueNamesAreUniqueShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage     = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
                ErrorLogQueue        = "error",
                ErrorQueue           = "error",
                ForwardErrorMessages = true
            };

            var p = new QueueNameValidator(newInstance)
            {
                SCInstances = new List <IServiceControlInstance>()
            };

            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreUniqueWithinInstance());

            Assert.That(ex.Message, Does.Contain("Each of the queue names specified for a instance should be unique"));
        }
Esempio n. 21
0
        public void CheckQueueNamesAreUniqueShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "audit",
                ErrorLogQueue    = "error",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = new List <IServiceControlTransportConfig>()
            };

            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreUniqueWithinInstance());

            Assert.That(ex.Message, Is.StringContaining("Each of the queue names specified for a instance should be unique"));
        }
Esempio n. 22
0
        internal ReportCard Add(ServiceControlNewInstance details, IProgress <ProgressDetails> progress, Func <PathInfo, bool> promptToProceed)
        {
            ZipInfo.ValidateZip();

            var instanceInstaller = details;

            instanceInstaller.ReportCard = new ReportCard();

            //Validation
            instanceInstaller.Validate(promptToProceed);
            if (instanceInstaller.ReportCard.HasErrors || instanceInstaller.ReportCard.CancelRequested)
            {
                instanceInstaller.ReportCard.Status = Status.FailedValidation;
                return(instanceInstaller.ReportCard);
            }

            progress.Report(3, 9, "Copying files...");
            instanceInstaller.CopyFiles(ZipInfo.FilePath);
            progress.Report(4, 9, "Writing configurations...");
            instanceInstaller.WriteConfigurationFile();
            progress.Report(5, 9, "Registering URL ACLs...");
            instanceInstaller.RegisterUrlAcl();
            progress.Report(6, 9, "Creating queues...");
            instanceInstaller.SetupInstance();

            if (!instanceInstaller.ReportCard.HasErrors)
            {
                progress.Report(7, 9, "Registering service...");
                instanceInstaller.RegisterService();
                //Post Installation
                progress.Report(8, 9, "Starting service...");
                var instance = InstanceFinder.FindServiceControlInstance(instanceInstaller.Name);
                if (!instance.TryStartService())
                {
                    instanceInstaller.ReportCard.Warnings.Add($"New instance did not startup - please check configuration for {instance.Name}");
                }
            }

            instanceInstaller.ReportCard.SetStatus();
            return(instanceInstaller.ReportCard);
        }
Esempio n. 23
0
        public void CreateInstanceMSMQ()
        {
            var installer    = new UnattendServiceControlInstaller(new TestLogger(), DeploymentCache);
            var instanceName = "Test.ServiceControl.Msmq";
            var root         = Path.Combine(@"c:\Test", instanceName);
            // ReSharper disable once UseObjectOrCollectionInitializer
            var details = new ServiceControlNewInstance
            {
                DisplayName             = instanceName.Replace(".", " "),
                Name                    = instanceName,
                ServiceDescription      = "Test SC Instance",
                DBPath                  = Path.Combine(root, "Database"),
                LogPath                 = Path.Combine(root, "Logs"),
                InstallPath             = Path.Combine(root, "Binaries"),
                HostName                = "localhost",
                Port                    = 33335,
                DatabaseMaintenancePort = 33336,
                VirtualDirectory        = null,
                AuditQueue              = "audittest",
                ForwardAuditMessages    = false,
                ForwardErrorMessages    = false,
                //TODO: Fix
                //AuditRetentionPeriod = TimeSpan.FromHours(SettingConstants.AuditRetentionPeriodDefaultInHoursForUI),
                ErrorRetentionPeriod = TimeSpan.FromDays(SettingConstants.ErrorRetentionPeriodDefaultInDaysForUI),
                ErrorQueue           = "testerror",
                TransportPackage     = ServiceControlCoreTransports.All.First(t => t.Name == TransportNames.MSMQ),
                ReportCard           = new ReportCard()
            };

            // constructer of ServiceControlInstanceMetadata extracts version from zip
            // but this fails for unit tests as the deploymentCache path is not used
            details.Version = installer.ZipInfo.Version;

            details.Validate(s => false);
            if (details.ReportCard.HasErrors)
            {
                throw new Exception($"Validation errors:  {string.Join("\r\n", details.ReportCard.Errors)}");
            }

            Assert.DoesNotThrow(() => installer.Add(details, s => false));
        }
        static void UnattendedInstall(Session session, MSILogger logger, UnattendServiceControlInstaller unattendedInstaller)
        {
            logger.Info("Checking for unattended file");

            var unattendedFilePropertyValue = session["UNATTENDEDFILE"];

            if (string.IsNullOrWhiteSpace(unattendedFilePropertyValue))
            {
                return;
            }

            var serviceAccount = session["SERVICEACCOUNT"];
            var password       = session["PASSWORD"];

            logger.Info($"UNATTENDEDFILE: {unattendedFilePropertyValue}");
            var currentDirectory   = session["CURRENTDIRECTORY"];
            var unattendedFilePath = Environment.ExpandEnvironmentVariables(Path.IsPathRooted(unattendedFilePropertyValue) ? unattendedFilePropertyValue : Path.Combine(currentDirectory, unattendedFilePropertyValue));

            logger.Info($"Expanded unattended filepath to : {unattendedFilePropertyValue}");

            if (File.Exists(unattendedFilePath))
            {
                logger.Info($"File Exists : {unattendedFilePropertyValue}");
                var instanceToInstallDetails = ServiceControlNewInstance.Load(unattendedFilePath);

                if (!string.IsNullOrWhiteSpace(serviceAccount))
                {
                    instanceToInstallDetails.ServiceAccount    = serviceAccount;
                    instanceToInstallDetails.ServiceAccountPwd = password;
                }

                unattendedInstaller.Add(instanceToInstallDetails, s => false);
            }
            else
            {
                logger.Error($"The specified unattended install file was not found : '{unattendedFilePath}'");
            }
        }
Esempio n. 25
0
        public bool Add(ServiceControlNewInstance details, Func <PathInfo, bool> promptToProceed)
        {
            ZipInfo.ValidateZip();

            var checkLicenseResult = CheckLicenseIsValid();

            if (!checkLicenseResult.Valid)
            {
                logger.Error($"Install aborted - {checkLicenseResult.Message}");
                return(false);
            }

            var instanceInstaller = details;

            instanceInstaller.ReportCard = new ReportCard();

            //Validation
            instanceInstaller.Validate(promptToProceed);
            if (instanceInstaller.ReportCard.HasErrors)
            {
                foreach (var error in instanceInstaller.ReportCard.Errors)
                {
                    logger.Error(error);
                }
                return(false);
            }

            try
            {
                instanceInstaller.CopyFiles(ZipInfo.FilePath);
                instanceInstaller.WriteConfigurationFile();
                instanceInstaller.RegisterUrlAcl();
                instanceInstaller.SetupInstance();
                instanceInstaller.RegisterService();
                foreach (var warning in instanceInstaller.ReportCard.Warnings)
                {
                    logger.Warn(warning);
                }

                if (instanceInstaller.ReportCard.HasErrors)
                {
                    foreach (var error in instanceInstaller.ReportCard.Errors)
                    {
                        logger.Error(error);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return(false);
            }

            //Post Installation
            var instance = InstanceFinder.FindServiceControlInstance(instanceInstaller.Name);

            if (!instance.TryStartService())
            {
                logger.Warn("The service failed to start");
            }
            return(true);
        }
        async Task Add(object arg)
        {
            viewModel.SubmitAttempted = true;
            if (!viewModel.ValidationTemplate.Validate())
            {
                viewModel.NotifyOfPropertyChange(string.Empty);
                viewModel.SubmitAttempted = false;
                windowManager.ScrollFirstErrorIntoView(viewModel);

                return;
            }

            viewModel.InProgress = true;

            var serviceControlNewInstance = new ServiceControlNewInstance
            {
                DisplayName             = viewModel.ServiceControl.InstanceName,
                Name                    = viewModel.ServiceControl.InstanceName.Replace(' ', '.'),
                ServiceDescription      = viewModel.ServiceControl.Description,
                DBPath                  = viewModel.ServiceControl.DatabasePath,
                LogPath                 = viewModel.ServiceControl.LogPath,
                InstallPath             = viewModel.ServiceControl.DestinationPath,
                HostName                = viewModel.ServiceControl.HostName,
                Port                    = Convert.ToInt32(viewModel.ServiceControl.PortNumber),
                DatabaseMaintenancePort = Convert.ToInt32(viewModel.ServiceControl.DatabaseMaintenancePortNumber),
                VirtualDirectory        = null, // TODO
                ErrorQueue              = viewModel.ServiceControl.ErrorQueueName,
                ErrorLogQueue           = viewModel.ServiceControl.ErrorForwarding.Value ? viewModel.ServiceControl.ErrorForwardingQueueName : null,
                TransportPackage        = viewModel.SelectedTransport,
                ConnectionString        = viewModel.ConnectionString,
                ErrorRetentionPeriod    = viewModel.ServiceControl.ErrorRetentionPeriod,
                ServiceAccount          = viewModel.ServiceControl.ServiceAccount,
                ServiceAccountPwd       = viewModel.ServiceControl.Password
            };

            var auditNewInstance = new ServiceControlAuditNewInstance
            {
                DisplayName                = viewModel.ServiceControlAudit.InstanceName,
                Name                       = viewModel.ServiceControlAudit.InstanceName.Replace(' ', '.'),
                ServiceDescription         = viewModel.ServiceControlAudit.Description,
                DBPath                     = viewModel.ServiceControlAudit.DatabasePath,
                LogPath                    = viewModel.ServiceControlAudit.LogPath,
                InstallPath                = viewModel.ServiceControlAudit.DestinationPath,
                HostName                   = viewModel.ServiceControlAudit.HostName,
                Port                       = Convert.ToInt32(viewModel.ServiceControlAudit.PortNumber),
                DatabaseMaintenancePort    = Convert.ToInt32(viewModel.ServiceControlAudit.DatabaseMaintenancePortNumber),
                AuditLogQueue              = viewModel.ServiceControlAudit.AuditForwarding.Value ? viewModel.ServiceControlAudit.AuditForwardingQueueName : null,
                AuditQueue                 = viewModel.ServiceControlAudit.AuditQueueName,
                ForwardAuditMessages       = viewModel.ServiceControlAudit.AuditForwarding.Value,
                TransportPackage           = viewModel.SelectedTransport,
                ConnectionString           = viewModel.ConnectionString,
                AuditRetentionPeriod       = viewModel.ServiceControlAudit.AuditRetentionPeriod,
                ServiceAccount             = viewModel.ServiceControlAudit.ServiceAccount,
                ServiceAccountPwd          = viewModel.ServiceControlAudit.Password,
                ServiceControlQueueAddress = serviceControlNewInstance.Name
            };

            serviceControlNewInstance.AddRemoteInstance(auditNewInstance.Url);

            using (var progress = viewModel.GetProgressObject("ADDING INSTANCE"))
            {
                var installationCancelled = await InstallInstance(serviceControlNewInstance, progress);

                if (installationCancelled)
                {
                    return;
                }
            }

            using (var progress = viewModel.GetProgressObject("ADDING AUDIT INSTANCE"))
            {
                var installationCancelled = await InstallInstance(auditNewInstance, progress);

                if (installationCancelled)
                {
                    return;
                }
            }

            viewModel.TryClose(true);

            eventAggregator.PublishOnUIThread(new RefreshInstances());
        }