Ejemplo n.º 1
0
        public DealerSalesReport(int dealerID, DateTime startDate, DateTime endDate)
        {
            DealerID  = dealerID;
            StartDate = startDate;
            EndDate   = EndDate;

            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            this.DataSource = DealerMailingListCaseService.GetByDealerSalesReport(dealerID, startDate, endDate);

            txtStartDate.Value = startDate.ToShortDateString();
            txtEndDate.Value   = endDate.ToShortDateString();

            Dealer _dealer = DealerService.GetByID(DealerID);

            txtDealerName.Value = _dealer.DealerName;
        }
Ejemplo n.º 2
0
        public Dealer Copy()
        {
            Dealer _dealer = new Dealer();

            _dealer.ID                            = _iD;
            _dealer.DealerName                    = _dealerName;
            _dealer.DealerNumber                  = _dealerNumber;
            _dealer.AddressLine1                  = _addressLine1;
            _dealer.City                          = _city;
            _dealer.State                         = _state;
            _dealer.Zip                           = _zip;
            _dealer.Phone                         = _phone;
            _dealer.Fax                           = _fax;
            _dealer.Latitude                      = _latitude;
            _dealer.Longitude                     = _longitude;
            _dealer.MaxDistance                   = _maxDistance;
            _dealer.DealerURL                     = _dealerURL;
            _dealer.ExportFilePath                = _exportFilePath;
            _dealer.CreatedOn                     = _createdOn;
            _dealer.LastUpdate                    = _lastUpdate;
            _dealer.NumberOfMailers               = _numberOfMailers;
            _dealer.StartDate                     = _startDate;
            _dealer.Term                          = _term;
            _dealer.DealerLogo                    = _dealerLogo;
            _dealer.Price                         = _price;
            _dealer.AcknowledgedTOS               = _acknowledgedTOS;
            _dealer.AcknowledgedTOSDate           = _acknowledgedTOSDate;
            _dealer.AcknowledgedTOSName           = _acknowledgedTOSName;
            _dealer.AcknowledgedTOSSignature      = _acknowledgedTOSSignature;
            _dealer.DefaultDocTemplateID          = _defaultDocTemplateID;
            _dealer.LegalDisclaimer               = _legalDisclaimer;
            _dealer.Active                        = _active;
            _dealer.DealerPrimaryContactName      = _dealerPrimaryContactName;
            _dealer.DealerPrimaryContactPhone     = _dealerPrimaryContactPhone;
            _dealer.DefaultDocTemplateDisplayName = _defaultDocTemplateDisplayName;
            return(_dealer);
        }
