public void BatchDownloadFinancialReport()
        {
            DbMango mongo = new DbMango();

            mongo.connect();

            String[] stocks = new string[] { /*"2371",*/ "2373", "2374", "2375", "2376", "2377", "2379" };
            foreach (String stock in stocks)
            {
                YearSeason yearseason = mongo.FinancialReport_FindLatest(stock);
                yearseason = (yearseason == null) ? new YearSeason(104, 1) : yearseason.next();
                for (int year = 104; year <= 108; year++)
                {
                    for (int season = 1; season <= 4; season++)
                    {
                        if (SeasonalReportReady(year, season))
                        {
                            int     try_count        = 1;
                            Boolean download_success = false;
                            do
                            {
                                download_success = DownloadSeasonalReport(stock, year, season);
                                Thread.Sleep(1000 * try_count);
                            } while (!download_success && (try_count < 10));
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public YearSeason FinancialReport_FindLatest(String stock_index)
        {
            YearSeason res        = null;
            var        collection = twstock_db.GetCollection <BsonDocument>("financial_report");

            //var filter = Builders<Dictionary<String, String>>.Filter.Eq("name", "dsfasdf");
            //var filter = Builders<BsonDocument>.Filter.Eq("name", "dsfasdf");
            //var query = Query.EQ("name", "dsfasdf");
            //var res = collection.Find(filter).First();
            var stock_found = collection.Find(x => x["stock_index"] == stock_index).Sort("{year:1, season:1}").Limit(10).ToList();

            if (stock_found.Count != 0)
            {
                res = new YearSeason(stock_found[0]["year"].AsInt32, stock_found[0]["season"].AsInt32);
            }
            return(res);
        }