//private void btnUpdateVersion_Click(object sender, RoutedEventArgs e) //{ // //ECFVersionByCourt _ecf = new ECFVersionByCourt(); // //List<ECFVersion> _versions = _ecf.GetBankruptcyCourtVersions(); // if (cboCourt.SelectedIndex == -1) // { // MessageBox.Show("Please Select a Court!"); // return; // } // else if (cboECFVersion.SelectedIndex == -1) // { // MessageBox.Show("Please Select an ECF Version!"); // return; // } // else // { // try // { // Court _court = (Court)cboCourt.SelectedValue; // //get the corresponding ID; // _court.PacerFileFormatID = ((PacerFileFormat)cboECFVersion.SelectedValue).ID; // CourtService.Save(_court); // MessageBox.Show("Version updated to " + ((PacerFileFormat)cboECFVersion.SelectedValue).PacerFileVersion + " for court: " + _court.CourtName); // lblECFVersion.Content = ((PacerFileFormat)cboECFVersion.SelectedValue).PacerFileVersion; // cboECFVersion.SelectedIndex = -1; // } // catch (Exception ex) // { // MessageBox.Show("Error: " + ex.ToString()); // } // } //} private void btnCheckCourtVersions_Click(object sender, RoutedEventArgs e) { //ECFVersionByCourt _ecf = new ECFVersionByCourt(); //List<ECFVersion> _versions = _ecf.GetBankruptcyCourtVersions(); try { Mouse.OverrideCursor = Cursors.Wait; MessageBox.Show(CourtService.CheckECFVersions(), "PACER ECF Version Update Results!"); Mouse.OverrideCursor = Cursors.Arrow; } catch (Exception ex) { MessageBox.Show("Error: " + ex.ToString()); Mouse.OverrideCursor = Cursors.Arrow; } }
private void bwAsync_DoWork(object sender, DoWorkEventArgs e) { try { // The Sender is the BackgroundWorker object we need it to // report progress and check for cancellation. BackgroundWorker bwAsync = sender as BackgroundWorker; MutipleProcessSpec _spec = (MutipleProcessSpec)e.Argument; int i = 0; string _state = "Checking ECF Versions..."; bwAsync.ReportProgress(0, _state); _state = CourtService.CheckECFVersions(); bwAsync.ReportProgress(0, _state); Thread.Sleep(1000); foreach (object _court in _spec.Courts) { i++; //refresh court from ID to get version that may have been updated CourtService.Refresh((Court)_court); if ((_spec.FiledOnly == true && (((Court)_court).LastPacerLoadFileDate == DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()))) || (_spec.FiledOnly == false && (((Court)_court).LastPacerLoadDischargeDate == DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString())))) { //do nothing } else { // Periodically report progress to the main thread so that it can // update the UI. _state = "Downloading cases for " + ((Court)_court).CourtName + "..."; bwAsync.ReportProgress(Convert.ToInt32(i * (100.0 / _courts.Count)), _state); PacerImportTransaction _transaction = new PacerImportTransaction(); _transaction.CourtID = ((Court)_court).ID; _transaction.CourtName = ((Court)_court).CourtName; _transaction.DischargedCases = !_spec.FiledOnly; if (_spec.StartDate != null) { _transaction.StartDate = (DateTime)_spec.StartDate; } //filed only cases use the LastPacerLoadFileDate else if (_spec.FiledOnly == true) { if (((DateTime)((Court)_court).LastPacerLoadFileDate) > DateTime.MinValue) { _transaction.StartDate = ((DateTime)((Court)_court).LastPacerLoadFileDate).AddDays(1); } else { _transaction.StartDate = DateTime.Now.AddMonths(-1); } } //discharged cases use the LastPacerLoadFileDate else if (_spec.FiledOnly == false) { if (((DateTime)((Court)_court).LastPacerLoadDischargeDate) > DateTime.MinValue) { _transaction.StartDate = ((DateTime)((Court)_court).LastPacerLoadDischargeDate).AddDays(1); } else { _transaction.StartDate = DateTime.Now.AddMonths(-1); } } if (_spec.EndDate != null) { _transaction.EndDate = (DateTime)_spec.EndDate; } else { _transaction.EndDate = DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()); } _transaction.PacerFileFormatID = ((Court)_court).PacerFileFormatID; //check if the transaction overlaps prior periods to avoid extra chanrges, if so throw an error _transaction.CheckForPriorOverlappingDownloads(); _transaction.DownloadNewCases(_spec.GeocodeAddresses); _multipleTransactions.Add(_transaction); // Periodically check if a Cancellation request is pending. If the user // clicks cancel the line _asyncWorker.CancelAsync(); if (bwAsync.CancellationPending) { // Pause for bit to demonstrate that there is time between // "Cancelling..." and "Canceled". // Thread.Sleep(1200); // Set the e.Cancel flag so that the WorkerCompleted event // knows that the process was canceled. e.Cancel = true; return; } } } bwAsync.ReportProgress(100); } catch (Exception ex) { MessageBox.Show(ex.Message); } }