f0a48aa8d5
+ Added new nc error management
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Microsoft.Owin.Hosting;
|
|
using Step.UI;
|
|
using System.Threading;
|
|
using TeamDev.SDK.MVVM;
|
|
using Step.Config;
|
|
using static Step.Config.StartupConfig;
|
|
using static Step.Utils.StepLogger;
|
|
using static Step.Utils.Constants;
|
|
using Step.Database;
|
|
using Step.Core;
|
|
using Step.Listeners;
|
|
using System;
|
|
|
|
namespace Step
|
|
{
|
|
public class Application
|
|
{
|
|
|
|
public static readonly ManualResetEvent StopRequest = new ManualResetEvent(false);
|
|
|
|
public static int MessageService { get; private set; }
|
|
|
|
public static void Main()
|
|
{
|
|
LogInfo("Application started");
|
|
StartupConfigController.ReadStartupConfig();
|
|
|
|
DatabaseContext.TestDatabaseConnection();
|
|
|
|
// Start self host application
|
|
string configuredUri = "http://*:" + ServerConfig.ServerPort.ToString();
|
|
|
|
// Register listener to "close application" messages
|
|
MessageServices.Current.Subscribe(STOP_SERVER, (a, b) =>
|
|
{
|
|
StopRequest.Set();
|
|
});
|
|
|
|
// Start server services
|
|
using (WebApp.Start<Step.App_Start.Startup>(url: configuredUri))
|
|
{
|
|
// Start WinForm
|
|
ServerControlWindow.Start();
|
|
// Start Threads
|
|
ThreadsHandler.Start();
|
|
// Start listeners
|
|
ListenersHandler.Start();
|
|
|
|
// Wait interrupt from client
|
|
StopRequest.WaitOne();
|
|
LogInfo("Application closed");
|
|
}
|
|
// Stop Threads
|
|
ThreadsHandler.Stop();
|
|
// Stop messageservice listeners
|
|
ListenersHandler.Stop();
|
|
// Close WinForm
|
|
ServerControlWindow.Stop();
|
|
}
|
|
}
|
|
}
|