private static void Test1() { TradingReporterConfiguration config = new TradingReporterConfiguration(); config.UpdateFromAppConfig(); ILogger logger = new DebugLogger(); TradingReporter reporter = new TradingReporter(config, logger); DateTime dt = DateTime.UtcNow; for (int i = 0; i < 3; i++) { dt = dt.AddHours(1); try { logger.Log(LogLevel.Debug, $"reporter.MakeReport({dt:u});"); reporter.MakeReport(dt); } catch (Exception ex) { Debug.WriteLine($"{dt}: {ex.Message} -- {ex.StackTrace}"); } } }
public Service() { InitializeComponent(); _logger = new ServiceLogger(this); _config = new TradingReporterConfiguration(); _config.UpdateFromAppConfig(); TradingReporter = new TradingReporter(_config, _logger); }
private static void Test2() { TradingReporterConfiguration config = new TradingReporterConfiguration(); config.UpdateFromAppConfig(); ILogger logger = new ConsoleLogger(); TradingReporter reporter = new TradingReporter(config, logger); while (true) { var key = Console.ReadKey().KeyChar; switch (key) { case 's': logger.Log(LogLevel.Debug, "Start"); reporter.OnStart(); break; case 'x': logger.Log(LogLevel.Debug, "Stop"); reporter.OnStop(); break; case 'p': logger.Log(LogLevel.Debug, "Pause"); reporter.OnPause(); break; case 'c': logger.Log(LogLevel.Debug, "Continue"); reporter.OnContinue(); break; case 'q': return; default: Console.WriteLine(); continue; } logger.Log(LogLevel.Debug, $"Config.ReportingInterval = {config.ReportingInterval}"); logger.Log(LogLevel.Debug, $"Config.SessionInfo.SessionStart = {config.SessionInfo.SessionStart}"); logger.Log(LogLevel.Debug, $"Config.ReportingDirrectory = {config.ReportingDirrectory}"); } }
protected override void OnStart(string[] args) { _config.UpdateFromAppConfig(); TradingReporter.OnStart(); }