/// <summary> /// This method returns the account address information for the given Phone Number. /// </summary> /// <param name="phoneNumber10"></param> /// <param name="streetNumber"></param> /// <returns></returns> public CustomerAccountProfile GetCustomerAccountByPhoneNbrAndStreetNbr([RequiredItem()][StringLength(10, 10)][RegEx(@"\d{10}", RegexOptions.Compiled)] string phoneNumber10 , string streetNumber) { //create log and begin logging CustomerAccountLogEntry logEntry = new CustomerAccountLogEntry(eCustomerAccountActivityType.GetCustomerAccountByPhoneNbrAndStreetNbr, phoneNumber10, streetNumber); using (Log log = CreateLog(logEntry)) { try { logEntry.Note = "phoneNumber10:" + phoneNumber10 + " and street#:" + streetNumber; // validate the parameters. MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), phoneNumber10); validator.Validate(); try { if (Convert.ToUInt64(phoneNumber10) == 0) { throw new ValidationException(); } } catch { throw new ValidationException("Invalid Phonenumber"); } //create dal to get customer accounts for given phone number ad street address DalCustomerPhone dalCustomerPhone = new DalCustomerPhone(); CustomerAccountProfileSchema.AccountMatchesDataTable accountMatches = dalCustomerPhone.GetCustomerAccountMatches(phoneNumber10, streetNumber); if (String.IsNullOrEmpty(streetNumber)) { if (accountMatches.Rows.Count > 1) { throw new MultipleMatchsFoundException(String.Format(_multipleMatchesWithPhoneOnly, phoneNumber10)); } else if (accountMatches.Rows.Count == 0) { throw new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10)); } else { return(GetCustomerAccountProfile(accountMatches[0].Site_ID, accountMatches[0].Account_Number)); } } else { if (accountMatches.Rows.Count > 1) { throw new MultipleMatchsFoundException(String.Format(_multipleMatchesWithStreet, phoneNumber10, streetNumber)); } else if (accountMatches.Rows.Count == 0) { throw new NoMatchFoundException(String.Format(_noMatchWithStreet, phoneNumber10, streetNumber)); } else { return(GetCustomerAccountProfile(accountMatches[0].Site_ID, accountMatches[0].Account_Number)); } } } catch (ValidationException ve) { logEntry.SetError(new ExceptionFormatter(ve).Format()); throw; } catch (InvalidAccountNumberException) { logEntry.SetError(new ExceptionFormatter(new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10))).Format()); throw new NoMatchFoundException(String.Format(_noMatchWithPhoneOnly, phoneNumber10)); } catch (BusinessLogicLayerException blle) { logEntry.SetError(new ExceptionFormatter(blle).Format()); throw; } catch (Exception e) { logEntry.SetError(new ExceptionFormatter(e).Format()); throw new UnexpectedSystemException(e); } } }
/// <summary> /// Placeholder for constants /// </summary> #endregion constants #region member variables ///// <summary> ///// Member variable containing _accountNumber object. ///// </summary> //protected CustomerAccountNumber _accountNumber=null; ///// <summary> ///// Member variable containing siteId ///// </summary> //protected int _siteId=0; ///// <summary> ///// Member variable containing siteCode ///// </summary> //protected string _siteCode=null; ///// <summary> ///// Member variable containing username. ///// </summary> //protected string _userName=null; ///// <summary> ///// Member variable containing phone number. ///// </summary> //protected string _phoneNumber = null; #endregion member variables #region ctors /// <summary> /// The default constructor /// </summary> //public CustomerAccountAdapter(string phoneNumber) //{ // // set value // _phoneNumber = phoneNumber; //} #endregion ctors #region public methods #region FillMultiple /// <summary> /// Fills the AccountAddress object - multiple addresses returned. /// </summary> /// <param name="customerContactInformation"></param> /// <param name="phoneNumber10"></param> /// <param name="filter"></param> public static void MultipleReturns(List <CustomerContactInformation> customerContactInformation, string phoneNumber10, bool getNeverAndFormerAsWell) { try { DalCustomerPhone dalCustomerPhone = new DalCustomerPhone(); CustomerAccountProfileSchema.AccountMatchesDataTable accountMatches = dalCustomerPhone.GetCustomerAccountMatches(phoneNumber10, getNeverAndFormerAsWell); //Check if any account matches were found if (accountMatches.Rows.Count > 0) { //Get CSV string containing pairs of siteids and account numbers string csvSiteIdAndAccountNumbers = GetCSVSiteIdAndAccountNumbers(accountMatches); DalAccount dalAccount = new DalAccount(); //Get customer account information by passing above generated csv string CustomerAccountSchema.CustomerAddressesDataTable addresses; //Since we cannot process varchar more than 4000, we have to divide the string appropraitely if (csvSiteIdAndAccountNumbers.Length > 4000) { //create the list of strings to hold the string of max allowed length List <String> csvStringList = new List <String>(); //max allowed length must be less than 4000 and should be divisible by 13 //13 = 3 digit siteid + 1 for comma + 9 digit account number. int maxAllowedLength = (int)4000 - (4000 % 13); //keep on looping untill all the all the parts of string are added. while (true) { //add max allowed length part of csv string to the list. //maxAllowedLength-2, because since index start from 0 we have to subtract 1 and to remove extra comma at the end we subtract 1 again. csvStringList.Add(csvSiteIdAndAccountNumbers.Substring(0, maxAllowedLength - 2)); //remove the part added to the list from the csv string csvSiteIdAndAccountNumbers = csvSiteIdAndAccountNumbers.Substring(maxAllowedLength - 1); //when the remaining csv string is less than max allowed length, directly add it and exit. if (csvSiteIdAndAccountNumbers.Length < maxAllowedLength - 1) { csvStringList.Add(csvSiteIdAndAccountNumbers); break; } } addresses = dalAccount.GetAccountByPhoneNumber(csvStringList, getNeverAndFormerAsWell); } else { addresses = dalAccount.GetAccountByPhoneNumber(csvSiteIdAndAccountNumbers, getNeverAndFormerAsWell); } if (addresses == null) { customerContactInformation = null; return; } // if we don't get back an address, then its not a valid accountNumber. foreach (CustomerAccountSchema.CustomerAddress ca in addresses) { CustomerContactInformation aa = new CustomerContactInformation(); PopulateAccountInformation(aa, ca); //Check if the match found was cox secondary number or not if (accountMatches.Select("Site_ID='" + aa.SiteId + "' and Account_Number='" + aa.AccountNumber13.Substring(4) + "' and Customer_TN_Flag=1").Length != 0) { aa.CustomerTNNumber = Convert.ToUInt64(phoneNumber10); } customerContactInformation.Add(aa); } } //if not match found return null else { customerContactInformation = null; } } catch (BusinessLogicLayerException) { // already handled throw; } catch (DataSourceException dse) { // not handled. need to handle throw new DataSourceUnavailableException(dse); } catch (Exception ex) { // not handled. need to handle throw new UnexpectedSystemException(ex); } }