public void Update(string metastockFolder) { DateTime lastDate; try { lastDate = DateTime.Parse(LastUpdate); } catch (Exception) { return; } var source = Sources.FirstOrDefault(x => x.Id == SelectedSource); if (source == null) { return; } var missingPriceRecords = source.GetPriceRecords(lastDate); Metastock.UpdateSymbol(metastockFolder, Symbol, missingPriceRecords); LastUpdate = Metastock.GetLastDateStatus(metastockFolder, Symbol); }
private void BwGetTickersLastDate(object sender, DoWorkEventArgs e) { MetastockFolderReady = false; BackgroundWorkerNotBusy = false; MainButtonAction = "Loading..."; var worker = sender as System.ComponentModel.BackgroundWorker; if (worker != null) { worker.ReportProgress(0); } for (var i = 0; i < Tickers.Count; i++) { if (worker != null && worker.CancellationPending) { e.Cancel = true; break; } var ticker = Tickers[i]; ticker.LastUpdate = Metastock.GetLastDateStatus(MetastockFolder, ticker.Symbol); if (worker != null) { worker.ReportProgress(((i + 1) * 100) / Tickers.Count); } } if (worker != null && !e.Cancel) { worker.ReportProgress(100); } else if (worker != null) { worker.ReportProgress(0); } MainButtonAction = "Update Database"; MetastockFolderReady = true; BackgroundWorkerNotBusy = true; }