/// <summary>
        /// This method returns account and statement information for the given account.
        /// </summary>
        /// <param name="accountNumber9"></param>
        /// <param name="siteId"></param>
        /// <returns></returns>
        public Account InquireAccount([RequiredItem()][StringLength(9, 9)] string accountNumber9, [RequiredItem()] int siteId)
        {
            BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, accountNumber9 == null?string.Empty:accountNumber9.PadLeft(16, '0'));

            using (Log log = CreateLog(logEntry))
            {
                try
                {
                    // validate the parameters.
                    MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), accountNumber9, siteId);
                    validator.Validate();

                    //log the site id
                    logEntry.SiteId = siteId;

                    //look up the company and division for this account
                    string     siteCode   = DalSiteCode.Instance.GetSiteCode(siteId);
                    DalAccount dalAccount = new DalAccount();
                    CompanyDivisionFranchise companyDivisionFranchise = dalAccount.GetCompanyDivisionFranchise(siteId, siteCode, accountNumber9);

                    //turn accountNumber9 into accountNumber13
                    string accountNumber13 = companyDivisionFranchise.Company.ToString().PadLeft(2, '0') + companyDivisionFranchise.Division.ToString().PadLeft(2, '0') + accountNumber9;

                    // convert to CustomerAccountNumber
                    CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter(
                        typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13);

                    PopulateSiteInfo(accountNumber);

                    //log the account number
                    logEntry.CustomerAccountNumber = accountNumber.AccountNumber16;

                    // setup return
                    Account account = new Account();

                    // setup adapter and fill account object.
                    AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode);
                    adapter.Fill(account);

                    //set the AllowOnlineOrdering flag
                    SetAllowOnlineOrderingFlag(ref account);

                    // all done.
                    return(account);
                }
                catch (ValidationException ve)
                {
                    logEntry.SetError(ve.Message);
                    throw;
                }
                catch (InvalidAccountNumberException ie)
                {
                    logEntry.SetError(ie.Message);
                    throw;
                }
                catch (DataSourceException de)
                {
                    logEntry.SetError(de.Message);
                    throw new DataSourceUnavailableException(de);
                }
                catch (UnexpectedSystemException ue)
                {
                    logEntry.SetError(ue.Message);
                    throw;
                }
                catch (Exception e)
                {
                    logEntry.SetError(e.Message);
                    throw new UnexpectedSystemException(e);
                }
            }
        }
        /// <summary>
        /// This method returns account and statement information for the given account.
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="setTopBoxId"></param>
        /// <returns></returns>
        public Account InquireAccount([RequiredItem()] int siteId, [RequiredItem()][StringLength(1, 16)] string setTopBoxId)
        {
            BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, siteId, setTopBoxId);

            using (Log log = CreateLog(logEntry))
            {
                try
                {
                    // validate the parameters.
                    MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), siteId, setTopBoxId);
                    validator.Validate();

                    //look up the sitecode
                    string siteCode = DalSiteCode.Instance.GetSiteCode(siteId);

                    //get account number
                    string       accountNumber9 = null;
                    DalEquipment dalEquipment   = new DalEquipment();
                    accountNumber9 = dalEquipment.GetAccountFromSetTopBoxId(siteId, siteCode,
                                                                            setTopBoxId).PadLeft(9, '0');

                    if (accountNumber9 == null || accountNumber9 == string.Empty)
                    {
                        throw new InvalidSetTopBoxIdException(string.Format(
                                                                  __setTopBoxIdToAccountNumberException, setTopBoxId));
                    }

                    //look up division for this account
                    DalAccount dalAccount = new DalAccount();
                    CompanyDivisionFranchise companyDivisionFranchise = dalAccount.GetCompanyDivisionFranchise(siteId,
                                                                                                               siteCode, accountNumber9);

                    //turn accountNumber9 into accountNumber13
                    string accountNumber13 = companyDivisionFranchise.Company.ToString().PadLeft(2, '0') + companyDivisionFranchise.Division.ToString().PadLeft(2, '0') + accountNumber9;

                    // convert to CustomerAccountNumber
                    CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter(
                        typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13);

                    // get the siteid/sitecode information
                    PopulateSiteInfo(accountNumber);
                    logEntry.CustomerAccountNumber = accountNumber.AccountNumber16;

                    // setup return
                    Account account = new Account();

                    // setup adapter and fill account object.
                    AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode);
                    adapter.Fill(account);

                    //set the AllowOnlineOrdering flag
                    SetAllowOnlineOrderingFlag(ref account);

                    // all done.
                    return(account);
                }
                catch (ValidationException ve)
                {
                    logEntry.SetError(ve.Message);
                    throw;
                }
                catch (BusinessLogicLayerException blle)
                {
                    logEntry.SetError(new ExceptionFormatter(blle).Format());
                    throw;
                }
                catch (DataSourceException de)
                {
                    logEntry.SetError(de.Message);
                    throw new DataSourceUnavailableException(de);
                }
                catch (Exception e)
                {
                    logEntry.SetError(e.Message);
                    throw new UnexpectedSystemException(e);
                }
            }
        }
