/// <summary> /// Update streaming data to database /// </summary> static public void UpdateStreaming() { Tools.Log("Streaming service started!"); while (true) { try { Thread.Sleep(1000); DB.DoCommand("delete from Intraday where QuoteTime<?", new DbParam[] { new DbParam("@QuoteTime", DbType.DateTime, DateTime.Today.AddDays(-7)) }); DataClientBase dcb = new EasyChartDataClient(); dcb.Proxy = Config.WebProxy; dcb.OnStreamingData += new StreamingDataChanged(dcb_OnStreamingData); dcb.OnStreamingStopped += new EventHandler(dcb_OnStreamingStopped); while (true) { if (StreamingStopped) { StreamingStopped = false; Tools.Log("Streaming service start again!"); dcb.StartStreaming(Config.IntradaySymbols); } Thread.Sleep(100); } } catch (Exception e) { Tools.Log("Streaming service:" + e); } Thread.Sleep(1000); } }
/// <summary> /// Update streaming data to database /// </summary> static public void UpdateStreaming() { SetUSCulture(); Tools.Log("Streaming service started!" + ",ThreadId=" + Thread.CurrentThread.GetHashCode()); try { while (true) { try { Thread.Sleep(1000); DB.DoCommand("delete from Intraday where QuoteTime<?", new DbParam[] { new DbParam("@QuoteTime", DbType.DateTime, DateTime.Today.AddDays(-7)) }); DataClientBase dcb; if (Config.StreamingDataClient == "YahooDataClient") { dcb = new YahooDataClient(); } else { dcb = new EasyChartDataClient(); } Tools.Log(dcb.GetType().ToString()); dcb.Proxy = Config.WebProxy; dcb.OnStreamingData += new StreamingDataChanged(dcb_OnStreamingData); dcb.OnStreamingStopped += new EventHandler(dcb_OnStreamingStopped); while (true) { if (StreamingStopped) { StreamingStopped = false; Tools.Log("Streaming service start again!" + ",ThreadId=" + Thread.CurrentThread.GetHashCode()); dcb.StartStreaming(Config.IntradaySymbols); } Thread.Sleep(100); } } catch (Exception e) { if (e is ThreadAbortException) { tUpdateStreaming = null; } Tools.Log("Streaming service:" + e + ",ThreadId=" + Thread.CurrentThread.GetHashCode()); } Thread.Sleep(1000); } } finally { tUpdateStreaming = null; } }