* Fixed no website directory
* Fixed message errros and startup orders
This commit is contained in:
@@ -31,13 +31,16 @@ public static class ThreadsFunctions
|
||||
MessageServices.Current.Publish(SEND_ALARMS, null, alarms);
|
||||
}
|
||||
Thread.Sleep(200);
|
||||
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
TryNcConnection();
|
||||
ncHandler.Dispose();
|
||||
TryNcConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +63,10 @@ public static class ThreadsFunctions
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
@@ -87,6 +94,10 @@ public static class ThreadsFunctions
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace Step.Utils
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Step.Utils
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
@@ -49,6 +52,7 @@
|
||||
// Filenames
|
||||
public const string STARTUP_CONFIG_SCHEMA_PATH = "serverConfigValidator.xsd";
|
||||
public const string STARTUP_CONFIG_PATH = "serverConfig.xml";
|
||||
public static string WEBSITE_DIRECTORY = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "wwwroot");
|
||||
|
||||
// MVVM Messages names
|
||||
public const string STOP_SERVER = "STOP_SERVER";
|
||||
|
||||
@@ -3,8 +3,6 @@ using Microsoft.Owin;
|
||||
using Owin;
|
||||
using System.Web.Http;
|
||||
using Microsoft.Owin.StaticFiles;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.Owin.FileSystems;
|
||||
using System.Configuration;
|
||||
using Microsoft.Owin.Security.OAuth;
|
||||
@@ -13,6 +11,8 @@ using Step.Provider;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR.Hubs;
|
||||
using Step.Attributes;
|
||||
using Step.Utils;
|
||||
using System.IO;
|
||||
|
||||
[assembly: OwinStartup(typeof(Step.App_Start.Startup))]
|
||||
|
||||
@@ -39,16 +39,17 @@ namespace Step.App_Start
|
||||
|
||||
// SignalR config & startup
|
||||
SignalRConfig(app);
|
||||
|
||||
var directoryBrowsing = ConfigurationManager.AppSettings["enableDirectoryBrowsing"] == "true";
|
||||
// Check if web site directory exists
|
||||
if (!Directory.Exists(Constants.WEBSITE_DIRECTORY))
|
||||
ExceptionManager.Manage(Constants.ERROR_LEVEL.FATAL, "Main window directory not found!");
|
||||
|
||||
string rootDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "wwwroot");
|
||||
var options = new FileServerOptions()
|
||||
{
|
||||
EnableDefaultFiles = !directoryBrowsing,
|
||||
EnableDirectoryBrowsing = directoryBrowsing,
|
||||
RequestPath = PathString.Empty,
|
||||
FileSystem = new PhysicalFileSystem(rootDir)
|
||||
FileSystem = new PhysicalFileSystem(Constants.WEBSITE_DIRECTORY)
|
||||
};
|
||||
|
||||
app.UseFileServer(options);
|
||||
|
||||
+12
-13
@@ -30,33 +30,32 @@ namespace Step
|
||||
// Start self host application
|
||||
string configuredUri = "http://localhost:" + ServerConfig.ServerPort.ToString();
|
||||
|
||||
// Start WinForm
|
||||
ServerControlWindow.Start();
|
||||
|
||||
// Register listener to "close application" messages
|
||||
MessageServices.Current.Subscribe(STOP_SERVER, (a, b) =>
|
||||
{
|
||||
StopRequest.Set();
|
||||
});
|
||||
|
||||
// Start Threads
|
||||
ThreadsHandler.Start();
|
||||
// Start listeners
|
||||
ListenersHandler.Start();
|
||||
});
|
||||
|
||||
// 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();
|
||||
|
||||
// Stop Threads
|
||||
ThreadsHandler.Stop();
|
||||
// Stop messageservice listeners
|
||||
ListenersHandler.Stop();
|
||||
LogInfo("Application closed");
|
||||
}
|
||||
|
||||
// Stop Threads
|
||||
ThreadsHandler.Stop();
|
||||
// Stop messageservice listeners
|
||||
ListenersHandler.Stop();
|
||||
// Close WinForm
|
||||
ServerControlWindow.Stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user