private void btnProcessSelected_Click(object sender, RoutedEventArgs e)
        {
            foreach (var _removeMail in grdViewRemoveEmails.SelectedItems.ToList())
            {
                if (((RemoveMail)_removeMail).Subject.ToUpper() == "REMOVE")
                {
                    string[]       _body = ((RemoveMail)_removeMail).Body.Trim().Split(',');
                    string[]       _name = _body[0].Split(' ');
                    BankruptcyCase _case = BankruptcyCaseService.GetByNameAndZip(_name[0], "", _name[1], Int32.Parse(_body[1].Trim()));

                    if (_case != null)
                    {
                        _case.DontSend = true;
                        BankruptcyCaseService.Save(_case, false);

                        ((RemoveMail)_removeMail).Processed       = true;
                        ((RemoveMail)_removeMail).FoundAndRemoved = true;
                    }
                    else
                    {
                        ((RemoveMail)_removeMail).Processed       = true;
                        ((RemoveMail)_removeMail).FoundAndRemoved = false;
                    }

                    Imap.QuickDownloadMessages(ConfigurationManager.AppSettings["RemovePOP3Server"], ConfigurationManager.AppSettings["RemovePOP3User"], ConfigurationManager.AppSettings["RemovePOP3Password"], "Inbox");
                }
            }
        }
Esempio n. 2
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (_selectedBankruptcyCase == null)
     {
         _selectedBankruptcyCase = new BankruptcyCase();
     }
     SaveScreenToBankruptcyCase();
     BankruptcyCaseService.Save(_selectedBankruptcyCase, false);
     _rtc.Items.Remove(_rt);
     _rtc.SelectedItem = _rtc.Items[2];
 }
        private void LoadAndProcessRemoveEmails()
        {
            try
            {
                MailMessageCollection msgs;
                grdViewRemoveEmails.ItemsSource = null;

                Imap imp = new Imap();
                imp.Connect(ConfigurationManager.AppSettings["RemovePOP3Server"]);
                imp.Login(ConfigurationManager.AppSettings["RemovePOP3User"], ConfigurationManager.AppSettings["RemovePOP3Password"]);
                imp.SelectFolder("Inbox");

                int totalCount = imp.MessageCount;
                msgs = imp.DownloadEntireMessages("1:" + totalCount.ToString(), false);

                if (totalCount > 0)
                {
                    _removeMailMessages = new List <RemoveMail>();
                    RemoveMail _removeMailMessage = new RemoveMail();

                    int i = 1;

                    foreach (MailMessage _msg in msgs)
                    {
                        _removeMailMessage = new RemoveMail()
                        {
                            IndexOnMailServer = i, MsgDateTime = _msg.DateReceived, ToAddress = _msg.To.ToString(), FromAddress = _msg.From.ToString(), Body = _msg.BodyPlainText, Subject = _msg.Subject
                        };

                        if (((RemoveMail)_removeMailMessage).Subject.ToUpper().Contains("REMOVE"))
                        {
                            try
                            {
                                string[]       _body = ((RemoveMail)_removeMailMessage).Body.Trim().Split(',');
                                string[]       _name = _body[0].Split(' ');
                                BankruptcyCase _case = BankruptcyCaseService.GetByNameAndZip(_name[0], "", _name[1], Int32.Parse(_body[1].Trim()));

                                if (_case != null)
                                {
                                    _case.DontSend = true;
                                    BankruptcyCaseService.Save(_case, false);

                                    ((RemoveMail)_removeMailMessage).Processed       = true;
                                    ((RemoveMail)_removeMailMessage).FoundAndRemoved = true;
                                }
                                else
                                {
                                    ((RemoveMail)_removeMailMessage).Processed       = true;
                                    ((RemoveMail)_removeMailMessage).FoundAndRemoved = false;
                                }
                            }
                            catch { }
                        }

                        _removeMailMessages.Add(_removeMailMessage);

                        //save to the DB
                        RemoveMailService.Save(_removeMailMessage);
                    }

                    grdViewRemoveEmails.ItemsSource = _removeMailMessages;
                }

                //delete the messages
                if (ConfigurationManager.AppSettings["RemovePOP3Messages"] == "true")
                {
                    imp.DeleteMessages(Imap.AllMessages, false);
                    //_removeMailMessages.Clear();
                }
                imp.Close();
                imp.Disconnect();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
        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);
        }