Ejemplo n.º 1
0
        private void RateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                DateTime sTime = (DateTime)e.Argument;

                StockAnalyser   analyser = new StockAnalyser();
                List <DateTime> dataList = new List <DateTime>();

                RateWorker.ReportProgress(0, "Rate Start");

                using (stockdbaEntities db = new stockdbaEntities())
                {
                    dataList.AddRange(db.DailySummary.Where(o => o.receiveDate >= sTime).GroupBy(o => o.receiveDate).Select(o => o.Key));
                }

                foreach (var item in dataList)
                //Parallel.ForEach(dataList, item =>
                {
                    RateWorker.ReportProgress(0, item);

                    analyser.DoDailyRate(item);

                    analyser.DoWeeklyRate(item);

                    analyser.DoTotalRate(item);
                }//);

                RateWorker.ReportProgress(0, "Rate Done");
            }
            catch (Exception ex)
            {
                RateWorker.ReportProgress(0, ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void btnWeeklyRate_Click(object sender, EventArgs e)
 {
     if (RateWorker.IsBusy == false)
     {
         RateWorker.RunWorkerAsync(dtpRate.Value);
     }
 }