/// <summary> /// Инициализировать установщик службы /// </summary> protected void Init(string defSvcName, string defDescr) { // загрузка и проверка свойств службы SvcProps svcProps = new SvcProps(); if (!svcProps.LoadFromFile()) { svcProps.ServiceName = defSvcName; svcProps.Description = defDescr; } if (string.IsNullOrEmpty(svcProps.ServiceName)) { throw new ScadaException(SvcProps.ServiceNameEmptyError); } // настройка установщика ServiceInstaller serviceInstaller = new ServiceInstaller(); ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller(); serviceInstaller.ServiceName = svcProps.ServiceName; serviceInstaller.DisplayName = svcProps.ServiceName; serviceInstaller.Description = svcProps.Description ?? ""; serviceInstaller.StartType = ServiceStartMode.Automatic; serviceProcessInstaller.Account = ServiceAccount.LocalSystem; serviceProcessInstaller.Password = null; serviceProcessInstaller.Username = null; Installers.AddRange(new Installer[] { serviceInstaller, serviceProcessInstaller }); }
/// <summary> /// Initialize the service installer /// </summary> protected void Init(string defSvcName, string defDescr) { // loading and checking service properties var svcProps = new SvcProps(); if (!svcProps.LoadFromFile()) { svcProps.ServiceName = defSvcName; svcProps.Description = defDescr; } if (string.IsNullOrEmpty(svcProps.ServiceName)) { throw new ScadaException(SvcProps.ServiceNameEmptyError); } // installer setup var serviceInstaller = new ServiceInstaller(); var serviceProcessInstaller = new ServiceProcessInstaller(); serviceInstaller.ServiceName = svcProps.ServiceName; serviceInstaller.DisplayName = svcProps.ServiceName; serviceInstaller.Description = svcProps.Description ?? ""; serviceInstaller.StartType = ServiceStartMode.Automatic; serviceProcessInstaller.Account = ServiceAccount.LocalSystem; serviceProcessInstaller.Password = null; serviceProcessInstaller.Username = null; Installers.AddRange(new Installer[] { serviceInstaller, serviceProcessInstaller }); }
/// <summary> /// Initializes the service installer. /// </summary> protected void Init(string defaultServiceName, string defaultDescription) { // load and validate service properties SvcProps svcProps = new SvcProps(); if (!svcProps.LoadFromFile()) { svcProps.ServiceName = defaultServiceName; svcProps.Description = defaultDescription; } if (string.IsNullOrEmpty(svcProps.ServiceName)) { throw new ScadaException(Locale.IsRussian ? "Имя службы не должно быть пустым." : "Service name must not be empty."); } // configure installer ServiceInstaller serviceInstaller = new ServiceInstaller { ServiceName = svcProps.ServiceName, DisplayName = svcProps.ServiceName, Description = svcProps.Description ?? "", StartType = ServiceStartMode.Automatic }; ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem, Password = null, Username = null }; Installers.AddRange(new Installer[] { serviceInstaller, serviceProcessInstaller }); }