Ejemplo n.º 3
0
        static public List <ZipGeoCode> GetInsideRadius(Dealer dealer)
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BKLeadsOnline");

            System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_ZipGeoCodesInRadiusLoad");
            db.AddInParameter(dbCommand, "Latitude", DbType.Double, dealer.Latitude);
            db.AddInParameter(dbCommand, "Longitude", DbType.Double, dealer.Longitude);
            db.AddInParameter(dbCommand, "MaxDistance", DbType.Double, dealer.MaxDistance);

            using (IDataReader reader = db.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCodeWithDistanceAndNumLeads(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }
Ejemplo n.º 4
0
        public byte[] CreateMailingList(int MailingListID, bool UseWord)
        {
            DealerMailingList _originalMailingList;
            Dealer            _mergeDealer;

            _originalMailingList = DealerMailingListService.GetByID(MailingListID);
            _mergeDealer         = DealerService.GetByID(_originalMailingList.DealerID);

            if (WordDoc == null || WordFileSize == 0)
            {
                return(null);
            }
            else //if (_wordDoc != null && _wordFileSize > 0 )
            {
                //use ASPOSE to create PDF doc from Word byte array with no merging
                //do an on the fly conversion to PDF
                MemoryStream inStream = new MemoryStream(_wordDoc);

                //we also need a bankruptcy case or actully a list of cases with one item
                List <BankruptcyCase> _cases = BankruptcyCaseService.getMailingList(_originalMailingList.ID, _mergeDealer.ID, false);
                //_cases.Add(new BankruptcyCase() { FirstName = "Jane", LastName = "Doe", AddrLine1 = "1 Main St.", City = "Anytown", StateCode = "KS", ZipCodeString = "1001" });

                // Load the stream into a new document object.
                Aspose.Words.Document _asposeDoc = new Document(inStream);

                //Set up the event handler for image fields.
                _asposeDoc.MailMerge.FieldMergingCallback = new HandleMergeImageFieldFromBlob(_mergeDealer);

                //Example of a very simple mail merge to populate fields only once from an array of values.
                //does the dealer have a legal disclaimer?

                string _legalDisclaimer;
                if (_mergeDealer.LegalDisclaimer.Length > 0)
                {
                    _legalDisclaimer = _mergeDealer.LegalDisclaimer;
                }
                else
                {
                    _legalDisclaimer = _mergeDealer.DealerName + ConfigurationManager.AppSettings["LegalDisclaimer"];
                }

                _asposeDoc.MailMerge.Execute(
                    new string[] { "DealerName", "DealerFullAddress", "DealerPhoneNumber", "DealerPrimaryContactName", "DealerURL", "LegalDisclaimer", "DealerAddress", "DealerCity", "DealerState", "DealerZipCode", "MailingDate" },
                    new object[] { _mergeDealer.DealerName, _mergeDealer.DealerFullAddress, _mergeDealer.Phone, _mergeDealer.DealerPrimaryContactName, _mergeDealer.DealerURL, _legalDisclaimer, _mergeDealer.AddressLine1, _mergeDealer.City, _mergeDealer.State, _mergeDealer.Zip, DateTime.Now.ToShortDateString() });

                //det the dealer logo if the dealer is form the DB
                if (_mergeDealer.ID > 0)
                {
                    DealerService.GetLogo(_mergeDealer);
                }

                BankruptcyCaseMailMergeDataSource _source = new BankruptcyCaseMailMergeDataSource(_cases);
                _asposeDoc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedFields;

                //execute the mail merge
                _asposeDoc.MailMerge.Execute(_source);

                //send back a converted PDF
                MemoryStream outStream = new MemoryStream();
                //_asposeDoc.Save(outStream, Aspose.Words.SaveFormat.Doc);
                if (UseWord)
                {
                    _asposeDoc.Save(outStream, Aspose.Words.SaveFormat.Doc);
                }
                else
                {
                    _asposeDoc.Save(outStream, Aspose.Words.SaveFormat.Pdf);
                }

                _mailngListDoc = outStream.ToArray();
                return(_mailngListDoc);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// If no paramters are passed other than the dealer then we get the new leads since last login.
        /// If this is the first login or default we get the most recent default number of mailings
        /// </summary>
        /// <param name="_dealer"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <param name="NumberOfMailings"></param>
        /// <returns></returns>

        public byte[] CreateMailingList(Dealer _dealer, DateTime StartDate, DateTime EndDate, int NumberOfMailings, bool UseWord)
        {
            DateTime _startDate = DateTime.MinValue;
            DateTime _endDate   = DateTime.MinValue;
            int      _numberOfMailings;

            _mergeDealer = _dealer;

            if (WordDoc == null || WordFileSize == 0)
            {
                return(null);
            }
            //the options are
            else //1.  Start and End Date are null requested NumberOfMailings = 0   - get most recent
            {
                if ((StartDate == null || StartDate == DateTime.MinValue) && NumberOfMailings == 0)
                {
                    //get all data since the last mailinglist
                    List <DealerMailingList> _lists = DealerMailingListService.GetForDealer(_dealer.ID);
                    if (_lists.Count > 0)
                    {
                        //_startDate = DateTime.Parse(_lists[0].EndFilterDate.ToString("MM/dd/yyyy")).AddDays(1);
                        _startDate = DealerMailingListService.GetMaxDischargedDateForDealerMailingList(_dealer.ID);
                    }
                    else
                    {
                        _startDate = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy")).AddYears(-2);
                    }
                }
                else if (StartDate > DateTime.MinValue)
                {
                    _startDate = DateTime.Parse(StartDate.ToString("MM/dd/yyyy"));
                }
                else
                {
                    _startDate = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy")).AddYears(-2);
                }

                if (EndDate == null || EndDate == DateTime.MinValue)
                {
                    _endDate = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy"));
                }
                else
                {
                    _endDate = DateTime.Parse(EndDate.ToString("MM/dd/yyyy"));
                }

                if (NumberOfMailings == 0)
                {
                    //use the default number from the dealer
                    _numberOfMailings = _dealer.NumberOfMailers;
                }
                else
                {
                    _numberOfMailings = NumberOfMailings;
                }

                //use ASPOSE to create PDF doc from Word byte array with no merging
                //do an on the fly conversion to PDF
                MemoryStream inStream = new MemoryStream(_wordDoc);

                //we also need a bankruptcy case or actully a list of cases with one item
                List <BankruptcyCase> _cases = BankruptcyCaseService.getMailingList(_startDate, _endDate, _mergeDealer.ID, _numberOfMailings);

                if (_cases.Count == 0)
                {
                    return(null);
                }

                //_cases.Add(new BankruptcyCase() { FirstName = "Jane", LastName = "Doe", AddrLine1 = "1 Main St.", City = "Anytown", StateCode = "KS", ZipCodeString = "1001" });

                // Load the stream into a new document object.
                Aspose.Words.Document _asposeDoc = new Document(inStream);

                //Set up the event handler for image fields.
                _asposeDoc.MailMerge.FieldMergingCallback = new HandleMergeImageFieldFromBlob(_mergeDealer);

                //Example of a very simple mail merge to populate fields only once from an array of values.
                //does the dealer have a legal disclaimer?

                string _legalDisclaimer;
                if (_mergeDealer.LegalDisclaimer.Length > 0)
                {
                    _legalDisclaimer = _mergeDealer.LegalDisclaimer;
                }
                else
                {
                    _legalDisclaimer = _mergeDealer.DealerName + ConfigurationManager.AppSettings["LegalDisclaimer"];
                }

                _asposeDoc.MailMerge.Execute(
                    new string[] { "DealerName", "DealerFullAddress", "DealerPhoneNumber", "DealerPrimaryContactName", "DealerURL", "LegalDisclaimer", "DealerAddress", "DealerCity", "DealerState", "DealerZipCode", "MailingDate" },
                    new object[] { _mergeDealer.DealerName, _mergeDealer.DealerFullAddress, _mergeDealer.Phone, _mergeDealer.DealerPrimaryContactName, _mergeDealer.DealerURL, _legalDisclaimer, _mergeDealer.AddressLine1, _mergeDealer.City, _mergeDealer.State, _mergeDealer.Zip, DateTime.Now.ToShortDateString() });

                //det the dealer logo if the dealer is form the DB
                if (_mergeDealer.ID > 0)
                {
                    DealerService.GetLogo(_mergeDealer);
                }

                BankruptcyCaseMailMergeDataSource _source = new BankruptcyCaseMailMergeDataSource(_cases);
                _asposeDoc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedFields;

                //execute the mail merge
                _asposeDoc.MailMerge.Execute(_source);

                //send back a converted PDF
                MemoryStream outStream = new MemoryStream();
                if (UseWord)
                {
                    _asposeDoc.Save(outStream, Aspose.Words.SaveFormat.Doc);
                }
                else
                {
                    _asposeDoc.Save(outStream, Aspose.Words.SaveFormat.Pdf);
                }
                _mailngListDoc = outStream.ToArray();

                //save the dealer mailinglist in the database
                DealerMailingList _list = new DealerMailingList()
                {
                    CreationDate = DateTime.Now, DealerID = _mergeDealer.ID, DocTemplateID = this.ID, StartFilterDate = _startDate, EndFilterDate = _endDate, NumberCases = _cases.Count
                };
                DealerMailingListService.Save(_list);
                foreach (BankruptcyCase _case in _cases)
                {
                    DealerMailingListCaseService.Insert(new DealerMailingListCase()
                    {
                        BankruptcyCaseID = _case.ID, DealerID = _mergeDealer.ID, DealerMailingListID = _list.ID
                    });
                }

                return(_mailngListDoc);
            }
        }
Ejemplo n.º 6
0
 public HandleMergeImageFieldFromBlob(Dealer dealer)
 {
     _dealer = dealer;
 }
Ejemplo n.º 7
0
 static private void Update(Dealer objDealer, Database db, DbTransaction trans)
 {
     //Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline");
     System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_DealerUpdate");
     db.AddInParameter(dbCommand, "ID", DbType.Int32, objDealer.ID);
     db.AddInParameter(dbCommand, "DealerName", DbType.String, objDealer.DealerName);
     db.AddInParameter(dbCommand, "DealerNumber", DbType.Int32, objDealer.DealerNumber);
     db.AddInParameter(dbCommand, "AddressLine1", DbType.String, objDealer.AddressLine1);
     db.AddInParameter(dbCommand, "City", DbType.String, objDealer.City);
     db.AddInParameter(dbCommand, "State", DbType.String, objDealer.State);
     db.AddInParameter(dbCommand, "Zip", DbType.String, objDealer.Zip);
     db.AddInParameter(dbCommand, "Phone", DbType.String, objDealer.Phone);
     db.AddInParameter(dbCommand, "Fax", DbType.String, objDealer.Fax);
     db.AddInParameter(dbCommand, "Latitude", DbType.Double, objDealer.Latitude);
     db.AddInParameter(dbCommand, "Longitude", DbType.Double, objDealer.Longitude);
     db.AddInParameter(dbCommand, "MaxDistance", DbType.Double, objDealer.MaxDistance);
     db.AddInParameter(dbCommand, "DealerURL", DbType.String, objDealer.DealerURL);
     db.AddInParameter(dbCommand, "ExportFilePath", DbType.String, objDealer.ExportFilePath);
     if (objDealer.CreatedOn > DateTime.MinValue)
     {
         db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, objDealer.CreatedOn);
     }
     else
     {
         db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, Convert.DBNull);
     }
     if (objDealer.LastUpdate > DateTime.MinValue)
     {
         db.AddInParameter(dbCommand, "LastUpdate", DbType.DateTime, objDealer.LastUpdate);
     }
     else
     {
         db.AddInParameter(dbCommand, "LastUpdate", DbType.DateTime, Convert.DBNull);
     }
     db.AddInParameter(dbCommand, "NumberOfMailers", DbType.Int32, objDealer.NumberOfMailers);
     if (objDealer.StartDate > DateTime.MinValue)
     {
         db.AddInParameter(dbCommand, "StartDate", DbType.DateTime, objDealer.StartDate);
     }
     else
     {
         db.AddInParameter(dbCommand, "StartDate", DbType.DateTime, Convert.DBNull);
     }
     db.AddInParameter(dbCommand, "Term", DbType.String, objDealer.Term);
     db.AddInParameter(dbCommand, "DealerLogo", DbType.Binary, objDealer.DealerLogo);
     db.AddInParameter(dbCommand, "Price", DbType.Decimal, objDealer.Price);
     db.AddInParameter(dbCommand, "AcknowledgedTOS", DbType.Boolean, objDealer.AcknowledgedTOS);
     if (objDealer.AcknowledgedTOSDate > DateTime.MinValue)
     {
         db.AddInParameter(dbCommand, "AcknowledgedTOSDate", DbType.DateTime, objDealer.AcknowledgedTOSDate);
     }
     else
     {
         db.AddInParameter(dbCommand, "AcknowledgedTOSDate", DbType.DateTime, Convert.DBNull);
     }
     db.AddInParameter(dbCommand, "AcknowledgedTOSName", DbType.String, objDealer.AcknowledgedTOSName);
     db.AddInParameter(dbCommand, "AcknowledgedTOSSignature", DbType.Binary, objDealer.AcknowledgedTOSSignature);
     if (objDealer.DefaultDocTemplateID > 0)
     {
         db.AddInParameter(dbCommand, "DefaultDocTemplateID", DbType.Int32, objDealer.DefaultDocTemplateID);
     }
     else
     {
         db.AddInParameter(dbCommand, "DefaultDocTemplateID", DbType.Int32, Convert.DBNull);
     }
     db.AddInParameter(dbCommand, "LegalDisclaimer", DbType.String, objDealer.LegalDisclaimer);
     db.AddInParameter(dbCommand, "Active", DbType.Boolean, objDealer.Active);
     db.ExecuteNonQuery(dbCommand, trans);
 }
Ejemplo n.º 8
0
 static private void LoadDealerPartial(Dealer objDealer, IDataReader _reader)
 {
     if (_reader.IsDBNull(0) != true)
     {
         objDealer.ID = _reader.GetInt32(0);
     }
     if (_reader.IsDBNull(1) != true)
     {
         objDealer.DealerName = _reader.GetString(1);
     }
     if (_reader.IsDBNull(2) != true)
     {
         objDealer.DealerNumber = _reader.GetInt32(2);
     }
     if (_reader.IsDBNull(3) != true)
     {
         objDealer.AddressLine1 = _reader.GetString(3);
     }
     if (_reader.IsDBNull(4) != true)
     {
         objDealer.City = _reader.GetString(4);
     }
     if (_reader.IsDBNull(5) != true)
     {
         objDealer.State = _reader.GetString(5);
     }
     if (_reader.IsDBNull(6) != true)
     {
         objDealer.Zip = _reader.GetString(6);
     }
     if (_reader.IsDBNull(7) != true)
     {
         objDealer.Phone = _reader.GetString(7);
     }
     if (_reader.IsDBNull(8) != true)
     {
         objDealer.Fax = _reader.GetString(8);
     }
     if (_reader.IsDBNull(9) != true)
     {
         objDealer.Latitude = _reader.GetDouble(9);
     }
     if (_reader.IsDBNull(10) != true)
     {
         objDealer.Longitude = _reader.GetDouble(10);
     }
     if (_reader.IsDBNull(11) != true)
     {
         objDealer.MaxDistance = _reader.GetDouble(11);
     }
     if (_reader.IsDBNull(12) != true)
     {
         objDealer.DealerURL = _reader.GetString(12);
     }
     if (_reader.IsDBNull(13) != true)
     {
         objDealer.ExportFilePath = _reader.GetString(13);
     }
     if (_reader.IsDBNull(14) != true)
     {
         objDealer.CreatedOn = _reader.GetDateTime(14);
     }
     if (_reader.IsDBNull(15) != true)
     {
         objDealer.LastUpdate = _reader.GetDateTime(15);
     }
     if (_reader.IsDBNull(16) != true)
     {
         objDealer.NumberOfMailers = _reader.GetInt32(16);
     }
     if (_reader.IsDBNull(17) != true)
     {
         objDealer.StartDate = _reader.GetDateTime(17);
     }
     if (_reader.IsDBNull(18) != true)
     {
         objDealer.Term = _reader.GetString(18);
     }
     if (_reader.IsDBNull(19) != true)
     {
         objDealer.Price = _reader.GetDecimal(19);
     }
     if (_reader.IsDBNull(20) != true)
     {
         objDealer.AcknowledgedTOS = _reader.GetBoolean(20);
     }
     if (_reader.IsDBNull(21) != true)
     {
         objDealer.AcknowledgedTOSDate = _reader.GetDateTime(21);
     }
     if (_reader.IsDBNull(22) != true)
     {
         objDealer.AcknowledgedTOSName = _reader.GetString(22);
     }
     if (_reader.IsDBNull(23) != true)
     {
         objDealer.DefaultDocTemplateID = _reader.GetInt32(23);
     }
     if (_reader.IsDBNull(24) != true)
     {
         objDealer.LegalDisclaimer = _reader.GetString(24);
     }
     if (_reader.IsDBNull(25) != true)
     {
         objDealer.Active = _reader.GetBoolean(25);
     }
     if (_reader.IsDBNull(26) != true)
     {
         objDealer.DealerPrimaryContactName = _reader.GetString(26);
     }
     if (_reader.IsDBNull(27) != true)
     {
         objDealer.DealerPrimaryContactPhone = _reader.GetString(27);
     }
     if (_reader.IsDBNull(28) != true)
     {
         objDealer.DefaultDocTemplateDisplayName = _reader.GetString(28);
     }
 }