using System;
using System.Diagnostics;
using System.ServiceProcess;
namespace TGS.Server.Service
{
///
/// Windows adapter for
///
public sealed class Service : ServiceBase, ILogger
{
///
/// The entry point for the program. Calls with a new as a parameter
///
public static void Main() => Run(new Service());
///
/// The the manages
///
Server activeServer;
///
/// Constructs a
///
Service()
{
ServiceName = "TG Station Server";
}
///
public void WriteAccess(string username, bool authSuccess, byte loggingID)
{
EventLog.WriteEntry(String.Format("Access from: {0}", username), authSuccess ? EventLogEntryType.SuccessAudit : EventLogEntryType.FailureAudit , (int)EventID.Authentication + loggingID);
}
///
public void WriteError(string message, EventID id, byte loggingID)
{
EventLog.WriteEntry(message, EventLogEntryType.Error, (int)id + loggingID);
}
///
public void WriteInfo(string message, EventID id, byte loggingID)
{
EventLog.WriteEntry(message, EventLogEntryType.Information, (int)id + loggingID);
}
///
public void WriteWarning(string message, EventID id, byte loggingID)
{
EventLog.WriteEntry(message, EventLogEntryType.Warning, (int)id + loggingID);
}
///
/// Called when the is started. Creates a new
///
/// The service start arguments
protected override void OnStart(string[] args)
{
activeServer = new Server(args, this);
}
///
/// Called when the is stopped. Calls on
///
protected override void OnStop()
{
activeServer.Dispose();
}
}
}