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);
            }
        }
Exemplo n.º 2
0
        static public void Delete(PacerFileFormat objPacerFileFormat)
        {
            Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");

            System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_PacerFileFormatDelete");
            db.AddInParameter(dbCommand, "ID", DbType.Int32, objPacerFileFormat.ID);
            db.ExecuteNonQuery(dbCommand);
        }
Exemplo n.º 3
0
        public PacerFileFormat Copy()
        {
            PacerFileFormat _pacerFileFormat = new PacerFileFormat();

            _pacerFileFormat.ID = _iD;
            _pacerFileFormat.PacerFileVersion = _pacerFileVersion;
            _pacerFileFormat.NumberColumns    = _numberColumns;
            return(_pacerFileFormat);
        }
Exemplo n.º 4
0
        static private void Update(PacerFileFormat objPacerFileFormat)
        {
            Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");

            System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_PacerFileFormatUpdate");
            db.AddInParameter(dbCommand, "ID", DbType.Int32, objPacerFileFormat.ID);
            db.AddInParameter(dbCommand, "PacerFileVersion", DbType.String, objPacerFileFormat.PacerFileVersion);
            db.AddInParameter(dbCommand, "NumberColumns", DbType.Int32, objPacerFileFormat.NumberColumns);
            db.ExecuteNonQuery(dbCommand);
        }
Exemplo n.º 5
0
        static private void Insert(PacerFileFormat objPacerFileFormat)
        {
            Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");

            System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_PacerFileFormatInsert");
            db.AddOutParameter(dbCommand, "ID", DbType.Int32, 4);
            db.AddInParameter(dbCommand, "PacerFileVersion", DbType.String, objPacerFileFormat.PacerFileVersion);
            db.AddInParameter(dbCommand, "NumberColumns", DbType.Int32, objPacerFileFormat.NumberColumns);
            db.ExecuteNonQuery(dbCommand);
            objPacerFileFormat.ID = Int32.Parse(db.GetParameterValue(dbCommand, "ID").ToString());
        }
Exemplo n.º 6
0
        static public string CheckECFVersions()
        {
            ECFVersionByCourt _version = new ECFVersionByCourt();

            List <ECFVersion> _versions = _version.GetBankruptcyCourtVersions();

            int iUnknownFormat = 0;
            int iUnknownCourt  = 0;
            int iUpdated       = 0;
            int iMatch         = 0;

            foreach (ECFVersion _ecf in _versions)
            {
                PacerFileFormat _format = PacerFileFormatService.GetByVersionString(_ecf.versionString);
                if (_format == null)
                {
                    iUnknownFormat++;
                }
                else
                {
                    Court _icourt = CourtService.GetByECFCourtString(_ecf.courtName);

                    //if ( _icourt.CourtName == "Illinois Central")
                    //    Debug.WriteLine(_icourt.CourtAndFileVersion);

                    if (_icourt != null && _icourt.PacerFileFormatID == _format.ID)
                    {
                        iMatch++;
                    }
                    else if (_icourt != null)
                    {
                        _icourt.PacerFileFormatID = _format.ID;
                        _icourt.PacerFileVersion  = _format.PacerFileVersion;
                        CourtService.Save(_icourt);
                        iUpdated++;
                    }
                    else
                    {
                        iUnknownCourt++;
                    }
                }
            }

            return(iUpdated + " courts updated, " + iMatch + " court versions matched, " + iUnknownFormat + " pacer file formats unknown, " + iUnknownCourt + " Courts unknown ");
        }
Exemplo n.º 7
0
        static public List <PacerFileFormat> GetAll()
        {
            List <PacerFileFormat> objPacerFileFormats = new List <PacerFileFormat>();
            Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _selectViewSQL))
            {
                while (reader.Read())
                {
                    PacerFileFormat objPacerFileFormat = new PacerFileFormat();
                    LoadPacerFileFormat(objPacerFileFormat, reader);
                    objPacerFileFormat.IsModified = false;
                    objPacerFileFormats.Add(objPacerFileFormat);
                }
                // always call Close when done reading.
                reader.Close();
                return(objPacerFileFormats);
            }
        }
Exemplo n.º 8
0
        static public PacerFileFormat GetByVersionString(string _version)
        {
            PacerFileFormat objPacerFileFormat = new PacerFileFormat();
            string          query = _selectViewSQL + " where PacerFileVersion = '" + _version + "'";
            Database        db    = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, query))
            {
                if (reader.Read())
                {
                    LoadPacerFileFormat(objPacerFileFormat, reader);
                    // always call Close when done reading.
                    reader.Close();
                    objPacerFileFormat.IsModified = false;
                    return(objPacerFileFormat);
                }
                else
                {
                    return(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)
            }
        }