markus / ConvertService / ServiceBase / Markus.Service.Station / ProjectInstaller.cs @ 2c629eec
이력 | 보기 | 이력해설 | 다운로드 (3.07 KB)
1 | 53c9637d | taeseongkim | using log4net; |
---|---|---|---|
2 | using System; |
||
3 | using System.Collections; |
||
4 | using System.Collections.Generic; |
||
5 | using System.ComponentModel; |
||
6 | using System.Configuration.Install; |
||
7 | using System.Linq; |
||
8 | using System.Threading.Tasks; |
||
9 | |||
10 | namespace Markus.Service |
||
11 | { |
||
12 | [RunInstaller(true)] |
||
13 | public partial class ProjectInstaller : System.Configuration.Install.Installer |
||
14 | { |
||
15 | protected ILog logger = LogManager.GetLogger(typeof(ProjectInstaller)); |
||
16 | |||
17 | public ProjectInstaller() |
||
18 | { |
||
19 | InitializeComponent(); |
||
20 | } |
||
21 | |||
22 | protected override void OnBeforeInstall(IDictionary savedState) |
||
23 | { |
||
24 | //if (System.ServiceProcess.ServiceController.GetServices().Count(x => x.ServiceName == serviceInstaller1.ServiceName) > 0) |
||
25 | //{ |
||
26 | // logger.Info("ServiceStation Stop "); |
||
27 | |||
28 | // using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController(serviceInstaller1.ServiceName)) |
||
29 | // { |
||
30 | // serviceController?.Stop(); |
||
31 | // } |
||
32 | //} |
||
33 | |||
34 | base.OnBeforeInstall(savedState); |
||
35 | } |
||
36 | |||
37 | protected override void OnAfterInstall(IDictionary savedState) |
||
38 | { |
||
39 | base.OnAfterInstall(savedState); |
||
40 | |||
41 | try |
||
42 | { |
||
43 | |||
44 | //logger.Info("ServiceStation Start "); |
||
45 | |||
46 | ////if (System.ServiceProcess.ServiceController.GetServices().Count(x => x.ServiceName == serviceInstaller1.ServiceName) > 0) |
||
47 | ////{ |
||
48 | // using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController(serviceInstaller1.ServiceName)) |
||
49 | // { |
||
50 | // serviceController?.Start(); |
||
51 | |||
52 | // logger.Info("ServiceStation Start Good."); |
||
53 | // } |
||
54 | ////} |
||
55 | } |
||
56 | catch (Exception ex) |
||
57 | { |
||
58 | logger.Error("After Install : Service Station Start Error : ", ex); |
||
59 | } |
||
60 | |||
61 | } |
||
62 | |||
63 | protected override void OnCommitting(IDictionary savedState) |
||
64 | { |
||
65 | base.OnCommitting(savedState); |
||
66 | } |
||
67 | |||
68 | protected override void OnBeforeUninstall(IDictionary savedState) |
||
69 | { |
||
70 | try |
||
71 | { |
||
72 | logger.Info("ServiceStation stop "); |
||
73 | |||
74 | if (System.ServiceProcess.ServiceController.GetServices().Count(x => x.ServiceName == serviceInstaller1.ServiceName) > 0) |
||
75 | { |
||
76 | using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController(serviceInstaller1.ServiceName)) |
||
77 | { |
||
78 | serviceController?.Stop(); |
||
79 | } |
||
80 | } |
||
81 | else |
||
82 | { |
||
83 | logger.Info("ServiceStation not stop"); |
||
84 | } |
||
85 | } |
||
86 | catch (Exception ex) |
||
87 | { |
||
88 | logger.Error("After Install : Service Station stop Error : ", ex); |
||
89 | } |
||
90 | |||
91 | base.OnBeforeUninstall(savedState); |
||
92 | |||
93 | } |
||
94 | } |
||
95 | } |