Esempio n. 3
0
        //Added new method on 4-Feb-2010
        /// <summary>
        /// GetCustomerAccountProfile
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="accountNumber9"></param>
        /// <returns></returns>
        private CustomerAccountProfile GetCustomerAccountProfile(int siteId, string accountNumber9)
        {
            /// set the siteid/sitecode information
            PopulateSiteInfo(siteId);
            DalAccount dalAccount = new DalAccount();

            if (!dalAccount.IsAccountNumberValid(siteId, accountNumber9))
            {
                throw new Cox.BusinessLogic.Exceptions.InvalidAccountNumberException();
            }
            CompanyDivisionFranchise cdf = new CompanyDivisionFranchise();

            try
            {
                cdf = dalAccount.GetCompanyDivisionFranchise(_siteId,
                                                             _siteCode, accountNumber9);
            }
            catch (Exception e)
            {
                throw new DataSourceUnavailableException(e);
            }

            // convert to customerAccountNumber object
            CustomerAccountNumber accountNumber = new CustomerAccountNumber(
                string.Empty, cdf.Company.ToString(), cdf.Division.ToString(),
                accountNumber9);
            DalCustomerAccount dalCustomerAccount = new DalCustomerAccount();

            // call dal

            //[28-01-2009] Start Changes to reflect services for an account
            CustomerAccountProfileSchema customerAccountSchema = dalCustomerAccount.GetAccountProfile(siteId, accountNumber9);

            CustomerAccountProfileSchema.CustomerAccountDataTable customerAccountDT = customerAccountSchema.CustomerAccount;


            CustomerAccountProfileSchema.CustomerServicesDataTable customerServicesDataTable = customerAccountSchema.CustomerServices;

            CustomerAccountProfile customerAccountProfile = new CustomerAccountProfile();

            if (customerAccountDT != null && customerAccountDT.Rows.Count > 0)
            {
                BuildCustomerAccountBase(customerAccountDT, customerAccountProfile);
                BuildCustomerAccountCampaign(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);
                BuildCustomerAccountStatement(accountNumber9, accountNumber, customerAccountProfile);
                BuildCustomerAccountContract(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);
                BuildCustomerAccountPhones(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);
                BuildCustomerAccountPrivacy(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);
                BuildCustomerAccountCCRMInfo(siteId, accountNumber9, customerAccountProfile);
                BuildContactEmail(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);

                // [17-05-11] Changes starts here for price lock enhancement
                BuildPriceLockDetails(siteId, accountNumber9, dalCustomerAccount, customerAccountProfile);
                // [17-05-11] Changes ends here for price lock enhancement
            }

            if (customerServicesDataTable != null && customerServicesDataTable.Rows.Count > 0)
            {
                List <AvailableService> services = new List <AvailableService>();

                foreach (CustomerAccountProfileSchema.CustomerServicesRow row in customerServicesDataTable.Rows)
                {
                    services.Add(new AvailableService(DalServiceCategory.Instance.GetServiceCategoryDesc(row.Service_Category_Code), (ServiceStatus)TypeDescriptor.GetConverter(typeof(ServiceStatus)).ConvertFrom(row.ServiceStatus)));
                }
                customerAccountProfile.Services = services;
            }

            //[28-01-2009] End Changes to reflect services for an account

            // Changes for Self Reg Ernest Griffin **START**//
            //Account account = new Account();

            //AccountActivity accountActivity = new AccountActivity(_userName);
            //account = accountActivity.InquireAccount(accountNumber9, siteId);

            //if (account.AllowOnlineOrdering)
            //{
            //    customerAccountProfile.OnlineOrderDelinquentBalance = false;
            //}
            //else
            //{
            //    customerAccountProfile.OnlineOrderDelinquentBalance = true;
            //}

            //if (account.OnlineOrderingOptOut != 0)
            //{
            //    customerAccountProfile.OnlineOrderBlock = true;
            //}
            //else
            //{
            //    customerAccountProfile.OnlineOrderBlock = false;
            //}
            return(customerAccountProfile);
        }