d350183fb5
+ Added new library version (30) with pre and post power on data * Refactor
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.ServerConfig;
|
|
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");
|
|
ServerConfigController.ReadStartupConfig();
|
|
|
|
DatabaseContext.TestDatabaseConnection();
|
|
|
|
// Start self host application
|
|
string configuredUri = "http://*:" + ServerStartupConfig.ServerPort.ToString();
|
|
|
|
// Register listener to "close application" messages
|
|
MessageServices.Current.Subscribe(SEND_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();
|
|
}
|
|
}
|
|
}
|