Exemple #1
0
        public static void Validate(IServiceControlInstance instance)
        {
            var validator = new ConnectionStringValidator(instance.ConnectionString, instance.ServiceAccount);

            if (instance.TransportPackage.ZipName.Equals("SQLServer", StringComparison.OrdinalIgnoreCase))
            {
                validator.CheckMsSqlConnectionString();
            }
        }
        public static void RunQueueCreation(IServiceControlInstance instance)
        {
            var accountName = instance.ServiceAccount;

            RunQueueCreation(instance.InstallPath,
                             Constants.ServiceControlExe,
                             instance.Name,
                             accountName);
        }
        public static void Validate(IServiceControlInstance instance)
        {
            var validator = new ConnectionStringValidator(instance.ConnectionString, instance.ServiceAccount);

            if (instance.TransportPackage == "SQLServer")
            {
                validator.CheckMsSqlConnectionString();
            }
        }
        public ConfigurationWriter(IServiceControlInstance details)
        {
            this.details = details;
            var exeMapping = new ExeConfigurationFileMap {
                ExeConfigFilename = Path.Combine(details.InstallPath, "ServiceControl.exe.config")
            };

            configuration = ConfigurationManager.OpenMappedExeConfiguration(exeMapping, ConfigurationUserLevel.None);
        }
        public static void Validate(IServiceControlInstance instance)
        {
            var validator = new QueueNameValidator(instance)
            {
                SCInstances    = InstanceFinder.ServiceControlInstances().Where(p => p.Name != instance.Name & p.TransportPackage.Equals(instance.TransportPackage)).AsEnumerable <IServiceControlInstance>().ToList(),
                AuditInstances = InstanceFinder.ServiceControlAuditInstances().Where(p => p.Name != instance.Name & p.TransportPackage.Equals(instance.TransportPackage)).AsEnumerable <IServiceControlAuditInstance>().ToList(),
            };

            validator.RunValidation();
        }
        public static void RunQueueCreation(IServiceControlInstance instance, string overrideUserName = null)
        {
            var accountName = overrideUserName ?? instance.ServiceAccount;
            var userAccount = UserAccount.ParseAccountName(accountName);

            string args = $"--setup --serviceName={instance.Name}";

            if (!userAccount.IsLocalSystem())
            {
                args += $" --userName=\"{userAccount.QualifiedName}\"";
            }

            var processStartupInfo = new ProcessStartInfo
            {
                CreateNoWindow        = true,
                UseShellExecute       = false,
                FileName              = Path.Combine(instance.InstallPath, "ServiceControl.exe"),
                Arguments             = args,
                WorkingDirectory      = instance.InstallPath,
                RedirectStandardError = true
            };

            var p = Process.Start(processStartupInfo);

            if (p != null)
            {
                var error = p.StandardError.ReadToEnd();
                p.WaitForExit((int)TimeSpan.FromMinutes(1).TotalMilliseconds);
                if (!p.HasExited)
                {
                    p.Kill();
                    throw new ServiceControlQueueCreationTimeoutException("Timed out waiting for ServiceControl to created queues. This usually indicates a configuration error.");
                }

                if (p.ExitCode != 0)
                {
                    throw new ServiceControlQueueCreationFailedException($"ServiceControl.exe threw an error when creating queues. This typically indicates a configuration error such a as an invalid connection string. The error output from ServiceControl.exe was:\r\n {error}");
                }
            }
            else
            {
                throw new Exception("Attempt to launch ServiceControl.exe failed.");
            }
        }
        public static void Validate(IServiceControlInstance instance)
        {
            if (instance.Version < SettingsList.DatabaseMaintenancePort.SupportedFrom)
            {
                return;
            }

            if (!instance.DatabaseMaintenancePort.HasValue)
            {
                throw new EngineValidationException("Maintenance port number is not set");
            }

            if (instance.DatabaseMaintenancePort < 1 || instance.DatabaseMaintenancePort > 49151)
            {
                throw new EngineValidationException("Maintenance port number is not between 1 and 49151");
            }

            if (!PortUtils.CheckAvailable(instance.DatabaseMaintenancePort.Value))
            {
                throw new EngineValidationException($"Port {instance.DatabaseMaintenancePort} is not available");
            }
        }
        public static void Validate(IServiceControlInstance instance)
        {
            if (instance.Version.Major < 2) //Maintenance port was introduced in Version 2
            {
                return;
            }

            if (!instance.DatabaseMaintenancePort.HasValue)
            {
                throw new EngineValidationException("Maintenance port number is not set");
            }

            if (instance.DatabaseMaintenancePort < 1 || instance.DatabaseMaintenancePort > 49151)
            {
                throw new EngineValidationException("Maintenance port number is not between 1 and 49151");
            }

            if (!PortUtils.CheckAvailable(instance.DatabaseMaintenancePort.Value))
            {
                throw new EngineValidationException($"Port {instance.DatabaseMaintenancePort} is not available");
            }
        }
        void DetermineServiceControlQueueNames(IServiceControlInstance instance)
        {
            queues = new List <QueueInfo>
            {
                new QueueInfo
                {
                    PropertyName     = "ErrorQueue",
                    ConnectionString = instance.ConnectionString,
                    QueueName        = instance.ErrorQueue,
                    QueueType        = QueueType.Error
                }
            };

            if (instance.ForwardErrorMessages)
            {
                queues.Add(new QueueInfo
                {
                    PropertyName     = "ErrorLogQueue",
                    ConnectionString = instance.ConnectionString,
                    QueueName        = instance.ErrorLogQueue,
                    QueueType        = QueueType.ErrorLog
                });
            }
        }
Exemple #10
0
 public AppConfig(IServiceControlInstance details) : base(Path.Combine(details.InstallPath, $"{Constants.ServiceControlExe}.config"))
 {
     this.details = details;
 }
Exemple #11
0
 public ServiceControlAppConfig(IServiceControlInstance instance) : base(Path.Combine(instance.InstallPath, $"{Constants.ServiceControlExe}.config"))
 {
     details = instance;
 }
        public static void RunDatabaseMigrations(IServiceControlInstance instance, Action <string> updateProgress)
        {
            var args = $"--database --serviceName={instance.Name}";

            RunDataMigration(updateProgress, instance.LogPath, instance.InstallPath, Constants.ServiceControlExe, () => args);
        }
 internal QueueNameValidator(IServiceControlInstance instance) : this()
 {
     DetermineServiceControlQueueNames(instance);
 }
 ConnectionStringValidator(IServiceControlInstance instance)
 {
     this.instance = instance;
 }