Ejemplo n.º 1
0
        private void AddToDb <T>(object sender, DataUpdatedArgs args, StockType st) where T : StockBase
        {
            logger.Info("Adding to DB with stocktype=" + st.ToString());
            var stocksValues = args.Values;

            foreach (var stockAnsiToValues in stocksValues)
            {
                if (st == StockType.RT)
                {
                    StockRT stock = new StockRT(stockAnsiToValues.Value);
                    logger.Debug("Adding stock with type RT with stockname=" + stockAnsiToValues.Key);
                    this.stocks[stockAnsiToValues.Key].Tables.RT.Add(stock);
                }
                else if (st == StockType.Daily)
                {
                    StockDaily stock = new StockDaily(stockAnsiToValues.Value);
                    logger.Debug("Adding stock with type Daily with stockname=" + stockAnsiToValues.Key);
                    this.stocks[stockAnsiToValues.Key].Tables.Daily.Add(stock);
                }
                else
                {
                    logger.Error("Unknown stock type while trying to enter data to DB");
                    throw new Exception("Unknown stock type");
                }
                this.stocks[stockAnsiToValues.Key].Tables.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private void AddToDb <T>(object sender, DataUpdatedArgs args, StockType st) where T : StockBase
        {
            var stocksValues = args.Values;

            foreach (var stockAnsiToValues in stocksValues)
            {
                if (st == StockType.RT)
                {
                    StockRT stock = new StockRT(stockAnsiToValues.Value);
                    this.stocks[stockAnsiToValues.Key].Tables.RT.Add(stock);
                }
                else if (st == StockType.Daily)
                {
                    StockDaily stock = new StockDaily(stockAnsiToValues.Value);
                    this.stocks[stockAnsiToValues.Key].Tables.Daily.Add(stock);
                }
                else
                {
                    throw new Exception("Unknown stock type");
                }
            }
        }