コード例 #1
0
        private void button_DownloadEarning_Click(object sender, EventArgs e)
        {
            db_manager.DBConnect();
            CompanyProfilePage cpp = new CompanyProfilePage();

            // cpp.DownloadEarningInfoAll(db_manager.getConnection(), "2379");             //from 98-102. profit margin
            cpp.DownloadEpsInfo(db_manager.getConnection(), "2379", 100, 1);      //eps
            cpp.DownloadMonthRevenue(db_manager.getConnection(), "2379", 100, 1); //revenue

            cpp.DownloadEpsInfo(db_manager.getConnection(), "2379", 102, 1);      //eps
            cpp.DownloadMonthRevenue(db_manager.getConnection(), "2379", 102, 1); //revenue
            int         rev = cpp.GetMonthRevenue(db_manager.getConnection(), "2379", 102, 1);
            EarningInfo ei  = cpp.GetSeasonEarning(db_manager.getConnection(), "2379", 102, 1);

            YearSeasonMonth ysm = cpp.GetLatestRevenueInfoDate(db_manager.getConnection(), "2379");

            ysm = cpp.GetLatestEarningInfoDate(db_manager.getConnection(), "2379");
        }
コード例 #2
0
        private void backgroundWorker_check_download_EPS_DoWork(object sender, DoWorkEventArgs e)
        {
            db_manager.DBConnect();
            MySqlConnection    conn = db_manager.getConnection();
            CompanyProfilePage cpp  = new CompanyProfilePage();

            while (true)
            {
                List <stockSeason> nulleps = new List <stockSeason>();
                string             qstr    = "SELECT * FROM company_earning WHERE eps is NULL order by stock_index;";
                MySqlCommand       cmd     = new MySqlCommand(qstr, conn);
                MySqlDataReader    rdr     = null;
                try
                {
                    rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        string idx    = (string)rdr["stock_index"];
                        int    year   = (int)rdr["year"];
                        int    season = (int)rdr["season"];
                        nulleps.Add(new stockSeason(idx, year, season));
                    }
                }
                catch (Exception ex)
                {
                    //Logger.e("isEPS_Null:" + stock_index + "(" + year + "," + season + ")  failed");
                }
                finally
                {
                    if (rdr != null)
                    {
                        rdr.Close();
                    }
                }

                Logger.v("total " + nulleps.Count + " eps items are null!");
                backgroundWorker_downloadrevenue_inprogress = true;
                foreach (stockSeason stkseason in nulleps)
                {
                    cpp.DownloadEpsInfo(db_manager.getConnection(), stkseason.stock_index, stkseason.year, stkseason.season);
                    downloadrevenue_index++;
                    //Thread.Sleep(3);
                }
            }
        }
コード例 #3
0
        private void backgroundWorker_downloadrevenue_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker downloadrevenue_worker = sender as BackgroundWorker;

            List <String>   stocks     = GetAllStocks();
            DateTime        current    = DateTime.Now;
            YearSeasonMonth currentYSM = new YearSeasonMonth(current, true);

            CompanyProfilePage cpp = new CompanyProfilePage();

            backgroundWorker_downloadrevenue_inprogress = true;

            foreach (String stock_idx in stocks)
            {
                if (downloadrevenue_worker.CancellationPending)
                {
                    Logger.v("cancelling databases update");
                    backgroundWorker_downloadrevenue_inprogress = false;
                    break;
                }

                //earning
                YearSeasonMonth        latestEarning = cpp.GetLatestEarningInfoDate(db_manager.getConnection(), stock_idx);
                List <YearSeasonMonth> EPS2download  = new List <YearSeasonMonth>();
                YearSeasonMonth        nextEarning;
                if ((latestEarning == null) || (latestEarning.year < 102))
                {
                    cpp.DownloadEarningInfo_beforeIFRS(db_manager.getConnection(), stock_idx, EPS2download);
                    nextEarning = IfrsStart;
                }
                else
                {
                    nextEarning = latestEarning.NextSeason();
                }

                downloadrevenue_index++;
                for (int y = nextEarning.year; y <= (current.Year - 1911); y++)
                {
                    cpp.DownloadEarningInfo(db_manager.getConnection(), stock_idx, y, EPS2download);
                    downloadrevenue_index++;
                }

                //eps info is from another page
                foreach (YearSeasonMonth season in EPS2download)
                {
                    cpp.DownloadEpsInfo(db_manager.getConnection(), stock_idx, season.year, season.season);
                    downloadrevenue_index++;
                    int loop;
                    for (loop = 0; loop < 10; loop++)
                    {
                        if (cpp.isEPS_Null(db_manager.getConnection(), stock_idx, season.year, season.season))
                        {
                            cpp.DownloadEpsInfo(db_manager.getConnection(), stock_idx, season.year, season.season);
                            downloadrevenue_index++;
                        }
                    }
                }

                YearSeasonMonth latestRevenue = cpp.GetLatestRevenueInfoDate(db_manager.getConnection(), stock_idx);
                if (latestRevenue == null)
                {
                    latestRevenue = EarningStart;
                }
                for (YearSeasonMonth month = latestRevenue; month < currentYSM; month.NextMonth())
                {
                    cpp.DownloadMonthRevenue(db_manager.getConnection(), stock_idx, month.year, month.month);
                    downloadrevenue_index++;
                }
            }
        }