static public int ProcessImportedLineItems(PacerImportTransaction objPacerImportTransaction, bool GeocodeLocations)
        {
            List <PacerImportData> _data        = PacerImportDataService.GetForImportTransaction(objPacerImportTransaction.ID);
            PacerImportData        _previousRow = null;
            int insertedRowCount = 0;
            int updatedRowCount  = 0;
            int formatErrors     = 0;

            string StateCode = null;

            foreach (PacerImportData _row in _data)
            {
                if (_previousRow == null)
                {
                    //first row - is this row a debtor  - if this row fails we just exit with failure because the
                    //file format is most likely incorrect.
                    if (((_row.PartyCaseRole.ToUpper() == "DEBTOR") || (_row.PartyCaseRole.ToUpper() == "CO-DEBTOR") || (_row.PartyCaseRole.ToUpper() == "JOINT DEBTOR")) && _row.CareOfOK)
                    {
                        _row.Imported = true;
                        PacerImportDataService.Save(_row);
                        try
                        {
                            BankruptcyCase _case = new BankruptcyCase(_row);

                            Debug.WriteLine(_case.CaseNumber4Digit);
                            if (GeocodeLocations)
                            {
                                YahooGeoCoder.GeocodeCase(_case);
                            }
                            _case.IsModified = true;

                            int returnvalue = BankruptcyCaseService.Save(_case, true);

                            if (returnvalue == 1)
                            {
                                insertedRowCount++;
                            }
                            else if (returnvalue == 2)
                            {
                                updatedRowCount++;
                            }
                        }
                        catch (Exception ex)
                        {
                            formatErrors++;
                        }
                    }
                    _previousRow = _row;
                }
                else //previousrow != null  if this row fails we do not exit with failure because the
                // it's just a bad row.
                {
                    if (_row.PartyAddressLine1 != _previousRow.PartyAddressLine1 && ((_row.PartyCaseRole.ToUpper() == "DEBTOR") || (_row.PartyCaseRole.ToUpper() == "CO-DEBTOR") || (_row.PartyCaseRole.ToUpper() == "JOINT DEBTOR")) && _row.CareOfOK)
                    {
                        try
                        {
                            //debtor at different address
                            _row.Imported = true;
                            PacerImportDataService.Save(_row);

                            BankruptcyCase _case = new BankruptcyCase(_row);

                            if (GeocodeLocations)
                            {
                                YahooGeoCoder.GeocodeCase(_case);
                            }
                            if (insertedRowCount == 318)
                            {
                                Debug.WriteLine(_case.CaseNumber4Digit);
                            }
                            if (_case.LastName == "Babakatis")
                            {
                                Debug.WriteLine(_case.CaseNumber4Digit);
                            }
                            _case.IsModified = true;
                            int returnvalue = BankruptcyCaseService.Save(_case, true);

                            if (returnvalue == 1)
                            {
                                insertedRowCount++;
                                if (insertedRowCount == 1654)
                                {
                                    Debug.WriteLine(insertedRowCount);
                                }
                            }
                            else if (returnvalue == 2)
                            {
                                updatedRowCount++;
                            }
                        }
                        catch (Exception e)
                        {
                            formatErrors++;
                        }
                    }

                    _previousRow = _row;
                }
            }

            // update counts for
            objPacerImportTransaction.InsertedCases = insertedRowCount;
            objPacerImportTransaction.LineCount     = _data.Count;
            objPacerImportTransaction.TotalCases    = insertedRowCount + updatedRowCount;
            if (objPacerImportTransaction.ImportMessage.Length > 0)
            {
                //we already have an import string - parse the result to add the previous total
                try
                {
                    if (objPacerImportTransaction.ImportMessage.IndexOf("Unique Cases Added") > 0)
                    {
                        int previoustotal = Int32.Parse(objPacerImportTransaction.ImportMessage.Substring(0, objPacerImportTransaction.ImportMessage.IndexOf("Unique Cases Added") - 1));
                        objPacerImportTransaction.ImportMessage = previoustotal + insertedRowCount + " Unique Cases Added!  " + updatedRowCount + " Cases Updated!  " + formatErrors + " format Errors.";
                    }
                    else
                    {
                        objPacerImportTransaction.ImportMessage = insertedRowCount + " Unique Cases Added!  " + updatedRowCount + " Cases Updated!  " + formatErrors + " format Errors.";
                    }
                }
                catch
                {
                }
            }
            else
            {
                objPacerImportTransaction.ImportMessage = insertedRowCount + " Unique Cases Added!  " + updatedRowCount + " Cases Updated!  " + formatErrors + " format Errors.";
            }
            objPacerImportTransaction.ImportStatus = "SUCCESS";
            Save(objPacerImportTransaction);

            Court _court = CourtService.GetByID(objPacerImportTransaction.CourtID);

            ZipGeoCodeService.UpdateStatsForState(_court.StateCode);
            return(insertedRowCount);
        }
        public PacerImportData Copy()
        {
            PacerImportData _pacerImportData = new PacerImportData();

            _pacerImportData.ID       = _iD;
            _pacerImportData.Imported = _imported;
            _pacerImportData.PacerImportTransactionID = _pacerImportTransactionID;
            _pacerImportData.CaseNumber2Digit         = _caseNumber2Digit;
            _pacerImportData.CaseNumber4Digit         = _caseNumber4Digit;
            _pacerImportData.CMECF                          = _cMECF;
            _pacerImportData.Chapter                        = _chapter;
            _pacerImportData.PreviousChapter                = _previousChapter;
            _pacerImportData.ConversionDate                 = _conversionDate;
            _pacerImportData.DischargedDate                 = _dischargedDate;
            _pacerImportData.DismissedDate                  = _dismissedDate;
            _pacerImportData.FiledDate                      = _filedDate;
            _pacerImportData.EnteredDate                    = _enteredDate;
            _pacerImportData.ClosedDate                     = _closedDate;
            _pacerImportData.Disposition                    = _disposition;
            _pacerImportData.CaseType                       = _caseType;
            _pacerImportData.TrusteeLastName                = _trusteeLastName;
            _pacerImportData.JudgeLastName                  = _judgeLastName;
            _pacerImportData.CountyFiled                    = _countyFiled;
            _pacerImportData.OfficeName                     = _officeName;
            _pacerImportData.FilingFeePaymentStatus         = _filingFeePaymentStatus;
            _pacerImportData.AssetsInCase                   = _assetsInCase;
            _pacerImportData.CaseDisposition                = _caseDisposition;
            _pacerImportData.JointDebtorDischargeDate       = _jointDebtorDischargeDate;
            _pacerImportData.JointDebtorDismissalDate       = _jointDebtorDismissalDate;
            _pacerImportData.JointDebtorDispositionCode     = _jointDebtorDispositionCode;
            _pacerImportData.JointDebtorDisposition         = _jointDebtorDisposition;
            _pacerImportData.DivisionalOfficeFiled          = _divisionalOfficeFiled;
            _pacerImportData.AdversaryProceedingSeqNo       = _adversaryProceedingSeqNo;
            _pacerImportData.AdversaryProceedingYear        = _adversaryProceedingYear;
            _pacerImportData.AdversaryProceedingDisposition = _adversaryProceedingDisposition;
            _pacerImportData.PartyFirstName                 = _partyFirstName;
            _pacerImportData.PartyMiddleName                = _partyMiddleName;
            _pacerImportData.PartyLastName                  = _partyLastName;
            _pacerImportData.PartyGeneration                = _partyGeneration;
            _pacerImportData.PartyOffice                    = _partyOffice;
            _pacerImportData.PartyAddressLine1              = _partyAddressLine1;
            _pacerImportData.PartyAddressLine2              = _partyAddressLine2;
            _pacerImportData.PartyAddressLine3              = _partyAddressLine3;
            _pacerImportData.PartyCity                      = _partyCity;
            _pacerImportData.PartyState                     = _partyState;
            _pacerImportData.PartyZipCode                   = _partyZipCode;
            _pacerImportData.PartyCountry                   = _partyCountry;
            _pacerImportData.PartyPhone                     = _partyPhone;
            _pacerImportData.PartySSNo                      = _partySSNo;
            _pacerImportData.PartyTaxID                     = _partyTaxID;
            _pacerImportData.PartyCaseSeqNo                 = _partyCaseSeqNo;
            _pacerImportData.PartyCaseRole                  = _partyCaseRole;
            _pacerImportData.PartyTerminatedDate            = _partyTerminatedDate;
            _pacerImportData.CaseTitle                      = _caseTitle;
            _pacerImportData.AttorneyFirstName              = _attorneyFirstName;
            _pacerImportData.AttorneyMiddleName             = _attorneyMiddleName;
            _pacerImportData.AttorneyLastName               = _attorneyLastName;
            _pacerImportData.AttorneyGeneration             = _attorneyGeneration;
            _pacerImportData.AttorneyOffice                 = _attorneyOffice;
            _pacerImportData.AttorneyOfficeLine1            = _attorneyOfficeLine1;
            _pacerImportData.AttorneyOfficeLine2            = _attorneyOfficeLine2;
            _pacerImportData.AttorneyOfficeLine3            = _attorneyOfficeLine3;
            _pacerImportData.AttorneyCity                   = _attorneyCity;
            _pacerImportData.AttorneyState                  = _attorneyState;
            _pacerImportData.AttorneyZipCode                = _attorneyZipCode;
            _pacerImportData.AttorneyCountry                = _attorneyCountry;
            _pacerImportData.AttorneyPhone                  = _attorneyPhone;
            _pacerImportData.CourtID                        = _courtID;
            _pacerImportData.DischargedCases                = _dischargedCases;
            _pacerImportData.CourtName                      = _courtName;
            return(_pacerImportData);
        }
