Esempio n. 1
0
        /// <summary>
        /// Creates the installer.
        /// </summary>
        /// <param name="args">The <see cref="ServiceInstallEventArgs" /> instance containing the event data.</param>
        /// <returns></returns>
        public Installer CreateInstaller(ServiceInstallEventArgs args)
        {
            var installArgs = new List <string>
            {
                "/LogFile=" + args.Install.LogFile,
                "/LogToConsole=false" + args.Install.LogToConsole,
            };

            if (!String.IsNullOrEmpty(args.Install.StateDir))
            {
                installArgs.Add("/InstallStateDir=" + args.Install.StateDir);
            }
            var installer = new IntegratedInstaller(installArgs.ToArray());

            installer.Installers.Add(CreateServiceInstaller(args));
            installer.Installers.Add(CreateServiceProcessInstaller(args));
            return(installer);
        }
Esempio n. 2
0
        public bool Execute(ICommandOptions options)
        {
            if (!options.Install)
            {
                return(false);
            }


            var installArgs = new ServiceInstallEventArgs
            {
                Options = options
            };

            Starter.OnServiceInstalling(installArgs);

            InstallService(installArgs);
            StartService(installArgs);

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Installs the service.
        /// </summary>
        /// <param name="args">The <see cref="ServiceInstallEventArgs" /> instance containing the event data.</param>
        public void InstallService(ServiceInstallEventArgs args)
        {
            Console.WriteLine("Installing service......");

            using (var installer = Starter.CreateInstaller(args))
            {
                IDictionary state = new Hashtable();
                try
                {
                    // Install service
                    installer.Install(state);
                    installer.Commit(state);
                    Console.WriteLine("Service installed.");
                }
                catch
                {
                    installer.Rollback(state);
                    throw;
                }
            }
        }
Esempio n. 4
0
 public virtual void OnServiceInstalling(ServiceInstallEventArgs args)
 {
     ServiceInstalling?.Invoke(this, args);
 }