using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading.Tasks; using log4net; namespace bsmd.AIS2Service { public partial class AIS2_Service : ServiceBase { private readonly ILog _log = LogManager.GetLogger(typeof(AIS2_Service)); public AIS2_Service() { InitializeComponent(); } protected override void OnStart(string[] args) { this.EventLog.Source = this.ServiceName; this.EventLog.Log = "Application"; this.EventLog.WriteEntry("BSMD AIS Service started.", EventLogEntryType.Information); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; _log.InfoFormat("Starting AIS2 Service. v.{0} -------------- ", version); AISManager.Start(); } protected override void OnStop() { AISManager.Stop(); _log.Info("AIS2 Service stopped."); } } }