Exemple #1
0
        public void TestShouldNotGetData()
        {
            TwseTradingExchangeApiDAO dao = new TwseTradingExchangeApiDAO();
            DateTime dt   = new DateTime(2020, 1, 1);
            var      data = dao.GetTwseTradingExchange(dt).ToList();

            Assert.AreEqual(1, data.Count());
        }
        public void UpdateData(DateTime st, DateTime et)
        {
            var data = _YearDataDic;
            TwseTradingExchangeApiDAO apiDao = new TwseTradingExchangeApiDAO();

            for (DateTime t = st; t <= et; t = t.AddDays(1))
            {
                int year = t.Year;
                if (!data.ContainsKey(year))
                {
                    data.Add(year, new List <TwseTradingExchangeModelData>());
                }
                var d = data[year];
                if (d.Count(x => x.Time == t) == 0)
                {
                    d.AddRange(apiDao.GetTwseTradingExchange(t));
                    Thread.Sleep(2500);
                }
            }
        }