private void HandleInformTimer(object sender, ElapsedEventArgs e) { //dbWriter.InsertGeneral("Listening", "Listener"); dbWriter.InsertSts(ServerTime.GetRealTime(), "Listener", "Listening"); if (IsEndOfWork()) { //dbWriter.InsertGeneral("Work Ended", "Listener"); dbWriter.InsertSts(Stocks.ServerTime.GetRealTime(), "Listener", "Work Ended"); DisconnectStockServer(); Environment.Exit(0); } }
public Listener() { Collector = new DataCollector(); dbWriter = new DBInputOutput.DBWriter(); dbReader = new DBInputOutput.DBReader(); dbWriter.InsertSts(ServerTime.GetRealTime(), "Listener", "Work Started"); Collector.BarsCollected += BarsCollectedHandler; InformTimer = new Timer(InformTimerInterval); InformTimer.AutoReset = true; InformTimer.Elapsed += HandleInformTimer; InformTimer.Start(); dbWriter.InsertSts(ServerTime.GetRealTime(), "Listener", "Listening"); DayOffs = dbReader.SelectDayOffs(ServerTime.GetRealTime()); bool isDayOff = IsDayOff(ServerTime.GetRealTime()); if (isDayOff || IsEndOfWork()) { Environment.Exit(0); } WasConnected = false; }