Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.Slave.WindowsService/3.3/ProjectInstaller.cs @ 7489

Last change on this file since 7489 was 7213, checked in by gkronber, 13 years ago

#1081 merged r7103:7209 from trunk into time series branch

File size: 1.4 KB
RevLine 
[6983]1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.ServiceProcess;
5
6
7namespace HeuristicLab.Clients.Hive.SlaveCore.WindowsService {
8  [RunInstaller(true)]
9  public partial class ProjectInstaller : System.Configuration.Install.Installer {
10    public ProjectInstaller() {
11      InitializeComponent();
12    }
13
[7213]14    protected override void OnBeforeUninstall(IDictionary savedState) {
15      base.OnBeforeUninstall(savedState);
16
17      //try to shutdown the service before uninstalling it
18      using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName)) {
19        try {
20          serviceController.Stop();
21        }
22        catch { }
23      }
24    }
25
[6983]26    protected override void OnAfterInstall(IDictionary savedState) {
27      base.OnAfterInstall(savedState);
28
29      //try to create an event log     
30      try {
31        if (!System.Diagnostics.EventLog.SourceExists("HLHive")) {
32          System.Diagnostics.EventLog.CreateEventSource("HLHive", "HiveSlave");
33        }
34      }
35      catch { }
36
37      //try to start the service after installation
38      using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName)) {
39        try {
40          serviceController.Start();
41        }
42        catch { }
43      }
44    }
45  }
46}
Note: See TracBrowser for help on using the repository browser.