private void btnReprocess_Click(object sender, RoutedEventArgs e)
        {
            RadButton _button = (RadButton)sender;

            PacerImportTransaction _transaction = ((PacerImportTransaction)_button.DataContext);

            //Dealer _selectedDealer = DealerService.GetByID(ID);

            Mouse.OverrideCursor = Cursors.Wait;

            if (cboECFVersion.SelectedIndex > -1)
            {
                _transaction.PacerFileFormatID = ((PacerFileFormat)cboECFVersion.SelectedItem).ID;
            }

            if (MessageBox.Show("Geocode the address locations?", "Geocode Locations?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                _transaction.Reprocess(false);
            }
            else
            {
                _transaction.Reprocess(true);
            }

            Mouse.OverrideCursor = Cursors.Arrow;
            LoadTransactions();
            MessageBox.Show(_transaction.ImportMessage);
        }
Beispiel #2
0
        private void btnDownLoad_Click(object sender, RoutedEventArgs e)
        {
            PacerImportTransaction _transaction = new PacerImportTransaction()
            {
                DischargedCases = (bool)rdoDischarged.IsChecked, StartDate = (DateTime)rdpStartDate.SelectedDate, EndDate = (DateTime)rdpEndDate.SelectedDate, CourtID = _court.ID, PacerFileFormatID = _court.PacerFileFormatID
            };

            Mouse.OverrideCursor = Cursors.Wait;

            if (_transaction.QueryNewCases() == true)
            {
                if (MessageBox.Show("Do you wish to download and pay for " + _transaction.BillablePages.ToString() + " billable pages for " + _transaction.Cost.ToString("C"), "Continue?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (_transaction.DownloadNewCases(true) == true)
                    {
                        Mouse.OverrideCursor = Cursors.Arrow;
                        MessageBox.Show(_transaction.ImportMessage);
                        this.DialogResult = true;
                        this.Close();
                    }
                    else
                    {
                        Mouse.OverrideCursor = Cursors.Arrow;
                        MessageBox.Show(_transaction.ImportMessage);
                    }
                }
                Mouse.OverrideCursor = Cursors.Arrow;
            }
            else
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(_transaction.ImportMessage);
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            RadButton _button = (RadButton)sender;

            PacerImportTransaction _transaction = ((PacerImportTransaction)_button.DataContext);

            //Dealer _selectedDealer = DealerService.GetByID(ID);

            if (MessageBox.Show("Delete the transaction from " + _transaction.DownloadTimeStamp.ToString() + " and all record of imported cases from the database?", "Delete Transaction?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                PacerImportTransactionService.Delete(_transaction);
                LoadTransactions();
            }
        }
        public RawDataWindow(PacerImportTransaction _transaction)
        {
            InitializeComponent();

            if (_transaction != null)
            {
                this._pITransaction   = _transaction;
                txtCourtName.Text     = _pITransaction.CourtName;
                txtBillablePages.Text = _pITransaction.BillablePages.ToString();
                txtCost.Text          = _pITransaction.Cost.ToString("c");
                txtTimestamp.Text     = _pITransaction.DownloadTimeStamp.ToLongTimeString();
                txtStartDate.Text     = _pITransaction.StartDate.ToShortDateString();
                txtEndDate.Text       = _pITransaction.EndDate.ToShortDateString();
                txtLines.Text         = _pITransaction.LineCount.ToString();
                txtUniqueCases.Text   = _pITransaction.TotalCases.ToString();
                txtImportStatus.Text  = _pITransaction.ImportStatus;

                try
                {
                    // Read the file as one string.
                    System.IO.StreamReader myFile = new System.IO.StreamReader(_pITransaction.FilePath);
                    txtRawData.Text = myFile.ReadToEnd();
                    myFile.Close();
                }
                catch (IOException e)
                {
                    // Let the user know what went wrong.
                    txtRawData.Text = "The original raw data file was not found and may have been moved/removed from the directory!";
                }

                GridViewLineItems.ItemsSource = PacerImportDataService.GetForImportTransaction(_pITransaction.ID);

                GridViewBankruptcyCases.ItemsSource = BankruptcyCaseService.GetFiltered(_pITransaction.ID.ToString(), string.Empty, string.Empty, string.Empty, 0, string.Empty, false);

                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);
            }
        }