static public bool ProcessManualImportTransaction(PacerImportTransaction objPacerImportTransaction) { //use this when the SSIS import fails. Database db = DatabaseFactory.CreateDatabase("BRGCaseMail"); if (objPacerImportTransaction.PacerFileFormatID == 0) { throw new ArgumentException("Pacer File Format not specified!"); } PacerFileFormat _format = PacerFileFormatService.GetByID(objPacerImportTransaction.PacerFileFormatID); // Read and display lines from the file until the end of // the file is reached. DbConnection conn = db.CreateConnection(); conn.Open(); DbTransaction trans = conn.BeginTransaction(); try { using (TextReader tr = File.OpenText(objPacerImportTransaction.FilePath)) { String line; int i = 0; while ((line = tr.ReadLine()) != null) { PacerTempRawImportData _data = new PacerTempRawImportData(line, _format); PacerTempRawImportDataService.Insert(_data, db, trans); if (i == 1167) { Debug.WriteLine("line:" + i.ToString() + " " + _data.CaseNumber4Digit); } i++; Debug.WriteLine("line:" + i.ToString() + " " + _data.CaseNumber4Digit); } System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_ImportRawPACERData"); db.AddInParameter(dbCommand, "PacerImportTransactionID", DbType.Int32, objPacerImportTransaction.ID); db.ExecuteNonQuery(dbCommand, trans); trans.Commit(); return(true); } } catch (Exception ex) { objPacerImportTransaction.ImportMessage = "Import Failed. Error: " + ex.Message; objPacerImportTransaction.ImportStatus = "FAILURE"; trans.Rollback(); //Save trans we're done. PacerImportTransactionService.Save(objPacerImportTransaction); return(false); } }
/// <summary> /// Checks to see if there are prior downloads that overlap the transaction search parameters /// </summary> public void CheckForPriorOverlappingDownloads() { List <PacerImportTransaction> _transactions = PacerImportTransactionService.GetOverLappingTransactions(this); if (_transactions.Count > 0) { throw new Exception("The Date Range for the Court: " + this.CourtName + " overlaps previous SUCCESSFUL import transactions of this type. You are trying to purchase duplicate data!"); } }
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) } }
public bool QueryNewCases() { o = new CaseSearchOptions(); string user = System.Configuration.ConfigurationManager.AppSettings.Get("PACERuser"); string pass = System.Configuration.ConfigurationManager.AppSettings.Get("PACERPassword"); _court = CourtService.GetByID(_courtID); _bankruptcyParser = new BankruptcyParser(_court.URLAbbrv, user, pass); // Login to the system if (!_bankruptcyParser.Login()) { _importMessage = "Could Not Login: "******"FAILURE"; _court = CourtService.GetByID(_courtID); _bankruptcyParser = new BankruptcyParser(_court.URLAbbrv, user, pass); if (!_bankruptcyParser.NextGenLogin()) { return(false); } else { return(true); } } // setup the search paramters o.open_cases = true; o.closed_cases = true; o.party_information = true; //set the chapters and discharged/filed o.chapter = new List <CaseSearchOptions.chapters>(); if (_dischargedCases == true) { o.date_type = CaseSearchOptions.date_types.discharged; o.chapter.Add(CaseSearchOptions.chapters.seven); o.chapter.Add(CaseSearchOptions.chapters.thirteen); } else { o.date_type = CaseSearchOptions.date_types.filed; o.chapter.Add(CaseSearchOptions.chapters.seven); } //set the case type o.case_type = new List <CaseSearchOptions.case_types>(); o.case_type.Add(CaseSearchOptions.case_types.bk); //Set the start and end dates. o.start = DateTime.Parse(_startDate.ToString()); o.end = DateTime.Parse(_endDate.ToString()); _result = _bankruptcyParser.FindCases(o); if (_result == null) { _importMessage = "Could Not Find Cases:" + _bankruptcyParser.lastError; _importStatus = "FAILURE"; PacerImportTransactionService.Save(this); return(false); } else { this.BillablePages = _result.billable_pages; this.Cost = Decimal.Parse(_result.cost.ToString()); SearchCriteria = _result.criteria; DownloadTimeStamp = DateTime.Now; PacerImportTransactionService.Save(this); //don't set the status and message yet as we still have to import... return(true); } }