/// <summary> /// Callback for all reporting banks in specified period /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Proxy_RetrievePanelOfReportersCompleted(object sender, RetrievePanelOfReportersCompletedEventArgs e) { PanelQueue.Enqueue(e); if (!PanelQueueWorking) { PanelQueueWorking = true; new Thread(() => { while (PanelQueue.Count > 0) { RetrievePanelOfReportersCompletedEventArgs ee = PanelQueue.Dequeue(); //For each bank, create a new entry if none exists, and add identifying information Bank newBank; int pendingRequests = ee.Result.Count(); OnRequestsRemaining(pendingRequests); using (var db = database.GetContext()) { // Each result will have a panel of bank objects to parse foreach (ReportingFinancialInstitution bank in ee.Result) { // Get or create the bank in our database newBank = db.GetBank(bank.ID_RSSD); // Update fields newBank.BankName = bank.Name; newBank.BankState = bank.State; newBank.BankCity = bank.City; newBank.BankAddress = bank.Address; newBank.BankZip = bank.ZIP; // Set report shell for this period newBank.GetReport((DateTime)ee.UserState); OnRequestsRemaining(--pendingRequests); } // Save changes db.SaveChanges(); OnRequestsRemaining(0); } } PanelQueueWorking = false; }).Start(); } }
public void TestDatabase() { using (var db = database.GetContext()) { Console.WriteLine("Banks: {0}", db.Banks.Count()); Console.WriteLine("Reports: {0}", db.Reports.Count()); Console.WriteLine("Points: {0}", db.DataPoints.Count()); } }
private void InitializeForm() { // Set status box textBoxWebDataStatus.DeselectAll(); textBoxWebDataStatus.TabStop = false; textBoxWebDataStatus.ReadOnly = true; textBoxWebDataStatus.GotFocus += (s, e) => { this.Focus(); }; // Status scroller webdata.RequestsRemaining += Webdata_RequestsRemaining; // Set toolbar -> Data -> XBRL Path selectXBRLPathToolStripMenuItem.Click += (s, e) => { FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { webdata.TemporaryDirectory = dialog.SelectedPath + "\\"; } }; // Set toolbar -> System -> Initialize initializeToolStripMenuItem.Click += (s, e) => { if (!webdata.Connected) { webdata.InitializeServices(); } }; // Set toolbar -> Data -> Test Load Banks LoadBanksToolStripMenuItem.Click += (s, e) => { foreach (DateTime Period in webdata.AllReportingPeriods) { webdata.LoadReportingInstitutions(Period); } }; // Testing downloadXBRLReportsToolStripMenuItem.Click += DownloadXBRLReportsToolStripMenuItem_Click; // Report Period Box webdata.Ready += (s, f) => { foreach (DateTime period in webdata.AllReportingPeriods) { checkedListBox_ReportingPeriods.Items.Add(period); } checkedListBox_ReportingPeriods.Refresh(); button_StartReportDownload.Enabled = true; }; // Download reports button button_StartReportDownload.Click += (s, e) => { using (var db = database.GetContext()) { foreach (DateTime selectedPeriod in checkedListBox_ReportingPeriods.SelectedItems) { foreach (Bank bank in db.GetBanksByPeriodWithoutDate(selectedPeriod)) { webdata.RequestXBRLReport(bank, selectedPeriod); } } } }; // Test print statistics printStatisticsToolStripMenuItem.Click += (s, e) => { using (var db = database.GetContext()) { Console.WriteLine("Banks: {0}", db.Banks.Count()); Console.WriteLine("Reports: {0}", db.Reports.Count()); Console.WriteLine("Points: {0}", db.DataPoints.Count()); foreach (DateTime period in webdata.AllReportingPeriods) { Console.WriteLine("Period {0} Reports {1}", period, db.GetBanksByPeriod(period).Count); } } }; }