Exemplo n.º 1
0
        /// <summary>
        /// Stop this service.
        /// </summary>
        protected override void OnStop()
        {
            Logger.WriteLine("Shutting down Server...");
            Logger.FlushClose();

            server.StopServer();
            server = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Boot the Service.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            try
            {
                configuration = (AlarmServerConfiguration)AlarmServerConfiguration.GetDefaultConfigurationPath();
            }
            catch (Exception ex) { this.EventLog.WriteEntry("Stopped by Misconfiguration. Error-Message: " + ex.Message, EventLogEntryType.Error); Stop(); return; }

            string currentLogFile = Path.Combine(Path.GetDirectoryName(AlarmServerConfiguration.GetDefaultConfigurationPath()), "Log at " + DateTime.Now.ToString("yyyy-MM-dd") + ".log");

            Logger.LoadLogFile(currentLogFile);
            Logger.WriteLine("Server starting...");

            server = new AlarmServer(configuration);
            server.StartServer();
            Logger.WriteLine("Server running at " + configuration.ServerAddress + ":" + configuration.ServerPort);
        }