public void ManuallyFetchFinanceReportProgress(IProgress <double> progress, string stockCode, string rawFinancialReport) { lock (lockObject) { try { int i = 0; Dictionary <string, string>[] package = FinancialReportJsonParser.FromJson(DataCollector.JsonEscape(rawFinancialReport)); int dataCount = package.Length; foreach (Dictionary <string, string> report in package) { DatabaseHelper.UpdateFinancialReport(stockCode, report); i++; progress.Report(100.0 * i / dataCount); } } catch (Exception ex) { SystemSetting.LogAndDisplayError(ex, "MainForm.cs, line 178"); } } }
public void FetchFinanceReportProgress(IProgress <double> progress) { lock (lockObject) { try { int dataCount = DatabaseHelper.Get006030StockRecordCount("stockList"); var reader = DatabaseHelper.GetAll006030StockRecords("stockList"); int i = 0; while (reader.Read()) { string stockCode = reader[1].ToString(); try { i++; DataCollector dataCollector = new DataCollector(); string rawFinantialReport = DataCollector.JsonEscape(dataCollector.GetHttpResponse(SystemSetting.rootUrlOfFinancialReport + stockCode, false).Result); Console.WriteLine($"{i}:{stockCode} --- {rawFinantialReport}"); Dictionary <string, string>[] package = FinancialReportJsonParser.FromJson(rawFinantialReport); foreach (Dictionary <string, string> report in package) { DatabaseHelper.UpdateFinancialReport(stockCode, report); } progress.Report(100.0 * i / dataCount); } catch (Exception ex0) { SystemSetting.LogAndDisplayError(ex0, $"{stockCode} MainForm.cs, line 169"); } } } catch (Exception ex) { SystemSetting.LogAndDisplayError(ex, "MainForm.cs, line 178"); } } }