ln.skyscanner/http/SkyScannerHttpManagement.cs

103 lines
2.8 KiB
C#
Raw Normal View History

2019-03-14 08:36:02 +01:00
// /**
// * File: SkyScannerHttpManagement.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using ln.http.resources;
using ln.logging;
using System.Threading;
2019-06-28 10:01:30 +02:00
using ln.logging;
2019-03-14 08:36:02 +01:00
namespace ln.skyscanner.http
{
public class SkyScannerHttpManagement : JsonCallResource
{
public SkyScanner SkyScanner { get; }
public SkyScannerHttpManagement(Resource container,SkyScanner skyScanner)
: base(container, "management")
{
SkyScanner = skyScanner;
}
public SkyScannerHttpManagement(Resource container, string name, SkyScanner skyScanner)
: base(container, name)
{
SkyScanner = skyScanner;
}
2019-08-03 12:57:32 +02:00
/*
2019-03-14 08:36:02 +01:00
[Callable]
public SkyScannerStatistics GetStatistics()
{
SkyScannerStatistics statistics = new SkyScannerStatistics(SkyScanner);
return statistics;
}
[Callable]
public void StartCrawler()
{
Logging.Log(LogLevel.INFO, "Management: StartCrawler() called");
2019-03-14 13:31:15 +01:00
SkyScanner.ConveniencePool.Enqueue(() => SkyScanner.StartCrawler());
}
[Callable]
public void StopCrawler()
{
Logging.Log(LogLevel.INFO, "Management: StopCrawler() called");
SkyScanner.ConveniencePool.Enqueue(() => SkyScanner.StopCrawler());
2019-03-14 08:36:02 +01:00
}
[Callable]
public void Shutdown()
{
Thread thread = new Thread(()=>SkyScanner.Stop());
thread.Start();
}
2019-03-18 08:12:54 +01:00
[Callable]
public MemoryLogger.LogEntry[] GetLogEntries()
{
return SkyScanner.MemoryLogger.GetLogEntries();
}
[Callable]
public MemoryLogger.LogEntry[] GetLogEntries(String _maxLogLevel)
{
return SkyScanner.MemoryLogger.GetLogEntries((LogLevel)int.Parse(_maxLogLevel));
}
2019-03-14 08:36:02 +01:00
public class SkyScannerStatistics
{
public SkyScannerState States;
2019-03-14 13:31:15 +01:00
public string ServerTime;
2019-03-14 08:36:02 +01:00
public SkyScannerStatistics(SkyScanner skyScanner)
{
2019-03-14 13:31:15 +01:00
ServerTime = DateTime.Now.ToString();
2019-03-14 08:36:02 +01:00
States.Crawler = skyScanner.CrawlerStatus;
States.Checks = ComponentState.STOPPED;
States.Dispatcher = ComponentState.STOPPED;
States.Manager = ComponentState.STARTED;
}
}
public struct SkyScannerState
{
public ComponentState HttpServer;
public ComponentState Crawler;
public ComponentState Manager;
public ComponentState Checks;
public ComponentState Dispatcher;
}
2019-08-03 12:57:32 +02:00
*/
2019-03-14 08:36:02 +01:00
}
}