init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
50
Kreta.WebApi/User/Kreta.User.WebApi/Global.asax.cs
Normal file
50
Kreta.WebApi/User/Kreta.User.WebApi/Global.asax.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
|
||||
namespace Kreta.User.WebApi
|
||||
{
|
||||
public class WebApiApplication : HttpApplication
|
||||
{
|
||||
protected static KretaServer.KretaServer kretaServer;
|
||||
|
||||
protected void Application_Start()
|
||||
{
|
||||
ServerStarter();
|
||||
}
|
||||
|
||||
protected void Application_End(object sender, EventArgs e)
|
||||
{
|
||||
if (kretaServer != null)
|
||||
{
|
||||
if (kretaServer.IsRunning)
|
||||
{
|
||||
kretaServer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
kretaServer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ServerStarter()
|
||||
{
|
||||
if (kretaServer == null || kretaServer.IsRunning == false)
|
||||
{
|
||||
var fullnode = (XmlNode)ConfigurationManager.GetSection("ServerConfig");
|
||||
var doc = new XmlDocument();
|
||||
doc.LoadXml(fullnode.SelectSingleNode("/ServerConfig/config").OuterXml);
|
||||
|
||||
if (kretaServer == null)
|
||||
{
|
||||
kretaServer = new KretaServer.KretaServer(doc.DocumentElement);
|
||||
}
|
||||
|
||||
kretaServer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue