public bool DownloadNewCases(bool GeoCodeAddresses)
        {
            //ceck if we've established conection and queried for the data

            bool _status = false;

            //we may be calling Downloadnewcases without the intermediate prompt that QueryCases allows.\
            //if so call it first.
            if (_result == null)
            {
                _status = QueryNewCases();
            }

            if (_status == true || _result != null)
            {
                try
                {
                    string _rawData = _bankruptcyParser.PurchaseCases(_result);
                    if (_rawData == null || _rawData.Length == 0)
                    {
                        _importStatus = "NO DATA";
                        return(false);
                    }
                    //_transaction.RawData = "text";

                    //string _rawData = "text";

                    //create the filepath
                    string newPath = System.IO.Path.Combine(ConfigurationManager.AppSettings.Get("PACERFilePath"), _court.FilePrefix);
                    System.IO.Directory.CreateDirectory(newPath);

                    _filePath = newPath + @"\" + _court.FilePrefix + _startDate.ToString("MMddyyyy") + "_" + _endDate.ToString("MMddyyyy") + ".txt";

                    System.IO.File.WriteAllText(_filePath, _rawData);

                    PacerImportTransactionService.Save(this);

                    //if (_court == null)
                    //{
                    //    _court = CourtService.GetByID(this.CourtID);
                    //}

                    // ZipGeoCodeService.UpdateStatsForState(_court.StateCode);

                    //execute the dts package
                    //Load DTSX

                    //Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
                    //Package package = app.LoadPackage(System.Configuration.ConfigurationManager.AppSettings.Get("PACERImportDTSXFile"), null);

                    ////Specify Excel Connection From DTSX Connection Manager
                    //Debug.WriteLine(package.Connections["SourceConnectionFlatFile"].ConnectionString);
                    //package.Connections["SourceConnectionFlatFile"].ConnectionString = _filePath;

                    //Debug.WriteLine(package.Connections["DestinationConnectionOLEDB"].ConnectionString);
                    //package.Connections["DestinationConnectionOLEDB"].ConnectionString = ConfigurationManager.AppSettings["DTSConnectionString"];

                    ////    //Execute DTSX.
                    //Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                    //if (results == DTSExecResult.Success)
                    //{
                    //    //yay!
                    //    BRGCaseMailServer.PacerImportTransactionService.ProcessImportTransaction(this);
                    //}
                    //else
                    //{
                    //    string _message = string.Empty;
                    //    foreach (DtsError _err in package.Errors)
                    //    {
                    //        _message += _err.Description + ".  ";

                    //    }
                    //    _message += "Please see you system adminstrator. ";

                    //    //dts did not work so load the file and parse manually
                    //    _importMessage = "SSIS Import Failed with the error:" + _message + ".  Trying Manaul import...";

                    if (BRGCaseMailServer.PacerImportTransactionService.ProcessManualImportTransaction(this) == true)
                    {
                        //process imported lines
                        int rows = PacerImportTransactionService.ProcessImportedLineItems(this, GeoCodeAddresses);
                        if (_court == null)
                        {
                            _court = CourtService.GetByID(this.CourtID);
                        }
                        if (this._dischargedCases == true)
                        {
                            _court.LastPacerLoadDischargeDate = this.EndDate;
                        }
                        else
                        {
                            _court.LastPacerLoadFileDate = this.EndDate;
                        }

                        CourtService.Save((Court)_court);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    _importMessage = ex.Message;
                    _importStatus  = "FAILURE";
                    PacerImportTransactionService.Save(this);
                    return(false);
                }
            }
            else
            {
                PacerImportTransactionService.Save(this);
                return(false); //end   if (_status == true || _result != null)
            }
        }
        public bool Reprocess(bool GeoCodeAddresses)
        {
            //ceck if we've established conection and queried for the data

            if (this.FilePath.Length > 0)
            {
                try
                {
                    // Read the file as one string.
                    System.IO.StreamReader myFile = new System.IO.StreamReader(this.FilePath);
                    string _rawData = myFile.ReadToEnd();
                    myFile.Close();

                    if (_rawData == null || _rawData.Length == 0)
                    {
                        _importStatus = "NO DATA";
                        return(false);
                    }

                    //delete all imported data but don;t bother deleting bankruptcy case data as it will get written over
                    //if already exists
                    PacerImportDataService.DeleteForTransaction(this.ID);

                    //get the court
                    //Court _court = CourtService.GetByID(this.CourtID);
                    //this.PacerFileFormatID = _format.ID;

                    PacerFileFormat _format = PacerFileFormatService.GetByID(this.PacerFileFormatID);

                    //on a reprocess we use the current format for the court
                    if (BRGCaseMailServer.PacerImportTransactionService.ProcessManualImportTransaction(this, _format) == true)
                    {
                        //process imported lines
                        int rows = PacerImportTransactionService.ProcessImportedLineItems(this, GeoCodeAddresses);
                        if (_court == null)
                        {
                            _court = CourtService.GetByID(this.CourtID);
                        }
                        if (this._dischargedCases == true)
                        {
                            _court.LastPacerLoadDischargeDate = this.EndDate;
                        }
                        else
                        {
                            _court.LastPacerLoadFileDate = this.EndDate;
                        }

                        CourtService.Save((Court)_court);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    this.ImportMessage = ex.Message;
                    this.ImportStatus  = "FAILURE";
                    PacerImportTransactionService.Save(this);
                    return(false);
                }
            }
            else
            {
                PacerImportTransactionService.Save(this);
                return(false); //end   if (_status == true || _result != null)
            }
        }