Esempio n. 3
0
        public BankruptcyCase(PacerImportData _row)
        {
            _iD      = 0;
            _courtID = _row.CourtID;

            try
            {
                //this is what sharp used for the casenumber.
                _cMECF_Internal = Int32.Parse(_row.CMECF);
            }
            catch
            { }

            _caseNumber4Digit         = _row.CaseNumber4Digit;
            _pacerImportTransactionID = _row.PacerImportTransactionID;
            _chapter   = _row.Chapter;
            _filedOnly = !_row.DischargedCases;

            if (_row.FiledDate != null)
            {
                _filedDate = (DateTime)_row.FiledDate;
            }
            if (_row.DischargedDate != null)
            {
                _dischargeDate = (DateTime)_row.DischargedDate;
            }

            _trustee    = _row.TrusteeLastName;
            _judge      = _row.JudgeLastName;
            _county     = _row.CountyFiled;
            _office     = _row.OfficeName;
            _fee        = _row.FilingFeePaymentStatus;
            _asset      = _row.AssetsInCase;
            _firstName  = _row.PartyFirstName;
            _middleName = _row.PartyMiddleName;
            _lastName   = _row.PartyLastName;
            if (_firstName.ToLower().Contains("test") || _lastName.ToLower().Contains("test"))
            {
                throw new Exception("Test Data in production");
            }

            //_suffix =
            _addrLine1 = _row.PartyAddressLine1;
            _addrLine2 = _row.PartyAddressLine2;
            _addrLine3 = _row.PartyAddressLine3;
            _city      = _row.PartyCity;
            _stateCode = _row.PartyState;
            //if this fails let the error percolate so the transaction can be rolled back
            _postalCode = Int32.Parse(_row.PartyZipCode.Substring(0, 5));
            //_postalLast4 = string.Empty;
            _country = _row.PartyCountry;
            _phone   = _row.PartyPhone;
            try
            {
                if (_row.PartySSNo == "xxx-xx-2939")
                {
                    Debug.WriteLine(_row.PartySSNo);
                }
                _ssnLast4 = _row.PartySSNo.Substring(_row.PartySSNo.LastIndexOf('-') + 1, 4);
            }
            catch
            {
            }
            //todo: hospital in Care of
            //_careOf = _row.
            //_dontSend = false;
            //_returned = false;
            //_soldCount = 0;
            //_lastSoldDate = System.DateTime.MinValue;
        }