Esempio n. 1
0
        private static TransactedInstaller CreateTransactedInstaller(ServiceBeschreibung name, string logFilePath) {
            var serviceProcessInstaller = new ServiceProcessInstaller {
                Account = ServiceAccount.LocalSystem
            };

            var transactedInstaller = new TransactedInstaller();
            transactedInstaller.Installers.Add(serviceProcessInstaller);
            var path = string.Format("/assemblypath={0}", Assembly.GetEntryAssembly().Location);
            var installContext = new InstallContext(logFilePath, new[] {path});
            transactedInstaller.Context = installContext;

            var serviceInstaller = new ServiceInstaller {
                ServiceName = name.Name,
                DisplayName = name.DisplayName,
                Description = name.Description
            };
            transactedInstaller.Installers.Add(serviceInstaller);
            return transactedInstaller;
        }
Esempio n. 2
0
        public static void Run(string[] args, string name, string displayName, string description, Action onStart, Action onStop) {
            var serviceInstallation = new ServiceInstallation();
            var argumenteAuswerten = new ArgumenteAuswerten();
            var serviceStarter = new ServiceStarter();
            var serviceProxy = new ServiceProxy();

            var serviceBeschreibung = new ServiceBeschreibung {
                Name = name,
                DisplayName = displayName,
                Description = description
            };

            serviceProxy.Out_Start += onStart;
            serviceProxy.Out_Stop += onStop;

            argumenteAuswerten.Out_Install += () => serviceInstallation.In_Installieren(serviceBeschreibung);
            argumenteAuswerten.Out_Uninstall += () => serviceInstallation.In_Deinstallieren(serviceBeschreibung);
            argumenteAuswerten.Out_Start += () => serviceStarter.In_Start(serviceBeschreibung);
            argumenteAuswerten.Out_Stop += () => serviceStarter.In_Stop(serviceBeschreibung);
            argumenteAuswerten.Out_RunAsService += () => ServiceBase.Run(serviceProxy);
            argumenteAuswerten.Out_Run += () => RunServiceOnConsole(serviceProxy);

            argumenteAuswerten.In_Process(args);
        }
Esempio n. 3
0
 public void In_Start(ServiceBeschreibung serviceName) {
     var serviceController = new ServiceController(serviceName.Name);
     serviceController.Start();
 }
Esempio n. 4
0
 public void In_Deinstallieren(ServiceBeschreibung name) {
     var transactedInstaller = CreateTransactedInstaller(name, "UnInstall.log");
     transactedInstaller.Uninstall(null);
 }
Esempio n. 5
0
 public void In_Installieren(ServiceBeschreibung name) {
     var transactedInstaller = CreateTransactedInstaller(name, "Install.log");
     transactedInstaller.Install(new Hashtable());
 }