Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data.Common
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Xml
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.CommonEntities.Library.CouponServices

''' ----------------------------------------------------------------------------
''' <summary>
''' 
'''     Project:  CharterDotCom.WebSite.Library
'''       Class:  BLAccountManager
''' 
''' Description:  Business logic class for account information and
'''               functionality.
''' 
''' </summary>
''' <remarks></remarks>
''' <history>
''' 	[jnaes]		11/22/2010	Issue #10934.  Added gift card lookup.
''' 	[jnaes]		11/23/2010	Issue #10934.  Refactored coupon redemption.
''' 	[jnaes]		11/29/2010	Issue #10934.  Added gift card redemption.
''' 	[jnaes]		01/05/2011	Issue #10934.  Added GetBillingAddress().
''' 	[jnaes]		01/05/2011	Issue #10934.  Added SetBillingAddress().
''' </history>
''' ----------------------------------------------------------------------------
Public Class BLAccountManager
    Inherits AccountClient

#Region "Private Fields"

    Friend account As BLAccount
    Friend gwyShoppingCart As ShoppingCart
    Friend LocaleID As Integer
    Friend CookieID As String
    Private addresses As Dictionary(Of String, IAddress)
    Private CSRLOGIN As String
    Private CSRPASSWORD As String
    Private PROVISIONID As String
    Private configdata_content As XmlNode
    Private configdata_ebs As XmlNode
    Private configdata_member As XmlNode
    Private configdata_g2b As XmlNode
    Private findServiceability As Boolean = True
    Friend serviceabilityResults As EntityEBSServices.GetServiceabilityResponse
    Private HouseRef As String
    Private EntityID As String
    Private _sysPrin As String
	Private _LastCCOMDisplayFriendlyExceptionMessage As String
	'****************************************************************
	'JPIRKEY: 4-2010 MyAccount Update - Retrieve Username enhancement
	'****************************************************************
	Private m_MyAccountRetUserName As BLRetUserNameAccount

#End Region

#Region "Constructors"

    Public Sub New()

    End Sub

    Public Sub New(ByVal DictionaryOfVariables As Dictionary(Of String, Object))
        If DictionaryOfVariables IsNot Nothing Then

            If DictionaryOfVariables.ContainsKey("account") Then
                If Not (DictionaryOfVariables("account") Is Nothing) Then
                    Me.account = CType(DictionaryOfVariables("account"), BLAccount)
                End If

                If DictionaryOfVariables.ContainsKey("gwyShoppingCart") Then
                    If Not (DictionaryOfVariables("gwyShoppingCart") Is Nothing) Then
                        Me.gwyShoppingCart = CType(DictionaryOfVariables("gwyShoppingCart"), ShoppingCart)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("LocaleID") Then
                    If Not (DictionaryOfVariables("LocaleID") Is Nothing) Then
                        Me.LocaleID = CType(DictionaryOfVariables("LocaleID"), Integer)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("CookieID") Then
                    If Not (DictionaryOfVariables("CookieID") Is Nothing) Then
                        Me.CookieID = CType(DictionaryOfVariables("CookieID"), String)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("addresses") Then
                    If Not (DictionaryOfVariables("addresses") Is Nothing) Then
                        Me.addresses = CType(DictionaryOfVariables("addresses"), Dictionary(Of String, IAddress))
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("serviceabilityResults") Then
                    If Not (DictionaryOfVariables("serviceabilityResults") Is Nothing) Then
                        Me.serviceabilityResults = CType(DictionaryOfVariables("serviceabilityResults"), EntityEBSServices.GetServiceabilityResponse)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("entityid") Then
                    If Not (DictionaryOfVariables("entityid") Is Nothing) Then
                        Me.EntityID = CType(DictionaryOfVariables("entityid"), String)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("_sysPrin") Then
                    If Not (DictionaryOfVariables("_sysPrin") Is Nothing) Then
                        Me._sysPrin = CType(DictionaryOfVariables("_sysPrin"), String)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("houseref") Then
                    If Not (DictionaryOfVariables("houseref") Is Nothing) Then
                        Me.HouseRef = CType(DictionaryOfVariables("houseref"), String)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("PROVISIONID") Then
                    If Not (DictionaryOfVariables("PROVISIONID") Is Nothing) Then
                        Me.PROVISIONID = CType(DictionaryOfVariables("PROVISIONID"), String)
                    End If
                End If

                If DictionaryOfVariables.ContainsKey("_LastCCOMDisplayFriendlyExceptionMessage") Then
                    If Not (DictionaryOfVariables("_LastCCOMDisplayFriendlyExceptionMessage") Is Nothing) Then
                        Me._LastCCOMDisplayFriendlyExceptionMessage = CType(DictionaryOfVariables("_LastCCOMDisplayFriendlyExceptionMessage"), String)
                    End If
				End If

				If DictionaryOfVariables.ContainsKey("MyAccountRetUNameAccount") Then
					If Not (DictionaryOfVariables("MyAccountRetUNameAccount") Is Nothing) Then
						Me.MyAccountRetUNameAccount = CType(DictionaryOfVariables("MyAccountRetUNameAccount"), BLRetUserNameAccount)
					End If
				End If

            Else
                Throw New ApplicationException("Accountmanager key does not have account")
            End If
        Else
            Me.account = New BLAccount
        End If
    End Sub

#End Region

#Region "Basic Account Functions"

    ''' <summary>
    ''' If the user is Returning user (who has visited the site before), the cookie id 
    ''' sent from Web clint is looked up against the DB and user experience is resumed.
    ''' </summary>
    ''' <remarks>
    ''' Cookie set by the web client is looke dup against the DB for user informations
    ''' such as Address and previous cart contents
    ''' If available, the account object and cart is set accordingly
    ''' Before calling this method Account Mangager's Localization or SinIn should be called.
    ''' </remarks>
    Public Overrides Sub SetVisitorID(ByVal trackingid As String, ByVal value As String)
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)


            'If account is not yet created then create one
            If account Is Nothing Then account = New BLAccount()
            account.UserStatus = UserStatus.UnIdentified
            'Cart / Address persistence code
            ' ''Dim cart As BLShoppingCart
            ' ''Dim addr As BLAddress
            '' ''set cookie id
            ' ''CookieID = value
            ' ''Dim objAM As Object = GetSession(Common.AddressKey)

            ' ''If objAM IsNot Nothing Then
            ' ''  addr = CType(objAM, BLAddress)
            ' ''  account.IsReturningUser = True
            ' ''  account.Address = addr
            ' ''  Dim objCM As Object = GetSession(Common.CartKey)
            ' ''  If objCM IsNot Nothing Then
            ' ''    cart = CType(objCM, BLShoppingCart)
            ' ''    gwyShoppingCart = PopulateGWYShoppingCart(cart)
            ' ''  End If
            ' ''  RemoveSession(CookieID)
            ' ''End If
            '' ''Persist state
            SetSession(BLCommon.AccountManagerKey, Me.ValuesForSetSession)
        Catch ex As Exception
            BLCommon.LogException(ex, ExceptionSeverity.Fatal)
            Throw ex
        Finally
        End Try
    End Sub

    Public ReadOnly Property ValuesForSetSession() As Dictionary(Of String, Object)
        Get
            Try
                Dim VarList As New Dictionary(Of String, Object)
                VarList.Add("account", Me.account)
                VarList.Add("gwyShoppingCart", Me.gwyShoppingCart)
                VarList.Add("LocaleID", Me.LocaleID)
                VarList.Add("CookieID", Me.CookieID)
                VarList.Add("addresses", Me.addresses)
                VarList.Add("serviceabilityResults", Me.serviceabilityResults)
                VarList.Add("entityid", Me.EntityID)
                VarList.Add("houseref", Me.HouseRef)
                VarList.Add("_sysPrin", Me._sysPrin)
                VarList.Add("PROVISIONID", Me.PROVISIONID)
				VarList.Add("_LastCCOMDisplayFriendlyExceptionMessage", Me._LastCCOMDisplayFriendlyExceptionMessage)
				VarList.Add("MyAccountRetUNameAccount", Me.MyAccountRetUNameAccount)
                Return VarList
            Catch ex As Exception
                Throw
            End Try
        End Get
    End Property


    Public Overrides Sub ClearCCOMDisplayFriendlyExceptionMessage(ByVal trackingID As String)
        Try
            '###############
            'Restore state
            '###############
            PopulateLocalVariables(trackingID)

            Me._LastCCOMDisplayFriendlyExceptionMessage = Nothing

            '##############
            'Persist state
            '##############
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

        Catch ex As Exception
            Throw
        End Try
    End Sub


    Protected Overrides Sub PopulateLocalVariables(ByVal trackingID As String)
        Try
            If Not (trackingID Is Nothing) Then
                MyBase.TrackingID = trackingID
                Dim lmanager As New BLAccountManager
                Dim sessionEntry As Object
                sessionEntry = Session(Common.AccountManagerKey)
                If Not sessionEntry Is Nothing Then
                    lmanager = New BLAccountManager(CType(sessionEntry, Dictionary(Of String, Object)))
                    Me.account = lmanager.account
                    Me.gwyShoppingCart = lmanager.gwyShoppingCart
                    Me.LocaleID = lmanager.LocaleID
                    Me.CookieID = lmanager.CookieID
                    Me.addresses = lmanager.addresses
                    Me.serviceabilityResults = lmanager.serviceabilityResults
                    Me.EntityID = lmanager.EntityID
                    Me.HouseRef = lmanager.HouseRef
                    Me._sysPrin = lmanager._sysPrin
                    Me.PROVISIONID = lmanager.PROVISIONID
					Me._LastCCOMDisplayFriendlyExceptionMessage = lmanager._LastCCOMDisplayFriendlyExceptionMessage
					Me.m_MyAccountRetUserName = CType(lmanager.MyAccountRetUNameAccount, BLRetUserNameAccount)
				Else
					lmanager = New BLAccountManager
					Me.account = New BLAccount
				End If
            Else
                Dim lmanager As New BLAccountManager
                lmanager = New BLAccountManager
                Me.account = New BLAccount
            End If

            CSRLOGIN = CStr(System.Web.HttpContext.Current.Application("CSR_LOGIN"))
            CSRPASSWORD = CStr(System.Web.HttpContext.Current.Application("CSR_PASSWORD"))

        Catch ex As Exception
            Throw
        End Try
    End Sub


    Public ReadOnly Property LastCCOMDisplayFriendlyExceptionMessage(ByVal trackingID As String) As String
        Get
            Try
                '###############
                'Restore state
                '###############
                PopulateLocalVariables(trackingID)

                Return _LastCCOMDisplayFriendlyExceptionMessage

            Catch ex As Exception

            End Try
        End Get
    End Property

    ''' <summary>
    ''' Method call to Register User  and create a Member Services account.
    ''' </summary>
    ''' <returns>Returns True / False based on Member service Registration response</returns>
    ''' <remarks>
    ''' based on the input parameters, a Web service call is made to Register an user and the Response is 
    ''' indicated on the same.
    ''' </remarks>
    Public Overrides Function RegisterUser(ByVal trackingid As String, ByVal username As String, ByVal accountnumber As String, ByVal password As String, ByVal securityquestion As String, ByVal securityanswer As String, ByVal contactemailaddress As String) As Boolean

        'Local variables
        Dim objrequest As New EntityMemberServices.CreateMemberServiceRequest
        Dim objResponse As New EntityMemberServices.TheCommonResponse
        Dim iProvider As IMemberServicesProvider

        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)


            objrequest.accountNumber = accountnumber
            objrequest.csrlogin = CSRLOGIN
            objrequest.csrpassword = CSRPASSWORD
            objrequest.userName = username
            objrequest.password = password
            objrequest.securityQuestion = securityquestion
            objrequest.securityAnswer = securityanswer
            objrequest.preferedEmailId = contactemailaddress



            '#######################################################################
            'MODIFICATION   FEB 5, 2008 ROD COPELAND
            '#######################################################################
            'THE VALUE OF PHONE AND ZIP IN THIS CASE OF REGISTER USER ARE 
            'COMING FROM AN EAI WS CALL BEING MADE INSIDE THE GETCPNIVERIFICATION 
            'IN THIS MANAGER
            '#########################################################################
            'THIS FOLLOWING SECTION OF CODE IS MENT TO GET THE PHONE NUMBER AND ZIPCODE BY MAKING ANOTHER WS CALL
            'TO EAI. THIS CHANGE WAS NEEDED BECAUSE THE CREATE MEMBER SERVICE WS METHOD PREVIOUSLY USED DIDNT 
            'HANDLE VIDEO ONLY CUSTOMERS WHO NEEDED TO CREATE A MS ACCOUNT. TO ADDRESS THIS THE MS AREA WANTED US 
            'TO USE THE NEW REGISTER MS WS METHOD WHICH WAS INTENDED TO BE USED FOR ALL USERS, VIDEO AND DATA BOTH.
            'THE PROBLEM WAS THE NEW REGISTER WS METHOD REQUIRED THE USE OF ZIP AND PHONE WHICH WAS NOT BEING 
            'COLLECTED ON THE PAGE. TO FURTHER COMPLICATE THINGS THE BUSINESS DIDNT WANT TO TAKE THE CHANCE OF THE
            'USER ENTERING SOMETHING WRONG ON THE PHONE AND ZIP AND FAILING THE WHOLE PROCESS OUT SO THEY REQUESTED 
            'THAT WE DO ANOTHER WS CALL TO EAI JUST TO GET THE PHONE AND ZIP AND SEND THOSE VALUES IN THE CREATE 
            'MEMEBER SERVICE WS REQUEST TO MAKE THE NEW REGISTER WS METHOD WORK. THATS THE NICKEL TOUR.
            '#########################################################################
            If Not (Me.account Is Nothing) Then
                objrequest.phone = Me.account.HomePhone
                If Not (Me.account.Address Is Nothing) Then
                    objrequest.zipCode = Me.account.Address.Zip
                End If
            End If
            '#######################################################################




            '################################
            'EXECUTE THE CALL TO THE PROVIDER
            '################################
            iProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.CreateMemberService(objrequest), TheCommonResponse)



            'Indicate a boolean value based on Web service response
            If Not objResponse.Exception Then
                Return True
            Else
                '##################################################################################
                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                '##################################################################################
                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                'ACCORDINGLY.
                '##################################################################################
                Select Case True
                    Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                End Select
                '##################################################################################


                '##############
                'Persist state
                '##############
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                'On failuer log exception as per Exception policy
                BLCommon.LogException(New Exception("Account Manager - Register User failed with  reason as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
                Return False
            End If

        Catch ex As Exception
            BLCommon.LogException(ex, ExceptionSeverity.High)
            Throw ex
        Finally
            objrequest = Nothing
            objResponse = Nothing
            iProvider = Nothing
        End Try
    End Function

    ''' <summary>
    ''' Method call to Login into the My Account section  and retrieve User information / Content Administration section.
    ''' </summary>
    ''' <returns>Returns True / False on successful Signin-In and retrieving Account information.</returns>
    ''' <remarks>
    ''' based on the input parameters, a Web service call is made to Register an user and the Response is 
    ''' indicated on the same.
    ''' </remarks>
    ''' 

    Public Overrides Function ValidateMyAccountIDandPW_NO_SIGN_IN(ByVal trackingid As String, ByVal userName As String, ByVal password As String) As String
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            '########################################################################
            'THIS SHOULD ONLY VERIFY THAT THE MYACCOUNT ID AND PW PROVIDED ARE A 
            'VALLID COMBINATION. THIS DOES NOT LOG IN THE USER, THAT WOULD REQUIRE 
            'THE USE OF THE SignIn METHOD. THIS METHOD WAS CREATED TO GIVE AN 
            'ALTERNATIVE FOR THE MYACCOUNT AREA TO VERIFY THE ID AND PWs USED.  
            'BEFORE THEY WERE USING THE SIGNIN METHOD AND IS WAS DOING A BIG WEBSERVICE 
            'CALL IN THE PROVIDERS AND BUILDING THE CUSTOMER OBJECT FOR MYACCOUNT WHEN 
            'ALL THEY WANTED TO DO IS MAKE SURE THE ID PW WAS CORRECT.  THE ADDITIONAL 
            'LOAD ON THE MS AREA BY CALLING THE SIGNIN IN THE ORDER FLOW WAS TOO MUCH 
            'FOR THE CEON TEAM.  THEY COMPLAINED ABOUT LOAD AND THIS METHOD WAS CREATED 
            'TO GIVE AN ALTERNATIVE.
            '########################################################################

            Dim objrequest As New EntityMemberServices.AuthenticateRequest
            Dim objResponse As New EntityMemberServices.AuthenticateResponse

            objrequest.csrLogin = CSRLOGIN
            objrequest.csrPassword = CSRPASSWORD
            objrequest.Login = userName
            objrequest.Password = password

            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.Authenticate(objrequest), EntityMemberServices.AuthenticateResponse)


            If Not (objResponse Is Nothing) Then
                If Not objResponse.Exception Then
                    '##########################################################
                    'THE AUTHENTICATION WAS GOOD, SO RETURN THE GOOD STATUS.
                    '##########################################################
                    Return objResponse.AccountID
                    'Return True
                Else
                    '##################################################################################
                    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                    '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                    '##################################################################################
                    'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                    'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                    'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                    'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                    'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                    'ACCORDINGLY.
                    '##################################################################################
                    Select Case True
                        Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                            Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                        Case Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                    End Select
                    '##################################################################################


                    '##############
                    'Persist state
                    '##############
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                    'Return False
                    Return Nothing
                End If
            Else
                'Return True
                Return Nothing
            End If

            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Catastrophic)
            Throw ex
        Finally
        End Try

    End Function

    Public Overrides Function SignIn(ByVal trackingid As String, ByVal userName As String, ByVal password As String, Optional ByVal IsContentAuthor As Boolean = False) As Boolean
        Return Me.SignIn_MyAccount(trackingid, userName, password, Nothing, IsContentAuthor)
    End Function
    Public Overrides Function SignIn(ByVal trackingid As String, ByVal userName As String, ByVal password As String, ByVal zipCode As String, Optional ByVal IsContentAuthor As Boolean = False) As Boolean
        Return Me.SignIn_MyAccount(trackingid, userName, password, zipCode, Nothing, IsContentAuthor)
    End Function
    Public Overrides Function SignIn(ByVal trackingid As String, ByVal userName As String, ByVal password As String, ByVal AffiliateID As Integer, Optional ByVal IsContentAuthor As Boolean = False) As Boolean
        Return Me.SignIn_MyAccount(trackingid, userName, password, AffiliateID, IsContentAuthor)
    End Function

    Private Function SignIn_MyAccount(ByVal trackingid As String, ByVal userName As String, ByVal password As String, ByVal zipCode As String, ByVal AffiliateID As Integer, Optional ByVal IsContentAuthor As Boolean = False) As Boolean
        Return Me.SignIn_MyAccount_Sequence(trackingid, userName, password, zipCode, Nothing, True, IsContentAuthor)
    End Function

    Private Function SignIn_MyAccount(ByVal trackingid As String, ByVal userName As String, ByVal password As String, ByVal AffiliateID As Integer, Optional ByVal IsContentAuthor As Boolean = False) As Boolean
        Return Me.SignIn_MyAccount_Sequence(trackingid, userName, password, Nothing, Nothing, False, IsContentAuthor)
    End Function

    Private Function SignIn_MyAccount_Sequence(ByVal trackingid As String, ByVal userName As String, ByVal password As String, ByVal zipCode As String, ByVal AffiliateID As Integer, Optional ByVal validateZipCode As Boolean = False, Optional ByVal IsContentAuthor As Boolean = False) As Boolean

        If Not IsContentAuthor Then

            Try
                '###############
                'Restore state
                '###############
                PopulateLocalVariables(trackingid)

                '####################################################################
                'THEY MAY HAVE LOCALIZED ALREADY SO PERSIST THE EXSITING SERVICES.
                '####################################################################
                Dim lExistingLOB As New List(Of Category)
                If Not (account Is Nothing) Then
                    If Not (account.ExistingLOB Is Nothing) Then
                        lExistingLOB = account.ExistingLOB
                    End If
                End If






                '#############################################################################
                'RESET THE ACCOUNT PACKAGE AND MEMEBER INFORMATION ON EACH ATTEMPT TO SIGN IN
                '#############################################################################
                account = New BLAccount






                '##################################################################
                'ASSIGN AFFILIATE ID TO THE ACCOUNT OBJECT. IF THIS USER IS FROM 
                'AN AFFILIATE SITE LIKE BEST BUY FOR INSTANCE, THEY WILL HAVE 
                'A AFFILIATE ID IN THE QUERYSTRING, IF THEY DONT, JUST USE THE 
                'CHARTER.COM AFFILIATE ID.  G2B EVEN TREATS THE CHARTER.COM 
                'WEBSITE AS AN AFFILIATE.
                '##################################################################
                If Not (account Is Nothing) Then
                    Select Case AffiliateID
                        Case 0
                            account.AffliateID = CharterDotCom.CommonEntities.Library.Common.m_CHARTER_AFFLIATE_ID
                        Case Else
                            '################################################
                            'SKIP, DO NOTHING SINCE ITS ALREADY POPULATED.
                            '################################################
                            account.AffliateID = AffiliateID
                    End Select
                End If



                '''###############################################################################
                '''BUILD THE MAIN SIGNIN REQUEST OBJECT 
                '''###############################################################################
                'Dim wsConfigProvider As New ConfigProvider.Service
                'Dim objGetSignInDataRequest As New ConfigProvider.GetSignInDataRequest
                'Dim objGetSignInDataResponse As New ConfigProvider.GetSignInDataResponse

                'objGetSignInDataRequest.csrLogin = CSRLOGIN
                'objGetSignInDataRequest.csrPassword = CSRPASSWORD
                'objGetSignInDataRequest.Login = userName
                'objGetSignInDataRequest.Password = password

                'wsConfigProvider.Url = ConfigurationManager.AppSettings("ConfigProvider.service")

                '''###############################################################################
                '''BUILD REQUEST OBJECT AND CALL THE WEBSERVER THAT RETURNS A HUGE OBJECT USED 
                ''TO POPULATE THE ACCOUNT OBJECT
                '''###############################################################################
                'objGetSignInDataResponse = wsConfigProvider.GetSignInData(objGetSignInDataRequest)









                Dim objrequest As New EntityMemberServices.GetSignInDataRequest
                Dim objGetSignInDataResponse As New EntityMemberServices.GetSignInDataResponse

                objrequest.csrLogin = CSRLOGIN
                objrequest.csrPassword = CSRPASSWORD
                objrequest.Login = userName
                objrequest.Password = password



                '######################################
                'CALL THE PROVIDER FOR AUTHENTICATION
                '######################################
                Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
                objGetSignInDataResponse = CType(iProvider.GetSignInData(objrequest), EntityMemberServices.GetSignInDataResponse)





                Dim objresponse As New EntityMemberServices.AuthenticateMsExResponse
                objresponse = objGetSignInDataResponse.MSAuthenticateMsExResponse



                If Not objresponse.Exception Then
                    '############################################################
                    'ADD TO THE EXISITING LINES OF BUSINESS IF THEY HAVE A 
                    'VALUE COMING BACK FROM MEMBER SERVICES.
                    '############################################################
                    Dim lLOB As New List(Of CharterDotCom.CommonEntities.Library.Enumerations.Category)


                    '####################################################################
                    'THEY MAY HAVE LOCALIZED ALREADY SO PERSIST THE EXSITING SERVICES.
                    '####################################################################
                    If Not (account Is Nothing) Then
                        account.ExistingLOB = lExistingLOB
                    End If




                    '##############################################################
                    'If no account Number is associated to the account , do not 
                    'process account Information.
                    '##############################################################
                    If objresponse.accountNumber Is Nothing Then
                        BLCommon.LogException(New Exception("Invalid account Number"), ExceptionSeverity.Fatal)
                        Return False
                    End If


                    '##################################################################################
                    'MODIFICATION   ROD COPELAND    Issue ID:  7334 BIG SKY FIX FOR MULTI-STATEMENTS
                    '##################################################################################
                    account.OSSProvidedAccountNumber = objresponse.accountNumber


                    '##############################################################
                    'Set user status and user Credentials on successful signing -In
                    '##############################################################
                    account.UserStatus = UserStatus.Authenticated
                    account.LoginID = userName


                    '############################################################
                    'POPULATE THE CustomerID FOR THE ACCOUNT
                    '############################################################
                    If Not (objGetSignInDataResponse.EAICustomerStatementsResponse Is Nothing) Then
                        If Not (objGetSignInDataResponse.EAICustomerStatementsResponse.CustomerId Is Nothing) Then
                            account.CSGcustomerID = objGetSignInDataResponse.EAICustomerStatementsResponse.CustomerId.Trim()
                        End If

                    End If

                    '############################################################
                    'POPULATE THE GENERAL SECURITY QUESTIONS FOR THE ACCOUNT
                    'THESE ARE USED IN DROPDOWN LISTS. THIS WILL BE A LIST OF ALL
                    ' QUESTIONS POSSIBILITIES.
                    '############################################################
                    If Not (System.Web.HttpContext.Current.Application("MYACCOUNT_GENERALQUESTIONLIST") Is Nothing) Then
                        Dim lQuestionList As List(Of String) = CType(System.Web.HttpContext.Current.Application("MYACCOUNT_GENERALQUESTIONLIST"), List(Of String))

                        account.SecurityQuestionList = lQuestionList
                    End If


                    '############################################################
                    'POPULATE THE SECURITY QUESTION/ANSWER STUFF FOR THE ACCOUNT
                    '############################################################
                    If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse Is Nothing) Then
                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.secretCode Is Nothing) Then
                            account.SecurityQuestion = objGetSignInDataResponse.MSAuthenticateMsExResponse.secretCode
                        End If
                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.secretHint Is Nothing) Then
                            account.SecurityAnswer = objGetSignInDataResponse.MSAuthenticateMsExResponse.secretHint
                        End If
                    End If

                    If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse Is Nothing) Then
                        '#######################################################################################################
                        'M O D I F I C A T I O N    9/25/2007 ROD COPELAND
                        '####################################
                        'NO MATTER WHERE THE USER HAS BEEN, WHEN THEY SIGN INTO MYACCOUNT, THEY START OVER WITH MEMBER INFO.
                        '#######################################################################################################
                        account.User = New BLAccount.BLMember


                        '#########################################################################
                        'ADD THE MEMBER SERVICES CONTACT EMAIL ADDRESS TO THE ACCOUNT.USER OBJECT
                        '#########################################################################
                        account.User.ContactEmailAddress = objGetSignInDataResponse.MSAuthenticateMsExResponse.contactEmail


                        '###########################################################
                        'ASSIGN THE FIRST AND LAST NAME TO THE ACCOUNT USER OBJECT
                        '###########################################################
                        account.User.FirstName = objGetSignInDataResponse.MSAuthenticateMsExResponse.firstName
                        account.User.LastName = objGetSignInDataResponse.MSAuthenticateMsExResponse.lastName


                        '###################################################################################
                        '12/12/2007 BRAD MILLER - ADD THE MEMBER SERVICES ACCOUNT TYPE TO THE ACCOUNT OBJECT
                        '###################################################################################
                        account.AccountType = objGetSignInDataResponse.MSAuthenticateMsExResponse.accountType


                        '##########################
                        'ASSIGN THE ADDRESS
                        '##########################
                        Dim lAddress As New BLAddress
                        lAddress.City = objGetSignInDataResponse.MSAuthenticateMsExResponse.city
                        lAddress.State = objGetSignInDataResponse.MSAuthenticateMsExResponse.StateInitials
                        lAddress.Street1 = objGetSignInDataResponse.MSAuthenticateMsExResponse.address1
                        lAddress.Street2 = objGetSignInDataResponse.MSAuthenticateMsExResponse.address2
                        lAddress.Zip = objGetSignInDataResponse.MSAuthenticateMsExResponse.zipCode





                        '###########################################################################
                        'MODIFICATION   ROD COPELAND    ISSUE ID 4376   OCT 22 2008
                        '###########################################################################
                        'PER CUST CARE, SECURITY WOULD LIKE ANOTHER LAYER OF VALIDATION FROM THE 
                        'CUSTOMER BEFORE THEY ARE LOGGING IN.  APPARENTLY, THERE ARE PEOPLE WHO 
                        'ARE GUESSING LOGIN IDs AND PW.  THE ASSUMPTION IS THAT THEY COULD NOT 
                        'GUESS WHAT THE ZIP CODE IS EITHER.
                        '###########################################################################
                        If validateZipCode Then
                            If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.zipCode Is Nothing) Then
                                If Not (zipCode Is Nothing) Then
                                    If zipCode.Contains(objGetSignInDataResponse.MSAuthenticateMsExResponse.zipCode.Trim()) Then
                                        '##########################################
                                        'THIS IS GOOD, CONTINUE WITH PROCESSING.
                                        '##########################################
                                    Else
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = "1 - The Service Address Zip Code provided does not match our records."

                                        '##############
                                        'Persist state
                                        '##############
                                        SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                        Return False
                                    End If
                                Else
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = "2 - The Service Address Zip Code provided does not match our records."

                                    '##############
                                    'Persist state
                                    '##############
                                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                    Return False
                                End If
                            Else
                                Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to validate your Service Address Zip Code at this time."

                                '##############
                                'Persist state
                                '##############
                                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                Return False
                            End If
                        End If
                        '###########################################################################

                        account.Address = lAddress


                        '##########################
                        'ASSIGN THE PHONE NUMBER
                        '##########################
                        account.HomePhone = objGetSignInDataResponse.MSAuthenticateMsExResponse.phoneNumber



                    End If








                    '############################################################
                    'ADD THE EXISING LINE OF BUSINESS TO THE ACCOUNT OBJECT.
                    '############################################################
                    If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse Is Nothing) Then
                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray Is Nothing) Then
                            If (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray.Length > 0) Then

                                For i As Integer = 0 To objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray.GetUpperBound(0)

                                    If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray Is Nothing) Then
                                        If (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray.Length > 0) Then
                                            If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i) Is Nothing) Then

                                                If Not (account.ExistingLOB Is Nothing) Then
                                                    If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).type Is Nothing) Then
                                                        Dim lDescription As String = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).description
                                                        If lDescription Is Nothing Then
                                                            lDescription = ""
                                                        End If
                                                        Select Case True
                                                            Case lDescription.ToLower().Contains("moxi")
                                                                'DONT ADD CATEGORY
                                                            Case lDescription.ToLower().Contains("voice")
                                                                'DONT ADD CATEGORY
                                                            Case Else
                                                                'ADD CATEGORY
                                                                Select Case objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).type.ToLower()
                                                                    Case "hsd"
                                                                        If Not account.ExistingLOB.Contains(Category.HSD) Then
                                                                            account.ExistingLOB.Add(Category.HSD)
                                                                        End If
                                                                    Case Else
                                                                        '################################################################
                                                                        'ASSIGN OTHER LINES AS NEEDED, RIGHT NOW, JUST HSD.  AS OF TODAY, 
                                                                        'THIS LOB IS NEEDED HERE TO DETERMINE WHICH LEFT NAV LINKS NEED 
                                                                        'TO BE DISPLAYED.
                                                                        '################################################################
                                                                End Select

                                                        End Select


                                                    End If
                                                End If

                                            End If
                                        End If
                                    End If
                                Next
                            End If
                        End If
                    End If







                    '##################################################################
                    'ADD WEBSERVICE PACKAGE TO THE ACCOUNT OBJECTS PACKAGE COLLECTION.
                    '##################################################################
                    If Not (objGetSignInDataResponse Is Nothing) Then
                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse Is Nothing) Then
                            If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray Is Nothing) Then
                                If (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray.Length > 0) Then

                                    For i As Integer = 0 To objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray.GetUpperBound(0)
                                        Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo

                                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).description Is Nothing) Then
                                            lPackage.descriptionField = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).description
                                        End If
                                        If (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).emailsAllowed > 0) Then
                                            lPackage.MaxEmailsAllowed = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).emailsAllowed
                                        End If
                                        If objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).pendingStatus Then
                                            lPackage.statusField = "ACTIVE"
                                        Else
                                            lPackage.statusField = "INACTIVE"
                                        End If
                                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).provisioningId Is Nothing) Then
                                            lPackage.provisioningIdField = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).provisioningId
                                        End If
                                        If objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).securityKeysAllowed > 0 Then
                                            lPackage.MaxSecurityKeysAllowed = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).securityKeysAllowed
                                        End If

                                        If Not (objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).type Is Nothing) Then
                                            lPackage.typeField = objGetSignInDataResponse.MSAuthenticateMsExResponse.packageArray(i).type
                                        End If




                                        '##############################################################
                                        'SEARCH FOR THE PROVISIONING ID IN THE EXISTING PACKAGES TO SEE 
                                        'IF ANY OF THEM NEED TO BE UPDATED WITH THESE SECURITY KEYS.
                                        '##############################################################
                                        If account Is Nothing Then
                                            account = New BLAccount
                                        End If
                                        If account.User Is Nothing Then
                                            account.User = New BLAccount.BLMember
                                        End If
                                        If account.User.MSPackageInfo Is Nothing Then
                                            account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
                                        End If


                                        '#####################################
                                        'ADD A NEW PACKAGE TO THE COLLECTION
                                        '#####################################
                                        account.User.MSPackageInfo.Add(lPackage)

                                    Next



                                End If
                            End If
                        End If
                    End If















                    '###############################################################
                    'Add retunred accountnumber associated to the account to a list 
                    '###############################################################
                    Dim acctNumber As New List(Of String)
                    Dim oldAcctNumber As New List(Of String)





                    '#########################################################
                    'MODIFICATION   ROD COPELAND    5/09/2008
                    'ISSUE 3838
                    '#########################################################
                    'ASSIGN THE DEFAULT MS ACCOUNT NUMBER (statement code of 
                    '003 appended to the account number returned from the 
                    'MS provider) IN THE EVENT WHEN 
                    'THE BILLING SYSTEM WS CALL DOENST RETURN ANY STATEMENTS 
                    'TO GET THE STATEMENTCODE APPENDED TO THE 16 DIGIT ICOMS 
                    'NUMBERS FROM THE MS WS. THE MS WS CAN TAKE A 16 DIGIT OR
                    'A 19 DIGIT ICOMS ACCOUNT NUMBER THAT HAS A STUBBED OUT 
                    'STATEMENT CODE THAT LOOKS LIKE '003', SO THAT IS THE BARE
                    'MIN THAT WE ARE DEFAULTING TO BELOW. PER ERIC KISIEL
                    '#########################################################
                    If Not (objresponse.billingType Is Nothing) Then
                        If objresponse.billingType.ToUpper().Trim() = "ICOMS" Then
                            If objresponse.accountNumber.Trim().Length() = 16 Then
                                acctNumber.Add(objresponse.accountNumber.Substring(0, 16) & "003")
                            Else
                                acctNumber.Add(objresponse.accountNumber)
                            End If
                        Else
                            acctNumber.Add(objresponse.accountNumber)
                        End If
                    Else
                        acctNumber.Add(objresponse.accountNumber)
                    End If

                    '#########################################################
                    '#########################################################








                    If Not account.Bill Is Nothing Then
                        For Each obj As BLAccount.BillSummary In account.Bill
                            oldAcctNumber.Add(obj.AccountNumber)
                        Next
                    End If



                    'Generate the Account Number list associated to the user
                    account.Bill = New List(Of IAccount.IBill)

                    'Determine Billing Vendor type (between ICOMS or CSG) based on the first 3 digits of Account Number
                    'As per business, if the Billing system is ICOMS, then first 3 digits should be one of
                    '100 , 200 , 300 , 400 , 500 , 600
                    'If not it is a CSG account

                    For Each strTemp As String In acctNumber
                        Select Case Left(strTemp, 3)
                            Case "100", "200", "300", "400", "500", "700", "800"
                                account.BillingVendorType = BillingVendorType.ICOM
                                Dim objBillAccount As New BLAccount.BillSummary(strTemp)
                                account.Bill.Add(objBillAccount)

                            Case Else
                                account.BillingVendorType = BillingVendorType.CSG
                                Dim objBillAccount As New BLAccount.BillSummary(strTemp)
                                account.Bill.Add(objBillAccount)
                        End Select
                    Next






                    '#########################################
                    'ASSIGN THE SITE ID TO THE ACCOUNT OBJECT
                    '#########################################
                    If Not (objresponse Is Nothing) Then
                        If Not (objresponse.accountNumber Is Nothing) Then
                            If Not (account Is Nothing) Then
                                account.Site = Left(objresponse.accountNumber, 3)
                            End If
                        End If
                    End If











                    ''############################################################
                    ''GET THE BILL SUMMARY INFO DEPENDING ON WHICH BILLING SYSTEM
                    ''############################################################
                    Dim objBillingSummary As New List(Of IAccount.IBill)

                    Select Case account.BillingVendorType
                        Case BillingVendorType.CSG
                            '################################################################################################
                            '################################################################################################
                            '################################################################################################
                            'MODIFICATION	ROD COPELAND	ISSUE ID 6661	CSG Multi-Statement - My Account Overview Page
                            '################################################################################################
                            If Not (objGetSignInDataResponse Is Nothing) Then
                                If Not (objGetSignInDataResponse.EAICustomerStatementsResponse Is Nothing) Then

                                    '#########################################################################
                                    'MODIFICATION   ROD COPELAND    Issue ID:  7125
                                    '#########################################################################
                                    If Not objGetSignInDataResponse.EAICustomerStatementsResponse.Exception Then
                                        If Not (objGetSignInDataResponse.EAICustomerStatementsResponse.AccountStatementAllInfo Is Nothing) Then
                                            For Each CustomerStatement As EntityEBSServices.AccountStatementAllInfo In objGetSignInDataResponse.EAICustomerStatementsResponse.AccountStatementAllInfo
                                                account.EBPP = CustomerStatement.EBPP

                                                Dim tempStatement As New BLAccount.BillSummary(CustomerStatement.AccountId)
                                                If Not (CustomerStatement.Statements Is Nothing) Then

                                                    For Each webserviceStatement As EntityEBSServices.Statement In CustomerStatement.Statements
                                                        '#########################################################################################
                                                        'ROD COPELAND 7/14/09 PER TIM WARTHEN, EVEN THOUGH THIS IS A COLLECTION OF STATEMENTS, 
                                                        'WE'RE ONLY GOING TO SEE JUST ONE ELEMENT COME BACK ON THIS COLLECTION EVER.  THE NEED 
                                                        'FOR THIS TO BE A COLLECTION IS REALLY FOR THE COUPON SYSTEM, NOT FOR CHARTER.COM
                                                        '#########################################################################################
                                                        tempStatement.CalculatedBalance_CSG_ONLY = webserviceStatement.CalculatedBalance
                                                        tempStatement.CalculatedBalanceStatus_CSG_ONLY = webserviceStatement.CalculatedBalanceStatus
                                                        tempStatement.CurrentStatementDate_CSG_ONLY = webserviceStatement.CurrentStatementDate
                                                        tempStatement.StatementBalance_CSG_ONLY = webserviceStatement.StatementBalance
                                                        tempStatement.PaymentDueDate_CSG_ONLY = webserviceStatement.PaymentDueDate
                                                        tempStatement.DueDateDescription = webserviceStatement.DueDateDescription
                                                        Exit For
                                                    Next

                                                End If

                                                tempStatement.DisplayBillSummary = True

                                                objBillingSummary.Add(tempStatement)
                                                account.Bill = objBillingSummary

                                            Next
                                        End If
                                    Else
                                        '#########################################################################
                                        'MODIFICATION   ROD COPELAND    Issue ID:  7334
                                        '#########################################################################
                                        If objGetSignInDataResponse.EAICustomerStatementsResponse.ExceptionMessage IsNot Nothing Then
                                            If objGetSignInDataResponse.EAICustomerStatementsResponse.ExceptionMessage.ToUpper().Contains("ODSDT2002") Then
                                                '################################################################################
                                                'MODIFICATION   BIGSKY SEPT 2, 2009     ROD COPELAND
                                                '################################################################################
                                                'DISPLAY MESSAGE THAT BILLING SUMMARY DATA IS NOT AVAILABLE AT THE MOMENT.  
                                                'IT CAN BE SAID THAT CONDITION ODSDT2002 IS AN ERROR FROM THE BILLING SYSTEM 
                                                'THAT INDICATES THAT THE CUSTOMER DOES EXIST BUT DOES NOT HAVE A CURRENT 
                                                'STATEMENT AVAILABLE TO BUILD THE BILLING SUMMARY PAGE DATA OUT.  THIS IS A 
                                                'TYPICAL RESPONSE FOR CUSTOMERS THAT ARE NEW IN THE BILLING SYSTEM AND IS 
                                                'RESOLVED WHEN THE ACCOUNT UNDERGOES A BILLING CYCLE TO CREATE THE FIRST 
                                                'STATEMENT, AT THAT POINT THE EAI RESPONSE WOULD BE NORMAL.
                                                '################################################################################




                                                '###########################################################################################
                                                'DO A LOOK UP TO FIND THE PRE-CONVERSION ICOMS NUMBER USING THE POST-CONVERSION CSG NUMBER.
                                                '###########################################################################################
                                                Dim objEAIRequest As New GetDataRequest
                                                Dim objEAIResponse As New GetDataResponseCSGToICOMSConversion

                                                objEAIRequest.AccountNumberCSG = objresponse.accountNumber



                                                '#####################
                                                'DO THE PROVIDER CALL
                                                '#####################
                                                Dim iEAIProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
                                                objEAIResponse = CType(iEAIProvider.FindICOMSAccountNumberFromCSGAccountNumber(objEAIRequest), GetDataResponseCSGToICOMSConversion)



                                                If objEAIResponse IsNot Nothing Then
                                                    If Not objEAIResponse.Exception Then
                                                        '################################################################################################
                                                        'TAKE THE PRE-CONVERSION ICOMS NUMBER AND DO A LOOK UP TO FIND THE STATEMENTS FOR THIS CUSTOMER.
                                                        '################################################################################################
                                                        Dim objGetAccountStatementsAllRequest As GetAccountStatementsAllRequestICOMS
                                                        Dim objGetAccountStatementsAllResponse As New GetAccountStatementsAllResponseICOMS
                                                        Dim objHeader As New IcomsHeaderInfo

                                                        If objEAIResponse IsNot Nothing Then
                                                            If objEAIResponse.PreConversionICOMSAccountNumber IsNot Nothing Then
                                                                Select Case Left(objEAIResponse.PreConversionICOMSAccountNumber, 3)
                                                                    Case "100"
                                                                        objHeader.SiteId = SiteId.Site100
                                                                    Case "200"
                                                                        objHeader.SiteId = SiteId.Site200
                                                                    Case "300"
                                                                        objHeader.SiteId = SiteId.Site300
                                                                    Case "400"
                                                                        objHeader.SiteId = SiteId.Site400
                                                                    Case "500"
                                                                        objHeader.SiteId = SiteId.Site500
                                                                    Case "600"
                                                                        objHeader.SiteId = SiteId.Site600
                                                                End Select

                                                                Dim lstrAccountNumber As String = objEAIResponse.PreConversionICOMSAccountNumber.Substring(3, 9)
                                                                objGetAccountStatementsAllRequest = New GetAccountStatementsAllRequestICOMS(objHeader, lstrAccountNumber)

                                                                '########################################################################
                                                                'MAKE CALL TO THE PROVIDER WHICH IN TURN WILL CALL THE EBS WEB SERVICE
                                                                '########################################################################
                                                                objGetAccountStatementsAllResponse = CType(iEAIProvider.GetAccountsFromICOMS(objGetAccountStatementsAllRequest), GetAccountStatementsAllResponseICOMS)

                                                            End If
                                                        End If


                                                        If Not objGetAccountStatementsAllResponse.Exception Then
                                                            '###############################################
                                                            'BUILD STATEMENTS TO BE PARSED INTO BILL OBJECT
                                                            '###############################################
                                                            Call getICOMSBillStatements(objEAIResponse.PreConversionICOMSAccountNumber, objGetAccountStatementsAllResponse)



                                                            '#############################################################################################
                                                            'ALOT OF THE OTHER PARTS OF THE SITE CONDITION OF THIS VALUE.  SINCE IN THIS RARE CASE WE 
                                                            'ARE LOGGING IN AS A CSG PERSON AND DOING A FETCH OF THE ICOMS STATEMENTS, ALL THE STATEMENT 
                                                            'DATA REQUIRES THE CUSTOMER TO LOOK LIKE AN ICOMS PERSON EVEN THOUGH THEY HAVE BEEN CONVERTED 
                                                            'TO CSG JUST SO THE SITE WILL DISPLAY AND BEHAVE AS ICOMS.
                                                            '#############################################################################################
                                                            account.BillingVendorType = BillingVendorType.ICOM


                                                            '########################################################################################
                                                            'SEND THE ICOMS STATEMENTS BACK TO THE PAGE TO BE DISPLAYED ON THE BILLING SUMMARY PAGE.
                                                            '########################################################################################
                                                        Else
                                                            '#######################################################################################
                                                            'ASSIGN STATE TO THE DISPLAYBILLSUMMARY ATTRIBUTE.
                                                            'THE DEFAULT FOR THE BILL OBJECT IS TO HAVE JUST BILL WITH STUBBED BILL DETAILS 
                                                            'WITH A REAL PRIMARY ACCOUNT NUMBER WHICH IS DERRIVED FROM THE OSS CALL TO 
                                                            'AUTHENTICATE, SO AT THIS POINT IN THE CODE, EVEN WHEN THE EAI CALL TO THE BILLING 
                                                            'SYSTEM FAILS WE SHOULD HAVE AT LEAST ONE ACCOUNT IN THE BILL OBJECT. 
                                                            '
                                                            'ANOTHER CONSIDERATION IS CURRENT STATE EAI GETS A COLLECTION OF BILLS POTENTIALLY 
                                                            'IF THEY ENCOUNTER AN ERROR DURING PROCESSING OF ANY ACCOUNT IN A COLLECTION, THEY 
                                                            'FAIL THE WHOLE BATCH/COLLECTION AS AN EXCEPTION.  THERE WAS TALKS FOR FUTURE TO 
                                                            'MAKE THE EXCEPTION APPLY AT A BILL LEVEL, JUST THERE AT THE MOMENT.  SO ANY ERRORS 
                                                            'ARE ALWAYS AT THE COLLECTION LEVEL, JUST TO SUPPORT GRABING JUST THE FIRST 
                                                            'OCCURANCE IN THE ACCOUNT.BILL COLLECTION SINCE THERE SHOULD ONLY BE ONE ENTRY 
                                                            'AT THIS POINT, FOR NOW.
                                                            '#######################################################################################
                                                            account.Bill(0).DisplayBillSummary = False
                                                        End If

                                                    Else
                                                        '#######################################################################################
                                                        'ASSIGN STATE TO THE DISPLAYBILLSUMMARY ATTRIBUTE.
                                                        'THE DEFAULT FOR THE BILL OBJECT IS TO HAVE JUST BILL WITH STUBBED BILL DETAILS 
                                                        'WITH A REAL PRIMARY ACCOUNT NUMBER WHICH IS DERRIVED FROM THE OSS CALL TO 
                                                        'AUTHENTICATE, SO AT THIS POINT IN THE CODE, EVEN WHEN THE EAI CALL TO THE BILLING 
                                                        'SYSTEM FAILS WE SHOULD HAVE AT LEAST ONE ACCOUNT IN THE BILL OBJECT. 
                                                        '
                                                        'ANOTHER CONSIDERATION IS CURRENT STATE EAI GETS A COLLECTION OF BILLS POTENTIALLY 
                                                        'IF THEY ENCOUNTER AN ERROR DURING PROCESSING OF ANY ACCOUNT IN A COLLECTION, THEY 
                                                        'FAIL THE WHOLE BATCH/COLLECTION AS AN EXCEPTION.  THERE WAS TALKS FOR FUTURE TO 
                                                        'MAKE THE EXCEPTION APPLY AT A BILL LEVEL, JUST THERE AT THE MOMENT.  SO ANY ERRORS 
                                                        'ARE ALWAYS AT THE COLLECTION LEVEL, JUST TO SUPPORT GRABING JUST THE FIRST 
                                                        'OCCURANCE IN THE ACCOUNT.BILL COLLECTION SINCE THERE SHOULD ONLY BE ONE ENTRY 
                                                        'AT THIS POINT, FOR NOW.
                                                        '#######################################################################################
                                                        account.Bill(0).DisplayBillSummary = False
                                                    End If
                                                Else
                                                    '#######################################################################################
                                                    'ASSIGN STATE TO THE DISPLAYBILLSUMMARY ATTRIBUTE.
                                                    'THE DEFAULT FOR THE BILL OBJECT IS TO HAVE JUST BILL WITH STUBBED BILL DETAILS 
                                                    'WITH A REAL PRIMARY ACCOUNT NUMBER WHICH IS DERRIVED FROM THE OSS CALL TO 
                                                    'AUTHENTICATE, SO AT THIS POINT IN THE CODE, EVEN WHEN THE EAI CALL TO THE BILLING 
                                                    'SYSTEM FAILS WE SHOULD HAVE AT LEAST ONE ACCOUNT IN THE BILL OBJECT. 
                                                    '
                                                    'ANOTHER CONSIDERATION IS CURRENT STATE EAI GETS A COLLECTION OF BILLS POTENTIALLY 
                                                    'IF THEY ENCOUNTER AN ERROR DURING PROCESSING OF ANY ACCOUNT IN A COLLECTION, THEY 
                                                    'FAIL THE WHOLE BATCH/COLLECTION AS AN EXCEPTION.  THERE WAS TALKS FOR FUTURE TO 
                                                    'MAKE THE EXCEPTION APPLY AT A BILL LEVEL, JUST THERE AT THE MOMENT.  SO ANY ERRORS 
                                                    'ARE ALWAYS AT THE COLLECTION LEVEL, JUST TO SUPPORT GRABING JUST THE FIRST 
                                                    'OCCURANCE IN THE ACCOUNT.BILL COLLECTION SINCE THERE SHOULD ONLY BE ONE ENTRY 
                                                    'AT THIS POINT, FOR NOW.
                                                    '#######################################################################################
                                                    account.Bill(0).DisplayBillSummary = False
                                                End If
                                            End If
                                        End If


                                    End If

                                End If
                                '################################################################################################
                                '################################################################################################
                                '################################################################################################
                            End If
                        Case BillingVendorType.ICOM
                            If Not (objGetSignInDataResponse Is Nothing) Then
                                If Not (objGetSignInDataResponse.EBSGetAccountStatementsAllResponseICOMS Is Nothing) Then
                                    If Not (objGetSignInDataResponse.EBSGetAccountStatementsAllResponseICOMS.AccountStatementAllInfo Is Nothing) Then
                                        If Not (objGetSignInDataResponse.EBSGetAccountStatementsAllResponseICOMS.AccountStatementAllInfo.Statement Is Nothing) Then

                                            Dim blnHasValue As Boolean = False
                                            For Each objICOMSaccount As EntityEBSServices.StatementAll In objGetSignInDataResponse.EBSGetAccountStatementsAllResponseICOMS.AccountStatementAllInfo.Statement


                                                '##############################################################################
                                                'MODIFICATION    ROD COPELAND   APRIL 13, 2009  ISSUE ID 5837
                                                'CUST CARE REQUESTED NO SERVICE STATEMENTS BE EXCLUDED FROM THE SITE DISPLAY.
                                                '##############################################################################
                                                If Not (objICOMSaccount Is Nothing) Then
                                                    If Not (objICOMSaccount.MOP Is Nothing) Then
                                                        Select Case objICOMSaccount.MOP.StatementStatus
                                                            Case StatementStatus.NoServices
                                                                '##################################################################
                                                                'SKIP DISPLAYING THIS IN THE OBJECT MODEL AND PAGE PER ISSUE 5837
                                                                '##################################################################
                                                            Case Else
                                                                '######################################################################################
                                                                'ADD STATEMENT TO OBJECT MODEL AND THE PAGE WILL EVENTUALLY DISPLAY THESE TO THE USERS.
                                                                '######################################################################################



                                                                '##################################################################################
                                                                'BUILD LOCAL BILL STATEMENT AND ASSIGN TO THE STATEMENT COLLECTION BEING RETURNED
                                                                '##################################################################################
                                                                Dim objBillAccount As New BLAccount.BillSummary(objresponse.accountNumber)



                                                                '#########################################################################################
                                                                '#########################################################################################
                                                                'MODIFICATION   ROD COPELAND APRIL 21, 2008
                                                                'CONDITION TO USE THE OLD ACCOUNT NUMBER FORMAT RATHER THAN THE NEW FORMAT BASED UPON 
                                                                'THE ISP RELEASE GOLIVE SCHEDULED FOR 17 MAY 2008.
                                                                '#########################################################################################
                                                                If Not (System.Web.HttpContext.Current.Application("USE_16_DIGIT_ACCOUNTNUMBER_POST_ISP_RELEASE") Is Nothing) Then
                                                                    If (System.Web.HttpContext.Current.Application("USE_16_DIGIT_ACCOUNTNUMBER_POST_ISP_RELEASE").ToString().Trim().ToUpper().Contains("T")) Then
                                                                        '###################################################################
                                                                        'USE THE POST-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 16 DIGITS.
                                                                        '###################################################################

                                                                        '#########################################################################################
                                                                        'MODIFICATION   ROD COPELAND APRIL 21, 2008
                                                                        '#########################################################################################
                                                                        'TO SUPPORT THE MS ISP RELEASE 2008, THEY ARE NOW SENDING ONLY 16 DIGIT ACCOUNT NUMBERS 
                                                                        'BACK SO WE NEED TO PAD THE ACCOUNT NUMBER WITH 2 ZEROS TO MAKE THE ACCOUNT NUMBER 19 
                                                                        'DIGITS AGAIN.  THERE ARE ONLY 7 STATEMENTCODES NOW WITH NO 2 DIGIT STATEMENT CODES BEING 
                                                                        'INTRODUCED ANY YEAR SOON SO ASSUMING A SINGLE DIGIT STATEMENTCODE MAKE SENCE A CODE MODE 
                                                                        'TO THE ENUM OF STATEMENT CODE WOULD HAVE TO BE MADE TO SUPPORT THE NEW STATEMENT CODE
                                                                        '#########################################################################################
                                                                        If Not (objresponse.accountNumber Is Nothing) Then
                                                                            Select Case objresponse.accountNumber.Length()
                                                                                Case 16 'NEW STANDARD FOR THE 2008 ISP RELEASE
                                                                                    objBillAccount.AccountNumber = objresponse.accountNumber & "00" & objICOMSaccount.StatementCode
                                                                                Case 19 'OLD STANDARD PRE 2008 ISP RELEASE
                                                                                    '####################################################################
                                                                                    'STRIP OFF THE LAST THREE (STATEMENT CODE) AND APPEND THE STATEMENT 
                                                                                    'CODE FROM THE EAI WS CALL
                                                                                    '####################################################################
                                                                                    objBillAccount.AccountNumber = objresponse.accountNumber.Substring(0, 16) & "00" & objICOMSaccount.StatementCode
                                                                                Case Else
                                                                                    objBillAccount.AccountNumber = objresponse.accountNumber
                                                                            End Select
                                                                        End If
                                                                        '#########################################################################################
                                                                    Else
                                                                        '###################################################################
                                                                        'USE THE PRE-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 19 DIGITS.
                                                                        'OLD CODE FOLLOWS:
                                                                        '###################################################################
                                                                        objBillAccount.AccountNumber = objresponse.accountNumber & objICOMSaccount.StatementCode
                                                                    End If
                                                                Else
                                                                    '###################################################################
                                                                    'USE THE PRE-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 19 DIGITS.
                                                                    'OLD CODE FOLLOWS:
                                                                    '###################################################################
                                                                    objBillAccount.AccountNumber = objresponse.accountNumber & objICOMSaccount.StatementCode
                                                                End If
                                                                '#########################################################################################
                                                                '#########################################################################################







                                                                objBillAccount.BillAmount = CDec(objICOMSaccount.BalanceLastStatement)

                                                                objBillAccount.BillDescription = objICOMSaccount.StatementDescription
                                                                objBillAccount.BillDueUponReceipt = False

                                                                '##############################################################
                                                                'MODIFICATION   ROD COPELAND    JAN 21, 2009
                                                                'PULL THE FOLLOWING FROM THE EAI WS RESPONSE AND DISPLAY 
                                                                'ON THE UI EVENTUALLY INTHE QUICKPAY.ASCX
                                                                'LastStatementDate  
                                                                'TotalStatementAmount 
                                                                'StatementDueDate 
                                                                '##############################################################
                                                                If Not (objICOMSaccount.TotalStatementAmount Is Nothing) Then
                                                                    objBillAccount.TotalStatementAmount_ICOMS_ONLY = CDec(objICOMSaccount.TotalStatementAmount)
                                                                End If

                                                                If Not (objICOMSaccount.LastStatementDate Is Nothing) Then
                                                                    If objICOMSaccount.LastStatementDate.Trim().Length() > 7 Then
                                                                        objBillAccount.LastStatementDate_ICOMS_ONLY = CDate(objICOMSaccount.LastStatementDate.Substring(4, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(6, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(0, 4))
                                                                    End If
                                                                End If

                                                                If Not (objICOMSaccount.StatementDueDate Is Nothing) Then
                                                                    If Len(objICOMSaccount.StatementDueDate.Trim()) = 8 Then
                                                                        objBillAccount.StatementDueDate_ICOMS_ONLY = CDate(objICOMSaccount.StatementDueDate.Trim().Substring(4, 2) & "/" & objICOMSaccount.StatementDueDate.Trim().Substring(6, 2) & "/" & objICOMSaccount.StatementDueDate.Trim().Substring(0, 4))
                                                                    Else
                                                                        If objICOMSaccount.StatementDueDate = "9999999" Then
                                                                            objBillAccount.BillDueUponReceipt = True
                                                                        Else
                                                                            '###################################################################################
                                                                            'MODIFICATION   ROD COPELAND    APRIL 14, 2009  ISSUE ID 5837
                                                                            '###################################################################################
                                                                            'COMMENTED THE STATEMENT BELOW THAT WAS ADDED DURING THE CREATIVE LIFT 
                                                                            ' 2009 BY SOMEONE TBD.  AT THIS POINT IN THE CODE, THERE SOULDNT BE A VALID 
                                                                            'DATE AVAILABLE TO SUBSTRING AS THE LEN IS NOT 8 CHAR IN LENGTH.  CURRENT 
                                                                            'STATE BUSINESS RULES INDICATE TO LEAVE THIS BLANK PER CUSTOMER CARE.
                                                                            '###################################################################################
                                                                            ''This is part of creative lift changes
                                                                            ''objBillAccount.StatementDueDate_ICOMS_ONLY = CDate(objICOMSaccount.StatementDueDate.Substring(4, 2) & "/" & objICOMSaccount.StatementDueDate.Substring(6, 2) & "/" & objICOMSaccount.StatementDueDate.Substring(0, 4))
                                                                        End If
                                                                    End If
                                                                End If

                                                                blnHasValue = True

                                                                objBillAccount.DisplayBillSummary = True

                                                                objBillingSummary.Add(objBillAccount)

                                                        End Select
                                                    End If
                                                End If



                                            Next
                                            If blnHasValue Then
                                                account.Bill = objBillingSummary
                                            End If
                                        Else
                                            'Return Nothing
                                        End If
                                    Else
                                        'Return Nothing
                                    End If
                                End If
                            End If
                    End Select























                    '#########################################################
                    'AS A BUSINESS RULE, 12-12-2006 JOHN SPYERS SAID THAT WE 
                    'NEED TO REMOVE THE MOXI BOX FROM THE LIST OF PACKAGES 
                    'THAT ARE RETURNED FROM THE MEMBER SERVICES AREA.
                    '#########################################################
                    Call RemoveNonDisplayablePackagesFromAccountObj()




                    '##############
                    'Persist state
                    '##############
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                    '#######################################################################
                    'WE HAVE A SUCESS, CLEAR FAIL COUNTS, RESET AND ALLOW THEM TO CONTINUE.
                    '#######################################################################
                    System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_TotalAttemptCount") = Nothing




                    Return True

                Else

                    If (System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_TotalAttemptCount") Is Nothing) Then
                        System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("MYACCOUNT_LOGIN_FAILED_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
                        System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_TotalAttemptCount") = "1"
                    Else
                        '#######################################
                        'UPDATE FAIL COUNT AND LET THEM CONTINUE
                        '#######################################
                        System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_TotalAttemptCount") = (CType(System.Web.HttpContext.Current.Session("MYACCOUNT_LOGIN_FAILED_TotalAttemptCount"), Integer) + 1).ToString()
                    End If




                    '##################################################################################
                    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                    '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                    '##################################################################################
                    'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                    'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                    'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                    'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                    'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                    'ACCORDINGLY.
                    '##################################################################################
                    Select Case True
                        Case Not objresponse.CharterDotCom_Friendly_Messages Is Nothing
                            Me._LastCCOMDisplayFriendlyExceptionMessage = objresponse.CharterDotCom_Friendly_Messages
                        Case Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                    End Select
                    '##################################################################################



                    '##############
                    'Persist state
                    '##############
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())


                    Common.LogException(New Exception("Account Manager -Sign In failed as:" & objresponse.ExceptionMessage), ExceptionSeverity.High)
                    Return False
                End If
            Catch ex As Exception
                Common.LogException(ex, ExceptionSeverity.Fatal)
                Throw ex
            Finally
                'objrequest = Nothing
                'objresponse = Nothing
                'lMemberProvider = Nothing
            End Try

        Else
            Try
                Dim lProvider As IContentProvider = CType(Activator.GetObject(GetType(IContentProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_ContentProvider"))), IContentProvider)

                If lProvider.SignIn(userName, password) Then
                    account.UserType = UserType.Author
                    account.LoginID = userName
                    Return True
                Else
                    Common.LogException(New Exception("Account Manager -Content Admin sign-in failed for:" & userName), ExceptionSeverity.High)
                    Return False
                End If

            Catch ex As Exception
                Common.LogException(ex, ExceptionSeverity.High)
            End Try
        End If
    End Function


    Private Function getICOMSBillStatements(ByVal accountNumber As String, ByVal statementCollection As GetAccountStatementsAllResponseICOMS) As List(Of IAccount.IBill)
        '#########################################################################
        'MODIFICATION   ROD COPELAND    Issue ID:  7334 OCT 1, 2009 BIGSKY
        '#########################################################################

        Dim objBillingSummary As New List(Of IAccount.IBill)

        If Not (statementCollection Is Nothing) Then
            If Not (statementCollection.AccountStatementAllInfo Is Nothing) Then
                If Not (statementCollection.AccountStatementAllInfo.Statement Is Nothing) Then

                    Dim blnHasValue As Boolean = False
                    For Each objICOMSaccount As EntityEBSServices.StatementAll In statementCollection.AccountStatementAllInfo.Statement


                        '##############################################################################
                        'MODIFICATION    ROD COPELAND   APRIL 13, 2009  ISSUE ID 5837
                        'CUST CARE REQUESTED NO SERVICE STATEMENTS BE EXCLUDED FROM THE SITE DISPLAY.
                        '##############################################################################
                        If Not (objICOMSaccount Is Nothing) Then
                            If Not (objICOMSaccount.MOP Is Nothing) Then
                                Select Case objICOMSaccount.MOP.StatementStatus
                                    Case StatementStatus.NoServices
                                        '##################################################################
                                        'SKIP DISPLAYING THIS IN THE OBJECT MODEL AND PAGE PER ISSUE 5837
                                        '##################################################################
                                    Case Else
                                        '######################################################################################
                                        'ADD STATEMENT TO OBJECT MODEL AND THE PAGE WILL EVENTUALLY DISPLAY THESE TO THE USERS.
                                        '######################################################################################



                                        '##################################################################################
                                        'BUILD LOCAL BILL STATEMENT AND ASSIGN TO THE STATEMENT COLLECTION BEING RETURNED
                                        '##################################################################################
                                        Dim objBillAccount As New BLAccount.BillSummary(accountNumber)



                                        '#########################################################################################
                                        '#########################################################################################
                                        'MODIFICATION   ROD COPELAND APRIL 21, 2008
                                        'CONDITION TO USE THE OLD ACCOUNT NUMBER FORMAT RATHER THAN THE NEW FORMAT BASED UPON 
                                        'THE ISP RELEASE GOLIVE SCHEDULED FOR 17 MAY 2008.
                                        '#########################################################################################
                                        If Not (System.Web.HttpContext.Current.Application("USE_16_DIGIT_ACCOUNTNUMBER_POST_ISP_RELEASE") Is Nothing) Then
                                            If (System.Web.HttpContext.Current.Application("USE_16_DIGIT_ACCOUNTNUMBER_POST_ISP_RELEASE").ToString().Trim().ToUpper().Contains("T")) Then
                                                '###################################################################
                                                'USE THE POST-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 16 DIGITS.
                                                '###################################################################

                                                '#########################################################################################
                                                'MODIFICATION   ROD COPELAND APRIL 21, 2008
                                                '#########################################################################################
                                                'TO SUPPORT THE MS ISP RELEASE 2008, THEY ARE NOW SENDING ONLY 16 DIGIT ACCOUNT NUMBERS 
                                                'BACK SO WE NEED TO PAD THE ACCOUNT NUMBER WITH 2 ZEROS TO MAKE THE ACCOUNT NUMBER 19 
                                                'DIGITS AGAIN.  THERE ARE ONLY 7 STATEMENTCODES NOW WITH NO 2 DIGIT STATEMENT CODES BEING 
                                                'INTRODUCED ANY YEAR SOON SO ASSUMING A SINGLE DIGIT STATEMENTCODE MAKE SENCE A CODE MODE 
                                                'TO THE ENUM OF STATEMENT CODE WOULD HAVE TO BE MADE TO SUPPORT THE NEW STATEMENT CODE
                                                '#########################################################################################
                                                If Not (accountNumber Is Nothing) Then
                                                    Select Case accountNumber.Length()
                                                        Case 16 'NEW STANDARD FOR THE 2008 ISP RELEASE
                                                            objBillAccount.AccountNumber = accountNumber & "00" & objICOMSaccount.StatementCode
                                                        Case 19 'OLD STANDARD PRE 2008 ISP RELEASE
                                                            '####################################################################
                                                            'STRIP OFF THE LAST THREE (STATEMENT CODE) AND APPEND THE STATEMENT 
                                                            'CODE FROM THE EAI WS CALL
                                                            '####################################################################
                                                            objBillAccount.AccountNumber = accountNumber.Substring(0, 16) & "00" & objICOMSaccount.StatementCode
                                                        Case Else
                                                            objBillAccount.AccountNumber = accountNumber
                                                    End Select
                                                End If
                                                '#########################################################################################
                                            Else
                                                '###################################################################
                                                'USE THE PRE-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 19 DIGITS.
                                                'OLD CODE FOLLOWS:
                                                '###################################################################
                                                objBillAccount.AccountNumber = accountNumber & objICOMSaccount.StatementCode
                                            End If
                                        Else
                                            '###################################################################
                                            'USE THE PRE-ISP RELEASE ACCOUNT NUMBER LENGTH WHICH IS 19 DIGITS.
                                            'OLD CODE FOLLOWS:
                                            '###################################################################
                                            objBillAccount.AccountNumber = accountNumber & objICOMSaccount.StatementCode
                                        End If
                                        '#########################################################################################
                                        '#########################################################################################







                                        objBillAccount.BillAmount = CDec(objICOMSaccount.BalanceLastStatement)

                                        objBillAccount.BillDescription = objICOMSaccount.StatementDescription
                                        objBillAccount.BillDueUponReceipt = False

                                        '##############################################################
                                        'MODIFICATION   ROD COPELAND    JAN 21, 2009
                                        'PULL THE FOLLOWING FROM THE EAI WS RESPONSE AND DISPLAY 
                                        'ON THE UI EVENTUALLY INTHE QUICKPAY.ASCX
                                        'LastStatementDate  
                                        'TotalStatementAmount 
                                        'StatementDueDate 
                                        '##############################################################
                                        If Not (objICOMSaccount.TotalStatementAmount Is Nothing) Then
                                            objBillAccount.TotalStatementAmount_ICOMS_ONLY = CDec(objICOMSaccount.TotalStatementAmount)
                                        End If

                                        If Not (objICOMSaccount.LastStatementDate Is Nothing) Then
                                            If objICOMSaccount.LastStatementDate.Trim().Length() > 7 Then
                                                objBillAccount.LastStatementDate_ICOMS_ONLY = CDate(objICOMSaccount.LastStatementDate.Substring(4, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(6, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(0, 4))
                                            End If
                                        End If

                                        If Not (objICOMSaccount.StatementDueDate Is Nothing) Then
                                            If Len(objICOMSaccount.StatementDueDate.Trim()) = 8 Then
                                                objBillAccount.StatementDueDate_ICOMS_ONLY = CDate(objICOMSaccount.StatementDueDate.Trim().Substring(4, 2) & "/" & objICOMSaccount.StatementDueDate.Trim().Substring(6, 2) & "/" & objICOMSaccount.StatementDueDate.Trim().Substring(0, 4))
                                            Else
                                                If objICOMSaccount.StatementDueDate = "9999999" Then
                                                    objBillAccount.BillDueUponReceipt = True
                                                Else
                                                    '###################################################################################
                                                    'MODIFICATION   ROD COPELAND    APRIL 14, 2009  ISSUE ID 5837
                                                    '###################################################################################
                                                    'COMMENTED THE STATEMENT BELOW THAT WAS ADDED DURING THE CREATIVE LIFT 
                                                    ' 2009 BY SOMEONE TBD.  AT THIS POINT IN THE CODE, THERE SOULDNT BE A VALID 
                                                    'DATE AVAILABLE TO SUBSTRING AS THE LEN IS NOT 8 CHAR IN LENGTH.  CURRENT 
                                                    'STATE BUSINESS RULES INDICATE TO LEAVE THIS BLANK PER CUSTOMER CARE.
                                                    '###################################################################################
                                                    ''This is part of creative lift changes
                                                    ''objBillAccount.StatementDueDate_ICOMS_ONLY = CDate(objICOMSaccount.StatementDueDate.Substring(4, 2) & "/" & objICOMSaccount.StatementDueDate.Substring(6, 2) & "/" & objICOMSaccount.StatementDueDate.Substring(0, 4))
                                                End If
                                            End If
                                        End If

                                        blnHasValue = True

                                        objBillAccount.DisplayBillSummary = True

                                        objBillingSummary.Add(objBillAccount)

                                End Select
                            End If
                        End If



                    Next
                    If blnHasValue Then
                        account.Bill = objBillingSummary
                    End If
                Else
                    'Return Nothing
                End If
            Else
                'Return Nothing
            End If
        End If


        Return objBillingSummary


    End Function


    Public Overrides Function GetCPNIVerification(ByVal trackingid As String, ByVal accountID As String, ByVal pin As String) As Boolean
        Dim iProvider As IEBSServicesProvider
        Dim objResponseCSG As New GetCPNIVerificationResponseCSG
        Dim objResponseICOMS As New GetCPNIVerificationResponseICOMS
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            'Instantiate account if nothing
            If Me.account Is Nothing Then
                Me.account = New BLAccount
            End If

            'Check incoming data
            If accountID Is Nothing Then
                _LastCCOMDisplayFriendlyExceptionMessage = "Account number must be provided for validation."
                Return False
            ElseIf Not IsNumeric(accountID) Then
                _LastCCOMDisplayFriendlyExceptionMessage = "Account number must be numeric for validation."
                Return False
            End If
            accountID = accountID.Trim()

            'Validate account number length and determine billing system
            If accountID.Length > 19 Then
                _LastCCOMDisplayFriendlyExceptionMessage = "Account numbers may not contain more than 19 characters for validation."
                Return False
            Else
                If accountID.Length > 16 Then
                    Select Case accountID.Substring(0, 1)
                        Case "1", "2", "3", "4", "5"
                            Me.account.BillingVendorType = BillingVendorType.ICOM
                        Case Else
                            _LastCCOMDisplayFriendlyExceptionMessage = "Account numbers must begin with 1, 2, 3, 4, or 5 for validation."
                            Return False
                    End Select
                Else
                    If accountID.Length = 16 Then
                        Select Case accountID.Substring(0, 1)
                            Case "8"
                                Me.account.BillingVendorType = BillingVendorType.CSG
                            Case Else
                                _LastCCOMDisplayFriendlyExceptionMessage = "Your account number should be at least 16 digits in length.  Please check your account number located on the upper right corner of your statement and try again."
                                Return False
                        End Select
                    Else
                        _LastCCOMDisplayFriendlyExceptionMessage = "Your account number should be at least 16 digits in length.  Please check your account number located on the upper right corner of your statement and try again."
                        Return False
                    End If
                End If
            End If

            'Call CPNI WS for given billing system
            Select Case Me.account.BillingVendorType
                Case BillingVendorType.CSG
                    Dim objRequest As GetCPNIVerificationRequestCSG
                    Dim objCsgHeaderInfo As New CsgHeaderInfo_CPNIVerification

                    objRequest = New GetCPNIVerificationRequestCSG()
                    objRequest.AccountNumber = accountID
                    objCsgHeaderInfo.RoutingArea = accountID.Substring(0, 6) & "00"
                    objRequest.CsgHeaderInfo = objCsgHeaderInfo
                    objRequest.PIN = pin

                    iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)



                    '#####################
                    'DO THE PROVIDER CALL
                    '#####################
                    objResponseCSG = CType(iProvider.GetCPNIVerificationFromCSG(objRequest), GetCPNIVerificationResponseCSG)



                    If objResponseCSG.Exception Then
                        '##################################################################################
                        '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                        '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                        '##################################################################################
                        'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                        'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                        'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                        'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                        'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                        'ACCORDINGLY.
                        '##################################################################################
                        Select Case True
                            Case Not objResponseCSG.CharterDotCom_Friendly_Messages Is Nothing
                                Me._LastCCOMDisplayFriendlyExceptionMessage = objResponseCSG.CharterDotCom_Friendly_Messages
                            Case Else
                                Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to validate Security Code"
                        End Select
                        '##################################################################################

                        Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & objResponseCSG.ExceptionMessage), ExceptionSeverity.High)
                        Return False
                    Else
                        '#######################################################################
                        'MODIFICATION    ROD COPELAND    6/18/2008
                        '#######################################################################
                        'PER GREG KOCH, WE COULD POTENTIALLY GET A SUCCESS BACK FROM THE EAI WS 
                        'WHEN THE ACCOUNT PEN COME BACK NOT VERIFIED.  tO ADDRESS THIS WE NEED 
                        'TO ADD AN ADDITIONAL CONDITION ON TOP OF TESTING IF AN EXCEPTION HAS 
                        'HAPPEN OR NOT, WE NEED TO MAKE SURE THE STATUS IS ALSO VERIFIED = TRUE 
                        'TO CONSIDER A VALID ACCOUNT PIN COMBINATION.
                        '#######################################################################
                        If Not objResponseCSG.Verified Then
                            Return False
                        End If

                        '##########################################################################################
                        'MODIFICATION   ROD COPELAND    2-5-2008
                        '##########################################################################################
                        'THIS IS A CONDITION USED IN THE INITIAL LAUNCH OF USING ADDING THE PHONE AND ZIP TO THE 
                        'CREATE MEMBER SERVICE WS CALL.  THE BUSINESS WANTED THE CHANGES IN PLACE IN PROD BUT 
                        'JUST TURNED OFF UNTIL THINGS HAVE BEEN FULLY TESTED AND APPROVED ALTHOUGH WE HAVE PROVEN 
                        'THE CHANGES TO BE FUNCTIONAL IN A UAT AND DEV ENVIRONMENT.
                        '##########################################################################################
                        Dim blnResult As String = CType(System.Web.HttpContext.Current.Application("USE_REGISTRATION_WS"), String)
                        If Not (blnResult Is Nothing) Then
                            If blnResult.Trim() <> "" Then
                                If blnResult.Trim().Trim() = "T" Then
                                    '#######################################################################
                                    'CONTINUE ON AND PLAN TO USE THE NEW REGISTRATION WS FROM THIS POINT ON.
                                    '#######################################################################
                                Else
                                    '##############################################################################
                                    'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                                    'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                                    '##############################################################################
                                    Return True
                                End If
                            Else
                                '##############################################################################
                                'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                                'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                                '##############################################################################
                                Return True
                            End If
                        Else
                            '##############################################################################
                            'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                            'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                            '##############################################################################
                            Return True
                        End If







                        '####################################################################################################
                        'MODIFICATION   ROD COPELAND    2-5-2008
                        '####################################################################################################
                        'THIS FOLLOWING SECTION OF CODE IS MENT TO GET THE PHONE NUMBER AND ZIPCODE BY MAKING ANOTHER WS CALL
                        'TO EAI. THIS CHANGE WAS NEEDED BECAUSE THE CREATE MEMBER SERVICE WS METHOD PREVIOUSLY USED DIDNT 
                        'HANDLE VIDEO ONLY CUSTOMERS WHO NEEDED TO CREATE A MS ACCOUNT. TO ADDRESS THIS THE MS AREA WANTED US 
                        'TO USE THE NEW REGISTER MS WS METHOD WHICH WAS INTENDED TO BE USED FOR ALL USERS, VIDEO AND DATA BOTH.
                        'THE PROBLEM WAS THE NEW REGISTER WS METHOD REQUIRED THE USE OF ZIP AND PHONE WHICH WAS NOT BEING 
                        'COLLECTED ON THE PAGE. TO FURTHER COMPLICATE THINGS THE BUSINESS DIDNT WANT TO TAKE THE CHANCE OF THE
                        'USER ENTERING SOMETHING WRONG ON THE PHONE AND ZIP AND FAILING THE WHOLE PROCESS OUT SO THEY REQUESTED 
                        'THAT WE DO ANOTHER WS CALL TO EAI JUST TO GET THE PHONE AND ZIP AND SEND THOSE VALUES IN THE CREATE 
                        'MEMEBER SERVICE WS REQUEST TO MAKE THE NEW REGISTER WS METHOD WORK. THATS THE NICKEL TOUR.
                        '####################################################################################################
                        Dim objGetAccountsRequest As GetAccountsRequestCSG
                        Dim objGetAccountsResponse As GetAccountsResponseCSG
                        Dim lGetAccountsCriteria As New AccountCriteriaCSG

                        lGetAccountsCriteria.Item = objRequest.AccountNumber 'USE VALUE FROM THE PREVIOUS CALL
                        lGetAccountsCriteria.ItemElementName = ItemChoiceTypeCSG.AccountNumber

                        objGetAccountsRequest = New GetAccountsRequestCSG(Nothing, lGetAccountsCriteria)



                        '##################################
                        'MAKE THE PROVIDER CALL TO THE WS
                        '##################################
                        objGetAccountsResponse = CType(iProvider.GetAccountsFromCSG(objGetAccountsRequest), GetAccountsResponseCSG)



                        If Not (objGetAccountsResponse Is Nothing) Then
                            If objGetAccountsResponse.Exception Then
                                '##################################################################################
                                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                                '##################################################################################
                                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                                'ACCORDINGLY.
                                '##################################################################################
                                Select Case True
                                    Case Not objGetAccountsResponse.CharterDotCom_Friendly_Messages Is Nothing
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = objGetAccountsResponse.CharterDotCom_Friendly_Messages
                                    Case Else
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to validate Security Code"
                                End Select
                                '##################################################################################

                                Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & objGetAccountsResponse.ExceptionMessage), ExceptionSeverity.High)
                                Return False
                            Else

                                '#####################################################  
                                '#####################################################  
                                If Not (objGetAccountsResponse.Accounts Is Nothing) Then
                                    If objGetAccountsResponse.Accounts.Length() > 0 Then
                                        Dim lAccount As AccountCSG = objGetAccountsResponse.Accounts(0)

                                        If Me.account Is Nothing Then
                                            Me.account = New BLAccount()
                                        End If

                                        If Me.account.Address Is Nothing Then
                                            Me.account.Address = New BLAddress()
                                        End If

                                        If Not (lAccount.ZipCode Is Nothing) Then
                                            Me.account.Address.Zip = lAccount.ZipCode.Substring(0, 5)
                                        End If
                                        Me.account.HomePhone = lAccount.PrimaryPhone

                                    Else
                                        '###########################################################
                                        'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                        'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                        'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                        'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                        '###########################################################
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                        Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)
                                        Return False

                                    End If
                                Else
                                    '###########################################################
                                    'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                    'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                    'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                    'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                    '###########################################################
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                    Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)
                                    Return False
                                End If
                            End If
                        Else
                            '#################################################################
                            'SOMETHING IS WRONG WITH ZIP AND PHONE GET SO THROW AN EXCEPTION.
                            'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                            'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                            'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                            'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                            '#################################################################
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                            Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)

                            '##############
                            'Persist state
                            '##############
                            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                            Return False
                        End If

                        '####################################################################################################
                        '####################################################################################################







                        Return True
                    End If

                Case BillingVendorType.ICOM
                    Dim objRequest As GetCPNIVerificationRequestICOMS
                    Dim objIcomsHeaderInfo As New IcomsHeaderInfo_CPNIVerification

                    objRequest = New GetCPNIVerificationRequestICOMS()
                    objRequest.AccountNumber = accountID.Substring(3, 9)
                    objIcomsHeaderInfo.SiteId = accountID.Substring(0, 3)
                    objRequest.IcomsHeaderInfo = objIcomsHeaderInfo
                    objRequest.PIN = pin

                    iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)




                    '##################################
                    'MAKE THE PROVIDER CALL TO THE WS
                    '##################################
                    objResponseICOMS = CType(iProvider.GetCPNIVerificationFromICOMS(objRequest), GetCPNIVerificationResponseICOMS)



                    If objResponseICOMS.Exception Then
                        '##################################################################################
                        '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                        '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                        '##################################################################################
                        'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                        'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                        'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                        'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                        'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                        'ACCORDINGLY.
                        '##################################################################################
                        Select Case True
                            Case Not objResponseICOMS.CharterDotCom_Friendly_Messages Is Nothing
                                Me._LastCCOMDisplayFriendlyExceptionMessage = objResponseICOMS.CharterDotCom_Friendly_Messages
                            Case Else
                                Me._LastCCOMDisplayFriendlyExceptionMessage = "The account number entered was unable to be validated.  Please reference the account number and security code on your bill and try again."
                        End Select
                        '##################################################################################

                        Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for ICOMS as:" & objResponseICOMS.ExceptionMessage), ExceptionSeverity.High)
                        Return False
                    Else
                        '#######################################################################
                        'MODIFICATION    ROD COPELAND    6/18/2008
                        '#######################################################################
                        'PER GREG KOCH, WE COULD POTENTIALLY GET A SUCCESS BACK FROM THE EAI WS 
                        'WHEN THE ACCOUNT PEN COME BACK NOT VERIFIED.  tO ADDRESS THIS WE NEED 
                        'TO ADD AN ADDITIONAL CONDITION ON TOP OF TESTING IF AN EXCEPTION HAS 
                        'HAPPEN OR NOT, WE NEED TO MAKE SURE THE STATUS IS ALSO VERIFIED = TRUE 
                        'TO CONSIDER A VALID ACCOUNT PIN COMBINATION.
                        '#######################################################################
                        If Not objResponseICOMS.Verified Then
                            Return False
                        End If



                        '##########################################################################################
                        'MODIFICATION   ROD COPELAND    2-5-2008
                        '##########################################################################################
                        'THIS IS A CONDITION USED IN THE INITIAL LAUNCH OF USING ADDING THE PHONE AND ZIP TO THE 
                        'CREATE MEMBER SERVICE WS CALL.  THE BUSINESS WANTED THE CHANGES IN PLACE IN PROD BUT 
                        'JUST TURNED OFF UNTIL THINGS HAVE BEEN FULLY TESTED AND APPROVED ALTHOUGH WE HAVE PROVEN 
                        'THE CHANGES TO BE FUNCTIONAL IN A UAT AND DEV ENVIRONMENT.
                        '##########################################################################################
                        Dim blnResult As String = CType(System.Web.HttpContext.Current.Application("USE_REGISTRATION_WS"), String)
                        If Not (blnResult Is Nothing) Then
                            If blnResult.Trim() <> "" Then
                                If blnResult.Trim().Trim() = "T" Then
                                    '#######################################################################
                                    'CONTINUE ON AND PLAN TO USE THE NEW REGISTRATION WS FROM THIS POINT ON.
                                    '#######################################################################
                                Else
                                    '##############################################################################
                                    'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                                    'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                                    '##############################################################################
                                    Return True
                                End If
                            Else
                                '##############################################################################
                                'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                                'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                                '##############################################################################
                                Return True
                            End If
                        Else
                            '##############################################################################
                            'SKIP USING THE NEW REGISTRATION WS, JUST USE THE OLD CREATE MEMEBER SERVICE 
                            'WS AND DONT MAKE THE ADDITIONAL EAI WS CALL FOR PHONE AND ZIP.
                            '##############################################################################
                            Return True
                        End If







                        '####################################################################################################
                        'MODIFICATION   ROD COPELAND    2-5-2008
                        '####################################################################################################
                        'THIS FOLLOWING SECTION OF CODE IS MENT TO GET THE PHONE NUMBER AND ZIPCODE BY MAKING ANOTHER WS CALL
                        'TO EAI. THIS CHANGE WAS NEEDED BECAUSE THE CREATE MEMBER SERVICE WS METHOD PREVIOUSLY USED DIDNT 
                        'HANDLE VIDEO ONLY CUSTOMERS WHO NEEDED TO CREATE A MS ACCOUNT. TO ADDRESS THIS THE MS AREA WANTED US 
                        'TO USE THE NEW REGISTER MS WS METHOD WHICH WAS INTENDED TO BE USED FOR ALL USERS, VIDEO AND DATA BOTH.
                        'THE PROBLEM WAS THE NEW REGISTER WS METHOD REQUIRED THE USE OF ZIP AND PHONE WHICH WAS NOT BEING 
                        'COLLECTED ON THE PAGE. TO FURTHER COMPLICATE THINGS THE BUSINESS DIDNT WANT TO TAKE THE CHANCE OF THE
                        'USER ENTERING SOMETHING WRONG ON THE PHONE AND ZIP AND FAILING THE WHOLE PROCESS OUT SO THEY REQUESTED 
                        'THAT WE DO ANOTHER WS CALL TO EAI JUST TO GET THE PHONE AND ZIP AND SEND THOSE VALUES IN THE CREATE 
                        'MEMEBER SERVICE WS REQUEST TO MAKE THE NEW REGISTER WS METHOD WORK. THATS THE NICKEL TOUR.
                        '####################################################################################################
                        Dim objGetAccountDetailsRequest As New GetAccountDetailsRequest
                        Dim objGetAccountDetailsResponse As New GetAccountDetailsResponse
                        Dim objHeader As New IcomsHeaderInfo

                        '###################################################
                        'BUILD THE REQUEST OBJECT FOR APP SERVER REQUEST.
                        '###################################################
                        Select Case objIcomsHeaderInfo.SiteId
                            Case "100"
                                objHeader.SiteId = SiteId.Site100
                            Case "200"
                                objHeader.SiteId = SiteId.Site200
                            Case "300"
                                objHeader.SiteId = SiteId.Site300
                            Case "400"
                                objHeader.SiteId = SiteId.Site400
                            Case "500"
                                objHeader.SiteId = SiteId.Site500
                            Case "600"
                                objHeader.SiteId = SiteId.Site600
                        End Select
                        objGetAccountDetailsRequest.IcomsHeaderInfo = objHeader


                        objGetAccountDetailsRequest.Criteria = New AccountCriteriaICOMS()
                        objGetAccountDetailsRequest.Criteria.Item = objRequest.AccountNumber
                        objGetAccountDetailsRequest.Criteria.ItemElementName = ItemChoiceTypeICOMS.AccountId



                        '############################################
                        'MAKE A CALL TO APP SERVER TO THE PROVIDER
                        '############################################
                        objGetAccountDetailsResponse = CType(iProvider.GetAccountDetailsFromICOMS(objGetAccountDetailsRequest), GetAccountDetailsResponse)



                        If Not (objGetAccountDetailsResponse Is Nothing) Then
                            If objGetAccountDetailsResponse.Exception Then
                                '##################################################################################
                                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                                '##################################################################################
                                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                                'ACCORDINGLY.
                                '##################################################################################
                                Select Case True
                                    Case Not objGetAccountDetailsResponse.CharterDotCom_Friendly_Messages Is Nothing
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = objGetAccountDetailsResponse.CharterDotCom_Friendly_Messages
                                    Case Else
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to validate Security Code"
                                End Select
                                '##################################################################################

                                Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & objGetAccountDetailsResponse.ExceptionMessage), ExceptionSeverity.High)
                                Return False
                            Else

                                If Not (objGetAccountDetailsResponse.AccountInfo Is Nothing) Then
                                    If Not (objGetAccountDetailsResponse.AccountInfo.Account Is Nothing) Then
                                        If Not (objGetAccountDetailsResponse.AccountInfo.Account.ZipCode Is Nothing) Then
                                            If Not (objGetAccountDetailsResponse.AccountInfo.Account.PrimaryPhone Is Nothing) Then
                                                If Me.account Is Nothing Then
                                                    Me.account = New BLAccount()
                                                End If
                                                If Me.account.Address Is Nothing Then
                                                    Me.account.Address = New BLAddress()
                                                End If

                                                If Not (objGetAccountDetailsResponse.AccountInfo.Account.ZipCode Is Nothing) Then
                                                    Me.account.Address.Zip = objGetAccountDetailsResponse.AccountInfo.Account.ZipCode.Substring(0, 5)
                                                End If
                                                Me.account.HomePhone = objGetAccountDetailsResponse.AccountInfo.Account.PrimaryPhone
                                            Else
                                                '###########################################################
                                                'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                                'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                                'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                                'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                                '###########################################################
                                                Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                                Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)
                                                Return False
                                            End If
                                        Else
                                            '###########################################################
                                            'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                            'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                            'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                            'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                            '###########################################################
                                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                            Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)

                                            '##############
                                            'Persist state
                                            '##############
                                            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                            Return False
                                        End If
                                    Else
                                        '######################################################
                                        'THERE IS A PROBLEM, THIS VALUE SHOULDNT BE NOTHING.
                                        'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                        'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                        'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                        'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                        '######################################################
                                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                        Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)

                                        '##############
                                        'Persist state
                                        '##############
                                        SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                        Return False
                                    End If

                                Else
                                    '######################################################
                                    'THERE IS A PROBLEM, THIS VALUE SHOULDNT BE NOTHING.
                                    'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                                    'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                                    'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                                    'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                                    '######################################################
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                                    Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)

                                    '##############
                                    'Persist state
                                    '##############
                                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                                    Return False
                                End If

                            End If
                        Else
                            '#################################################################
                            'SOMETHING IS WRONG WITH ZIP AND PHONE GET SO THROW AN EXCEPTION.
                            'CANT FIND THE ZIP AND PHONE WHICH ARE REQUIRED FOR THE MS 
                            'CALL TO THE REGISTER WS METHOD (NEXT STEP IN CREATE MEMBER 
                            'SERVICE FLOW), WITHOUT THESE, NO PONT IN MAKING THE MS WS 
                            'CALL WHEN IT WILL FAIL ON REQUIRED FIELDS PHONE AND ZIP.
                            '#################################################################
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Unable to create account, Phone Number and Zip Code associated to account were not found"
                            Common.LogException(New Exception("Account Manager - GetCPNIVerification failed for CSG as:" & "Unable to create account, Phone Number and Zip Code associated to account were not found"), ExceptionSeverity.High)

                            '##############
                            'Persist state
                            '##############
                            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                            Return False
                        End If



                        '##############
                        'Persist state
                        '##############
                        SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())


                        '####################################################################################################
                        '####################################################################################################

                        Return True

                    End If
            End Select

        Catch ex As Exception
            If Me.account IsNot Nothing Then
                Select Case Me.account.BillingVendorType
                    Case BillingVendorType.CSG
                        '##################################################################################
                        '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                        '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                        '##################################################################################
                        'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                        'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                        'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                        'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                        'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                        'ACCORDINGLY.
                        '##################################################################################
                        If Not objResponseCSG Is Nothing Then
                            Select Case True
                                Case Not objResponseCSG.CharterDotCom_Friendly_Messages Is Nothing
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = objResponseCSG.CharterDotCom_Friendly_Messages
                                Case Else
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination for CSG at this time."
                            End Select
                        Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination for CSG at this time."
                        End If
                        '##################################################################################

                    Case BillingVendorType.ICOM
                        '##################################################################################
                        '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                        '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                        '##################################################################################
                        'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                        'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                        'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                        'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                        'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                        'ACCORDINGLY.
                        '##################################################################################
                        If Not objResponseICOMS Is Nothing Then
                            Select Case True
                                Case Not objResponseICOMS.CharterDotCom_Friendly_Messages Is Nothing
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = objResponseICOMS.CharterDotCom_Friendly_Messages
                                Case Else
                                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination for ICOMS at this time."
                            End Select
                        Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination for ICOMS at this time."
                        End If
                        '##################################################################################
                End Select
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination at this time."
            End If
        Finally
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
            iProvider = Nothing
        End Try
    End Function

    Public Overrides Function AuthenticateLoginSecretQA(ByVal trackingid As String, ByVal loginID As String, ByVal secretQuestion As String, ByVal secretAnswer As String, ByVal zipCode As String, Optional ByVal validateZipCode As Boolean = False) As Boolean
        Dim objRequest As New EntityMemberServices.AuthenticateLoginSecretQARequest
        Dim objResponse As New EntityMemberServices.AuthenticateLoginSecretQAResponse

        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            'Instantiate account if nothing
            If Me.account Is Nothing Then
                Me.account = New BLAccount
            End If


            'Configure Request object
            objRequest.csrLogin = CSRLOGIN
            objRequest.csrPassword = CSRPASSWORD
            objRequest.LoginID = loginID
            objRequest.SecurityAnswer = secretAnswer
            objRequest.SecurityQuestion = secretQuestion

            'Call Authenticate WS
            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.AuthenticateLoginSecretQA(objRequest), EntityMemberServices.AuthenticateLoginSecretQAResponse)

            If Not objResponse.Exception Then
                '#######################################################################
                'WE HAVE A SUCESS, CLEAR FAIL COUNTS, RESET AND ALLOW THEM TO CONTINUE.
                '#######################################################################
                System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_TotalAttemptCount") = Nothing





                '###########################################################################
                'MODIFICATION   ROD COPELAND    ISSUE ID 4376   OCT 22
                '###########################################################################
                'PER CUST CARE, SECURITY WOULD LIKE ANOTHER LAYER OF VALIDATION FROM THE 
                'CUSTOMER BEFORE THEY ARE LOGGING IN.  APPARENTLY, THERE ARE PEOPLE WHO 
                'ARE GUESSING LOGIN IDs AND PW.  THE ASSUMPTION IS THAT THEY COULD NOT 
                'GUESS WHAT THE ZIP CODE IS EITHER.
                '###########################################################################
                If validateZipCode Then
                    If Not (objResponse.zipCode Is Nothing) Then
                        If Not (zipCode Is Nothing) Then
                            If zipCode.Contains(objResponse.zipCode.Trim()) Then
                                '##########################################
                                'THIS IS GOOD, CONTINUE WITH PROCESSING.
                                '##########################################
                            Else
                                Me._LastCCOMDisplayFriendlyExceptionMessage = "3 - The Service Address Zip Code provided does not match our records."

                                '##############
                                'Persist state
                                '##############
                                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                                Return False
                            End If
                        Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "4 - The Service Address Zip Code provided does not match our records."

                            '##############
                            'Persist state
                            '##############
                            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                            Return False
                        End If
                    Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to validate your Service Address Zip Code at this time."

                        '##############
                        'Persist state
                        '##############
                        SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                        Return False
                    End If
                End If

                '###########################################################################


                Me.account.LoginID = loginID
                Return True
            Else
                If (System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_TotalAttemptCount") Is Nothing) Then
                    System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("MYACCOUNT_SECRETQA_FAILED_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
                    System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_TotalAttemptCount") = "1"
                Else
                    '#######################################
                    'UPDATE FAIL COUNT AND LET THEM CONTINUE
                    '#######################################
                    System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_TotalAttemptCount") = (CType(System.Web.HttpContext.Current.Session("MYACCOUNT_SECRETQA_FAILED_TotalAttemptCount"), Integer) + 1).ToString()
                End If

                '##################################################################################
                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                '##################################################################################
                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                'ACCORDINGLY.
                '##################################################################################
                Select Case True
                    Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination at this time."
                End Select
                '##################################################################################

                Common.LogException(New Exception("Account Manager - AuthenticateLoginSecretQA failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
                Return False
            End If

        Catch ex As Exception
            '##################################################################################
            '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
            '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
            '##################################################################################
            'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
            'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
            'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
            'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
            'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
            'ACCORDINGLY.
            '##################################################################################
            If Not objResponse Is Nothing Then
                Select Case True
                    Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination at this time."
                End Select
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Could not authenticate username/Security question/Security answer combination at this time."
            End If
            '##################################################################################
        Finally
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
            'iProvider = Nothing
        End Try
    End Function

    Private Function GetEBSBillingSummaryInfo(ByVal BillVendor As BillingVendorType, ByVal AccountNumber As String, ByVal strSiteID As String) As List(Of IAccount.IBill)
        Dim lCustAccountProvider As IEBSServicesProvider
        Try
            Dim objBillingSummary As New List(Of IAccount.IBill)

            Select Case BillVendor
                Case BillingVendorType.CSG
                    Dim objRequest As GetAccountsRequestCSG
                    Dim objResponse As GetAccountsResponseCSG
                    Dim lCriteria As New AccountCriteriaCSG

                    lCriteria.Item = AccountNumber
                    lCriteria.ItemElementName = ItemChoiceTypeCSG.AccountNumber
                    objRequest = New GetAccountsRequestCSG(Nothing, lCriteria)



                    '########################################################################
                    'MAKE CALL TO THE PROVIDER WHICH IN TURN WILL CALL THE EBS WEB SERVICE
                    '########################################################################
                    lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
                    objResponse = CType(lCustAccountProvider.GetAccountsFromCSG(objRequest), GetAccountsResponseCSG)



                    Dim objBillAccount As New BLAccount.BillSummary(AccountNumber)

                    If Not objResponse.Accounts Is Nothing Then
                        objBillAccount.BillAmount = objResponse.Accounts(0).CurrentAccountBalance
                        objBillAccount.BillDuedDate = CType(objResponse.Accounts(0).BillingInfo.ThruDate, Date)

                        If Not objResponse.Accounts(0).LinesOfBusiness Is Nothing Then
                            For Each objLOB As LineOfBusiness In objResponse.Accounts(0).LinesOfBusiness
                                Select Case objLOB.Type
                                    Case LineOfBusinessTypeCSG.Data
                                        objBillAccount.BillDescription = objBillAccount.Description & "and High - Speed Internet  "
                                    Case LineOfBusinessTypeCSG.Telephony
                                        objBillAccount.BillDescription = objBillAccount.Description & "and Telephone  "
                                    Case LineOfBusinessTypeCSG.Video
                                        objBillAccount.BillDescription = objBillAccount.Description & "and Digital Cable  "
                                End Select
                            Next
                            If objBillAccount.Description <> String.Empty Then
                                objBillAccount.BillDescription = Right(objBillAccount.Description, Len(objBillAccount.Description) - 4)
                            End If
                        End If
                    Else
                        Return Nothing
                    End If

                    objBillingSummary.Add(objBillAccount)


                    Return objBillingSummary

                Case BillingVendorType.ICOM
                    Dim objRequest As GetAccountStatementsAllRequestICOMS
                    Dim objResponse As GetAccountStatementsAllResponseICOMS
                    Dim objHeader As New IcomsHeaderInfo

                    Select Case strSiteID
                        Case "100"
                            objHeader.SiteId = SiteId.Site100
                        Case "200"
                            objHeader.SiteId = SiteId.Site200
                        Case "300"
                            objHeader.SiteId = SiteId.Site300
                        Case "400"
                            objHeader.SiteId = SiteId.Site400
                        Case "500"
                            objHeader.SiteId = SiteId.Site500
                        Case "600"
                            objHeader.SiteId = SiteId.Site600
                    End Select

                    Dim lstrAccountNumber As String = AccountNumber.Substring(3, 9)
                    objRequest = New GetAccountStatementsAllRequestICOMS(objHeader, lstrAccountNumber)


                    '########################################################################
                    'MAKE CALL TO THE PROVIDER WHICH IN TURN WILL CALL THE EBS WEB SERVICE
                    '########################################################################
                    lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
                    objResponse = CType(lCustAccountProvider.GetAccountStatementsAllICOMS(objRequest), GetAccountStatementsAllResponseICOMS)



                    If Not (objResponse.AccountStatementAllInfo Is Nothing) Then
                        If Not (objResponse.AccountStatementAllInfo.Statement Is Nothing) Then
                            For Each objICOMSaccount As StatementAll In objResponse.AccountStatementAllInfo.Statement
                                '##################################################################################
                                'BUILD LOCAL BILL STATEMENT AND ASSIGN TO THE STATEMENT COLLECTION BEING RETURNED
                                '##################################################################################
                                Dim objBillAccount As New BLAccount.BillSummary(AccountNumber)
                                objBillAccount.AccountNumber = AccountNumber & objICOMSaccount.StatementCode
                                objBillAccount.BillAmount = CDec(objICOMSaccount.BalanceLastStatement)
                                objBillAccount.BillDescription = objICOMSaccount.StatementDescription
                                If Len(objICOMSaccount.LastStatementDate) = 8 Then
                                    objBillAccount.BillDuedDate = CDate(objICOMSaccount.LastStatementDate.Substring(4, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(6, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(0, 4))
                                End If

                                objBillingSummary.Add(objBillAccount)
                            Next
                        Else
                            Return Nothing
                        End If
                    Else
                        Return Nothing
                    End If



                    Return objBillingSummary


            End Select

        Catch ex As Exception
            Throw ex
        Finally
            lCustAccountProvider = Nothing
        End Try
    End Function

    Private Sub RemoveNonDisplayablePackagesFromAccountObj()
        '#########################################################
        'AS A BUSINESS RULE, 12-12-2006 JOHN SPYERS SAID THAT WE 
        'NEED TO REMOVE THE MOXI BOX FROM THE LIST OF PACKAGES 
        'THAT ARE RETURNED FROM THE MEMBER SERVICES AREA.
        '#########################################################
        If Not (account Is Nothing) Then
            If Not (account.User Is Nothing) Then
                If Not (account.User.MSPackageInfo Is Nothing) Then
                    '#########################################################
                    'GET A LOCAL COPY TO WORK FROM.  THIS WILL BE USED TO 
                    '#########################################################
                    Dim outMSPackageList As New List(Of BLAccount.BLMember.BLMSPackageInfo)

                    '###########################################
                    'ADD PACKAGES TO THE TEMP OUT PACKAGE LIST
                    '###########################################
                    For Each inPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
                        outMSPackageList.Add(inPackage)
                    Next

                    For Each inPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
                        If Not (inPackage Is Nothing) Then
                            Dim outPackage As New BLAccount.BLMember.BLMSPackageInfo

                            '##########################################################################
                            'SEARCH IN THE DESCRIPTION FOR THE NAME THAT INDEXES THE PACKAGE TO REMOVE.
                            '##########################################################################
                            If Not (inPackage.descriptionField Is Nothing) Then
                                Select Case True
                                    Case inPackage.descriptionField.ToLower().Contains("moxi"), inPackage.descriptionField.ToLower().Contains("voice")
                                        outMSPackageList.Remove(inPackage)

                                        '######################################################################
                                        'ROD COPELAND   MODIFICATION    JULY 10 2008 ISSUE ID 4230
                                        'RESET THE INDEX FOR THE PROVISIONING ID IN EACH PACKAGES WHEN REMOVED.
                                        '######################################################################
                                        Dim intCnt As Integer = 0
                                        For Each tempPackage As BLAccount.BLMember.BLMSPackageInfo In outMSPackageList
                                            intCnt = intCnt + 1
                                            tempPackage.provisioningIdField = intCnt.ToString()
                                        Next
                                        '######################################################################

                                End Select
                            End If
                        End If
                    Next

                    ''###########################################################################
                    ''ASSIGN THE TEMP PACKAGE COLLECTION TO THE ACCOUNT OBJECT, REPLACING 
                    ''THE EXISTING ONE WITH THE UPDATED ONE. THE NEWLY ASSIGNED PACKAGE 
                    ''WILL HAVE ONLY PACKAGES THAT ARE DEEMED DISPLAYABLE BY THE BUSINESS FOLKS (JOHN SPYERS).
                    ''###########################################################################
                    account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
                    For Each inPackage As IAccount.IMember.IMemberServicePackageInfo In outMSPackageList
                        account.User.MSPackageInfo.Add(inPackage)
                    Next

                End If
            End If
        End If


    End Sub

	Private Sub AssignBillingSystemLinkToAcctObj(ByVal objMSBillingSystemLinkResponse As ConfigProvider.GetMSBillingSystemLinkResponse)
		'#########################################################
		'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
		'#########################################################
		If Not (account Is Nothing) Then
			If Not (objMSBillingSystemLinkResponse Is Nothing) Then
				If (objMSBillingSystemLinkResponse.Exception = False) Then
					'If (objMSBillingSystemLinkResponse.status.Trim().ToUpper() = "SUCCESS") Then
					'If Not (objMSBillingSystemLinkResponse.WSErrorText Is Nothing) Then
					If Not (objMSBillingSystemLinkResponse.billingSys Is Nothing) Then
						If Not (objMSBillingSystemLinkResponse.URL Is Nothing) Then
							If Not (objMSBillingSystemLinkResponse.d Is Nothing) Then
								If Not (objMSBillingSystemLinkResponse.s Is Nothing) Then
									If Not (objMSBillingSystemLinkResponse.k Is Nothing) Then
										'#########################################################
										'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
										'#########################################################
										Select Case objMSBillingSystemLinkResponse.billingSys.Trim().ToLower()
											Case "csg"
												account.BillingSystemURL = "<a href=" & objMSBillingSystemLinkResponse.URL & "?d=" & objMSBillingSystemLinkResponse.d & """ target=""_blank"">Charter ePay</a>"
											Case "icoms"
												account.BillingSystemURL = "<a href=" & objMSBillingSystemLinkResponse.URL & "?d=" & objMSBillingSystemLinkResponse.d & "&k=" & objMSBillingSystemLinkResponse.k & "&s=" & objMSBillingSystemLinkResponse.s & """ target=""_blank"">Charter ePay</a>"
										End Select
									Else
										account.BillingSystemURL = Nothing
									End If
								Else
									account.BillingSystemURL = Nothing
								End If
							Else
								account.BillingSystemURL = Nothing
							End If
						Else
							account.BillingSystemURL = Nothing
						End If
					Else
						account.BillingSystemURL = Nothing
					End If
					'Else
					'    account.BillingSystemURL = Nothing
					'End If
					'Else
					'    account.BillingSystemURL = Nothing
					'End If
				Else
					account.BillingSystemURL = Nothing
				End If
			Else
				account.BillingSystemURL = Nothing
			End If
		End If


	End Sub

    Private Function GetBillingVendorLinkURL(ByVal objMSBillingSystemLinkResponse As GetMSBillingSystemLinkResponse) As String
        '#########################################################
        'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
        '#########################################################
        If Not (account Is Nothing) Then
            If Not (objMSBillingSystemLinkResponse Is Nothing) Then
                If (objMSBillingSystemLinkResponse.Exception = False) Then
                    'If (objMSBillingSystemLinkResponse.status.Trim().ToUpper() = "SUCCESS") Then
                    'If Not (objMSBillingSystemLinkResponse.WSErrorText Is Nothing) Then
                    If Not (objMSBillingSystemLinkResponse.billingSys Is Nothing) Then
                        If Not (objMSBillingSystemLinkResponse.URL Is Nothing) Then
                            If Not (objMSBillingSystemLinkResponse.d Is Nothing) Then
                                If Not (objMSBillingSystemLinkResponse.s Is Nothing) Then
                                    If Not (objMSBillingSystemLinkResponse.k Is Nothing) Then
                                        '#########################################################
                                        'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
                                        'AT TIMES THE MEMBER SERVICE AREA WILL SEND BACK A STRING 
                                        'WITH VBNEWLINE VALUES IN THE STRING.  WHAT HAPPENS IS THIS 
                                        'VALUE ENDS UP BACK ON THE PAGE WHICH IS TRYING TO DO A 
                                        'RESPONSE.REDIRECT USING THE URL RETURNED FROM HERE. IF THE
                                        'VBNEWLINE VALUES ARE IN THE STRING THE REDIRECT WILL HAVE AN 
                                        'EXCEPTION.  FOR WHAT EVER REASON, REPLACING THE VBNEWLINE 
                                        'DOESNT WORK, MAKES ME WONDER WHAT TYPE OF CHARACTER IT IS.  
                                        'NO TIME TO CHECK NOW, JUST A GOOD TODO:
                                        '#########################################################
                                        Select Case objMSBillingSystemLinkResponse.billingSys.Trim().ToLower()
                                            Case "csg"
                                                System.Web.HttpContext.Current.Session("URL") = objMSBillingSystemLinkResponse.URL.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("d") = objMSBillingSystemLinkResponse.d.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("k") = objMSBillingSystemLinkResponse.k.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("s") = objMSBillingSystemLinkResponse.s.Replace(Chr(10), "")
                                                Return objMSBillingSystemLinkResponse.URL.Replace(Chr(10), "") & "?d=" & objMSBillingSystemLinkResponse.d.Replace(Chr(10), "") & "&k=" & objMSBillingSystemLinkResponse.k.Replace(Chr(10), "") & "&s=" & objMSBillingSystemLinkResponse.s.Replace(Chr(10), "")
                                            Case "icoms"
                                                System.Web.HttpContext.Current.Session("URL") = objMSBillingSystemLinkResponse.URL.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("d") = objMSBillingSystemLinkResponse.d.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("k") = objMSBillingSystemLinkResponse.k.Replace(Chr(10), "")
                                                System.Web.HttpContext.Current.Session("s") = objMSBillingSystemLinkResponse.s.Replace(Chr(10), "")
                                                Return objMSBillingSystemLinkResponse.URL.Replace(Chr(10), "") & "?d=" & objMSBillingSystemLinkResponse.d.Replace(Chr(10), "")
                                        End Select
                                    Else
                                        account.BillingSystemURL = Nothing
                                    End If
                                Else
                                    account.BillingSystemURL = Nothing
                                End If
                            Else
                                account.BillingSystemURL = Nothing
                            End If
                        Else
                            account.BillingSystemURL = Nothing
                        End If
                    Else
                        account.BillingSystemURL = Nothing
                    End If
                    'Else
                    '    account.BillingSystemURL = Nothing
                    'End If
                    'Else
                    '    account.BillingSystemURL = Nothing
                    'End If
                Else
                    account.BillingSystemURL = Nothing
                End If
            Else
                account.BillingSystemURL = Nothing
            End If
        End If


    End Function

    Private Sub AssignBillingSystemLinkToAcctObj(ByVal objMSBillingSystemLinkResponse As GetMSBillingSystemLinkResponse)
        '#########################################################
        'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
        '#########################################################
        If Not (account Is Nothing) Then
            If Not (objMSBillingSystemLinkResponse Is Nothing) Then
                If (objMSBillingSystemLinkResponse.Exception = False) Then
                    'If (objMSBillingSystemLinkResponse.status.Trim().ToUpper() = "SUCCESS") Then
                    'If Not (objMSBillingSystemLinkResponse.WSErrorText Is Nothing) Then
                    If Not (objMSBillingSystemLinkResponse.billingSys Is Nothing) Then
                        If Not (objMSBillingSystemLinkResponse.URL Is Nothing) Then
                            If Not (objMSBillingSystemLinkResponse.d Is Nothing) Then
                                If Not (objMSBillingSystemLinkResponse.s Is Nothing) Then
                                    If Not (objMSBillingSystemLinkResponse.k Is Nothing) Then
                                        '#########################################################
                                        'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
                                        '#########################################################
                                        Select Case objMSBillingSystemLinkResponse.billingSys.Trim().ToLower()
                                            Case "csg"
                                                account.BillingSystemURL = "<a href=" & objMSBillingSystemLinkResponse.URL & "?d=" & objMSBillingSystemLinkResponse.d & """ target=""_blank"">Charter ePay</a>"
                                            Case "icoms"
                                                account.BillingSystemURL = "<a href=" & objMSBillingSystemLinkResponse.URL & "?d=" & objMSBillingSystemLinkResponse.d & "&k=" & objMSBillingSystemLinkResponse.k & "&s=" & objMSBillingSystemLinkResponse.s & """ target=""_blank"">Charter ePay</a>"
                                        End Select
                                    Else
                                        account.BillingSystemURL = Nothing
                                    End If
                                Else
                                    account.BillingSystemURL = Nothing
                                End If
                            Else
                                account.BillingSystemURL = Nothing
                            End If
                        Else
                            account.BillingSystemURL = Nothing
                        End If
                    Else
                        account.BillingSystemURL = Nothing
                    End If
                    'Else
                    '    account.BillingSystemURL = Nothing
                    'End If
                    'Else
                    '    account.BillingSystemURL = Nothing
                    'End If
                Else
                    account.BillingSystemURL = Nothing
                End If
            Else
                account.BillingSystemURL = Nothing
            End If
        End If


    End Sub

    ' this method is to call providers and populate account info
    Private Sub MyAccount(ByVal oldacctnumber As List(Of String))
        'TO DO: call Member services provider to get account details but currently populates only Account with sample values.
        Dim blnServiceability As Boolean = True
        Dim lCustAccountProvider As IEBSServicesProvider
        Try
            If Not account.Bill Is Nothing Then
                Select Case account.BillingVendorType

                    Case BillingVendorType.CSG

                        Dim objRequest As GetAccountsRequestCSG
                        Dim objResponse As GetAccountsResponseCSG
                        Dim lCriteria As New AccountCriteriaCSG

                        'Dim lCustAccountProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
                        'lCustAccountProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

                        'Common.RegisterChannels()
                        lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)




                        For Each obj As BLAccount.BillSummary In account.Bill
                            lCriteria.Item = obj.AccountNumber
                            lCriteria.ItemElementName = ItemChoiceTypeCSG.AccountNumber
                            objRequest = New GetAccountsRequestCSG(Nothing, lCriteria)
                            objResponse = CType(lCustAccountProvider.GetAccountsFromCSG(objRequest), GetAccountsResponseCSG)

                            If Not objResponse.Accounts Is Nothing Then

                                Dim objCSGaccount As AccountCSG = objResponse.Accounts(0)
                                If account.User Is Nothing Then account.User = New BLAccount.BLMember
                                account.User.FirstName = objCSGaccount.FirstName
                                account.User.LastName = objCSGaccount.LastName
                                account.User.Salutation = objCSGaccount.Salutation
                                account.HomePhone = objCSGaccount.PrimaryPhone

                                If account.Address.Zip Is Nothing Then
                                    blnServiceability = True
                                    account.Address = New BLAddress
                                    account.Address.Street1 = objResponse.Accounts(0).AddressLine1
                                    account.Address.Street2 = objResponse.Accounts(0).AddressLine2
                                    If objResponse.Accounts(0).ZipCode.Length > 5 Then
                                        account.Address.Zip = objResponse.Accounts(0).ZipCode.Substring(0, 5)
                                        CType(account.Address, BLAddress).Zip4 = objResponse.Accounts(0).ZipCode.Substring(5, 4)
                                    Else
                                        account.Address.Zip = objResponse.Accounts(0).ZipCode
                                    End If

                                    account.Address.City = objResponse.Accounts(0).City
                                    account.Address.State = objResponse.Accounts(0).State

                                Else
                                    If Not (account.Address.Street1 = objResponse.Accounts(0).AddressLine1 And account.Address.Street2 = objResponse.Accounts(0).AddressLine2 And account.Address.Zip = objResponse.Accounts(0).ZipCode) Then
                                        blnServiceability = True
                                        account.Address = New BLAddress
                                        account.Address.Street1 = objResponse.Accounts(0).AddressLine1
                                        account.Address.Street2 = objResponse.Accounts(0).AddressLine2
                                        If objResponse.Accounts(0).ZipCode.Length > 5 Then
                                            account.Address.Zip = objResponse.Accounts(0).ZipCode.Substring(0, 5)
                                            CType(account.Address, BLAddress).Zip4 = objResponse.Accounts(0).ZipCode.Substring(5, 4)
                                        Else
                                            account.Address.Zip = objResponse.Accounts(0).ZipCode
                                        End If
                                    Else
                                        blnServiceability = False
                                    End If
                                End If

                                If Not objCSGaccount.BillToAddress Is Nothing Then
                                    If account.BillingAddress Is Nothing Then account.BillingAddress = New BLAddress()
                                    account.BillingAddress.Street1 = objCSGaccount.BillToAddress.AddressLine1
                                    account.BillingAddress.Street2 = objCSGaccount.BillToAddress.AddressLine2
                                    account.BillingAddress.City = objCSGaccount.BillToAddress.City
                                    account.BillingAddress.State = objCSGaccount.BillToAddress.State
                                    If objCSGaccount.BillToAddress.ZipCode.Length > 5 Then
                                        account.BillingAddress.Zip = objResponse.Accounts(0).BillToAddress.ZipCode.Substring(0, 5)
                                        CType(account.BillingAddress, BLAddress).Zip4 = objResponse.Accounts(0).BillToAddress.ZipCode.Substring(5, 4)
                                    Else
                                        account.BillingAddress.Zip = objResponse.Accounts(0).BillToAddress.ZipCode
                                    End If
                                End If
                                obj.BillAmount = objCSGaccount.CurrentAccountBalance
                                If Not objCSGaccount.LinesOfBusiness Is Nothing Then
                                    If account.ExistingLOB Is Nothing Then account.ExistingLOB = New List(Of Category)
                                    For Each objLOB As LineOfBusiness In objCSGaccount.LinesOfBusiness
                                        Select Case objLOB.Type
                                            Case LineOfBusinessTypeCSG.Data
                                                obj.BillDescription = obj.Description & "and High - Speed Internet  "
                                                If Not account.ExistingLOB.Contains(Category.HSD) Then account.ExistingLOB.Add(Category.HSD)
                                            Case LineOfBusinessTypeCSG.Telephony
                                                obj.BillDescription = obj.Description & "and Telephone  "
                                                If Not account.ExistingLOB.Contains(Category.Telephoney) Then account.ExistingLOB.Add(Category.Telephoney)
                                            Case LineOfBusinessTypeCSG.Video
                                                obj.BillDescription = obj.Description & "and Digital Cable  "
                                                If Not account.ExistingLOB.Contains(Category.Cable) Then account.ExistingLOB.Add(Category.Cable)
                                        End Select
                                    Next
                                    If obj.Description <> String.Empty Then
                                        obj.BillDescription = Right(obj.Description, Len(obj.Description) - 4)
                                    End If
                                End If
                            End If

                            If blnServiceability Then
                                GetServiceabilityByAccountNumber(obj.AccountNumber)
                                blnServiceability = False
                            End If
                        Next

                    Case BillingVendorType.ICOM

                        Dim objRequest As GetAccountStatementsAllRequestICOMS
                        Dim objResponse As GetAccountStatementsAllResponseICOMS
                        Dim objHeader As New IcomsHeaderInfo

                        'Dim lCustAccountProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
                        'lCustAccountProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

                        'Common.RegisterChannels()
                        lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)



                        For Each obj As BLAccount.BillSummary In account.Bill
                            Dim strSite As String = Left(obj.AccountNumber, 3)
                            Dim strAcctNum As String = obj.AccountNumber.Substring(3, 9)

                            Select Case strSite
                                Case "100"
                                    objHeader.SiteId = SiteId.Site100
                                Case "200"
                                    objHeader.SiteId = SiteId.Site200
                                Case "300"
                                    objHeader.SiteId = SiteId.Site300
                                Case "400"
                                    objHeader.SiteId = SiteId.Site400
                                Case "500"
                                    objHeader.SiteId = SiteId.Site500
                                Case "600"
                                    objHeader.SiteId = SiteId.Site600
                            End Select

                            objRequest = New GetAccountStatementsAllRequestICOMS(objHeader, strAcctNum)
                            objResponse = CType(lCustAccountProvider.GetAccountStatementsAllICOMS(objRequest), GetAccountStatementsAllResponseICOMS)

                            If Not objResponse.AccountStatementAllInfo Is Nothing AndAlso Not objResponse.AccountStatementAllInfo.Statement Is Nothing Then
                                For Each objICOMSaccount As StatementAll In objResponse.AccountStatementAllInfo.Statement
                                    obj.AccountNumber = obj.AccountNumber & objICOMSaccount.StatementCode
                                    obj.BillAmount = CDec(objICOMSaccount.BalanceLastStatement)
                                    obj.BillDescription = objICOMSaccount.StatementDescription
                                    If Len(objICOMSaccount.LastStatementDate) = 8 Then
                                        obj.BillDuedDate = CDate(objICOMSaccount.LastStatementDate.Substring(4, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(6, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(0, 4))
                                    End If
                                Next

                            End If

                            If account.Address.Zip Is Nothing Then
                                If obj.AccountNumber.Length > 16 Then
                                    GetServiceabilityByAccountNumber(obj.AccountNumber.Substring(0, 16))
                                End If
                            Else

                                If oldacctnumber.IndexOf(obj.AccountNumber) = -1 Then
                                    If obj.AccountNumber.Length > 16 Then
                                        GetServiceabilityByAccountNumber(obj.AccountNumber.Substring(0, 16))
                                    End If
                                End If
                            End If

                        Next

                End Select
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)

            Else
                Common.LogException(New Exception("Could Not retrieve Account details due to invalid Account Number"), ExceptionSeverity.Fatal)
            End If
        Catch ex As Exception
            Throw
        Finally
            lCustAccountProvider = Nothing
        End Try
    End Sub

    Public Overrides Sub SignOut(ByVal trackingid As String)

        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            ResetAccount()
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Sub

    ' UI uses this method to get account object
    Public Overrides Function UpdateAccountObj(ByVal trackingid As String, ByVal lAccount As BLAccount) As Boolean
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)




            Me.account = lAccount



            '##############
            'Persist state
            '##############
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

            Return True
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

	' UI uses this method to get account object
    Public Overrides Function GetAccount(ByVal trackingid As String) As IAccount
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            Return account
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

    Public Overrides Function MyAccount_GetServiceability(ByVal trackingid As String) As Boolean
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)



            '################################################################
            'DO A EBS SERVICEABILITY CALL TO GET DATA LIKE THE PERSONS NAME, 
            'ADDRESS, EXISTING SERVICES, AND OTHER DATA NEEDED FOR G2B 
            'QUERYOFFER(CALLS)
            '################################################################
            Dim lProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
            Dim sc As New EntityEBSServices.ServiceabilityCriteria
            Dim objServiceabilityRequest As New EntityEBSServices.GetServiceabilityRequest
            Dim objServiceabilityResponse As EntityEBSServices.GetServiceabilityResponse

            Select Case account.BillingVendorType
                Case BillingVendorType.CSG
                    sc.Item = account.Bill(0).AccountNumber ' objresponse.AccountID
                Case BillingVendorType.ICOM
                    sc.Item = account.Bill(0).AccountNumber.Substring(0, 16) ' objresponse.AccountID.Substring(0, 16)
            End Select
            sc.ItemElementName = EntityEBSServices.ItemChoiceType.AccountNumber

            objServiceabilityRequest.Criteria = sc
            objServiceabilityResponse = CType(lProvider.GetServiceability(objServiceabilityRequest), EntityEBSServices.GetServiceabilityResponse)

            Call MyAccountPopulateUsingServiceabilityResult(objServiceabilityResponse)


            '##############
            'Persist state
            '##############
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

            Return True
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

    Public Overrides Function LocalizeByPhone(ByVal trackingID As String, ByVal phoneNumber As String, ByVal affiliateID As Integer) As Boolean
        Try
            Dim lProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
            Dim objrequest As New EntityEBSServices.GetLocationByPhoneRequest
            Dim objresponse As EntityEBSServices.GetLocationByPhoneResponse

            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)

            objrequest.TelephoneNumber = phoneNumber
            objresponse = CType(lProvider.GetLocationByPhone(objrequest), EntityEBSServices.GetLocationByPhoneResponse)



            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

            If objresponse IsNot Nothing AndAlso _
                objresponse.Address IsNot Nothing AndAlso _
                objresponse.Address.Length() > 0 AndAlso _
                objresponse.Address(0).AddressLine1 IsNot Nothing AndAlso _
                objresponse.Address(0).ZipCode IsNot Nothing Then
                '##############################################################################
                'MODIFICATION   FEB 16, 2009    ROD COPELAND ISSUE ID 8158
                '##############################################################################
                'IF THE BUNDLE BUILDER REDIRECTION IS ENABLED THEN SEND THE USERS ADDRESS 
                'OVER TO KNOTICE.
                '##############################################################################
                If System.Web.HttpContext.Current.Application("BB_REDIRECTION_ENABLED") IsNot Nothing AndAlso _
                    Web.HttpContext.Current.Application("BB_REDIRECTION_ENABLED").ToString().Trim().ToLower() = "t" Then

                    Dim strURL As String = getBBRedirectURL(objresponse.Address(0).AddressLine1, objresponse.Address(0).AddressLine2, objresponse.Address(0).ZipCode.Substring(0, 5))
                    If strURL IsNot Nothing Then
                        System.Web.HttpContext.Current.Response.Redirect(strURL)
                    Else
                        '#####################################
                        'DO THE NORMAL LOCALIZATION PROCESS.
                        '#####################################
                        Return Me.Localize(trackingID, objresponse.Address(0).AddressLine1, objresponse.Address(0).AddressLine2, objresponse.Address(0).ZipCode.Substring(0, 5), String.Empty, affiliateID)
                    End If
                Else
                    '#####################################
                    'DO THE NORMAL LOCALIZATION PROCESS.
                    '#####################################
                    Return Me.Localize(trackingID, objresponse.Address(0).AddressLine1, objresponse.Address(0).AddressLine2, objresponse.Address(0).ZipCode.Substring(0, 5), String.Empty, affiliateID)
                End If
            Else
                Common.LogException(New Exception("Account Manager - Localization failed for phone number, unable to find address: " & phoneNumber), ExceptionSeverity.High)
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                Return False
            End If

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Catastrophic)
            Throw ex
        End Try
    End Function

    Private Function getBBRedirectURL(ByVal street1 As String, ByVal street2 As String, ByVal zip As String) As String
        '#####################################################################################################
        'MODIFICATION   FEB 16, 2009    ROD COPELAND ISSUE ID 8158
        '#####################################################################################################
        'THIS IS AN EXAMPLE OF WHAT THIS URL COULD LOOK LIKE.  BE AWARE OF EDITORS LIKE FCKEDITOR AUTOCORRECTING THE 
        'URL AMPERSAND TO THE ENCODED VALUE.  THE ENCODED VALUE WILL CAUSE A PROBLEM FOR KNOTICE SERVERS.
        '"https://connect.charter.com/bundlebuilder/?streetaddress={StreetAddress}&AptNum={Apt}&Zip={Zipcode}"
        '#####################################################################################################
        Dim strBBURL As String

        If System.Web.HttpContext.Current.Application("BB_REDIRECT_URL") IsNot Nothing AndAlso _
           System.Web.HttpContext.Current.Application("BB_REDIRECT_URL").ToString().Trim() <> "" Then

            strBBURL = System.Web.HttpContext.Current.Application("BB_REDIRECT_URL").ToString()

            If street1 Is Nothing Then
                strBBURL = strBBURL.Replace("{StreetAddress}", System.Web.HttpContext.Current.Server.HtmlEncode(" "))
            Else
                strBBURL = strBBURL.Replace("{StreetAddress}", street1)
            End If

            If street2 Is Nothing Then
                strBBURL = strBBURL.Replace("{Apt}", System.Web.HttpContext.Current.Server.HtmlEncode(" "))
            Else
                strBBURL = strBBURL.Replace("{Apt}", street2)
            End If

            If street1 Is Nothing Then
                strBBURL = strBBURL.Replace("{Zipcode}", System.Web.HttpContext.Current.Server.HtmlEncode(" "))
            Else
                strBBURL = strBBURL.Replace("{Zipcode}", zip)
            End If

            Return strBBURL
        Else
            Return Nothing
        End If




    End Function

	Private Sub redirectForSpecificZipCodes(ByVal lZip As String)
		'#####################################################################
		'MODIFICATION   FEB 12, 2008    ROD COPELAND
		'#####################################################################
		'PER BILL HUSTON, LINDA LAMBERT - ISSUE ID 3280
		'CHECK TO SEE IF THIS CUSTOMER IS FROM THE SACRAMENTO CA AREA, IF SO, 
		'REDIRECT TO LEADSHARING PAGE BECAUSE OUR BILLING SYSTEM DOESNT HAVE 
		'THESE CUSTOMERS ANYMORE.
		'#####################################################################

		'#####################################################################################################################################################
		'THIS STRING SHOULD LOOK LIKE THE FOLLOWING EXAMPLE:
		'http://KSTLMWEB65/visitors/general.aspx?ownerid=18;94571;95605;95616;95618;95620;95691;95694;95695;95776;95934;95947;95971;96103;96106;96118;96122
		'#####################################################################################################################################################
		Dim SACRAMENTO_Zip_Collection As New Dictionary(Of String, String)
		If Not (System.Web.HttpContext.Current.Application("Zip_Collection") Is Nothing) Then
			SACRAMENTO_Zip_Collection = CType(System.Web.HttpContext.Current.Application("Zip_Collection"), Dictionary(Of String, String))

			If Not (SACRAMENTO_Zip_Collection Is Nothing) Then
				If SACRAMENTO_Zip_Collection.ContainsKey(lZip.Trim()) Then
					System.Web.HttpContext.Current.Response.Redirect(SACRAMENTO_Zip_Collection(lZip.Trim()))
				Else
					Exit Sub
				End If
			End If
		End If

		If Not System.Web.HttpContext.Current.Application("SACRAMENTO_REDIRECTURL_AND_ZIPS") Is Nothing Then
			Dim tempString As String = System.Web.HttpContext.Current.Application("SACRAMENTO_REDIRECTURL_AND_ZIPS").ToString()
			Dim URL_ZipCode_Array() As String = tempString.Split(CChar(";"))
			If URL_ZipCode_Array.Length() > 0 Then
				Dim lRedirectURL As String = URL_ZipCode_Array(0)

				For intCnt As Integer = 1 To URL_ZipCode_Array.GetUpperBound(0)
					If Not SACRAMENTO_Zip_Collection.ContainsKey(URL_ZipCode_Array(intCnt)) Then
						SACRAMENTO_Zip_Collection.Add(URL_ZipCode_Array(intCnt), lRedirectURL)
					End If
				Next

				System.Web.HttpContext.Current.Application("Zip_Collection") = SACRAMENTO_Zip_Collection

				If Not (SACRAMENTO_Zip_Collection Is Nothing) Then
					If SACRAMENTO_Zip_Collection.ContainsKey(lZip.Trim()) Then
						System.Web.HttpContext.Current.Response.Redirect(SACRAMENTO_Zip_Collection(lZip.Trim()))
					End If
				End If
			End If

		End If

		'#####################################################################


	End Sub

	'9/18/07 Brad Miller - added promoCode to signature for g2b 4.1
    Public Overrides Function Localize(ByVal trackingid As String, ByVal addr1 As String, ByVal addr2 As String, ByVal zipCode As String, ByVal promoCode As String, ByVal affliateID As Integer) As Boolean
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)



            '##############################################################################
            'MODIFICATION   FEB 16, 2009    ROD COPELAND ISSUE ID 8158
            '##############################################################################
            'IF THE BUNDLE BUILDER REDIRECTION IS ENABLED THEN SEND THE USERS ADDRESS 
            'OVER TO KNOTICE.
            '##############################################################################
            If System.Web.HttpContext.Current.Application("BB_REDIRECTION_ENABLED") IsNot Nothing AndAlso _
                Web.HttpContext.Current.Application("BB_REDIRECTION_ENABLED").ToString().Trim().ToLower() = "t" Then

                Dim strURL As String = getBBRedirectURL(addr1, addr2, zipCode)

                If strURL IsNot Nothing Then
                    System.Web.HttpContext.Current.Response.Redirect(strURL)
                End If
            End If
            '##############################################################################



            '#####################################################################
            'MODIFICATION   FEB 12, 2008    ROD COPELAND
            '#####################################################################
            'PER BILL HUSTON, LINDA LAMBERT - ISSUE ID 3280
            'CHECK TO SEE IF THIS CUSTOMER IS FROM THE SACRAMENTO CA AREA, IF SO, 
            'REDIRECT TO LEADSHARING PAGE BECAUSE OUR BILLING SYSTEM DOESNT HAVE 
            'THESE CUSTOMERS ANYMORE.
            '#####################################################################
            Call redirectForSpecificZipCodes(zipCode)
            '#####################################################################




            Dim _returnUser As Boolean = account.IsReturningUser
            account.AffliateID = affliateID

            If Not account.Address Is Nothing Then
                If account.IsReturningUser Then
                    If Not IsAddressSame(account.Address, addr1, addr2, zipCode) Then
                        _returnUser = False
                    End If
                    'Else
                    '    If IsAddressSame(account.Address, addr1, addr2, zipCode) Then
                    '        account.UserStatus = UserStatus.Localized
                    '        Return True
                    '    End If
                End If
            End If
            ' user may be trying to localize again, so first clear account object
            ResetAccount()

            '######################################################
            '9/18/07 Brad Miller - added population of promoCode for g2b 4.1
            '######################################################
            If affliateID <> CharterDotCom.CommonEntities.Library.Common.m_CHARTER_AFFLIATE_ID Then
                '########################################################################
                'WE HAVE AN AFFILIATE, CREATE AFFILIATE VERSION OF THE CATALOG MANAGER
                '########################################################################
                Dim cm As New BLAffliateCatalogManager()
                cm.PopulatePromoCodes(promoCode)

                SetSession(BLCommon.AffiliateCatalogManagerKey, cm.ValuesForSetSession)
            Else
                '########################################################################
                'THIS SHOULD ONLY BE THE CHARTER.COM AFFILIATE ID, CREATE A NEW INSTANCE 
                'OF THE NORMAL CATALOG MANAGER UNLESS ONE IS ALREADY IN SESSION.
                '########################################################################
                If Not Session(Common.CatalogManagerKey) Is Nothing Then
                    Dim cm As New BLCatalogManager(CType(Session(Common.CatalogManagerKey), Dictionary(Of String, Object)))
                    cm.PopulatePromoCodes(promoCode)
                    cm.ProductCatalog = Nothing 'reset catalog
                    SetSession(Common.CatalogManagerKey, cm.ValuesForSetSession)
                Else
                    '########################################################################
                    'Instantiate new CatalogManager this early because promoCode must be populated
                    '########################################################################
                    Dim cm As New BLCatalogManager()
                    cm.PopulatePromoCodes(promoCode)
                    SetSession(Common.CatalogManagerKey, cm.ValuesForSetSession)
                End If
            End If
            account.IsReturningUser = _returnUser

            'Make Serviceability call to the provider based on the localized information
            With account.Address
                .Street1 = addr1
                .Street2 = addr2
                .Zip = zipCode
            End With

            'account.IsMoving = isMoving

            If Not serviceabilityResults Is Nothing Then
                For Each obj As EntityEBSServices.GetServiceabilityResponseServiceabilityResult In serviceabilityResults.ServiceabilityResult
                    If Not obj.LocationAvailableServices Is Nothing Then
                        If addr1 = obj.LocationAvailableServices.AddressLine1 And addr2 = obj.LocationAvailableServices.AddressLine2 And zipCode = obj.LocationAvailableServices.ZipCode Then
                            PopulateUsingServiceabilityResult(obj)
                            findServiceability = False
                            serviceabilityResults = Nothing
                            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                            'If CookieID IsNot Nothing Then
                            '    'PersistSession(Common.AddressKey, account.Address)
                            'End If
                            Return True
                        End If
                    End If
                Next
            End If

            If Not findServiceability Then Exit Try

            If GetServiceabilityByAddress() Then
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                'If CookieID IsNot Nothing Then
                '    'PersistSession(Common.AddressKey, account.Address)
                'End If
                ' If isMoving Then
                ' ' clear all the user information
                'ResetUser()
                'End If
                Return True
            Else
                Common.LogException(New Exception("Account Manager - Localization failed for address:" & addr1 & " " & addr2 & " " & zipCode), ExceptionSeverity.High)
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                'If CookieID IsNot Nothing Then
                '    'PersistSession(Common.AddressKey, account.Address)
                'End If
                Return False
            End If
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Catastrophic)
            Throw ex
        End Try
    End Function

    Public Overrides Function Arealize(ByVal trackingid As String, ByVal zipCode As String) As String
        '##############
        'Restore state
        '##############
        PopulateLocalVariables(trackingid)


        'Dim contentProvider As IContentProvider = providerFactory.CreateProvider(Of IContentProvider)(Common.AssemblyName)
        'Dim contentProvider As IContentProvider = New ContentProvider.ProviderManager(configdata_content)
        'Common.RegisterChannels()
        Dim contentProvider As IContentProvider = CType(Activator.GetObject(GetType(IContentProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_ContentProvider"))), IContentProvider)


        Try
            If account Is Nothing Then
                account = New BLAccount()
            End If
            Dim strTemp As String
            With account
                strTemp = contentProvider.GetAreaID(zipCode)
                Dim arrTemp() As String
                Dim charSeparator(1) As Char
                charSeparator(0) = CChar("@")
                arrTemp = strTemp.Split(charSeparator, StringSplitOptions.RemoveEmptyEntries)

                .AreaID = CInt(arrTemp(0))
                .AreaName = arrTemp(1)
                .UserStatus = UserStatus.Arealized
            End With
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
            Return strTemp
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Catastrophic)
            Throw ex
        Finally
        End Try
    End Function

    Public Overrides Function SetLocaleID(ByVal trackingid As String, ByVal localeName As String) As Boolean
        'ToDO:Get Id from database
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            Select Case localeName
                Case "EN-US"
                    Me.LocaleID = 1
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                    Return True
                Case Else
                    Common.LogException(New Exception("Account Manager - Set Locale ID ID for localename: " & localeName), ExceptionSeverity.Catastrophic)
                    Return False
            End Select
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Catastrophic)
            Throw ex
        End Try
    End Function

    Public Overrides Function GetAddresses(ByVal trackingid As String) As Dictionary(Of String, IAddress)

        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            Dim lManager As New BLAccountManager(CType(Session(Common.AccountManagerKey), Dictionary(Of String, Object)))
            Dim blAddress As BLAddress
            addresses = lManager.addresses
            Dim location As GetServiceabilityResponseServiceabilityResultLocationAvailableServices

            If addresses Is Nothing Then
                If Not serviceabilityResults Is Nothing Then
                    addresses = New Dictionary(Of String, IAddress)
                    Dim i As Integer = 0
                    For Each result As GetServiceabilityResponseServiceabilityResult In serviceabilityResults.ServiceabilityResult
                        location = result.LocationAvailableServices
                        blAddress = New BLAddress(location.AddressLine1, location.AddressLine2, location.City, location.State, location.ZipCode, location.ZipCode4)
                        addresses.Add(i.ToString, blAddress)
                        i += 1
                    Next
                End If
            End If
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
            Return addresses
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw ex
        End Try

    End Function

	'9/18/07 Brad Miller - added promoCode to signature for g2b 4.1
    Public Overrides Function SelectAddress(ByVal trackingid As String, ByVal addressID As String, ByVal promoCode As String) As Boolean
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            Dim address As IAddress = New BLAddress(addresses(addressID).Street1, addresses(addressID).Street2, addresses(addressID).City, addresses(addressID).State, addresses(addressID).Zip, CType(addresses(addressID), BLAddress).Zip4)

            Dim result As Boolean = Localize(trackingid, address.Street1, address.Street2, address.Zip, promoCode, account.AffliateID)

            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
            Return result
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw ex
        End Try
    End Function

    Public Overrides Sub SetShippingAddress(ByVal trackingid As String, ByVal street As String, ByVal apt As String, ByVal city As String, ByVal state As String, ByVal zip As String)
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            Dim gwyaddress As New Address(street, apt, city, state, zip, String.Empty)
            'account.ShippingAddress = New BLAddress()
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Sub

    Private Function GetServiceabilityByAddress() As Boolean
        'TODO: call serviceability provider by passing account object
        ' then take out all this code for populating accounting object

        Try
            ' call serviceability provider with address
            'Dim lProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
            'Dim lProvider As IEBSServicesProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

            'Common.RegisterChannels()
            Dim lProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)




            Dim sc As New EntityEBSServices.ServiceabilityCriteria
            Dim scaddress As New EntityEBSServices.ServiceabilityCriteriaAddress
            Dim objrequest As New EntityEBSServices.GetServiceabilityRequest
            Dim objresponse As EntityEBSServices.GetServiceabilityResponse

            With scaddress
                .AddressLine1 = account.Address.Street1
                .AddressLine2 = account.Address.Street2
                .ZipCode = account.Address.Zip
                .CleansedAddress = False
                .ZipCode4 = ""
            End With

            With sc
                .Item = scaddress
                .ItemElementName = EntityEBSServices.ItemChoiceType.Address
            End With

            objrequest.Criteria = sc


            '###################################################
            'MODIFICATION   ROD COPELAND    MARCH 12, 2008
            '###################################################
            'CLEAR OUT ANY OLD SERVICEABILITY RELEATED DATA PRIOR 
            'TO MAKING ANOTHER SERVICEABILITY CALL.
            '###################################################
            Me.addresses = Nothing
            Me.gwyShoppingCart = Nothing
            Me.findServiceability = True
            Me.serviceabilityResults = Nothing
            Me.HouseRef = Nothing
            Me.EntityID = Nothing




            '###################################################
            'MAKE CALL TO THE PROVIDER FOR SERVICEABILITY CALL
            '###################################################
            objresponse = CType(lProvider.GetServiceability(objrequest), EntityEBSServices.GetServiceabilityResponse)




            If Not objresponse.ServiceabilityResult Is Nothing AndAlso objresponse.ServiceabilityResult.Length > 0 Then
                If objresponse.ServiceabilityResult.Length > 1 Then
                    serviceabilityResults = objresponse
                    Return False
                End If
            Else
                Call ResetAccount()
                Common.LogException(New Exception("Account Manager - Serviceaability failed with  reason as:" & objresponse.ExceptionMessage & "-" & objresponse.ExceptionStackTrace), ExceptionSeverity.Fatal)
                Return False
                Exit Function
            End If


            If account.AffliateID = CharterDotCom.CommonEntities.Library.Common.m_CHARTER_AFFLIATE_ID Then
                If Not Session(Common.CatalogManagerKey) Is Nothing Then
                    Dim lmanager As New BLCatalogManager(CType(Session(Common.CatalogManagerKey), Dictionary(Of String, Object)))

                    If Not lmanager.ProductCatalog Is Nothing Then
                        lmanager.ProductCatalog = Nothing
                        SetSession(Common.CatalogManagerKey, lmanager.ValuesForSetSession)
                    End If
                End If
            Else
                If Not Session(BLCommon.AffiliateCatalogManagerKey) Is Nothing Then
                    Dim lmanager As New BLAffliateCatalogManager(CType(Session(BLCommon.AffiliateCatalogManagerKey), Dictionary(Of String, Object)))
                    If Not lmanager.ProductCatalog Is Nothing Then
                        lmanager.ProductCatalog = Nothing
                        SetSession(BLCommon.AffiliateCatalogManagerKey, lmanager.ValuesForSetSession)
                    End If
                End If
            End If


            PopulateUsingServiceabilityResult(objresponse.ServiceabilityResult(0))


            serviceabilityResults = objresponse

            SetSession(BLCommon.AffiliateCatalogManagerKey, Me.ValuesForSetSession)


            If Not (account Is Nothing) Then
                '######################################################################################################
                'MODIFICATION   ROD COPELAND    MARCH 11, 2008
                'WE'RE LOOKING FOR THE SITUATION WHERE THE SERVICEABILITY CALL SHOWS AN ADDRESS 
                'AS SERVICEABLE BUT THE WHEN YOU LOOK AT THE INDIVIDUAL SERVICES, THE AVAILABLE ATTRIBUTE IS SET 
                'TO FALSE.  FROM WHAT I GATHER THE NEIGHBORHOOD IS LIKELY NEW AND THE NEIGHBORHOOD IS WIRED FOR 
                'THE GIVEN SERVICES BUT THE HOUSE OR AREA CLOSE TO THE HOUSE IS NOT SO IT SHOWS SERVICEABLE BUT 
                'THE AVAILABLE IS SET TO FALSE.  STRAIT FORWARD RIGHT? WHEN THE ADDRESS SHOWS THAT THE AVAILABLE 
                'LINES OF BUSINESS IS EMPTY, WE SHOULD SHOW THE NO SERVICE AVAILABLE PAGE TO THE USER.
                '######################################################################################################
                If Not (account.AvailableLOB Is Nothing) Then
                    If (account.AvailableLOB.Count > 0) Then
                        Return True
                    Else
                        Call ResetAccount()
                        Return False
                    End If
                Else
                    Call ResetAccount()
                    Return False
                End If
            Else
                Return False
            End If



        Catch ex As Exception
            Throw ex
        Finally
        End Try
    End Function


    Private Function GetServiceabilityByAccountNumber(ByVal acctnumber As String) As Boolean
        'TODO: call serviceability provider by passing account object
        ' then take out all this code for populating accounting object

        Try
            ' call serviceability provider with address
            'Dim lProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
            'Dim lProvider As IEBSServicesProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

            'Common.RegisterChannels()
            Dim lProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)



            Dim sc As New EntityEBSServices.ServiceabilityCriteria
            Dim objrequest As New EntityEBSServices.GetServiceabilityRequest
            Dim objresponse As EntityEBSServices.GetServiceabilityResponse


            With sc
                .Item = acctnumber
                .ItemElementName = EntityEBSServices.ItemChoiceType.AccountNumber
            End With

            objrequest.Criteria = sc
            objresponse = CType(lProvider.GetServiceability(objrequest), EntityEBSServices.GetServiceabilityResponse)
            If Not objresponse.ServiceabilityResult Is Nothing AndAlso objresponse.ServiceabilityResult.Length > 0 Then
                If objresponse.ServiceabilityResult.Length > 1 Then
                    serviceabilityResults = objresponse
                    Return False
                End If
            Else
                Common.LogException(New Exception("Account Manager - Serviceaability failed with  reason as:" & objresponse.ExceptionMessage & "-" & objresponse.ExceptionStackTrace), ExceptionSeverity.Fatal)
                Return False
                Exit Function
            End If

            Dim objcm As Object = Session(Common.CatalogManagerKey)
            If objcm IsNot Nothing Then
                Dim lmanager As New BLCatalogManager(CType(objcm, Dictionary(Of String, Object)))
                If Not lmanager Is Nothing Then
                    lmanager.ProductCatalog = Nothing
                    SetSession(Common.CatalogManagerKey, lmanager.ValuesForSetSession)
                End If
            End If
            PopulateUsingServiceabilityResult(objresponse.ServiceabilityResult(0))
        Catch ex As Exception
            Throw ex
        Finally
        End Try
    End Function

	Private Sub MyAccountPopulateUsingServiceabilityResult(ByVal objResponse As EntityEBSServices.GetServiceabilityResponse)
		Try

			With account
				Dim lContentProvider As IContentProvider = CType(Activator.GetObject(GetType(IContentProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_ContentProvider"))), IContentProvider)

				Dim intTemp As Integer = lContentProvider.GetBillingStationID(objResponse.ServiceabilityResult(0).LocationAvailableServices.BillingSystem)
				If intTemp <> 0 Then
					.BillingCode = intTemp

					.FTA = objResponse.ServiceabilityResult(0).LocationAvailableServices.FTA.PadLeft(4, CChar("0"))
				Else
					.BillingCode = 0

					.FTA = String.Empty
				End If
				If objResponse.ServiceabilityResult(0).LocationAvailableServices.BillingProvider = "ICOMS" Then
					.BillingVendorType = BillingVendorType.ICOM
					.Site = objResponse.ServiceabilityResult(0).LocationAvailableServices.Site
				Else
					.BillingVendorType = BillingVendorType.CSG
				End If
				.UserStatus = UserStatus.Localized

				HouseRef = objResponse.ServiceabilityResult(0).LocationAvailableServices.HouseRef
				EntityID = objResponse.ServiceabilityResult(0).LocationAvailableServices.EntityID

				.Address.Street1 = objResponse.ServiceabilityResult(0).LocationAvailableServices.AddressLine1
				.Address.Street2 = objResponse.ServiceabilityResult(0).LocationAvailableServices.AddressLine2
				.Address.Zip = objResponse.ServiceabilityResult(0).LocationAvailableServices.ZipCode
				.Address.City = objResponse.ServiceabilityResult(0).LocationAvailableServices.City
				.Address.State = objResponse.ServiceabilityResult(0).LocationAvailableServices.State
				CType(.Address, BLAddress).Zip4 = objResponse.ServiceabilityResult(0).LocationAvailableServices.ZipCode4

				DirectCast(.Address, BLAddress).Zip4 = objResponse.ServiceabilityResult(0).LocationAvailableServices.ZipCode4
				If Not objResponse.ServiceabilityResult(0).LocationAvailableServices.Service Is Nothing Then
					If .AvailableLOB Is Nothing Then .AvailableLOB = New List(Of BLServiceType)
					For Each objservice As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationAvailableServicesService In objResponse.ServiceabilityResult(0).LocationAvailableServices.Service
						Select Case objservice.Description
							Case BLCommon.Serviceablity_Basic
								If Not .AvailableLOB.Contains(BLServiceType.Basic) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Basic)
							Case BLCommon.Serviceablity_DVR
								If Not .AvailableLOB.Contains(BLServiceType.DVR) And objservice.Available Then .AvailableLOB.Add(BLServiceType.DVR)
							Case BLCommon.Serviceablity_Digital
								If Not .AvailableLOB.Contains(BLServiceType.Digital) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Digital)
							Case BLCommon.Serviceablity_HDTV
								If Not .AvailableLOB.Contains(BLServiceType.HDTV) And objservice.Available Then .AvailableLOB.Add(BLServiceType.HDTV)
							Case BLCommon.Serviceablity_VOD
								If Not .AvailableLOB.Contains(BLServiceType.VOD) And objservice.Available Then .AvailableLOB.Add(BLServiceType.VOD)
							Case BLCommon.Serviceablity_HSD
								If Not .AvailableLOB.Contains(BLServiceType.HSD) And objservice.Available Then .AvailableLOB.Add(BLServiceType.HSD)
							Case BLCommon.Serviceablity_Telephony
								If Not .AvailableLOB.Contains(BLServiceType.Telephony) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Telephony)
						End Select
					Next
				Else
					'TO DO: uncomment this and return not localized but until we figure out the mapping between serviceability category and LOB wait
					Common.LogException(New Exception("Account Manager - Serviceability failed with  no Availableservices"), ExceptionSeverity.Fatal)
					Exit Sub
				End If

				If Not objResponse.ServiceabilityResult(0).LocationResidentServices Is Nothing Then
					.IsExistingUser = True
					If .ExistingLOB Is Nothing Then .ExistingLOB = New List(Of Category)
					For Each objaccount As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationResidentServices In objResponse.ServiceabilityResult(0).LocationResidentServices
						If account.User Is Nothing Then account.User = New BLAccount.BLMember
						account.User.FirstName = objaccount.FirstName
						account.User.LastName = objaccount.LastName
						account.User.Salutation = String.Empty
						account.HomePhone = objaccount.TelephoneNumber

						If Not objaccount.Service Is Nothing Then
							For Each objservice As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationResidentServicesService In objaccount.Service
								Select Case objservice.LOB_Descr
									Case BLCommon.Serviceablity_Data
										If Not .ExistingLOB.Contains(Category.HSD) Then .ExistingLOB.Add(Category.HSD)
									Case BLCommon.Serviceablity_Video
										If Not .ExistingLOB.Contains(Category.Cable) Then .ExistingLOB.Add(Category.Cable)
									Case BLCommon.Serviceablity_Voice, BLCommon.Serviceablity_Telephony
										If Not .ExistingLOB.Contains(Category.Telephoney) Then .ExistingLOB.Add(Category.Telephoney)
								End Select
							Next
						End If
					Next
				End If
			End With
		Catch ex As Exception
			Throw ex
		End Try
	End Sub

	Private Function GetServiceabilityByTelephoneeNumber(ByVal TelephoneNumber As String, _
			   ByRef billingvendortype As BillingVendorType, _
			   ByRef Zipcode As String, _
			   ByRef strAddress1 As String, _
			   ByRef strAddress2 As String, _
			   ByRef strCity As String, _
			   ByRef strState As String) As List(Of IAccount.IBill)
		'TODO: call serviceability provider by passing account object
		' then take out all this code for populating accounting object

		'' DB - Added Address field to display first four digits of street address on Bill Summary page

		Try
			' call serviceability provider with address
			'Dim lProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
			'Dim lProvider As IEBSServicesProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)


			'Common.RegisterChannels()
			Dim lProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)


			Dim sc As New EntityEBSServices.ServiceabilityCriteria
			Dim objrequest As New EntityEBSServices.GetServiceabilityRequest
			Dim objresponse As EntityEBSServices.GetServiceabilityResponse
			Dim objBilling As List(Of IAccount.IBill)

			With sc
				.Item = TelephoneNumber
				.ItemElementName = EntityEBSServices.ItemChoiceType.TelephoneNumber
			End With

			objrequest.Criteria = sc
			objresponse = CType(lProvider.GetServiceability(objrequest), EntityEBSServices.GetServiceabilityResponse)


			If Not objresponse.ServiceabilityResult Is Nothing AndAlso objresponse.ServiceabilityResult.Length > 0 Then
				If objresponse.ServiceabilityResult.Length > 1 Then
					serviceabilityResults = objresponse
					Return Nothing
				Else
					If Not (objresponse Is Nothing) Then
						If (objresponse.ServiceabilityResult.Length > 0) Then
							If Not (objresponse.ServiceabilityResult(0) Is Nothing) Then
								If Not (objresponse.ServiceabilityResult(0).LocationAvailableServices Is Nothing) Then
									If Not (objresponse.ServiceabilityResult(0).LocationAvailableServices.Sys Is Nothing) Then
										If Not (objresponse.ServiceabilityResult(0).LocationAvailableServices.Prin Is Nothing) Then
											_sysPrin = objresponse.ServiceabilityResult(0).LocationAvailableServices.Sys & objresponse.ServiceabilityResult(0).LocationAvailableServices.Prin
										End If
									End If
								End If
							End If
						End If
					End If

					With objresponse.ServiceabilityResult(0).LocationAvailableServices
						Zipcode = .ZipCode
						strAddress1 = .AddressLine1
						strAddress2 = .AddressLine2
						strCity = .City
						strState = .State
					End With

					If objresponse.ServiceabilityResult(0).LocationAvailableServices.BillingProvider = "ICOMS" Then
						billingvendortype = billingvendortype.ICOM
					Else
						billingvendortype = billingvendortype.CSG
					End If
				End If
			Else
				Common.LogException(New Exception("Account Manager - Serviceaability failed with  reason as:" & objresponse.ExceptionMessage & "-" & objresponse.ExceptionStackTrace), ExceptionSeverity.Fatal)
				Return Nothing
				Exit Function
			End If

			If Not objresponse.ServiceabilityResult(0).LocationResidentServices Is Nothing Then
				objBilling = New List(Of IAccount.IBill)
				For Each objaccount As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationResidentServices In objresponse.ServiceabilityResult(0).LocationResidentServices
					Dim objBillAccount As New BLAccount.BillSummary(objaccount.AccountNumber)
					objBilling.Add(objBillAccount)
				Next
			End If

			Return objBilling

		Catch ex As Exception
			Throw ex
		Finally
		End Try
	End Function

	Private Sub PopulateUsingServiceabilityResult(ByVal objResponse As EntityEBSServices.GetServiceabilityResponseServiceabilityResult)
		Try

			With account
				'Dim lContentProvider As IContentProvider = providerFactory.CreateProvider(Of IContentProvider)(Common.AssemblyName)
				'Dim lContentProvider As IContentProvider = New ContentProvider.ProviderManager(configdata_content)

				'Common.RegisterChannels()
				Dim lContentProvider As IContentProvider = CType(Activator.GetObject(GetType(IContentProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_ContentProvider"))), IContentProvider)





				Dim intTemp As Integer = lContentProvider.GetBillingStationID(objResponse.LocationAvailableServices.BillingSystem)
				If intTemp <> 0 Then
					.BillingCode = intTemp

					.FTA = objResponse.LocationAvailableServices.FTA.PadLeft(4, CChar("0"))
				Else
					.BillingCode = 0

					.FTA = String.Empty
				End If
				If objResponse.LocationAvailableServices.BillingProvider = "ICOMS" Then
					.BillingVendorType = BillingVendorType.ICOM
					.Site = objResponse.LocationAvailableServices.Site
				Else
					.BillingVendorType = BillingVendorType.CSG
				End If
				.UserStatus = UserStatus.Localized

				HouseRef = objResponse.LocationAvailableServices.HouseRef
				EntityID = objResponse.LocationAvailableServices.EntityID

				.Address.Street1 = objResponse.LocationAvailableServices.AddressLine1
				.Address.Street2 = objResponse.LocationAvailableServices.AddressLine2
				.Address.Zip = objResponse.LocationAvailableServices.ZipCode
				.Address.City = objResponse.LocationAvailableServices.City
				.Address.State = objResponse.LocationAvailableServices.State
				CType(.Address, BLAddress).Zip4 = objResponse.LocationAvailableServices.ZipCode4

				DirectCast(.Address, BLAddress).Zip4 = objResponse.LocationAvailableServices.ZipCode4
				If Not objResponse.LocationAvailableServices.Service Is Nothing Then
					If .AvailableLOB Is Nothing Then .AvailableLOB = New List(Of BLServiceType)
					For Each objservice As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationAvailableServicesService In objResponse.LocationAvailableServices.Service
						Select Case objservice.Description
							Case BLCommon.Serviceablity_Basic
								If Not .AvailableLOB.Contains(BLServiceType.Basic) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Basic)
							Case BLCommon.Serviceablity_DVR
								If Not .AvailableLOB.Contains(BLServiceType.DVR) And objservice.Available Then .AvailableLOB.Add(BLServiceType.DVR)
							Case BLCommon.Serviceablity_Digital
								If Not .AvailableLOB.Contains(BLServiceType.Digital) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Digital)
							Case BLCommon.Serviceablity_HDTV
								If Not .AvailableLOB.Contains(BLServiceType.HDTV) And objservice.Available Then .AvailableLOB.Add(BLServiceType.HDTV)
							Case BLCommon.Serviceablity_VOD
								If Not .AvailableLOB.Contains(BLServiceType.VOD) And objservice.Available Then .AvailableLOB.Add(BLServiceType.VOD)
							Case BLCommon.Serviceablity_HSD
								If Not .AvailableLOB.Contains(BLServiceType.HSD) And objservice.Available Then .AvailableLOB.Add(BLServiceType.HSD)
							Case BLCommon.Serviceablity_Telephony
								If Not .AvailableLOB.Contains(BLServiceType.Telephony) And objservice.Available Then .AvailableLOB.Add(BLServiceType.Telephony)
						End Select
					Next
				Else
					'TO DO: uncomment this and return not localized but until we figure out the mapping between serviceability category and LOB wait
					Common.LogException(New Exception("Account Manager - Serviceability failed with  no Availableservices"), ExceptionSeverity.Fatal)
					Exit Sub
				End If

				If Not objResponse.LocationResidentServices Is Nothing Then
					.IsExistingUser = True
					If .ExistingLOB Is Nothing Then .ExistingLOB = New List(Of Category)
					For Each objaccount As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationResidentServices In objResponse.LocationResidentServices

						'If account.Bill Is Nothing Then
						account.Bill = New List(Of IAccount.IBill)
						Dim objBillAccount As New BLAccount.BillSummary(objaccount.AccountNumber)
						account.Bill.Add(objBillAccount)
						'End If
						If account.User Is Nothing Then account.User = New BLAccount.BLMember
						account.User.FirstName = objaccount.FirstName
						account.User.LastName = objaccount.LastName
						account.User.Salutation = String.Empty
						account.HomePhone = objaccount.TelephoneNumber

						If Not objaccount.Service Is Nothing Then
							For Each objservice As EntityEBSServices.GetServiceabilityResponseServiceabilityResultLocationResidentServicesService In objaccount.Service
								Select Case objservice.LOB_Descr
									Case BLCommon.Serviceablity_Data
										If Not .ExistingLOB.Contains(Category.HSD) Then .ExistingLOB.Add(Category.HSD)
									Case BLCommon.Serviceablity_Video
										If Not .ExistingLOB.Contains(Category.Cable) Then .ExistingLOB.Add(Category.Cable)
									Case BLCommon.Serviceablity_Voice, BLCommon.Serviceablity_Telephony
										If Not .ExistingLOB.Contains(Category.Telephoney) Then .ExistingLOB.Add(Category.Telephoney)
								End Select
							Next
						End If
					Next
				End If
			End With
		Catch ex As Exception
			Throw ex
		End Try
	End Sub

    Public Overrides Sub ChangeCustomerStatus(ByVal trackingID As String, ByVal status As String)
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)

            Select Case status
                Case UserStatus.Localized.ToString
                    account.UserStatus = UserStatus.Localized
                    If account.IsExistingUser Then
                        ResetExistingUserInformation()
                    End If
                Case UserStatus.Authenticated.ToString
                    account.UserStatus = UserStatus.Authenticated
                Case UserStatus.Arealized.ToString
                    account.UserStatus = UserStatus.Arealized
                Case UserStatus.Identified.ToString
                    account.UserStatus = UserStatus.Identified
                Case Else
                    account.UserStatus = UserStatus.UnIdentified
            End Select
            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
        End Try
    End Sub

    Private Sub ResetExistingUserInformation()
        With account
            .Bill = Nothing
            .BillingAddress = Nothing
            '.BillingCode = 0
            If Not .ExistingLOB Is Nothing Then .ExistingLOB = Nothing
            .HomePhone = String.Empty
            .SecurityQuestion = String.Empty
            .SecurityAnswer = String.Empty
            .ShippingAddress = Nothing
            .SSN = String.Empty
            If Not .User Is Nothing Then .User = Nothing
            .WebSpaceID = String.Empty
            .IsExistingUser = False
        End With
    End Sub

    '09/01/2009 Sheila Shahpari 
    'Retrieves account number, user name, and csr login (if any) from session entry and
    'performs oss auth string request to the BL Member Services provider
    Public Overrides Function GetOSSAuthString(ByVal trackingid As String, ByVal clientIp As String) As String
        Dim objRequest As New EntityMemberServices.GetEncryptStringRequest
        Dim objResponse As EntityMemberServices.GetEncryptStringResponse
        Dim retVal As String = Nothing
        PopulateLocalVariables(trackingid)

        '#####################################################################################################
        ' ISSUE ID #11442   11-12-2010  JLN
        '#####################################################################################################
        ' Description:  An incorrect account was sometimes being sent for authentication when a customer had
        '               multiple accounts.
        '      Change:  Changed code to use OSSProvidedAccountNumber instead of Bill(0).AccountNumber.
        '#####################################################################################################
        If account IsNot Nothing AndAlso Not String.IsNullOrEmpty(account.OSSProvidedAccountNumber) Then
            objRequest.AccountNumber = account.OSSProvidedAccountNumber

            objRequest.UserName = account.LoginID
            If CSRLOGIN IsNot Nothing Then
                objRequest.AuditUser = CSRLOGIN
            Else
                objRequest.AuditUser = account.LoginID
            End If

            objRequest.SourceIPAddress = clientIp
            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.GetOSSAuthString(objRequest), EntityMemberServices.GetEncryptStringResponse)

            retVal = objResponse.AuthString
        End If

        Return retVal

    End Function

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  SetBillingAddress
    ''' 
    ''' Description:  Assigns the specified billing address to the account in
    '''               the current session.
    ''' 
    ''' </summary>
    ''' <param name="trackingid"></param>
    ''' <param name="billingAddress"></param>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Public Overrides Sub SetBillingAddress(ByVal trackingid As String, ByVal billingAddress As IAddress)

        Try

            If billingAddress IsNot Nothing Then

                '---------------------------------------------------------------
                ' Restore state.
                '---------------------------------------------------------------
                Me.PopulateLocalVariables(trackingid)

                '---------------------------------------------------------------
                ' Assign billing address to session account object.
                '---------------------------------------------------------------
                Me.account.BillingAddress = billingAddress
                Me.SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)

            End If

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw
        End Try

    End Sub

#End Region

#Region "Manage Account"

    Public Function GetHouseRefID(ByVal trackingID As String) As String
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)


            '#################################################################
            'ISSUE ID 6146      ROD COPELAND    JUNE 16, 2009
            'USED FOR KNOTICE 'COOKIE' TRACKING IN A GET TO KNOTICE DOMAIN.
            '#################################################################
            Return Me.HouseRef

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

    Public Function GetEntityID(ByVal trackingID As String) As String
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)


            '#################################################################
            'ISSUE ID 6146      ROD COPELAND    JUNE 16, 2009
            'USED FOR KNOTICE 'COOKIE' TRACKING IN A GET TO KNOTICE DOMAIN.
            '#################################################################
            Return Me.EntityID

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

    Public Overrides Function GetMSBillingSystemLink(ByVal trackingID As String, ByVal successPage As String) As String
        Dim objRequest As New GetMSBillingSystemLinkRequest
        Dim objResponse As New GetMSBillingSystemLinkResponse
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)

            '########################################################
            'MODIFICATION   ROD COPELAND    ISSUE ID:7780
            '########################################################
            'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
            'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
            '########################################################
            objRequest.accountId = account.OSSProvidedAccountNumber

            objRequest.login = CSRLOGIN
            objRequest.password = CSRPASSWORD
            objRequest.successPage = successPage




            '################################
            'EXECUTE THE CALL TO THE PROVIDER
            '################################
            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.GetMSBillingSystemLink(objRequest), GetMSBillingSystemLinkResponse)





            If Not (objResponse Is Nothing) Then
                If Not (objResponse.Exception) Then
                    '#########################################################
                    'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
                    '#########################################################
                    Return GetBillingVendorLinkURL(objResponse)
                Else
                    '##################################################################################
                    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                    '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                    '##################################################################################
                    'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                    'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                    'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                    'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                    'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                    'ACCORDINGLY.
                    '##################################################################################
                    Select Case True
                        Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                            Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                        Case Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                    End Select
                    '##################################################################################


                    '##############
                    'Persist state
                    '##############
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                    Return Nothing
                End If

            End If


            'SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

            'Return account.BillingSystemURL

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        Finally
            objRequest = Nothing
            objResponse = Nothing
        End Try
    End Function

    Public Overrides Function GetMSBillingSystemLink(ByVal trackingID As String, ByVal strSiblingAccountIDClicked As String, ByVal successPage As String) As String
        '#################################################################
        'MODIFICATION   ROD COPELAND    ISSUE ID 6782   AUG 13, 2009
        '#################################################################
        'SUPPORT CSG MULTI-STATEMENT LINKS NOT DIRECTING TO SPECIFIC ACCTS 
        'ON THE BILL VENDOR DOMAIN
        '#################################################################

        Dim objRequest As New GetMSBillingSystemLinkRequest
        Dim objResponse As New GetMSBillingSystemLinkResponse
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingID)

            '#################################################################
            'ASSIGN THE CORRECT BILLING ACCOUNT NUMBER TO THE REQUEST OBJECT
            'AMONG OTHER THINGS, THIS SHOULD TAKE OFF THE STATEMENT CODE THAT 
            'IS SOMETIMES APPENDED TO THE ACCOUNT NUMBER
            '#################################################################
            objRequest.accountId = GetAccountNumberWithoutStatementCode(strSiblingAccountIDClicked)

            objRequest.login = CSRLOGIN
            objRequest.password = CSRPASSWORD
            objRequest.successPage = successPage




            '################################
            'EXECUTE THE CALL TO THE PROVIDER
            '################################
            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.GetMSBillingSystemLink(objRequest), GetMSBillingSystemLinkResponse)





            If Not (objResponse Is Nothing) Then
                If Not (objResponse.Exception) Then
                    '#########################################################
                    'SET THE BILLING SYSTEM URL VALUE IN THE ACCOUNT OBJECT
                    '#########################################################
                    Return GetBillingVendorLinkURL(objResponse)
                Else
                    '##################################################################################
                    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                    '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                    '##################################################################################
                    'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                    'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                    'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                    'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                    'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                    'ACCORDINGLY.
                    '##################################################################################
                    Select Case True
                        Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                            Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                        Case Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                    End Select
                    '##################################################################################


                    '##############
                    'Persist state
                    '##############
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                    Return Nothing
                End If

            End If


            'SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

            'Return account.BillingSystemURL

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        Finally
            objRequest = Nothing
            objResponse = Nothing
        End Try
    End Function

    Public Overrides Function ChangeAccountUserID(ByVal trackingid As String, ByVal newUserID As String) As Boolean
        Dim objrequest As New EntityMemberServices.ChangeMSLoginRequest
        Dim objResponse As New EntityMemberServices.TheCommonResponse
        Try
            '##############
            'Restore state
            '##############
            PopulateLocalVariables(trackingid)

            objrequest.csrlogin = CSRLOGIN
            objrequest.csrpassword = CSRPASSWORD
            objrequest.newUserName = newUserID
            objrequest.userName = account.LoginID


            '################################
            'EXECUTE THE CALL TO THE PROVIDER
            '################################
            Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            objResponse = CType(iProvider.ChangeMSLogin(objrequest), TheCommonResponse)



            If Not objResponse.Exception Then
                account.LoginID = newUserID
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
                Return True
            Else
                '##################################################################################
                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                '##################################################################################
                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                'ACCORDINGLY.
                '##################################################################################
                Select Case True
                    Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                End Select
                '##################################################################################


                '##############
                'Persist state
                '##############
                SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



                Common.LogException(New Exception("Account Manager -Change Account User ID failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
                Return False
            End If
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try
    End Function

	'##################################################################
	'JPIRKEY: This routine is ONLY to be called from the MyAccount/RetrieveUsername flow
	'It will pull the username from a different object than the standard Account object!
	'##################################################################
	Public Function ChangeMyAccountPasswordFromForgotUserName(ByVal trackingid As String, ByVal newPassword As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeMSPasswordRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse
		Dim bContinue As Boolean

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD

			'JPIRKEY - Use the MyAccount specific object here!
			If Not Me.MyAccountRetUNameAccount Is Nothing AndAlso Me.MyAccountRetUNameAccount.UserName > "" Then
				objrequest.userName = Me.MyAccountRetUNameAccount.UserName
				bContinue = True
			Else
				'no useraccount object available, can't possible change the password, fail the process
				bContinue = False
				Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
			End If

			If bContinue Then

				objrequest.password = newPassword

				'################################
				'EXECUTE THE CALL TO THE PROVIDER
				'################################
				Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
				objResponse = CType(iProvider.ChangeMSPassword(objrequest), TheCommonResponse)

				If Not objResponse.Exception Then
					Return True
				Else
					'##################################################################################
					'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
					'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
					'##################################################################################
					'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
					'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
					'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
					'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
					'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
					'ACCORDINGLY.
					'##################################################################################
					Select Case True
						Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
							Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
						Case Else
							Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
					End Select
					'##################################################################################

					'##############
					'Persist state
					'##############
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

					Common.LogException(New Exception("Account Manager -Change Account Password failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
					Return False
				End If
			End If
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Function

	Public Overrides Function ChangeAccountPassword(ByVal trackingid As String, ByVal newPassword As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeMSPasswordRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			If Not account Is Nothing Then
				objrequest.userName = account.LoginID
			End If

			objrequest.password = newPassword

			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.ChangeMSPassword(objrequest), TheCommonResponse)

			If Not objResponse.Exception Then
				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################

				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

				Common.LogException(New Exception("Account Manager -Change Account Password failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Function

	Public Overrides Function ChangeSecurityQA(ByVal trackingid As String, ByVal newQuestion As String, ByVal newAnswer As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeMSSecurityQARequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			objrequest.userName = account.LoginID
			objrequest.securityQuestion = newQuestion
			objrequest.securityAnswer = newAnswer


			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.changeMSSecurityQA(objrequest), TheCommonResponse)



			If Not (objResponse Is Nothing) Then
				If Not objResponse.Exception Then
					If Not (account Is Nothing) Then
						'###########################
						'UPDATE THE ACCOUNT OBJECT
						'###########################
						account.SecurityQuestion = newQuestion
						account.SecurityAnswer = newAnswer


						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

						Return True
					Else
						'##################################################################################
						'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
						'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
						'##################################################################################
						'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
						'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
						'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
						'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
						'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
						'ACCORDINGLY.
						'##################################################################################
						Select Case True
							Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
								Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
							Case Else
								Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
						End Select
						'##################################################################################


						'##############
						'Persist state
						'##############
						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



						Common.LogException(New Exception("Account Manager -Change Security QA failed the account object was nothing when trying to assign the new question and answer to it. "), ExceptionSeverity.High)
						Return False
					End If
				Else
					'##################################################################################
					'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
					'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
					'##################################################################################
					'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
					'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
					'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
					'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
					'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
					'ACCORDINGLY.
					'##################################################################################
					Select Case True
						Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
							Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
						Case Else
							Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
					End Select
					'##################################################################################


					'##############
					'Persist state
					'##############
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



					Common.LogException(New Exception("Account Manager -Change Security QA failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
					Return False
				End If
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
		Return True
	End Function

	'9/18/07 Brad Miller - added isShippingAddress to signature for g2b 4.1
	Public Overrides Sub UpdateMemberInformation(ByVal trackingid As String, ByVal lName As String, ByVal fName As String, _
	 ByVal phone As String, ByVal email As String, Optional ByVal street1 As String = Nothing, _
	 Optional ByVal street2 As String = Nothing, Optional ByVal city As String = Nothing, Optional ByVal state As String = Nothing, _
	 Optional ByVal zip As String = Nothing, Optional ByVal isShippingAddress As Boolean = False)
		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			With account
				If account.User Is Nothing Then
					account.User = New BLAccount.BLMember
				End If

				.User.LastName = lName
				.User.FirstName = fName

				If Not email = String.Empty Then
					If .User.Email Is Nothing Then
						.User.Email = New List(Of IAccount.IMember.IEmail)
					End If
					.User.Email.Add(New BLAccount.BLMember.BLEMail(email, True))
				End If

				.HomePhone = phone

				If Not street1 Is Nothing Then
					'9/18/07 Brad Miller - added population of ShippingAddress for g2b 4.1
					If isShippingAddress Then
						If .ShippingAddress Is Nothing Then
							.ShippingAddress = New BLAddress
						End If
						.ShippingAddress.Street1 = street1
						.ShippingAddress.Street2 = street2
						.ShippingAddress.City = city
						.ShippingAddress.State = state
						.ShippingAddress.Zip = zip
					Else
						If .BillingAddress Is Nothing Then
							.BillingAddress = New BLAddress
						End If
						.BillingAddress.Street1 = street1
						.BillingAddress.Street2 = street2
						.BillingAddress.City = city
						.BillingAddress.State = state
						.BillingAddress.Zip = zip
					End If
				End If
			End With
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try

	End Sub

	Public Overrides Function GetMSSecurityKeys(ByVal trackingid As String) As Boolean
		'##############
		'Restore state
		'##############
		PopulateLocalVariables(trackingid)

		Try
			'####################################################################
			'CHECK ALL PACKAGES SECURITY KEY VALUES TO SEE IF ANY ARE MISSING.
			'IF ANY ARE MISSING, DO A CALL FOR ALL AND UPDATE THE VALUES FOR 
			'ALL(PACKAGES) WITH FRESH DATA EVEN THOUGH YOU MAY ONLY NEED TO 
			'UPDATE JUST ONE OF THE PACKAGES.
			'####################################################################
			If Not (account Is Nothing) Then
				'#############################################################################
				'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
				'#############################################################################
				'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
				'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
				'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
				'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
				'IN THIS CASE, TO KEEP FROM DOING 
				'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
				'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
				'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
				'#############################################################################
				If Not account.MyAccountCachedPropertyNames Is Nothing Then
					If Not account.MyAccountCachedPropertyNames.Contains("securitykeys") Then

						If Not (account.User Is Nothing) Then
							If Not (account.User.MSPackageInfo Is Nothing) Then
								If (account.User.MSPackageInfo.Count > 0) Then
									For Each AccountObjPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
										If AccountObjPackage.SecurityKeys Is Nothing Then
											'#############################################
											'THEN DO A WEB SERVICE CALL AND SEE IF ANY 
											'EXIST SO A UPDATE CAN BE DONE LOCALLY ON 
											'THE ACCOUNT OBJECT.
											'#############################################
											Dim blnResult As Boolean = UpdateMyAccountSecurityKeysInAccountObject()
											Return blnResult
										Else
											'If AccountObjPackage.SecurityKeys.Count = 0 Then
											'    Dim blnResult As Boolean = UpdateMyAccountSecurityKeysInAccountObject()
											'    Return blnResult
											'Else
											'    '############################################################
											'    'SINCE THEY ALREADY HAVE A SECURITY KEY COLLECTION, LETS 
											'    'NOT DO ANOTHER WEB SERVICE REQUEST TO UPDATE VALUES THAT 
											'    'LIKELY HAVENT CHANGED ANYWAY.
											'    '############################################################
											'    Return True
											'End If
										End If
									Next
								End If
							End If
						End If


					End If
				End If


			End If


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			'objRequest = Nothing
			'objResponse = Nothing
		End Try
	End Function

	Private Function UpdateMyAccountSecurityKeysInAccountObject() As Boolean
		Dim objRequest As New GetMSSecurityKeysRequest
		Dim objResponse As New GetMSSecurityKeysResponse

		'########################################################
		'MODIFICATION   ROD COPELAND    ISSUE ID:7780
		'########################################################
		'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
		'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
		'########################################################
		objRequest.accountId = account.OSSProvidedAccountNumber

		objRequest.csrLogin = CSRLOGIN
		objRequest.csrPassword = CSRPASSWORD
		objRequest.type = "SECURITYKEY"



		'#############################################################################
		'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
		'#############################################################################
		'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
		'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
		'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
		'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
		'IN THIS CASE, TO KEEP FROM DOING 
		'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
		'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
		'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
		'#############################################################################
		If Not account.MyAccountCachedPropertyNames.Contains("securitykeys") Then
			account.MyAccountCachedPropertyNames.Add("securitykeys")

			'##############
			'Persist state
			'##############
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
		End If



		'################################
		'EXECUTE THE CALL TO THE PROVIDER
		'################################
		Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
		objResponse = CType(iProvider.GetMSSecurityKeys(objRequest), GetMSSecurityKeysResponse)




		If Not (objResponse Is Nothing) Then
			If Not objResponse.Exception Then
				If Not (objResponse.packageArray Is Nothing) Then
					If objResponse.packageArray.Length > 0 Then
						For i As Integer = 0 To objResponse.packageArray.GetUpperBound(0)
							Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo

							lPackage.provisioningIdField = objResponse.packageArray(i).provisioningId

							If Not (objResponse.packageArray(i).securityKeysArray Is Nothing) Then
								'##############################################################
								'LOOP THROUGH SECURITYKEYS AND ADD THEM TO THE TEMP PACKAGE OBJECT.
								'##############################################################
								If Not (objResponse.packageArray(i).securityKeysArray.KeysArray Is Nothing) Then
									lPackage.SecurityKeys = New List(Of String)
									For i2 As Integer = 0 To objResponse.packageArray(i).securityKeysArray.KeysArray.GetUpperBound(0)
										lPackage.SecurityKeys.Add(objResponse.packageArray(i).securityKeysArray.KeysArray(i2))
									Next
								End If
							End If

							'##############################################################
							'SEARCH FOR THE PROVISIONING ID IN THE EXISTING PACKAGES TO SEE 
							'IF ANY OF THEM NEED TO BE UPDATED WITH THESE SECURITY KEYS.
							'##############################################################

							If account Is Nothing Then
								account = New BLAccount
							End If
							If account.User Is Nothing Then
								account.User = New BLAccount.BLMember
							End If
							If account.User.MSPackageInfo Is Nothing Then
								account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
							End If
							If account.User.MSPackageInfo.Count > 0 Then
								'############################################
								'MODIFY AN EXISITNG PACKAGE IN THE COLLECTION
								'############################################
								For Each acctPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
									'######################################################################################
									'THIS CONDITION CHECKS TO SEE IF THE SECURITY KEY VALUE IS NOTHING, IF SO, IT WILL 
									'ASSIGN A INSTANTIATED VALUE THAT HAS NO VALUES IN IT, JUST SO ITS NOT NOTHING.  
									'WHEN THE GET SECURITY KEYS METHOD IS CALLED FROM THE PAGE, IT WILL CHECK THIS 
									'VALUE IF ITS NOTHING OR NOT.  IF ITS NOTHING IT WILL MAKE A WEB SERVICE CALL TO GO 
									'AND CHECK IF THERE IS A VALUE. TO AVOID GOING BACK EVERY TIME SINCE ONE OF THE 
									'PACKAGES IN THE COLLECTION MAY HAVE NOT HAVE SECURITY KEYS ALLOWED, GIVING A VALUE OF 
									'SOMETHING OTHER THAN NOTHING SHOULD STOP THAT. THIS IS UNTIL SOMEONE CHANGES THAT 
									'GET SECURITY KEYS METHOD.
									'######################################################################################
									If acctPackage.SecurityKeys Is Nothing Then
										acctPackage.SecurityKeys = New List(Of String)
									End If


									If acctPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
										acctPackage.SecurityKeys = lPackage.SecurityKeys
									End If
								Next
							Else
								'#####################################
								'ADD A NEW PACKAGE TO THE COLLECTION
								'#####################################
								account.User.MSPackageInfo.Add(lPackage)
							End If
						Next




						'##############
						'Persist state
						'##############
						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

						Return True
					Else
						Return False
					End If
				Else
					Return False
				End If
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



			End If

		Else
			'##################################################################################
			'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
			'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
			'##################################################################################
			'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
			'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
			'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
			'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
			'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
			'ACCORDINGLY.
			'##################################################################################
			Select Case True
				'Case Not objresponse.CharterDotCom_Friendly_Messages Is Nothing
				'    Me._LastCCOMDisplayFriendlyExceptionMessage = objresponse.CharterDotCom_Friendly_Messages
				Case Else
					Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
			End Select
			'##################################################################################


			'##############
			'Persist state
			'##############
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



			Return False
		End If
	End Function

	Public Overrides Function GetSecurityQA(ByVal trackingid As String) As List(Of String)
		Dim objRequest As New GetMSSecurityQAForAccountRequest
		Dim objResponse As New GetMSSecurityQAForAccountResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objRequest.accountId = account.OSSProvidedAccountNumber

			objRequest.csrLogin = CSRLOGIN
			objRequest.csrPassword = CSRPASSWORD
			objRequest.type = "SECURITYQA"



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.GetMSSecurityQAForAccount(objRequest), GetMSSecurityQAForAccountResponse)



			Dim lSecurityQuestions As New List(Of String)
			If Not (objResponse Is Nothing) Then

				If Not (objResponse.Exception) Then
					If Not objResponse.securityQuestion Is Nothing Then
						lSecurityQuestions.Add(objResponse.securityQuestion)
					Else
						Return Nothing
					End If
				Else
					'##################################################################################
					'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
					'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
					'##################################################################################
					'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
					'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
					'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
					'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
					'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
					'ACCORDINGLY.
					'##################################################################################
					Select Case True
						Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
							Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
						Case Else
							Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
					End Select
					'##################################################################################


					'##############
					'Persist state
					'##############
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



					Return Nothing
				End If
			Else
				Return Nothing
			End If


			Return lSecurityQuestions

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objRequest = Nothing
			objResponse = Nothing
		End Try
	End Function

	'****************************************************************
	'JPIRKEY: This is an exact duplicate of GetSecurityQA, but this takes an AccountNumber param instead of using the
	'OSSProvidedAccountNumber. 4-2010 MyAccount RetrieveUsername Update
	'****************************************************************
	Public Function GetSecurityQuestion(ByVal trackingid As String, ByVal AccountNumber As String) As List(Of String)
		Dim objRequest As New GetMSSecurityQAForAccountRequest
		Dim objResponse As New GetMSSecurityQAForAccountResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objRequest.accountId = AccountNumber

			objRequest.csrLogin = CSRLOGIN
			objRequest.csrPassword = CSRPASSWORD
			objRequest.type = "SECURITYQA"



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.GetMSSecurityQAForAccount(objRequest), GetMSSecurityQAForAccountResponse)



			Dim lSecurityQuestions As New List(Of String)
			If Not (objResponse Is Nothing) Then

				If Not (objResponse.Exception) Then
					If Not objResponse.securityQuestion Is Nothing Then
						lSecurityQuestions.Add(objResponse.securityQuestion)
					Else
						Return Nothing
					End If
				Else
					'##################################################################################
					'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
					'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
					'##################################################################################
					'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
					'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
					'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
					'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
					'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
					'ACCORDINGLY.
					'##################################################################################
					Select Case True
						Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
							Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
						Case Else
							Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
					End Select
					'##################################################################################


					'##############
					'Persist state
					'##############
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



					Return Nothing
				End If
			Else
				Return Nothing
			End If


			Return lSecurityQuestions

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objRequest = Nothing
			objResponse = Nothing
		End Try
	End Function
	Public Overrides Function GetSecurityQAWithoutAccount(ByVal trackingid As String) As List(Of String)
		'Dim objRequest As New GetMSSecurityQARequest
		'Dim objResponse As New GetMSSecurityQAResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)




			Dim lQuestions As List(Of String)
			If Not (System.Web.HttpContext.Current.Application("MYACCOUNT_GENERALQUESTIONLIST") Is Nothing) Then
				lQuestions = CType(System.Web.HttpContext.Current.Application("MYACCOUNT_GENERALQUESTIONLIST"), List(Of String))
			Else
				Return Nothing
			End If




			'##############
			'Persist state
			'##############
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())


			Return lQuestions

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Function

	Private Sub ResetAccount()
		Try
			With account
				.Address = New BLAddress(String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
				.AddressID = Nothing
				.AreaID = 0
				If Not .AvailableLOB Is Nothing Then .AvailableLOB = Nothing
				.Bill = Nothing
				.BillingAddress = Nothing
				.BillingCode = 0
				.BillingVendorType = Nothing 'BillingVendorType.CSG
				If Not .ExistingLOB Is Nothing Then .ExistingLOB = Nothing
				.FTA = String.Empty
				.HomePhone = String.Empty
				.KMAID = 0
				.RegionID = 0
				.SecurityQuestion = String.Empty
				.SecurityAnswer = String.Empty
				.ShippingAddress = Nothing
				.SSN = String.Empty	'THIS IS AN ENCRYPTED PROPERTY, JUST FYI...
				If Not .User Is Nothing Then .User = Nothing
				.UserStatus = UserStatus.UnIdentified
				.UserType = UserType.Visitor
				.WebSpaceID = String.Empty
				.IsExistingUser = False

				.LoginID = Nothing
				.MyAccountCachedPropertyNames = Nothing
				.SecurityQuestionList = Nothing
				.Site = Nothing
				.BillingSystemURL = Nothing

				'.G2B_AuthQuestion = Nothing
				'addresses = Nothing
				'serviceabilityResults = Nothing

			End With


			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Sub

	Private Sub ResetUser()
		Try
			With account
				'  .Address = New BLAddress(String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
				'  .AddressID = Nothing
				'  .AreaID = 0
				'   If Not .AvailableLOB Is Nothing Then .AvailableLOB = Nothing
				.Bill = Nothing
				.BillingAddress = Nothing
				.BillingCode = 0
				' .BillingVendorType = BillingVendorType.CSG
				.ExistingLOB = Nothing
				'.FTA = String.Empty
				.HomePhone = String.Empty
				'.KMAID = 0
				'.RegionID = 0
				.SecurityQuestion = String.Empty
				.SecurityAnswer = String.Empty
				.ShippingAddress = Nothing
				.SSN = String.Empty
				.User = Nothing
				.UserStatus = UserStatus.Localized
				.UserType = UserType.Visitor
				.WebSpaceID = String.Empty
				.IsExistingUser = False
			End With
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw New ApplicationException("Cannot Clear User Information", ex)
		End Try
	End Sub

	'Public Overrides Function ForgotPassword(ByVal trackingid As String, ByVal eMailID As String) As Boolean
	'    Dim objrequest As New EntityMemberServices.forgotMSPasswordRequest
	'    Dim objResponse As New EntityMemberServices.TheCommonResponse

	'    Try
	'        '##############
	'        'Restore state
	'        '##############
	'        PopulateLocalVariables(trackingid)

	'        objrequest.CSRLogin = CSRLOGIN
	'        objrequest.CSRPassword = CSRPASSWORD
	'        objrequest.MSContactEmail = eMailID



	'        '################################
	'        'EXECUTE THE CALL TO THE PROVIDER
	'        '################################
	'        Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
	'        objResponse = CType(iProvider.forgotMSPassword(objrequest), TheCommonResponse)




	'        If Not objResponse.Exception Then
	'            Return True
	'        Else
	'            '##################################################################################
	'            '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
	'            '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
	'            '##################################################################################
	'            'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
	'            'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
	'            'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
	'            'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
	'            'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
	'            'ACCORDINGLY.
	'            '##################################################################################
	'            Select Case True
	'                Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
	'                    Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
	'                Case Else
	'                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
	'            End Select
	'            '##################################################################################


	'            '##############
	'            'Persist state
	'            '##############
	'            SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



	'            Common.LogException(New Exception("Account Manager -Forgot password failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
	'            Return False
	'        End If
	'    Catch ex As Exception
	'        Common.LogException(ex, ExceptionSeverity.High)
	'        Throw ex
	'    End Try
	'End Function

	Public Overrides Function ChangeContactEMailAddress(ByVal trackingid As String, ByVal newEmailAddress As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeMAContactEmailRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			objrequest.userName = account.LoginID
			objrequest.preferedEmailId = newEmailAddress



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.ChangeMSContactEmail(objrequest), TheCommonResponse)




			If Not objResponse.Exception Then
				If Not (account Is Nothing) Then
					If Not (account.User Is Nothing) Then
						account.User.ContactEmailAddress = newEmailAddress
					End If
				End If

				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Change contact Email Address failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Function

	Public Overrides Function ValidateUser(ByVal trackingid As String, ByVal passedInAccountID As String) As String
		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			'#############################################################
			'MODIFICATION   ROD COPELAND    OCT 8, 2009 ISSUE ID    6885
			'WHEN THE USER LOGS IN INSIDE THE ORDER FLOW, TAKE THE ACCOUNT 
			'NUMBER RETURN FROM THE OSS CALL AND COMPAIR IT TO THE ACCOUNT 
			'NUMBER RETURNED FROM EAI ADDRESS SERVICEABILITY CALL AND MAKE 
			'SURE THEY MATCH PRIOR TO LETTING THEM ORDERING SERVICES ON 
			'THIS ADDRESS.
			'#############################################################
			If serviceabilityResults Is Nothing Then
				Return "The login and password do not match the address provided."
			End If
			If serviceabilityResults.ServiceabilityResult Is Nothing Then
				Return "The login and password do not match the address provided."
			End If
			If serviceabilityResults.ServiceabilityResult.Length <= 0 Then
				Return "The login and password do not match the address provided."
			End If
			If serviceabilityResults.ServiceabilityResult(0).LocationResidentServices Is Nothing Then
				Return "The login and password do not match the address provided."
			End If
			If serviceabilityResults.ServiceabilityResult(0).LocationResidentServices.Length <= 0 Then
				Return "The login and password do not match the address provided."
			End If
			If serviceabilityResults.ServiceabilityResult(0).LocationResidentServices(0).AccountNumber Is Nothing Then
				Return "The login and password do not match the address provided."
			End If
			Dim serviceabilityWSAccountID As String = serviceabilityResults.ServiceabilityResult(0).LocationResidentServices(0).AccountNumber


			If passedInAccountID.Length >= 17 Then
				'###################################################
				'REMOVE THE STATEMENT CODE FROM THE ACCOUNT NUMBER 
				'PRIOR TO THE COMPARISON TO THE WS ACCOUNT ID
				'###################################################
				passedInAccountID = passedInAccountID.Substring(0, 15)
			End If

			If serviceabilityWSAccountID = passedInAccountID Then
				If Not account.UserStatus = UserStatus.Authenticated Then
					account.UserStatus = UserStatus.Identified
				End If


				SetSession(Common.AccountManagerKey, ValuesForSetSession)

				Return ""
			Else
				Return "The login and password do not match the address provided."
			End If


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try
	End Function

	Public Overrides Function FindCSGAccountNumber(ByVal trackingid As String, ByVal accountNumber As String) As String
		'###########################################################################
		'PROJECT BIG SKY, JULY 2009     ROD COPELAND    ISSUE ID 6724
		'###########################################################################
		'CONVERT THE ICOMS ACCOUNT NUMBER AND PASS THE DATA INTO THE PROVISIONING 
		'SYSTEM AS A CSG CUSTOMER THAT HAS BEEN CONVERTED FROM ICOMS.
		'###########################################################################
		Dim objrequest As New GetDataRequest
		Dim objResponse As New GetDataResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'##############################################################################
			'N O T A B L E  ALTHOUGH THIS CALL IS GOING THROUGH EAI AND THEY NORMALLY TREAT 
			'ICOMS ACCOUNT NUMBERS LIKE .Substring(3, 9).  THIS CALL ON THE OTHER SIDE OF 
			'EAI IS REALLY GOING TO AN OSS DATABASE SO WE NEED TO PASS IN THE FULL 16 DIGITS 
			'FOR NORMAL OSS INTERACTIONS.
			'##############################################################################
			objrequest.AccountNumberICOMS = accountNumber






			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
			objResponse = CType(iProvider.FindCSGAccountNumber(objrequest), GetDataResponse)




			If Not objResponse.Exception Then
				'##########
				'GOOD
				'##########

				If Not (objResponse.ConvertedAccounts Is Nothing) Then

					For Each BillingAccount As ConvertedBillingAccount In objResponse.ConvertedAccounts
						If Not (BillingAccount.LinesOfBusiness Is Nothing) Then
							'###############################################################
							'"C" IS FOR CABLE    "I" IS FOR INTERNET   "T" IS FOR TELEPHONE
							'###############################################################
							If BillingAccount.LinesOfBusiness.ToUpper().Contains("I") Then
								'###########################
								'RETURN THIS ACCOUNT NUMBER.
								'###########################
								If Not (BillingAccount.AccountID Is Nothing) Then
									account.ConvertedBillingAccountsSummary = New List(Of BLConvertedBillingAccount)()

									Dim lConvertedBillingAccount As New BLConvertedBillingAccount
									lConvertedBillingAccount.AccountID = BillingAccount.AccountID.Trim()
									lConvertedBillingAccount.LinesOfBusiness = BillingAccount.LinesOfBusiness.Trim()
									lConvertedBillingAccount.PreconversionParentAccountNumber = accountNumber

									account.ConvertedBillingAccountsSummary.Add(lConvertedBillingAccount)


									'##############
									'Persist state
									'##############
									SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())


									Return BillingAccount.AccountID.Trim()
								End If
							End If
						End If
					Next
				End If





				Return Nothing

			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################

				Common.LogException(New Exception("Account Manager -Change contact Email Address failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)


				Return Nothing
			End If


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw
		End Try

	End Function

	Public Overrides Function GetCPNISecurityCode(ByVal trackingID As String, ByVal accountnumber As String, ByVal customerID As String) As String
		'###########################################################################
		'MyAcount Security Code Update, March 2010     Sriman kanuri
		'###########################################################################
		'Get Security Code for a Customer from CSG using EAI web services
		'Provides ability for the customer to update this value
		'###########################################################################

		Dim objrequest As New GetCustomerRequest
		Dim objResponse As New GetCustomerResponse
		Dim objcsgHeader As New CsgHeaderInfo

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingID)
			'#############
			'set Request object
			'*#############
			objrequest.customerID = customerID
			objcsgHeader.ConversationId = ""
			objcsgHeader.Region = ""
			objcsgHeader.RoutingArea = accountnumber.Substring(0, 6) & "00"
			objrequest.csgHeaderInfo = objcsgHeader

			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
			objResponse = CType(iProvider.GetCustomer(objrequest), GetCustomerResponse)
			Dim lSecurityCode As String

			If Not objResponse.Exception Then
				'##########
				'GOOD
				'##########


				If Not (objResponse.SecurityCode Is Nothing) Then
					lSecurityCode = objResponse.SecurityCode
					If Not (account Is Nothing) Then
						account.CPNISecuritycode = lSecurityCode
					End If
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
					Return lSecurityCode
				Else
					Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, your account does not have a current security code."
					'if no security code is retrieved send back nothng
					Return Nothing
				End If


			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to retrieve your security code."
				End Select
				'##################################################################################

				Common.LogException(New Exception("Account Manager - Get Customer  failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)


				Return Nothing
			End If




		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		End Try


	End Function

	Public Overrides Function UpdateCPNISecurityCode(ByVal trackingID As String, ByVal accountnumber As String, ByVal customerID As String, ByVal securityCode As String) As Boolean

		'###########################################################################
		'MyAcount Security Code Update, March 2010     Sriman kanuri
		'###########################################################################
		'Update Security Code for a Customer from CSG using EAI web services
		'Provides ability for the customer to update this value
		'###########################################################################

		Dim objrequest As New UpdateCustomFieldRequest
		Dim objResponse As New UpdateCustomFieldResponse
		Dim objcsgHeader As New CsgHeaderInfo
		Dim objCustomfield As New customFieldUpdate

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingID)
			'#############
			'set Request object
			'*#############
			objrequest.CustomerID = customerID
			objcsgHeader.ConversationId = ""
            objcsgHeader.Region = ""
            If Not (accountnumber Is Nothing) Then
                objcsgHeader.RoutingArea = accountnumber.Substring(0, 6) & "00"
            End If
            objrequest.CsgHeaderInfo = objcsgHeader

            objCustomfield.Index = "4" ' Security code code Index is always 4 in the custom field array 
            objCustomfield.Value = securityCode
            objrequest.CustomField = objCustomfield

            '################################
            'EXECUTE THE CALL TO THE PROVIDER
            '################################
            Dim iProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
            objResponse = CType(iProvider.UpdateCustomField(objrequest), UpdateCustomFieldResponse)

            If Not (objResponse Is Nothing) Then

                If Not objResponse.Exception Then
                    '##########
                    'GOOD
                    '##########

                    '##################################################################################
                    'Accourding Tim Warthen, 03/29/10 UPpdateCustomField call is considered successful,
                    'if the Response Result is successful and no result has no exception info 
                    'We do not have to check for any value in the response. We can safely assume
                    'that securityCode is safely updated. (In case we ever need, customField with Index 4
                    'on Response object can retrieve the new security code 
                    '##################################################################################
                    '##############
                    'Do we want to update the session with new code?
                    '#####################
                    If Not (account Is Nothing) Then
                        account.CPNISecuritycode = securityCode
                    End If
                    SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

                    Return True

                Else
                    Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to update your security code."
                    Return False

                End If

                'if no security code is retrieved send back nothng


            Else
                '##################################################################################
                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                '##################################################################################
                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                'ACCORDINGLY.
                '##################################################################################
                Select Case True
                    Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to update your security code."
                End Select
                '##################################################################################

                Common.LogException(New Exception("Account Manager - Update Security Code  failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)


                Return False
            End If




        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        End Try


	End Function

	Public Overrides Function GetLoginIDUserName(ByVal trackingID As String) As Boolean
		'###########################################################################
		'MyAcount Forgot UserName  April 2010     Sriman kanuri
		'###########################################################################
		'Get userName  for a Customer based on the account number provided using OSSAPI web services
		'Provides ability for the customer to retrieve the Username 
		'###########################################################################

		Dim objrequest As New GetLoginRequest
		Dim objResponse As New GetLoginResponse


		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingID)
			'#############
			'set Request object
			'*#############
			If Not (Me.MyAccountRetUNameAccount.AccountNumber Is Nothing) Then
				objrequest.AccountNumber = Me.MyAccountRetUNameAccount.AccountNumber


				'################################
				'EXECUTE THE CALL TO THE PROVIDER
				'################################
				Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
				objResponse = CType(iProvider.GetLoginID(objrequest), GetLoginResponse)


				If Not objResponse.Exception Then
					'##########
					'GOOD
					'##########


					If Not (objResponse.UserName Is Nothing) Then

						If Not (Me.MyAccountRetUNameAccount Is Nothing) Then
							Me.MyAccountRetUNameAccount.UserName = objResponse.UserName
                        End If
                        ''Save Security Question from the answer. this need to be set as the
                        'default question in the drop down list of Security questions
                        If Not (objResponse.SecretQuestion Is Nothing) Then
                            Me.account.SecurityQuestion = objResponse.SecretQuestion
                        End If

						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

						Return True
					Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, unable retrieve username for this account number."
						'if no security code is retrieved send back nothng
						Return False
					End If


				Else
					'##################################################################################
					'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
					'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
					'##################################################################################
					'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
					'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
					'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
					'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
					'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
					'ACCORDINGLY.
					'##################################################################################
					Select Case True
						Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
							Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
						Case Else
							Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to retrieve your username."
					End Select
					'##################################################################################

					Common.LogException(New Exception("Account Manager - Get Login username  failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)


					Return False
				End If

			End If




		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to retrieve your username."
			Throw ex
		End Try


	End Function

	'****************************************************************
	'JPIRKEY: 4-2010 MyAccount Update - Retrieve Username enhancement
	'****************************************************************
	Public Function GetAccountsForRetrieveUsername(ByVal TrackingID As String, ByVal AccountNumber As String, ByVal PhoneNumber As String, ByVal ZipCode As String) As BLRetUsernameStatus
		'submit the account number or phone number and return a list of accounts
		'cycle through results and narrow by zip. if only one account matches
		'return a success value. if no accounts exist or multiples exist, 
		'return an appropriate status value. 
		Dim iProvider As IEBSServicesProvider
		Dim objGetAccountsRequest As GetAccountsRequestCSG
		Dim objGetAccountsResponse As GetAccountsResponseCSG
		Dim _ReturnStatus As BLRetUsernameStatus
		Dim lCriteria As New AccountCriteriaCSG
        Dim _Accounts As New List(Of IRetUNameAccount)
		Dim _Questions As List(Of String)
		Dim iCounter As Integer
		Try

			PopulateLocalVariables(TrackingID)


			'if we have the account number, use that first, only use the phone number if we have to
			If Not AccountNumber Is Nothing AndAlso AccountNumber.Length = 16 Then
				lCriteria.Item = AccountNumber
				lCriteria.ItemElementName = ItemChoiceTypeCSG.AccountNumber
			Else
				'use the phone number
				lCriteria.Item = PhoneNumber
				lCriteria.ItemElementName = ItemChoiceTypeCSG.TelephoneNumber
			End If
            objGetAccountsRequest = New GetAccountsRequestCSG(Nothing, lCriteria)




            '#########################
            'DO THE PROVIDER CALL
            '#########################
            iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)
			objGetAccountsResponse = CType(iProvider.GetAccountsFromCSG(objGetAccountsRequest), GetAccountsResponseCSG)




            If objGetAccountsResponse.Exception Then
                _ReturnStatus = BLRetUsernameStatus.Error

                '##################################################################################
                '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
                '#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
                '##################################################################################
                'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
                'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
                'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
                'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
                'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
                'ACCORDINGLY.
                '##################################################################################
                Select Case True
                    Case Not objGetAccountsResponse.CharterDotCom_Friendly_Messages Is Nothing
                        Me._LastCCOMDisplayFriendlyExceptionMessage = objGetAccountsResponse.CharterDotCom_Friendly_Messages
                    Case Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "No accounts were found with the provided account number or phone number"
                End Select
                '##################################################################################
            Else
                If Not objGetAccountsResponse.Accounts Is Nothing Then
                    If objGetAccountsResponse.Accounts.Length() > 0 Then



                        For Each lAccount As AccountCSG In objGetAccountsResponse.Accounts
                            Dim _RetAcct As New BLRetUserNameAccount
                            If lAccount.ConnectStatus <> ConnectStatus.ChargedOff AndAlso _
                            lAccount.ConnectStatus <> ConnectStatus.VoluntaryDisconnect Then


                                If lAccount.ZipCode IsNot Nothing AndAlso lAccount.ZipCode.Length() > 4 Then
                                    _RetAcct.ZipCode = lAccount.ZipCode.Substring(0, 5)
                                End If

                                If Not (lAccount.AccountId Is Nothing) Then
                                    _RetAcct.AccountNumber = lAccount.AccountId
                                End If


                                _Accounts.Add(_RetAcct)
                            End If
                        Next



                        '#####################################################################
                        'DO A COUNT OF HOW MANY ACCOUNTS HAVE A MATCHING ZIP CODE, IDEALLY THIS 
                        'SHOULD BE ONE, IF MORE THAN ONE ACCOUNT MATCHES, THEY HAVE TO CALL A 
                        'CSR SO TREAT AS AN ERROR RESPONSE.
                        '#####################################################################
                        For Each act As BLRetUserNameAccount In _Accounts
                            If act.ZipCode = ZipCode Then
                                iCounter += 1
                            End If
                            If iCounter > 1 Then Exit For 'just need to know if its a multiple at most
                        Next



                        If iCounter > 1 Then
                            _ReturnStatus = BLRetUsernameStatus.Mutliple
                        ElseIf iCounter = 1 Then
                            _ReturnStatus = BLRetUsernameStatus.Success

                            '#########################################################
                            'now we need to get the secret question for this account:
                            '#########################################################
                            _Questions = GetSecurityQuestion(TrackingID, _Accounts(0).AccountNumber)


                            If Not _Questions Is Nothing AndAlso _Questions.Count > 0 Then
                                Me.MyAccountRetUNameAccount.SecretQuestion = _Questions(0)
                                Me.MyAccountRetUNameAccount.AccountNumber = _Accounts(0).AccountNumber
                                Me.MyAccountRetUNameAccount.ZipCode = _Accounts(0).ZipCode
                            Else
                                '########################################################################
                                'MODIFICATION   ROD COPELAND    MAY 19TH, 2010  Issue ID:  9343
                                '########################################################################
                                'OSS DID NOT RETURN A QUESTION WHICH MEANS, THEY COULD NOT FIND THE 
                                'ACCOUNT NUMBER PROVIDED TO THEM OR THEY RESPONDED WITH A WS 
                                'EXCEPTION OF SOME TYPE.  EITHER CASE, THIS IS A UI EXCEPTION TO HANDLE.
                                '########################################################################
                                _ReturnStatus = BLRetUsernameStatus.Error
                            End If
                        Else
                            '##################################################
                            'THEY WOULD HAVE ZERO ACCOUNTS THAT MATCH THE ZIP.
                            '##################################################
                            _ReturnStatus = BLRetUsernameStatus.Error
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Our system is unable to provide the information necessary to obtain your username online at this time.  Please call 1-888-438-2427 for assistance."
                        End If

                    Else
                        Me._LastCCOMDisplayFriendlyExceptionMessage = "Our system is unable to provide the information necessary to obtain your username online at this time.  Please call 1-888-438-2427 for assistance."
                        _ReturnStatus = BLRetUsernameStatus.Error

                    End If
                End If

            End If

		Catch ex As Exception
			_ReturnStatus = BLRetUsernameStatus.Error
		Finally
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
			iProvider = Nothing
		End Try
		Return _ReturnStatus
	End Function

	'****************************************************************
	'JPIRKEY: 4-2010 MyAccount Update - Retrieve Username enhancement
	'****************************************************************
	Public Function GetMyAccountRetUNameAccount(ByVal trackingid As String) As IRetUNameAccount
		PopulateLocalVariables(trackingid)
		Return Me.MyAccountRetUNameAccount
	End Function

	Private Property MyAccountRetUNameAccount() As BLRetUserNameAccount
		Get
			If m_MyAccountRetUserName Is Nothing Then
				m_MyAccountRetUserName = New BLRetUserNameAccount
			End If
			Return m_MyAccountRetUserName
		End Get
		Set(ByVal value As BLRetUserNameAccount)
			m_MyAccountRetUserName = value
		End Set
	End Property

#End Region

#Region "Manage Email"

	Public Overrides Sub GetEmailAccounts(ByVal trackingid As String)
		Dim objRequest As New GetEmailAddressListForLoginRequest
		Dim objResponse As New GetEmailAddressListForLoginResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'##########################################################################################################
			'BUILD THE COLLECTION OF PACKAGES (WHICH CONTAIN EMAILS ASSIGNED TO THE PACKAGE THAT CONTAINS IT).  
			'EACH PACKAGE HAS ITS OWN PROVISIONING ID WHICH IS USED TO CREATE NEW EMAIL ACCOUNTS FOR THAT PACKAGE.
			'ALL EMAIL ACCOUNTS UNDER A PACKAGE SHOULD SHARE THE SAME PROVISIONING ID.
			'##########################################################################################################
			If Not (account Is Nothing) Then

				'#############################################################################
				'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
				'#############################################################################
				'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
				'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
				'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
				'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
				'IN THIS CASE, TO KEEP FROM DOING 
				'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
				'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
				'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
				'#############################################################################
				If Not account.MyAccountCachedPropertyNames Is Nothing Then
					If Not account.MyAccountCachedPropertyNames.Contains("email") Then



						If Not (account.User Is Nothing) Then
							If Not (account.User.MSPackageInfo Is Nothing) Then
								If (account.User.MSPackageInfo.Count > 0) Then
									For Each AccountObjPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
										If AccountObjPackage.emailsField Is Nothing Then
											objRequest.csrLogin = CSRLOGIN
											objRequest.csrPassword = CSRPASSWORD
											objRequest.userName = account.LoginID


											'#############################################################################
											'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
											'#############################################################################
											'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
											'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
											'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
											'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
											'IN THIS CASE, TO KEEP FROM DOING 
											'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
											'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
											'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
											'#############################################################################
											If Not account.MyAccountCachedPropertyNames.Contains("email") Then
												account.MyAccountCachedPropertyNames.Add("email")

												'##############
												'Persist state
												'##############
												SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
											End If


											'################################
											'EXECUTE THE CALL TO THE PROVIDER
											'################################
											Dim lProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
											objResponse = CType(lProvider.GetEmailAddressListForLogin(objRequest), GetEmailAddressListForLoginResponse)

											If Not (objResponse.Exception) Then
												'#############################################
												'THEN DO A WEB SERVICE CALL AND SEE IF ANY 
												'EXIST SO A UPDATE CAN BE DONE LOCALLY ON 
												'THE ACCOUNT OBJECT.
												'#############################################
												Call BuildMSPackage_ForGetEmailAccounts(objResponse)
											Else
												'##################################################################################
												'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
												'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
												'##################################################################################
												'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
												'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
												'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
												'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
												'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
												'ACCORDINGLY.
												'##################################################################################
												Select Case True
													Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
														Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
													Case Else
														Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
												End Select
												'##################################################################################


												'##############
												'Persist state
												'##############
												SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



											End If

										Else
											'############################################################
											'SINCE THEY ALREADY HAVE A SECURITY KEY COLLECTION, LETS 
											'NOT DO ANOTHER WEB SERVICE REQUEST TO UPDATE VALUES THAT 
											'LIKELY HAVENT CHANGED ANYWAY.
											'############################################################
										End If
									Next
								End If
							End If
						End If




					End If
				End If

			End If



			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objRequest = Nothing
			objResponse = Nothing
		End Try
	End Sub
	Private Sub BuildMSPackage_ForGetEmailAccounts(ByVal objResponse As EntityMemberServices.GetEmailAddressListForLoginResponse)
		'##########################################################################################################
		'BUILD THE COLLECTION OF PACKAGES (WHICH CONTAIN EMAILS ASSIGNED TO THE PACKAGE THAT CONTAINS IT).  
		'EACH PACKAGE HAS ITS OWN PROVISIONING ID WHICH IS USED TO CREATE NEW EMAIL ACCOUNTS FOR THAT PACKAGE.
		'ALL EMAIL ACCOUNTS UNDER A PACKAGE SHOULD SHARE THE SAME PROVISIONING ID.
		'##########################################################################################################
		If Not (objResponse Is Nothing) Then
			If Not objResponse.families Is Nothing Then
				If account.User Is Nothing Then
					account.User = New BLAccount.BLMember
				End If
				If account.User.MSPackageInfo Is Nothing Then
					account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
				End If

				For Each objPackage As EntityMemberServices.PackageInfo In objResponse.families
					If Not (objPackage Is Nothing) Then
						'############################
						'BUILD THE PACKAGE
						'############################
						Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo()

						If Not (objPackage.emails Is Nothing) Then
							lPackage.emailsField = New List(Of IAccount.IMember.IMemberServiceEmailInfo)
							For Each objEmail As EntityMemberServices.EmailInfo In objPackage.emails
								If Not (objEmail Is Nothing) Then
									'#########################################
									'CREATE NEW EMAIL TO ADD TO THE PACKAGE
									'#########################################
									Dim newEmail As New BLAccount.BLMember.BLMSEmailInfo
									If Not (objEmail.domain Is Nothing) Then
										newEmail.domainField = objEmail.domain
									End If
									If Not (objEmail.HOHStatus Is Nothing) Then
										newEmail.hOHStatusField = objEmail.HOHStatus
										Select Case objEmail.HOHStatus.ToString().Trim().ToUpper()
											Case "P" 'MEANS PARENT EMAIL ACCOUNT
												newEmail.IsParentEAddress = True
											Case "C" 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
											Case Else 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
										End Select
									End If
									If Not (objEmail.provisioningId Is Nothing) Then
										newEmail.provisioningIdField = objEmail.provisioningId
									End If
									If Not (objEmail.status Is Nothing) Then
										newEmail.statusField = objEmail.status
									End If
									If Not (objEmail.userName Is Nothing) Then
										newEmail.userNameField = objEmail.userName
									End If

									lPackage.emailsField.Add(newEmail)
								End If
							Next
						End If

						If Not (objPackage.provisioningId Is Nothing) Then
							lPackage.provisioningIdField = objPackage.provisioningId
						End If


						'#####################################################
						'CHECK TO SEE IF PACKAGE ALREADY EXISTS IN USER obj FIRST.
						'THIS CHECK IS DONE TO POTENTIALLY SAVE THE WEBSPACE 
						'NAME FOR A GIVEN PACKAGE ON AN EXISTING PACKAGE SINCE 
						'THE PROVIDER CALL FOR THE EMAIL LIST DOESNT RETURN THE 
						'WEBSPACE INFO WITH IT.  SINCE WE WANT TO SAVE THE WEBSPACE 
						'INFO WE JUST PLACE IT IN A TEMP VARIABLE, ASSIGN THE EMAIL 
						'LIST THEN ASSIGN THE WEBSPACE INFO BACK TO THE PACKAGE.
						'#####################################################
						For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
							'######################################################################################
							'THIS CONDITION CHECKS TO SEE IF THE EMAIL VALUE IS NOTHING, IF SO, IT WILL 
							'ASSIGN A NEWLY INSTANTIATED VALUE THAT HAS NO VALUES IN IT, JUST SO ITS NOT NOTHING.  
							'WHEN THE GET EMAIL ACCOUNTS METHOD IS CALLED FROM THE PAGE, IT WILL CHECK THIS 
							'VALUE IF ITS NOTHING OR NOT.  IF ITS NOTHING IT WILL MAKE A WEB SERVICE CALL TO GO 
							'AND CHECK IF THERE IS A VALUE. TO AVOID GOING BACK EVERY TIME SINCE ONE OF THE 
							'PACKAGES IN THE COLLECTION MAY HAVE NOT HAVE EMAIL ACCOUNTS ALLOWED, GIVING A VALUE OF 
							'SOMETHING OTHER THAN NOTHING SHOULD STOP THAT WEB SERVICE CALL FROM BEING MADE. 
							'THIS IS UNTIL SOMEONE CHANGES THAT GET SECURITY KEYS METHOD.
							'######################################################################################
							If userPackage.emailsField Is Nothing Then
								userPackage.emailsField = New List(Of IAccount.IMember.IMemberServiceEmailInfo)
							End If

							If userPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
								userPackage.emailsField = lPackage.emailsField
							End If
						Next


						'##############
						'Persist state
						'##############
						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
					End If
				Next
			End If
		End If
	End Sub

	Private Sub BuildMSPackage(ByVal objResponse As EntityMemberServices.GetEmailAddressListForLoginResponse)

		'##########################################################################################################
		'BUILD THE COLLECTION OF PACKAGES (WHICH CONTAIN EMAILS ASSIGNED TO THE PACKAGE THAT CONTAINS IT).  
		'EACH PACKAGE HAS ITS OWN PROVISIONING ID WHICH IS USED TO CREATE NEW EMAIL ACCOUNTS FOR THAT PACKAGE.
		'ALL EMAIL ACCOUNTS UNDER A PACKAGE SHOULD SHARE THE SAME PROVISIONING ID.
		'##########################################################################################################
		If Not (objResponse Is Nothing) Then
			If Not objResponse.families Is Nothing Then
				If account.User Is Nothing Then
					account.User = New BLAccount.BLMember
				End If
				If account.User.MSPackageInfo Is Nothing Then
					account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
				End If

				For Each objPackage As EntityMemberServices.PackageInfo In objResponse.families
					If Not (objPackage Is Nothing) Then
						'############################
						'BUILD THE PACKAGE
						'############################
						Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo()

						If Not (objPackage.description Is Nothing) Then
							lPackage.descriptionField = objPackage.description
						End If

						If Not (objPackage.emails Is Nothing) Then
							lPackage.emailsField = New List(Of IAccount.IMember.IMemberServiceEmailInfo)
							For Each objEmail As EntityMemberServices.EmailInfo In objPackage.emails
								If Not (objEmail Is Nothing) Then
									'#########################################
									'CREATE NEW EMAIL TO ADD TO THE PACKAGE
									'#########################################
									Dim newEmail As New BLAccount.BLMember.BLMSEmailInfo
									If Not (objEmail.domain Is Nothing) Then
										newEmail.domainField = objEmail.domain
									End If
									If Not (objEmail.HOHStatus Is Nothing) Then
										newEmail.hOHStatusField = objEmail.HOHStatus
										Select Case objEmail.HOHStatus.ToString().Trim().ToUpper()
											Case "P" 'MEANS PARENT EMAIL ACCOUNT
												newEmail.IsParentEAddress = True
											Case "C" 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
											Case Else 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
										End Select
									End If
									If Not (objEmail.provisioningId Is Nothing) Then
										newEmail.provisioningIdField = objEmail.provisioningId
									End If
									If Not (objEmail.status Is Nothing) Then
										newEmail.statusField = objEmail.status
									End If
									If Not (objEmail.userName Is Nothing) Then
										newEmail.userNameField = objEmail.userName
									End If

									lPackage.emailsField.Add(newEmail)
								End If
							Next
						End If

						If Not (objPackage.provisioningId Is Nothing) Then
							lPackage.provisioningIdField = objPackage.provisioningId
						End If
						If Not (objPackage.status Is Nothing) Then
							lPackage.statusField = objPackage.status
						End If
						If Not (objPackage.type Is Nothing) Then
							lPackage.typeField = objPackage.type
						End If


						'#####################################################
						'CHECK TO SEE IF PACKAGE ALREADY EXISTS IN USER obj FIRST.
						'THIS CHECK IS DONE TO POTENTIALLY SAVE THE WEBSPACE 
						'NAME FOR A GIVEN PACKAGE ON AN EXISTING PACKAGE SINCE 
						'THE PROVIDER CALL FOR THE EMAIL LIST DOESNT RETURN THE 
						'WEBSPACE INFO WITH IT.  SINCE WE WANT TO SAVE THE WEBSPACE 
						'INFO WE JUST PLACE IT IN A TEMP VARIABLE, ASSIGN THE EMAIL 
						'LIST THEN ASSIGN THE WEBSPACE INFO BACK TO THE PACKAGE.
						'#####################################################
						For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
							If userPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
								lPackage.webspaceField = userPackage.webspaceField
								account.User.MSPackageInfo.Remove(userPackage)
								Exit For
							End If
						Next



						'############################
						'ADD THE PACKAGE JUST BUILT.
						'############################
						account.User.MSPackageInfo.Add(lPackage)
					End If
				Next
			End If
		End If
	End Sub

	Private Sub BuildMSPackage(ByVal objResponse As ConfigProvider.GetEmailAddressListForLoginResponse)

		'##########################################################################################################
		'BUILD THE COLLECTION OF PACKAGES (WHICH CONTAIN EMAILS ASSIGNED TO THE PACKAGE THAT CONTAINS IT).  
		'EACH PACKAGE HAS ITS OWN PROVISIONING ID WHICH IS USED TO CREATE NEW EMAIL ACCOUNTS FOR THAT PACKAGE.
		'ALL EMAIL ACCOUNTS UNDER A PACKAGE SHOULD SHARE THE SAME PROVISIONING ID.
		'##########################################################################################################
		If Not (objResponse Is Nothing) Then
			If Not objResponse.families Is Nothing Then
				If account.User Is Nothing Then
					account.User = New BLAccount.BLMember
				End If
				If account.User.MSPackageInfo Is Nothing Then
					account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
				End If

				'For Each objPackage As EntityMemberServices.PackageInfo In objResponse.families
				For Each objPackage As ConfigProvider.PackageInfo In objResponse.families
					If Not (objPackage Is Nothing) Then
						'############################
						'BUILD THE PACKAGE
						'############################
						Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo()

						If (objPackage.MaxEmailsAllowed > 0) Then
							lPackage.MaxEmailsAllowed = objPackage.MaxEmailsAllowed
						End If

						If Not (objPackage.description Is Nothing) Then
							lPackage.descriptionField = objPackage.description
						End If


						If Not (objPackage.emails Is Nothing) Then
							lPackage.emailsField = New List(Of IAccount.IMember.IMemberServiceEmailInfo)
							'For Each objEmail As EntityMemberServices.EmailInfo In objPackage.emails
							For Each objEmail As ConfigProvider.EmailInfo In objPackage.emails
								If Not (objEmail Is Nothing) Then
									'#########################################
									'CREATE NEW EMAIL TO ADD TO THE PACKAGE
									'#########################################
									Dim newEmail As New BLAccount.BLMember.BLMSEmailInfo
									If Not (objEmail.domain Is Nothing) Then
										newEmail.domainField = objEmail.domain
									End If
									If Not (objEmail.HOHStatus Is Nothing) Then
										newEmail.hOHStatusField = objEmail.HOHStatus
										Select Case objEmail.HOHStatus.ToString().Trim().ToUpper()
											Case "P" 'MEANS PARENT EMAIL ACCOUNT
												newEmail.IsParentEAddress = True
											Case "C" 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
											Case Else 'MEANS CHILD EMAIL ACCOUNT
												newEmail.IsParentEAddress = False
										End Select
									End If
									If Not (objEmail.provisioningId Is Nothing) Then
										newEmail.provisioningIdField = objEmail.provisioningId
									End If
									If Not (objEmail.status Is Nothing) Then
										newEmail.statusField = objEmail.status
									End If
									If Not (objEmail.userName Is Nothing) Then
										newEmail.userNameField = objEmail.userName
									End If

									lPackage.emailsField.Add(newEmail)
								End If
							Next
						End If

						If Not (objPackage.provisioningId Is Nothing) Then
							lPackage.provisioningIdField = objPackage.provisioningId
						End If
						If Not (objPackage.status Is Nothing) Then
							lPackage.statusField = objPackage.status
						End If
						If Not (objPackage.type Is Nothing) Then
							lPackage.typeField = objPackage.type
						End If


						'#####################################################
						'CHECK TO SEE IF PACKAGE ALREADY EXISTS IN USER obj FIRST.
						'THIS CHECK IS DONE TO POTENTIALLY SAVE THE WEBSPACE 
						'NAME FOR A GIVEN PACKAGE ON AN EXISTING PACKAGE SINCE 
						'THE PROVIDER CALL FOR THE EMAIL LIST DOESNT RETURN THE 
						'WEBSPACE INFO WITH IT.  SINCE WE WANT TO SAVE THE WEBSPACE 
						'INFO WE JUST PLACE IT IN A TEMP VARIABLE, ASSIGN THE EMAIL 
						'LIST THEN ASSIGN THE WEBSPACE INFO BACK TO THE PACKAGE.
						'#####################################################
						For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
							If userPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
								lPackage.webspaceField = userPackage.webspaceField
								account.User.MSPackageInfo.Remove(userPackage)
								Exit For
							End If
						Next



						'############################
						'ADD THE PACKAGE JUST BUILT.
						'############################
						account.User.MSPackageInfo.Add(lPackage)
					End If
				Next
			End If
		End If
	End Sub


	Public Overrides Function AddEmailAccount(ByVal trackingid As String, ByVal eMailID As String, ByVal password As String, ByVal lProvisioningID As String) As Boolean
		Dim objRequest As New CreateEmailAccountRequest
		Dim objResponse As New TheCommonResponse
		Dim strDomain As String

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)

			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objRequest.accountId = account.OSSProvidedAccountNumber

			objRequest.provisionId = lProvisioningID
			objRequest.csrlogin = CSRLOGIN
			objRequest.csrpassword = CSRPASSWORD
			If InStr(eMailID, "@") > 0 Then
				strDomain = Right(eMailID, Len(eMailID) - InStr(eMailID, "@"))
				objRequest.emailLogin = eMailID.Substring(0, InStr(eMailID, "@") - 1)
			Else
				Return False
			End If
			objRequest.emailPassword = password
			objRequest.emailDomain = strDomain



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim lProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(lProvider.CreateEmailAccount(objRequest), TheCommonResponse)



			If Not objResponse.Exception Then
				'###########################################################
				'ADD THE NEWLY CREATED EMAIL ADDRESS TO THE CORRECT PACKAGE 
				'###########################################################
				If Not (account Is Nothing) Then
					If Not (account.User Is Nothing) Then
						If Not (account.User.MSPackageInfo Is Nothing) Then
							For Each lpackage As IAccount.IMember.IMemberServicePackageInfo In account.User.MSPackageInfo
								If lpackage.provisioningIdField = lProvisioningID Then
									If lpackage.emailsField Is Nothing Then
										lpackage.emailsField = New List(Of IAccount.IMember.IMemberServiceEmailInfo)
									End If
									Dim email As New BLAccount.BLMember.BLMSEmailInfo
									email.domainField = strDomain
									email.IsParentEAddress = False
									email.provisioningIdField = lProvisioningID
									email.userNameField = eMailID.Substring(0, InStr(eMailID, "@") - 1)
									lpackage.emailsField.Add(email)
								End If
							Next
						End If
					End If
				End If




				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
				Return True
			Else

				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Return False
				Common.LogException(New Exception("Account Manager -Add Email Account failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objRequest = Nothing
			objResponse = Nothing
		End Try
	End Function


	Private Function GetAccountNumberWithoutStatementCode(ByVal strSpecificAccountNumSelectedByUser As String) As String
		'##################################################################################
		'MODIFICATION   ROD COPELAND    Issue ID:  7334 BIG SKY FIX FOR MULTI-STATEMENTS
		'##################################################################################

		'#################################################################
		'ASSIGN THE CORRECT BILLING ACCOUNT NUMBER TO THE REQUEST OBJECT
		'AMONG OTHER THINGS, THIS SHOULD TAKE OFF THE STATEMENT CODE THAT 
		'IS SOMETIMES APPENDED TO THE ACCOUNT NUMBER
		'#################################################################
		Dim outAccountID As String = ""
		If Not (account Is Nothing) Then
			If Not (account.Bill Is Nothing) Then
				If account.Bill.Count() > 0 Then
					If Not (account.Bill(0).AccountNumber Is Nothing) Then
						Select Case account.BillingVendorType
							Case BillingVendorType.CSG

								If strSpecificAccountNumSelectedByUser Is Nothing Then
									'###############################################################
									'THE USER MAY HAVE CLICKED A MY BILL TAB OR THE MY SERVICES TAB, 
									'BOTH OF WHICH DO NOT INDICATE A SPECIFIC ACCOUNT NUMBER TO BE 
									'PASSED TO THE OSS WS CALL TO LINK OVER TO THE BILL VENDOR DOMAIN 
									'PASSING THAT SPECIFIC ACCOUNT NUMBER.
									'###############################################################
									'DO THE OLD WAY OF GETTING ACCOUNT NUMBER, WHICH COMES FROM OSS 
									'AUTHENTICATION CALL THAT HAPPENS AT INITIAL LOGIN FOR THE USER.
									'###############################################################
									If account.OSSProvidedAccountNumber.Length > 15 Then
										outAccountID = account.OSSProvidedAccountNumber.Substring(0, 16)
									Else
										outAccountID = account.OSSProvidedAccountNumber
									End If
									Return outAccountID
								End If

								Dim blnUseAccountSpecificEpayLinkNumbers As Boolean = False

								If System.Web.HttpContext.Current.Application("USE_ACCOUNT_SPECIFIC_EPAY_LINK_NUMBERS") IsNot Nothing Then
									If System.Web.HttpContext.Current.Application("USE_ACCOUNT_SPECIFIC_EPAY_LINK_NUMBERS").ToString().Trim().ToUpper() = "T" Then
										'#####################################################################################
										'DO THE NEW WAY OF GETTING ACCOUNT SPECIFIC ACCOUNT NUMBERS PASSED TO THE EPAY LINK, 
										'CSG WILL NEED TO READ THIS SPECIFIC ACCOUNT NUMBER WHICH WILL GET PASSED IN THE 
										'ENCRYPTED STRING.
										'#####################################################################################
										blnUseAccountSpecificEpayLinkNumbers = True

										If strSpecificAccountNumSelectedByUser IsNot Nothing Then
											If strSpecificAccountNumSelectedByUser.Length > 15 Then
												outAccountID = strSpecificAccountNumSelectedByUser.Substring(0, 16)
											Else
												outAccountID = strSpecificAccountNumSelectedByUser
											End If
										End If
									End If
								End If

								If Not blnUseAccountSpecificEpayLinkNumbers Then
									'###############################################################
									'DO THE OLD WAY OF GETTING ACCOUNT NUMBER, WHICH COMES FROM OSS 
									'AUTHENTICATION CALL THAT HAPPENS AT INITIAL LOGIN FOR THE USER.
									'###############################################################
									If account.OSSProvidedAccountNumber.Length > 15 Then
										outAccountID = account.OSSProvidedAccountNumber.Substring(0, 16)
									Else
										outAccountID = account.OSSProvidedAccountNumber
									End If
								End If

							Case Else
								'###############################################################
								'DO THE OLD WAY OF GETTING ACCOUNT NUMBER, WHICH COMES FROM OSS 
								'AUTHENTICATION CALL THAT HAPPENS AT INITIAL LOGIN FOR THE USER.
								'###############################################################
								If account.OSSProvidedAccountNumber.Length > 15 Then
									outAccountID = account.OSSProvidedAccountNumber.Substring(0, 16)
								Else
									outAccountID = account.OSSProvidedAccountNumber
								End If
						End Select
					End If
				End If
			End If
		End If

		Return outAccountID

	End Function



	Private Function GetAccountNumberWithoutStatementCode() As String
		'#################################################################
		'ASSIGN THE CORRECT BILLING ACCOUNT NUMBER TO THE REQUEST OBJECT
		'AMONG OTHER THINGS, THIS SHOULD TAKE OFF THE STATEMENT CODE THAT 
		'IS SOMETIMES APPENDED TO THE ACCOUNT NUMBER
		'#################################################################
		Dim outAccountID As String = ""
		If Not (account Is Nothing) Then
			If Not (account.Bill Is Nothing) Then
				If account.Bill.Count() > 0 Then
					If Not (account.Bill(0).AccountNumber Is Nothing) Then
						Select Case account.BillingVendorType
							Case BillingVendorType.CSG
								If account.Bill(0).AccountNumber.Length > 15 Then
									outAccountID = account.Bill(0).AccountNumber.Substring(0, 16)
								Else
									outAccountID = account.Bill(0).AccountNumber
								End If

							Case BillingVendorType.ICOM
								If account.Bill(0).AccountNumber.Length > 18 Then
									outAccountID = account.Bill(0).AccountNumber.Substring(0, 19)
								Else
									outAccountID = account.Bill(0).AccountNumber
								End If
							Case Else
								outAccountID = account.Bill(0).AccountNumber
						End Select
					End If
				End If
			End If
		End If

		Return outAccountID

	End Function

	Public Overrides Function ActivateMSSecurityKey(ByVal trackingid As String, ByVal ProvisioningID As String) As Boolean
		Dim objRequest As New ActivateMSSecurityKeyRequest
		Dim objResponse As New ActivateMSSecurityKeyResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objRequest.accountId = account.OSSProvidedAccountNumber

			objRequest.CSRlogin = CSRLOGIN
			objRequest.CSRpassword = CSRPASSWORD
			objRequest.provisioningId = ProvisioningID



			'#################################
			'EXECUTE THE CALL TO PROVIDER
			'#################################
			Dim lProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(lProvider.ActivateMSSecurityKey(objRequest), ActivateMSSecurityKeyResponse)



			If Not objResponse.Exception Then
				Dim objMSSecurityKeysRequest As New GetMSSecurityKeysRequest
				Dim objMSSecurityKeysResponse As New GetMSSecurityKeysResponse

				'########################################################
				'MODIFICATION   ROD COPELAND    ISSUE ID:7780
				'########################################################
				'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
				'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
				'########################################################
				objRequest.accountId = account.OSSProvidedAccountNumber

				objMSSecurityKeysRequest.csrLogin = CSRLOGIN
				objMSSecurityKeysRequest.csrPassword = CSRPASSWORD
				objMSSecurityKeysRequest.type = "SECURITYKEY"


				'#################################
				'EXECUTE THE CALL TO PROVIDER
				'#################################
				objMSSecurityKeysResponse = CType(lProvider.GetMSSecurityKeys(objMSSecurityKeysRequest), GetMSSecurityKeysResponse)

				''############################################################
				''POPULATE THE SECURITY KEY VALUES FOR A GIVEN ACCOUNT.
				''############################################################
				'If Not (objMSSecurityKeysResponse Is Nothing) Then
				'    If Not (objMSSecurityKeysResponse.securityKeyArray Is Nothing) Then
				'        If objMSSecurityKeysResponse.securityKeyArray.Length > 0 Then
				'            'account.SecurityKeys = New List(Of String)
				'            'For Each SK As String In objMSSecurityKeysResponse.securityKeyArray
				'            '    account.SecurityKeys.Add(SK)
				'            'Next
				'        End If
				'    End If
				'End If




				If Not (objMSSecurityKeysResponse Is Nothing) Then
					If Not (objMSSecurityKeysResponse.packageArray Is Nothing) Then
						'######################
						'LOOP THROUGH PACKAGES
						'######################
						For i As Integer = 0 To objMSSecurityKeysResponse.packageArray.GetUpperBound(0)
							Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo

							lPackage.provisioningIdField = objMSSecurityKeysResponse.packageArray(i).provisioningId



							'##############################################################
							'LOOP THROUGH SECURITYKEYS AND BUILD THE TEMP PACKAGE OBJECT.
							'##############################################################
							lPackage.SecurityKeys = New List(Of String)
							For i2 As Integer = 0 To objMSSecurityKeysResponse.packageArray(i).securityKeysArray.KeysArray.GetUpperBound(0)
								lPackage.SecurityKeys.Add(objMSSecurityKeysResponse.packageArray(i).securityKeysArray.KeysArray(i2))
							Next

							'##############################################################
							'SEARCH FOR THE PROVISIONING ID IN THE EXISTING PACKAGES TO SEE 
							'IF ANY OF THEM NEED TO BE UPDATED WITH THESE SECURITY KEYS.
							'##############################################################

							If account Is Nothing Then
								account = New BLAccount
							End If
							If account.User Is Nothing Then
								account.User = New BLAccount.BLMember
							End If
							If account.User.MSPackageInfo Is Nothing Then
								account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
							End If
							If account.User.MSPackageInfo.Count > 0 Then
								'############################################
								'MODIFY AN EXISITNG PACKAGE IN THE COLLECTION
								'############################################
								For Each acctPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
									If acctPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
										acctPackage.SecurityKeys = lPackage.SecurityKeys
									End If
								Next
							Else
								'#####################################
								'ADD A NEW PACKAGE TO THE COLLECTION
								'#####################################
								account.User.MSPackageInfo.Add(lPackage)
							End If
						Next



						'#############################################################
						'NO NEED TO DO A CALL TO GET THE MAX KEY COUNT AVAIL, 
						'THIS VALUE SHOULDNT CHANGE WHILE THE USER IS ON THE SITE. 
						'NEXT TIME THEY LOG IN IT WILL LIKE CHANGE THEY PERHAPS, 
						'NOT RIGHT NOW, ODDS ARE AGAINST IT.
						'#############################################################
					End If
				End If





				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
				Return True
			Else

				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Return False
				Common.LogException(New Exception("Account Manager - Activate MS Security Key failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
			End If




		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objRequest = Nothing
			objResponse = Nothing
		End Try
	End Function



	Public Overrides Function ChangeAccountEmailPassword(ByVal trackingid As String, ByVal eMailID As String, ByVal newPassword As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeEmailPasswordRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			objrequest.emailAddress = eMailID
			objrequest.emailPassword = newPassword


			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.ChangeEmailPassword(objrequest), TheCommonResponse)



			If Not objResponse.Exception Then
				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Change Account Email Password failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objrequest = Nothing
			objResponse = Nothing
		End Try
	End Function

	'Public Function UpdateEmailAccount(ByVal emailID As String, ByVal password As String) As String

	'End Function

	Public Overrides Function DeleteEmailAccount(ByVal trackingid As String, ByVal eMailID As String) As Boolean
		Dim objrequest As New EntityMemberServices.RemoveEmailAccountRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			objrequest.preferedEmailId = eMailID



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.RemoveEmailAccount(objrequest), TheCommonResponse)




			If Not objResponse.Exception Then
				'###########################################################
				'REMOVE THE EMAIL ADDRESS FROM THE CORRECT PACKAGE 
				'###########################################################
				If Not (account Is Nothing) Then
					If Not (account.User Is Nothing) Then
						If Not (account.User.MSPackageInfo Is Nothing) Then
							For Each lpackage As IAccount.IMember.IMemberServicePackageInfo In account.User.MSPackageInfo
								For Each objMail As BLAccount.BLMember.BLMSEmailInfo In lpackage.emailsField
									If objMail.FullEmailAddress = eMailID Then
										lpackage.emailsField.Remove(objMail)
										SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
										Exit For
									End If
								Next
							Next
						End If
					End If
				End If


				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Delete E-Mail account failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objrequest = Nothing
			objResponse = Nothing
		End Try
	End Function

	Public Overrides Function ChangePrimaryEmail(ByVal trackingid As String, ByVal emailID As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeMSEmailToPrimaryRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			objrequest.csrlogin = CSRLOGIN
			objrequest.csrpassword = CSRPASSWORD
			objrequest.userName = account.LoginID
			objrequest.emailAddress = emailID




			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.ChangeMSEmailToPrimary(objrequest), TheCommonResponse)




			If Not objResponse.Exception Then
				'###########################################################
				'REMOVE THE EMAIL ADDRESS FROM THE CORRECT PACKAGE 
				'###########################################################
				If Not (account Is Nothing) Then
					If Not (account.User Is Nothing) Then
						If Not (account.User.MSPackageInfo Is Nothing) Then
							For Each lpackage As IAccount.IMember.IMemberServicePackageInfo In account.User.MSPackageInfo
								'###################################################
								'CHANGE THE EMAIL ID JUST PASSED IN TO THE PRIMARY
								'###################################################
								Dim blnSwitch As Boolean = False
								For Each objMail As BLAccount.BLMember.BLMSEmailInfo In lpackage.emailsField
									If objMail.FullEmailAddress = emailID Then
										objMail.IsParentEAddress = True
										objMail.hOHStatusField = "P"
										blnSwitch = True
									End If
								Next
								If blnSwitch Then
									'#############################################
									'GO BACK AND SWITCH THE OLD PRIMARY TO FALSE
									'#############################################
									For Each objMail As BLAccount.BLMember.BLMSEmailInfo In lpackage.emailsField
										If objMail.FullEmailAddress <> emailID Then
											objMail.IsParentEAddress = False
											objMail.hOHStatusField = "C"
										End If
									Next

									'###############################################
									'SET TO SESSION ONLY WHEN SOMETHING HAS CHANGED
									'###############################################
									SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)
								End If
							Next
						End If
					End If
				End If

				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())




				Common.LogException(New Exception("Account Manager -Change Primary Email failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objrequest = Nothing
			objResponse = Nothing
		End Try

	End Function

#End Region

#Region "Payment Management"

	Public Overrides Function PayByCreditCard(ByVal trackingid As String, ByVal accountNumber As String, ByVal amount As Decimal, ByVal nameOnCard As String, ByVal cardType As CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType, ByVal cardNumber As String, ByVal expDate As Date, ByVal emailAddress As String) As IConfirmation
		Dim iProvider As IEBSServicesProvider

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			'iProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)
			'Common.RegisterChannels()
			iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)


			Dim body As New System.Text.StringBuilder



			'#######################################################################
			'M O D I F I C A T I O N    5/24/2007 - ROD COPELAND
			'AS PART OF ISSUE TRACKER ITEM 2462, CURRENT FLOW DOSENT ASK FOR THE 
			'PAYORS NAME AND IT ASSUMES THAT THE PAYOR IS THE ACCOUNT HOLDER, 
			'WHICH(ISN) 'T ALWAYS TRUE.  UNTIL SOMEONE FROM THE BUSINESS ANSWERS 
			'IF A PERSON OTHER THAN THE ACCOUNT HOLDER CAN MAKE A PAYMENT THEN IT 
			'DOESN() 'T MAKE SENCE TO SEND A EMAIL OUT USING ACCOUNT NAME IN THE 
			'EMAIL WHEN I COULD BE OTHER PEOPLE.
			'COMMENT THE FOLLOWING CONDITION AND STEPS OUT.
			'#######################################################################
			'If Not account.User Is Nothing Then
			'    body.Append(account.User.FirstName + account.User.LastName + " ,")
			'End If
			'body.Append(ControlChars.NewLine)
			'body.Append("Thank you for your payment")
			'body.Append(ControlChars.NewLine)




			If accountNumber Is Nothing Then
				Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
				Return Nothing
			End If


			Select Case account.BillingVendorType
				Case BillingVendorType.CSG

					Dim objcardPaymentcsg As New EntityEBSServices.AddCardPaymentRequestCSG
					Dim objresponse As New EntityEBSServices.AddCardPaymentResponseCSG

					Dim objPayment(0) As EntityEBSServices.CardPaymentRequest
					objPayment(0) = New EntityEBSServices.CardPaymentRequest
					objcardPaymentcsg.CsgHeaderInfo = New EntityEBSServices.CsgHeaderInfo

					'###################################################################
					'COMBINATION OF SYS AND PRIN FROM THE SERVICEABILITY CALL EARLIER
					'###################################################################
					If Not Me._sysPrin Is Nothing Then
						objcardPaymentcsg.CsgHeaderInfo.RoutingArea = _sysPrin
					Else
						objcardPaymentcsg.CsgHeaderInfo.RoutingArea = account.Bill(0).AccountNumber.Substring(0, 6) & "00"
					End If

					objPayment(0).AccountId = accountNumber
					objPayment(0).CreditCard = New CardPaymentRequestCreditCard()
					objPayment(0).Source = "WEB"
					With objPayment(0).CreditCard
						.Amount = amount
						.ExpirationDate = CStr(expDate)
						.Number = cardNumber
						Select Case cardType
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Discover
								.Type = CardPaymentRequestCreditCardType.Discover
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Master
								.Type = CardPaymentRequestCreditCardType.Mastercard
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Visa
								.Type = CardPaymentRequestCreditCardType.Visa
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.AmericanExpress
								.Type = CardPaymentRequestCreditCardType.AmericanExpress
							Case Else
								Common.LogException(New Exception("Invalid card type: " & cardType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With
					objcardPaymentcsg.Payment = objPayment
					objresponse = CType(iProvider.AddCardPaymentCSG(objcardPaymentcsg), AddCardPaymentResponseCSG)

					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If

					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.Payment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.Payment(0).Authorization.Number, objresponse.Payment(0).Authorization.Response)
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = accountNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
							body.Append("Your Payment Confirmation Number: " + objConf.Number)
							body.Append(ControlChars.NewLine)
							body.Append(objConf.Message)
							body.Append(ControlChars.NewLine)


							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, nameOnCard, objConf.Number, accountNumber, amount.ToString(), cardNumber)




							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by credit card"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						Return Nothing
					End If

				Case BillingVendorType.ICOM

					Dim objcardPaymenticoms As New EntityEBSServices.AddCardPaymentRequestICOMS
					Dim objresponse As New EntityEBSServices.AddCardPaymentResponseICOMS
					Dim objPayment(0) As EntityEBSServices.CardPayment

					objPayment(0) = New EntityEBSServices.CardPayment
					objcardPaymenticoms.IcomsHeaderInfo = New EntityEBSServices.IcomsHeaderInfo


					Dim strSiteID As String = Left(accountNumber, 3)
					Select Case strSiteID
						Case "100"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site100
						Case "200"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site200
						Case "300"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site300
						Case "400"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site400
						Case "500"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site500
						Case "600"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site600
					End Select


					'Dim strAcctNum As String = Right(accountNumber, Len(accountNumber) - 3)
					Dim strlAccountNumber As String = accountNumber.Substring(3, 9)
					'objPayment(0).AccountID = strAcctNum
					objPayment(0).AccountID = strlAccountNumber

					Dim strStatementCode As String = Right(accountNumber, 1)

					'###################################################################
					'M O D I F  I C A T I O N    MARK SNYDER 05/23/2008
					'###################################################################
					'STATEMENT CODE VALIDATION BASED ON ENUMERATION
					'###################################################################
					If System.Enum.IsDefined(GetType(EntityEBSServices.StatementCode), CType(Right(accountNumber, 1), StatementCode)) Then
						objPayment(0).StatementCode = CType(Right(accountNumber, 1), StatementCode)
					Else
						Common.LogException(New Exception("Invalid Statement code: " & strlAccountNumber), ExceptionSeverity.Fatal)
						Return Nothing
					End If

					'Select Case Right(accountNumber, 1)
					'Select Case strStatementCode
					'    Case "1"
					'        objPayment(0).StatementCode = 1
					'    Case "2"
					'        objPayment(0).StatementCode = 2
					'    Case "3"
					'        objPayment(0).StatementCode = 3
					'    Case Else
					'        'Common.LogException(New Exception("Invalid Statement code: " & strAcctNum), ExceptionSeverity.Fatal)
					'        Common.LogException(New Exception("Invalid Statement code: " & strlAccountNumber), ExceptionSeverity.Fatal)
					'        Return Nothing
					'End Select

					With objPayment(0)
						.Amount = amount
						.CCExpirationDate = CStr(expDate)
						.CCNumber = cardNumber
						.CCName = nameOnCard
						Select Case cardType
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Discover
								.CreditCardType = EntityEBSServices.CreditCardType.Discover
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Master
								.CreditCardType = EntityEBSServices.CreditCardType.Mastercard
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Visa
								.CreditCardType = EntityEBSServices.CreditCardType.Visa
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Debit
								.CreditCardType = EntityEBSServices.CreditCardType.Debit
							Case Else
								Common.LogException(New Exception("Invalid card type: " & cardType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With

					objcardPaymenticoms.CardPayment = objPayment
					objresponse = CType(iProvider.AddCardPaymentICOMS(objcardPaymenticoms), AddCardPaymentResponseICOMS)


					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If




					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.CardPayment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.CardPayment(0).AuthTransactionID, objresponse.CardPayment(0).AuthMessage)
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = accountNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())





							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, nameOnCard, objConf.Number, strlAccountNumber, amount.ToString(), cardNumber)





							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by credit card"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						'#####################################################################################
						'MODIFICATION  5/24/2007 MADE BY ROD COPELAND
						'#####################################################################################
						'THESE LINES OF CODE WERE COMMENTED BECAUSE ERRORS WERE OCCURING ON THE APP SERVERS, 
						'PROBLEMS WITH THE PAYMENTS, AND THIS LOGIC WOULD NOT ALLOW THE EXCEPTION TO BUBBLE 
						'UP AS AN EXCEPTION.
						'#####################################################################################
						'Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						'Dim objConf As New BLConfirmation(objresponse.CardPayment(0).AuthTransactionID, objresponse.CardPayment(0).AuthMessage)
						'Return objConf

						Throw New Exception(objresponse.ExceptionMessage)

					End If
			End Select


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.Fatal)
			Throw ex
		Finally
			'iProvider = Nothing
		End Try
	End Function


	Private Sub SendCC_EFT_ConfirmationEmail(ByVal emailAddress As String, ByVal PayorsName As String, ByVal ConfirmationNumber As String, ByVal CharterAccountNumber As String, ByVal PaymentAmount As String, ByVal CC_or_BA_Number As String)
		'###################################################################################
		'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
		'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
		'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
		'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
		'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
		'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
		'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
		'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
		'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
		'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
		'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
		'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
		'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
		'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
		'###################################################################################
		Try
			If Not (System.Web.HttpContext.Current.Application("QUICKPAY_EMAIL_MESSAGE") Is Nothing) And _
			(System.Web.HttpContext.Current.Application("QUICKPAY_EMAIL_MESSAGE").ToString.Trim() <> "") Then
				If Not (emailAddress Is Nothing) Or emailAddress.Trim() <> "" Then
					Dim lEmailMessge As String = CType(System.Web.HttpContext.Current.Application("QUICKPAY_EMAIL_MESSAGE"), String)
					Dim lEmailSubject As String = CType(System.Web.HttpContext.Current.Application("QUICKPAY_EMAIL_SUBJECT"), String)
					Dim from As String = CType(System.Web.HttpContext.Current.Application(BLCommon.PAYMENT_EMAIL_SENDER), String)

					If Not (PayorsName Is Nothing) Then
						lEmailMessge = lEmailMessge.Replace("<NAMEONCARD>", "Dear " & PayorsName.ToLower() & "," & ControlChars.NewLine & ControlChars.NewLine)
					Else
						lEmailMessge = lEmailMessge.Replace("<NAMEONCARD>", "")
					End If
					lEmailMessge = lEmailMessge.Replace("<CONFIRMATIONNUMBER>", ConfirmationNumber)
					lEmailMessge = lEmailMessge.Replace("<LAST5_CCACCOUNTNUMBER>", CharterAccountNumber.Substring(CharterAccountNumber.Length - 5, 5))
					lEmailMessge = lEmailMessge.Replace("<PAYMENTAMOUNT>", PaymentAmount.ToString())
					lEmailMessge = lEmailMessge.Replace("<LAST4_CARDNUMBER>", CC_or_BA_Number.Substring(CC_or_BA_Number.Length - 4, 4))

					Dim iMail As ISupportProvider = CType(Activator.GetObject(GetType(ISupportProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_SupportProvider"))), ISupportProvider)
					iMail.SendEMail(from, emailAddress, lEmailSubject, lEmailMessge)
				End If
			End If
		Catch ex As Exception

		End Try
	End Sub



	Public Overrides Function PayByCreditCard(ByVal trackingid As String, ByVal amount As Decimal, ByVal nameOnCard As String, ByVal cardType As CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType, ByVal cardNumber As String, ByVal expDate As Date, ByVal emailAddress As String) As IConfirmation
		Dim iProvider As IEBSServicesProvider
		Try

			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			'iProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)
			'Common.RegisterChannels()
			iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)

			'Dim body As New System.Text.StringBuilder
			'If Not account.User Is Nothing Then
			'    body.Append(account.User.FirstName + account.User.LastName + " ,")
			'End If
			'body.Append(ControlChars.NewLine)
			'body.Append("Thank you for your payment")
			'body.Append(ControlChars.NewLine)

			Dim strAcctNumber As String
			If account.Bill Is Nothing Then
				strAcctNumber = MyAccount()
				If strAcctNumber Is Nothing Then
					Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
					Return Nothing
				Else
					account.Bill = New List(Of IAccount.IBill)
					account.Bill.Add(New BLAccount.BillSummary(strAcctNumber))
				End If
			End If

			Select Case account.BillingVendorType
				Case BillingVendorType.CSG

					Dim objcardPaymentcsg As New EntityEBSServices.AddCardPaymentRequestCSG
					Dim objresponse As New EntityEBSServices.AddCardPaymentResponseCSG

					Dim objPayment(0) As EntityEBSServices.CardPaymentRequest
					objPayment(0) = New EntityEBSServices.CardPaymentRequest
					objcardPaymentcsg.CsgHeaderInfo = New EntityEBSServices.CsgHeaderInfo

					'###################################################################
					'COMBINATION OF SYS AND PRIN FROM THE SERVICEABILITY CALL EARLIER
					'###################################################################
					If Not Me._sysPrin Is Nothing Then
						objcardPaymentcsg.CsgHeaderInfo.RoutingArea = _sysPrin
					Else
						objcardPaymentcsg.CsgHeaderInfo.RoutingArea = account.Bill(0).AccountNumber.Substring(0, 6) & "00"
					End If

					objPayment(0).AccountId = account.Bill(0).AccountNumber
					objPayment(0).Source = "WEB"
					objPayment(0).CreditCard = New CardPaymentRequestCreditCard()
					With objPayment(0).CreditCard
						.Amount = amount
						.ExpirationDate = CStr(expDate)
						.Number = cardNumber
						Select Case cardType
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Discover
								.Type = CardPaymentRequestCreditCardType.Discover
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Master
								.Type = CardPaymentRequestCreditCardType.Mastercard
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Visa
								.Type = CardPaymentRequestCreditCardType.Visa
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.AmericanExpress
								.Type = CardPaymentRequestCreditCardType.AmericanExpress
							Case Else
								Common.LogException(New Exception("Invalid card type: " & cardType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With


					objcardPaymentcsg.Payment = objPayment
					objresponse = CType(iProvider.AddCardPaymentCSG(objcardPaymentcsg), AddCardPaymentResponseCSG)





					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If





					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.Payment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.Payment(0).Authorization.Number, objresponse.Payment(0).Authorization.Response)
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = strAcctNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())





							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, nameOnCard, objConf.Number, account.Bill(0).AccountNumber, amount.ToString(), cardNumber)






							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by credit card"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						Return Nothing
					End If
				Case BillingVendorType.ICOM
					Dim objcardPaymenticoms As New EntityEBSServices.AddCardPaymentRequestICOMS
					Dim objresponse As New EntityEBSServices.AddCardPaymentResponseICOMS
					Dim objPayment(0) As EntityEBSServices.CardPayment

					objPayment(0) = New EntityEBSServices.CardPayment
					objcardPaymenticoms.IcomsHeaderInfo = New EntityEBSServices.IcomsHeaderInfo
					Dim strSite As String = Left(account.Bill(0).AccountNumber, 3)
					Dim strAcctNum As String = Right(account.Bill(0).AccountNumber, Len(account.Bill(0).AccountNumber) - 3)
					Select Case strSite
						Case "100"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site100
						Case "200"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site200
						Case "300"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site300
						Case "400"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site400
						Case "500"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site500
						Case "600"
							objcardPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site600
					End Select

					objPayment(0).AccountID = strAcctNum
					objPayment(0).StatementCode = EntityEBSServices.StatementCode.All

					With objPayment(0)
						.Amount = amount
						.CCExpirationDate = CStr(expDate)
						.CCNumber = cardNumber
						.CCName = nameOnCard
						Select Case cardType
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Discover
								.CreditCardType = EntityEBSServices.CreditCardType.Discover
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Master
								.CreditCardType = EntityEBSServices.CreditCardType.Mastercard
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Visa
								.CreditCardType = EntityEBSServices.CreditCardType.Visa
							Case CharterDotCom.CommonEntities.Library.Enumerations.CreditCardType.Debit
								.CreditCardType = EntityEBSServices.CreditCardType.Debit
							Case Else
								Common.LogException(New Exception("Invalid card type: " & cardType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With

					objcardPaymenticoms.CardPayment = objPayment
					objresponse = CType(iProvider.AddCardPaymentICOMS(objcardPaymenticoms), AddCardPaymentResponseICOMS)




					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If





					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.CardPayment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.CardPayment(0).AuthTransactionID, objresponse.CardPayment(0).AuthMessage)
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = strAcctNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, nameOnCard, objConf.Number, strAcctNum, amount.ToString(), cardNumber)




							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by credit card"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						Dim objConf As New BLConfirmation(objresponse.CardPayment(0).AuthTransactionID, objresponse.CardPayment(0).AuthMessage)
						Return objConf
					End If

			End Select



		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.Fatal)
			Throw ex
		Finally
			iProvider = Nothing
		End Try
	End Function

	Public Overrides Function PayByBankAccount(ByVal trackingid As String, ByVal amount As Decimal, ByVal bankName As String, ByVal routing As String, ByVal accountNumber As String, ByVal accountType As CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType, ByVal emailAddress As String) As IConfirmation
		Dim iProvider As IEBSServicesProvider
		Try

			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			'iProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)
			'Common.RegisterChannels()
			iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)




			Dim strAcctNumber As String

			If account.Bill Is Nothing Then
				strAcctNumber = MyAccount()
				If strAcctNumber Is Nothing Then
					Common.LogException(New Exception("Could not find account number to pay by bank Account"), ExceptionSeverity.Fatal)
					Return Nothing
				Else
					account.Bill = New List(Of IAccount.IBill)
					account.Bill.Add(New BLAccount.BillSummary(strAcctNumber))
				End If
			End If

			Select Case account.BillingVendorType
				Case BillingVendorType.CSG
					Dim objEFTPaymentcsg As New EntityEBSServices.AddEFTPaymentRequestCSG
					Dim objresponse As New EntityEBSServices.AddEFTPaymentResponseCSG

					Dim objPayment(0) As EntityEBSServices.EFTPaymentRequest
					objPayment(0) = New EntityEBSServices.EFTPaymentRequest
					objEFTPaymentcsg.CsgHeaderInfo = New EntityEBSServices.CsgHeaderInfo
					'###################################################################
					'COMBINATION OF SYS AND PRIN FROM THE SERVICEABILITY CALL EARLIER
					'###################################################################
					If Not Me._sysPrin Is Nothing Then
						objEFTPaymentcsg.CsgHeaderInfo.RoutingArea = _sysPrin
					Else
						objEFTPaymentcsg.CsgHeaderInfo.RoutingArea = account.Bill(0).AccountNumber.Substring(0, 6) & "00"
					End If

					objPayment(0).AccountId = account.Bill(0).AccountNumber
					objPayment(0).BankAccount = New EFTPaymentRequestBankAccount
					With objPayment(0).BankAccount
						.Amount = amount
						.Number = accountNumber
						.RoutingNumber = routing
						Select Case accountType
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Checking
								.Type = EFTPaymentRequestBankAccountType.Checking
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Savings
								.Type = EFTPaymentRequestBankAccountType.Savings
							Case Else
								Common.LogException(New Exception("Invalid account type: " & accountType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With

					objEFTPaymentcsg.Payment = objPayment
					objresponse = CType(iProvider.AddEFTPaymentCSG(objEFTPaymentcsg), AddEFTPaymentResponseCSG)





					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If





					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.Payment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.Payment(0).BatchDetailNumber, "Success")
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = strAcctNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next

							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, Nothing, objConf.Number, account.Bill(0).AccountNumber, amount.ToString(), accountNumber)




							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by bank account"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						Return Nothing
					End If

				Case BillingVendorType.ICOM

					Dim objeftPaymenticoms As New EntityEBSServices.AddEFTPaymentRequestICOMS
					Dim objresponse As New EntityEBSServices.AddEFTPaymentResponseICOMS
					Dim objPayment(0) As EntityEBSServices.EFTPayment

					objPayment(0) = New EntityEBSServices.EFTPayment
					objeftPaymenticoms.IcomsHeaderInfo = New EntityEBSServices.IcomsHeaderInfo

					Dim strSite As String = Left(account.Bill(0).AccountNumber, 3)
					Dim strAcctNum As String = Right(account.Bill(0).AccountNumber, Len(account.Bill(0).AccountNumber) - 3)
					Select Case strSite
						Case "100"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site100
						Case "200"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site200
						Case "300"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site300
						Case "400"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site400
						Case "500"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site500
						Case "600"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site600
					End Select

					objPayment(0).AccountID = strAcctNum
					'TODO:check on what this is
					objPayment(0).StatementCode = 1
					With objPayment(0)
						.Amount = amount
						.BankAccountNo = accountNumber
						.BankAccountRoutingNo = routing
						Select Case accountType
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Checking
								.BankAccountType = EntityEBSServices.BankAccountType.Checking
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Savings
								.BankAccountType = EntityEBSServices.BankAccountType.Savings
							Case Else
								Common.LogException(New Exception("Invalid account type: " & accountType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
						.BankAccountName = bankName
					End With

					objeftPaymenticoms.EFTPayment = objPayment
					objresponse = CType(iProvider.AddEFTPaymentICOMS(objeftPaymenticoms), AddEFTPaymentResponseICOMS)





					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If




					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.EFTPayment Is Nothing Then
							Dim objConf As New BLConfirmation(CStr(objresponse.EFTPayment(0).StatementCode), "Success")
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = strAcctNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next

							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())




							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, Nothing, objConf.Number, strAcctNum, amount.ToString(), accountNumber)


							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by bank account"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Pay by bank Account failed with the reason:" & objresponse.ExceptionMessage & " - " & objresponse.ExceptionStackTrace), ExceptionSeverity.Fatal)
						Return Nothing
					End If

			End Select


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.Fatal)
			Throw ex
		Finally
			iProvider = Nothing
		End Try
	End Function

	Public Overrides Function PayByBankAccount(ByVal trackingid As String, ByVal accountNumber As String, ByVal amount As Decimal, ByVal bankName As String, ByVal routing As String, ByVal BankAccountNumber As String, ByVal accountType As CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType, ByVal emailAddress As String) As IConfirmation
		Dim iProvider As IEBSServicesProvider
		Try

			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			'iProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)
			'Common.RegisterChannels()
			iProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)


			Select Case account.BillingVendorType
				Case BillingVendorType.CSG
					Dim objEFTPaymentcsg As New EntityEBSServices.AddEFTPaymentRequestCSG
					Dim objresponse As New EntityEBSServices.AddEFTPaymentResponseCSG

					Dim objPayment(0) As EntityEBSServices.EFTPaymentRequest
					objPayment(0) = New EntityEBSServices.EFTPaymentRequest
					objEFTPaymentcsg.CsgHeaderInfo = New EntityEBSServices.CsgHeaderInfo

					'###################################################################
					'COMBINATION OF SYS AND PRIN FROM THE SERVICEABILITY CALL EARLIER
					'###################################################################
					If Not Me._sysPrin Is Nothing Then
						objEFTPaymentcsg.CsgHeaderInfo.RoutingArea = _sysPrin
					Else
						objEFTPaymentcsg.CsgHeaderInfo.RoutingArea = account.Bill(0).AccountNumber.Substring(0, 6) & "00"
					End If

					objPayment(0).AccountId = accountNumber
					objPayment(0).BankAccount = New EFTPaymentRequestBankAccount
					With objPayment(0).BankAccount
						.Amount = amount
						.Number = BankAccountNumber
						.RoutingNumber = routing
						Select Case accountType
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Checking
								.Type = EFTPaymentRequestBankAccountType.Checking
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Savings
								.Type = EFTPaymentRequestBankAccountType.Savings
							Case Else
								Common.LogException(New Exception("Invalid account type: " & accountType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
					End With

					objEFTPaymentcsg.Payment = objPayment
					objresponse = CType(iProvider.AddEFTPaymentCSG(objEFTPaymentcsg), AddEFTPaymentResponseCSG)





					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If






					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.Payment Is Nothing Then
							Dim objConf As New BLConfirmation(objresponse.Payment(0).BatchDetailNumber, "Success")
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = accountNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())





							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, Nothing, objConf.Number, accountNumber, amount.ToString(), BankAccountNumber)





							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by bank account"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Could not find account number to pay by credit card"), ExceptionSeverity.Fatal)
						Return Nothing
					End If
				Case BillingVendorType.ICOM

					Dim objeftPaymenticoms As New EntityEBSServices.AddEFTPaymentRequestICOMS
					Dim objresponse As New EntityEBSServices.AddEFTPaymentResponseICOMS
					Dim objPayment(0) As EntityEBSServices.EFTPayment

					objPayment(0) = New EntityEBSServices.EFTPayment
					objeftPaymenticoms.IcomsHeaderInfo = New EntityEBSServices.IcomsHeaderInfo
					Dim strSite As String = Left(accountNumber, 3)
					'Dim strAcctNum As String = Right(accountNumber, Len(accountNumber) - 3)

					Dim strlAccountNumber As String = accountNumber.Substring(3, 9)


					Select Case strSite
						Case "100"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site100
						Case "200"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site200
						Case "300"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site300
						Case "400"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site400
						Case "500"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site500
						Case "600"
							objeftPaymenticoms.IcomsHeaderInfo.SiteId = SiteId.Site600
					End Select

					'objPayment(0).AccountID = strAcctNum
					objPayment(0).AccountID = strlAccountNumber

					'###################################################################
					'M O D I F  I C A T I O N    MARK SNYDER 05/23/2008
					'###################################################################
					'STATEMENT CODE VALIDATION BASED ON ENUMERATION
					'###################################################################
					If System.Enum.IsDefined(GetType(EntityEBSServices.StatementCode), CType(Right(accountNumber, 1), StatementCode)) Then
						objPayment(0).StatementCode = CType(Right(accountNumber, 1), StatementCode)
					Else
						Common.LogException(New Exception("Invalid Statement code: " & strlAccountNumber), ExceptionSeverity.Fatal)
						Return Nothing
					End If
					'Select Case Right(accountNumber, 1)
					'    Case "1"
					'        objPayment(0).StatementCode = 1
					'    Case "2"
					'        objPayment(0).StatementCode = 2
					'    Case "3"
					'        objPayment(0).StatementCode = 3
					'    Case Else
					'        'Common.LogException(New Exception("Invalid Statement code: " & strAcctNum), ExceptionSeverity.Fatal)
					'        Common.LogException(New Exception("Invalid Statement code: " & strlAccountNumber), ExceptionSeverity.Fatal)
					'        Return Nothing
					'End Select
					With objPayment(0)
						.Amount = amount
						.BankAccountNo = BankAccountNumber
						.BankAccountRoutingNo = routing
						Select Case accountType
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Checking
								.BankAccountType = EntityEBSServices.BankAccountType.Checking
							Case CharterDotCom.CommonEntities.Library.Enumerations.BankAccountType.Savings
								.BankAccountType = EntityEBSServices.BankAccountType.Savings
							Case Else
								Common.LogException(New Exception("Invalid account type: " & accountType), ExceptionSeverity.Fatal)
								Return Nothing
						End Select
						.BankAccountName = bankName
					End With

					objeftPaymenticoms.EFTPayment = objPayment
					objresponse = CType(iProvider.AddEFTPaymentICOMS(objeftPaymenticoms), AddEFTPaymentResponseICOMS)





					'################
					'ERROR CHECKING
					'################
					If objresponse Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If
					If objresponse.Exception Then
						If (System.Web.HttpContext.Current.Session("QP_ExpireDateTime") Is Nothing) Or (System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") Is Nothing) Then
							System.Web.HttpContext.Current.Session("QP_ExpireDateTime") = Now.AddMinutes(CType(System.Web.HttpContext.Current.Application("QP_LOCKOUT_WAIT_MINUTES"), Integer)).Ticks().ToString()
							System.Web.HttpContext.Current.Session("QP_TotalAttemptCount") = "1"
						End If

						If Not (objresponse.ExceptionMessage Is Nothing) Then
							If (objresponse.ExceptionMessage.Trim() <> "") Then
								Throw New Exception("Unable to apply payment at this time. " & objresponse.ExceptionMessage & ".")
							Else
								Throw New Exception("Unable to apply payment at this time.")
							End If
						Else
							Throw New Exception("Unable to apply payment at this time.")
						End If
					End If
					If objresponse.Result Is Nothing Then
						Throw New Exception("Unable to apply payment at this time.")
					End If




					If objresponse.Result.ReturnCode = ResultReturnCode.Success Then
						If Not objresponse.EFTPayment Is Nothing Then
							Dim objConf As New BLConfirmation(CStr(objresponse.EFTPayment(0).StatementCode), "Success")
							account.Paid = True
							For Each obj As BLAccount.BillSummary In account.Bill
								If obj.AccountNumber = accountNumber Then
									obj.BillPaid = True
									Exit For
								End If
							Next
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())




							'###################################################################################
							'CHANGE REQUESTED BY BUSINESS 5/24/2007 MADE BY ROD COPELAND
							'EMAILS WERE NOT BEING SENT TO CUSTOMERS WHEN PAYMENT WAS SUCESSFULL.
							'THIS OVERALL CASE STATEMENT IS BASED ON THE BILLING SYSTEM HAD RETURN 
							'STATEMENT IN EACH CASE THAT SKIPPED THE EMAIL PART OF THIS FUNCTION.
							'ANOTHER ISSUE IS THE REMOTING METHOD SIGNITURES SHOULD PASS THE EMAIL 
							'ADDRESS THE USER SUPPLIED.  SOMEONE DIDN'T WANT TO TAKE THE TIME TO 
							'CHAGNE THE METHOD SIGNITURE SO THEY ADDED THE EMAIL ADDRESS PROVIDED 
							'TO THE ACCOUNT OBJECT EMAIL ADDRESS.  I THINK THEY THOUGHT THIS WAS 
							'OK BECAUSE MYACCOUNT SECTION ON CHARTER.COM WASN'T LIVE SO THEY USED 
							'THE ACCOUNTOBJECT PRIMARY EMAIL BEING SET TOT THE VALUE OF THE EMAIL 
							'ADDRESS PROVIDED ON THE PAYYOURBILL.ASPX PAGE.  THERE ARE SOME CONCERNS 
							'AROUND ADDING THIS EMAIL ADDRESS AS THE PRIMARY WHEN MYACCOUNT GOES LIVE, 
							'NEED TO BE MINDFUL OF OVERWRITTING THE EXISTING PRIMARY EMAIL ADDRESS WHEN 
							'INTERACTING BETWEEN MYACCOUNT AND QUICKPAY/PAYYOURBILL.
							'###################################################################################
							Call SendCC_EFT_ConfirmationEmail(emailAddress, Nothing, objConf.Number, strlAccountNumber, amount.ToString(), BankAccountNumber)




							Return objConf
						Else
							Common.LogException(New Exception("Could not find confirmation number for pay by bank account"), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					Else
						Common.LogException(New Exception("Pay by bank Account failed with the reason:" & objresponse.ExceptionMessage & " - " & objresponse.ExceptionStackTrace), ExceptionSeverity.Fatal)
						Return Nothing
					End If
			End Select


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.Fatal)
			Throw ex
		Finally
			iProvider = Nothing
		End Try
	End Function

	Private Function MyAccount() As String
		'TO DO: call Member services provider to get account details but currently populates only Account with sample values.
		Dim lCustAccountProvider As IEBSServicesProvider
		Try
			Select Case account.BillingVendorType

				Case BillingVendorType.CSG

					Dim objRequest As GetAccountsRequestCSG
					Dim objResponse As GetAccountsResponseCSG
					Dim lCriteria As New AccountCriteriaCSG

					'Dim lCustAccountProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
					'lCustAccountProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

					'Common.RegisterChannels()
					lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)

					Dim objAddress As New AccountCriteriaCustomerAddress()
					objAddress.AddressLine1 = account.Address.Street1
					objAddress.AddressLine2 = account.Address.Street2
					objAddress.City = account.Address.City
					objAddress.State = account.Address.State
					objAddress.ZipCode = account.Address.Zip

					lCriteria.Item = objAddress
					lCriteria.ItemElementName = ItemChoiceTypeCSG.CustomerAddress
					objRequest = New GetAccountsRequestCSG(Nothing, lCriteria)
					objResponse = CType(lCustAccountProvider.GetAccountsFromCSG(objRequest), GetAccountsResponseCSG)

					If Not objResponse.Accounts Is Nothing Then
						If objResponse.Accounts.Length = 1 Then
							If Len(objResponse.Accounts(0).AccountId) > 7 Then
								Return Right(objResponse.Accounts(0).AccountId, 7)
							Else
								Return objResponse.Accounts(0).AccountId
							End If
						Else
							Common.LogException(New Exception("Account Manager: Pay By Credit Card - My Account returns multiple accounts for address: " & objAddress.AddressLine1 & " - " & objAddress.AddressLine2 & " - " & objAddress.ZipCode), ExceptionSeverity.Fatal)
							Return Nothing
						End If
					End If

				Case BillingVendorType.ICOM

					Dim strZip As String = ""
					Dim strAddress1 As String = ""
					Dim strAddress2 As String = ""
					Dim strCity As String = ""
					Dim strState As String = ""

					Dim billingvendortype As BillingVendorType
					Dim objBilldetails As List(Of IAccount.IBill) = GetServiceabilityByTelephoneeNumber(account.HomePhone, billingvendortype, strZip, strAddress1, strAddress2, strCity, strState)

					If Not objBilldetails Is Nothing AndAlso objBilldetails.Count > 0 Then
					Else
						Common.LogException(New Exception("Account Manager: Pay By Credit Card - My Account returns multiple accounts: " & account.HomePhone), ExceptionSeverity.Fatal)
						Return Nothing
					End If
					Dim objbill As IAccount.IBill = objBilldetails(0)
					Return objbill.AccountNumber.Substring(3, 9)
			End Select

		Catch ex As Exception
			Throw ex
		Finally
			lCustAccountProvider = Nothing
		End Try
	End Function

	Private Function MyAccount(ByVal telnumber As String, ByVal zipcode As String) As List(Of IAccount.IBill)
		Dim lCustAccountProvider As IEBSServicesProvider
		Try
			Dim billvendor As BillingVendorType
			Dim objBillingSummary As List(Of IAccount.IBill)
			Dim strZip As String = ""
			Dim strAddress1 As String = ""
			Dim strAddress2 As String = ""
			Dim strCity As String = ""
			Dim strState As String = ""


			'###################################################################
			'M O D I F  I C A T I O N    BY ROD COPELAND 5/09/07
			'###################################################################
			'PER GREG KOCH AND THE EBS TEAM, WE NEED TO STRIP OUT THE DASHES 
			'IN THE PHONE NUMBER SINCE THE SERVICEABILITY CALL WONT FAIL OUT
			'###################################################################
			Dim tempTelnumber As String = telnumber.Replace("-", "")
			tempTelnumber = tempTelnumber.Replace(".", "")
			tempTelnumber = tempTelnumber.Replace("/", "")
			objBillingSummary = GetServiceabilityByTelephoneeNumber(tempTelnumber, billvendor, strZip, strAddress1, strAddress2, strCity, strState)
			'###################################################################



			Select Case billvendor
				Case BillingVendorType.CSG
					account.BillingVendorType = BillingVendorType.CSG
				Case BillingVendorType.ICOM
					account.BillingVendorType = BillingVendorType.ICOM
			End Select

			If strZip Is Nothing Or strZip <> zipcode Then
				Common.LogException(New Exception("Provided Zip Code does not match Telephone Number."), ExceptionSeverity.Fatal)
				' DB - attempt to return a different error message
				' quick and dirty, create a Bill object, set the description, and set the account number to 0
				' Proof of Concept
				'' TODO: work it in the error mapping solution
				Dim objBill As New BLAccount.BillSummary("0")
				objBill.BillDescription = "Provided Zip Code does not match Telephone Number."
				Dim objErrorBillSummary As New List(Of IAccount.IBill)
				objErrorBillSummary.Add(objBill)
				Return objErrorBillSummary
				'Return Nothing
			End If

			If account.Address Is Nothing Then
				account.Address = New BLAddress
			End If

			' Using a cookie to temporarily persist this value, seems to want to disappear sporadically the 
			' first time through the process.  This way seems to work with no issues.  
			' remember to remove the cookie value after you're done using it
			'Dim address1Cookie As System.Web.HttpCookie = New System.Web.HttpCookie("Street1")
			'address1Cookie.Value = strAddress1
			'System.Web.HttpContext.Current.Response.Cookies.Add(address1Cookie)
			account.Address.Street1 = strAddress1
			account.Address.Street2 = strAddress2
			account.Address.Zip = strZip
			account.Address.State = strState
			account.Address.City = strCity

			'#######################################################
			'IF THE SERVICEABILITY CALL COMES BACK WITH NOTHING, 
			'WE SHOULD JUST SKIP THE REST AND RETURN NOTHING.
			'#######################################################
			If objBillingSummary Is Nothing Then Return Nothing

			'#####################################################################################
			'DETERMINE BILLING SYSTEM TYPE SO WE CAN CALL THE APPROPRIATE APP SERVER PROVIDER.
			'#####################################################################################
			Select Case billvendor
				Case BillingVendorType.CSG
					Dim objRequest As GetAccountsRequestCSG
					Dim objResponse As GetAccountsResponseCSG
					Dim lCriteria As New AccountCriteriaCSG

					lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)


					For Each obj As BLAccount.BillSummary In objBillingSummary
						Dim lAccountNumber As String = obj.AccountNumber
						lCriteria.Item = lAccountNumber
						lCriteria.ItemElementName = ItemChoiceTypeCSG.AccountNumber
						objRequest = New GetAccountsRequestCSG(Nothing, lCriteria)
						objResponse = CType(lCustAccountProvider.GetAccountsFromCSG(objRequest), GetAccountsResponseCSG)

						If Not objResponse.Accounts Is Nothing Then
							Dim objCSGaccount As AccountCSG = objResponse.Accounts(0)
							obj.BillAmount = objCSGaccount.CurrentAccountBalance
							obj.BillDuedDate = CType(objCSGaccount.BillingInfo.ThruDate, Date)

							If Not objCSGaccount.LinesOfBusiness Is Nothing Then
								For Each objLOB As LineOfBusiness In objCSGaccount.LinesOfBusiness
									Select Case objLOB.Type
										Case LineOfBusinessTypeCSG.Data
											obj.BillDescription = obj.Description & "and High - Speed Internet  "
										Case LineOfBusinessTypeCSG.Telephony
											obj.BillDescription = obj.Description & "and Telephone  "
										Case LineOfBusinessTypeCSG.Video
											obj.BillDescription = obj.Description & "and Digital Cable  "
									End Select
								Next
								If obj.Description <> String.Empty Then
									obj.BillDescription = Right(obj.Description, Len(obj.Description) - 4)
								End If
							End If
						Else
							'##############
							'Persist state
							'##############
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
							Return Nothing
						End If

					Next
					'##############
					'Persist state
					'##############
					SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

					Return objBillingSummary

				Case BillingVendorType.ICOM
					Dim objRequest As GetAccountStatementsAllRequestICOMS
					Dim objResponse As GetAccountStatementsAllResponseICOMS
					Dim objHeader As New IcomsHeaderInfo

					'###########################################
					'CREATE APP SERVER PROVIDER PROXY OBJECT
					'###########################################
					lCustAccountProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)




					'####################################################################################
					'M O D I F I C A T I O N   6/4/2007 - ROD COPELAND
					'####################################################################################
					'PER GREG KOCH - EAI TEAM, SAID THAT SERVICEABILITY BY PHONE NUMBER WILL ONLY RETURN
					'BACK 1 ACCOUNT NUMBER.  WE WOULD THEN THAT ACCOUNT NUMBER AND PASS IT INTO THE 
					'GETACCOUNTSALL WEB SERVICE METHOD AND GET BACK A COLLECTION OF BILLING STATMENTS 
					'ASSOCIATED WITH THIS ACCOUNT NUMBER.  WE NEED TO RETURN A LIST OF IBILL BACK 
					'FROM THIS FUNCTION.
					'####################################################################################
					For Each obj As BLAccount.BillSummary In objBillingSummary

						'###################################################
						'BUILD THE REQUEST OBJECT FOR APP SERVER REQUEST.
						'###################################################
						Dim strSiteID As String = Left(obj.AccountNumber, 3)
						Dim lstrAccountNumber As String = obj.AccountNumber.Substring(3, 9)
						Dim strAcctNum As String = obj.AccountNumber
						Select Case strSiteID
							Case "100"
								objHeader.SiteId = SiteId.Site100
							Case "200"
								objHeader.SiteId = SiteId.Site200
							Case "300"
								objHeader.SiteId = SiteId.Site300
							Case "400"
								objHeader.SiteId = SiteId.Site400
							Case "500"
								objHeader.SiteId = SiteId.Site500
							Case "600"
								objHeader.SiteId = SiteId.Site600
						End Select
						objRequest = New GetAccountStatementsAllRequestICOMS(objHeader, lstrAccountNumber)

						'############################################
						'MAKE A CALL TO APP SERVER TO THE PROVIDER
						'############################################
						objResponse = CType(lCustAccountProvider.GetAccountStatementsAllICOMS(objRequest), GetAccountStatementsAllResponseICOMS)

						'#########################################################################
						'WILL BE GETTING A COLLECTION OF BILL STATEMENTS BACK HERE.  LOOP THROUGH 
						'BUILDING A LIST/COLLECTION OF IBILL AND RETURN 
						'#########################################################################
						If Not objResponse.AccountStatementAllInfo Is Nothing AndAlso Not objResponse.AccountStatementAllInfo.Statement Is Nothing Then
							Dim outBillStatements As New List(Of IAccount.IBill)

							'########################################
							'BUILD EACH BILL FROM RESPONSE OBJECT.
							'########################################
							For Each objICOMSaccount As StatementAll In objResponse.AccountStatementAllInfo.Statement
								Dim lBillSummary As New BLAccount.BillSummary(obj.AccountNumber & objICOMSaccount.StatementCode)
								lBillSummary.AccountNumber = obj.AccountNumber & objICOMSaccount.StatementCode
								lBillSummary.BillAmount = CDec(objICOMSaccount.BalanceLastStatement)
								lBillSummary.BillDescription = objICOMSaccount.StatementDescription
								If Len(objICOMSaccount.LastStatementDate) = 8 Then
									lBillSummary.BillDuedDate = CDate(objICOMSaccount.LastStatementDate.Substring(4, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(6, 2) & "/" & objICOMSaccount.LastStatementDate.Substring(0, 4))
								End If
								outBillStatements.Add(lBillSummary)
							Next


							'##############
							'Persist state
							'##############
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

							Return outBillStatements
						Else
							'##############
							'Persist state
							'##############
							SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

							Return Nothing
						End If

					Next
			End Select

			'##############
			'Persist state
			'##############
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

		Catch ex As Exception
			Throw ex
		Finally
			lCustAccountProvider = Nothing
		End Try
	End Function

	Public Overrides Function GetBillingSummaryByTelephoneNumber(ByVal trackingid As String, ByVal telephoneNumber As String, ByVal ZipCode As String, ByVal email As String) As List(Of IAccount.IBill)
		Try

			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			Dim objBill As New List(Of IAccount.IBill)

			'If Not account.Bill Is Nothing Then
			'    For Each objBilling As BLAccount.BillSummary In account.Bill
			'        objBill.Add(objBilling)
			'    Next
			'    Return objBill
			'End If

			Dim objBilingSummary As List(Of IAccount.IBill) = MyAccount(telephoneNumber, ZipCode)

			'' DB - Change to make it more user friendly error response
			'' condition met that we want to display a message to the end user, 
			'' pass it back along

			'' TODO: work it in the error mapping solution
			If objBilingSummary Is Nothing Then
				Return Nothing
			End If

			If objBilingSummary(0).AccountNumber = "0" Then
				objBill.Add(objBilingSummary(0))
				account.Bill = objBilingSummary
				Return objBill
			End If

			For Each objBilling As BLAccount.BillSummary In objBilingSummary
				objBill.Add(objBilling)
			Next

			account.Bill = objBilingSummary

			'populate email
			If account.User Is Nothing Then
				account.User = New BLAccount.BLMember
			End If
			If account.User.Email Is Nothing Then
				account.User.Email = New List(Of IAccount.IMember.IEmail)
			End If
			account.User.Email.Add(New BLAccount.BLMember.BLEMail(email, True))

			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession)

			Return objBill

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.Fatal)
			Throw ex
		End Try
	End Function

#End Region

#Region "WebSpace Management"

	Public Overrides Function CreateWebSpaceAccount(ByVal trackingid As String, ByVal userID As String, ByVal password As String, ByVal provisioningID As String) As Boolean
		Dim objrequest As New EntityMemberServices.CreateWebspaceRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objrequest.accountId = account.OSSProvidedAccountNumber

			objrequest.provisionId = provisioningID
			objrequest.login = CSRLOGIN
			objrequest.password = CSRPASSWORD
			objrequest.webspaceLogin = userID
			objrequest.webspacePassword = password



			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.CreateWebspace(objrequest), TheCommonResponse)




			If Not objResponse.Exception Then
				'#####################################################
				'ADD NEW WEBSPACE VALUE TO THE CORRECT PACKAGE, THERE 
				'COULD BE SEVERAL PACKAGES.  FIND THE RIGHT ONE BY 
				'SEARCHING FOR THE PROVISIONING ID MATCH
				'#####################################################
				For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
					If userPackage.provisioningIdField.Trim() = provisioningID Then
						userPackage.webspaceField = userID
						Exit For
					End If
				Next



				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Create Webspace account failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			'iProvider = Nothing
		End Try
	End Function
	Public Overrides Function RemoveWebSpaceAccount(ByVal trackingid As String, ByVal provisioningID As String) As Boolean
		Dim objrequest As New EntityMemberServices.RemoveWebspaceRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objrequest.accountId = account.OSSProvidedAccountNumber

			objrequest.CSRlogin = CSRLOGIN
			objrequest.CSRpassword = CSRPASSWORD
			objrequest.provisionId = provisioningID


			'##################################################################
			'SEARCH FOR THE PROVISIONING ID IN THE ACCOUNT OBJECT AND FIND 
			'THE CORRESPONDING WEBSPACE ID FOR THAT PACKAGE.
			'##################################################################
			For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
				If userPackage.provisioningIdField.Trim() = provisioningID.Trim() Then
					objrequest.webspaceLogin = userPackage.webspaceField
					Exit For
				End If
			Next






			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.RemoveWebspace(objrequest), TheCommonResponse)




			If Not objResponse.Exception Then
				'#####################################################
				'REMOVE THE WEBSPACE ID FROM THE ACCOUNT OBJECT.
				'#####################################################
				For Each userPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
					If userPackage.provisioningIdField.Trim() = provisioningID.Trim() Then
						userPackage.webspaceField = Nothing
						Exit For
					End If
				Next


				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Remove Webspace account failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If
		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			'iProvider = Nothing
		End Try
	End Function

	Public Overrides Function CheckWebSpaceAccount(ByVal trackingid As String) As Boolean

		'##############
		'Restore state
		'##############
		PopulateLocalVariables(trackingid)


		Try
			'####################################################################
			'CHECK ALL PACKAGES WEBSPACE VALUES TO SEE IF ANY ARE MISSING.
			'IF ANY ARE MISSING, DO A CALL FOR ALL AND UPDATE THE VALUES FOR 
			'ALL(PACKAGES) WITH FRESH DATA EVEN THOUGH YOU MAY ONLY NEED TO 
			'UPDATE JUST ONE OF THE PACKAGES.
			'####################################################################
			If Not (account Is Nothing) Then




				'#############################################################################
				'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
				'#############################################################################
				'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
				'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
				'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
				'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
				'IN THIS CASE, TO KEEP FROM DOING 
				'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
				'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
				'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
				'#############################################################################
				If Not account.MyAccountCachedPropertyNames Is Nothing Then
					If Not account.MyAccountCachedPropertyNames.Contains("webspace") Then


						If Not (account.User Is Nothing) Then
							If Not (account.User.MSPackageInfo Is Nothing) Then
								If (account.User.MSPackageInfo.Count > 0) Then
									For Each AccountObjPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
										If AccountObjPackage.webspaceField Is Nothing Then
											'#############################################
											'THEN DO A WEB SERVICE CALL AND SEE IF ANY 
											'EXIST SO A UPDATE CAN BE DONE LOCALLY ON 
											'THE ACCOUNT OBJECT.
											'#############################################
											Dim blnResult As Boolean = UpdateMyAccountWebSpaceNameInAccountObject()
											Return blnResult
										Else
											'If AccountObjPackage.SecurityKeys.Count = 0 Then
											'    Dim blnResult As Boolean = UpdateMyAccountSecurityKeysInAccountObject()
											'    Return blnResult
											'Else
											'    '############################################################
											'    'SINCE THEY ALREADY HAVE A SECURITY KEY COLLECTION, LETS 
											'    'NOT DO ANOTHER WEB SERVICE REQUEST TO UPDATE VALUES THAT 
											'    'LIKELY HAVENT CHANGED ANYWAY.
											'    '############################################################
											'    Return True
											'End If
										End If
									Next
								End If
							End If
						End If


					End If
				End If


			End If


		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			'iProvider = Nothing
		End Try
	End Function


	Private Function UpdateMyAccountWebSpaceNameInAccountObject() As Boolean
		Dim objrequest As New EntityMemberServices.GetMSWebspaceSummaryRequest
		Dim objResponse As New EntityMemberServices.GetMSWebspaceSummaryResponse

		'########################################################
		'MODIFICATION   ROD COPELAND    ISSUE ID:7780
		'########################################################
		'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
		'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
		'########################################################
		objrequest.accountId = account.OSSProvidedAccountNumber

		objrequest.type = "WEBSPACE"
		objrequest.csrlogin = CSRLOGIN
		objrequest.csrpassword = CSRPASSWORD



		'#############################################################################
		'M O D I F I C A T I O N       ROD COPELAND SEPT 21, 2007
		'#############################################################################
		'SEE IF THE VALUE HAS HAD AN ATTEMPT TO RETREIVE IT OR NOT.  IF BY CHANCE 
		'THAT(WE'RE DOING A WEB SERIVCE CALL AND RETURNING A VALUE OF NOTHING 
		'BACK THE FIRST TIME, IT MAY LOOK LIKE THE VALUE IS NOTHING SO DO A CALL 
		'TO SEE IF WE HAVE ANY NEW VALUES ADDED THE NEXT TIME THE PAGE IS CALLS.  
		'IN THIS CASE, TO KEEP FROM DOING 
		'YET ANOTHER WEB SERVICE CALL, WE SHOULD CHECK THE LIST OF CACHED PROPERTIES 
		'TO SEE IF THEY HAVE BEEN ATTEMPTED ALREADY, IF SO, FOR NOW JUST SKIP OVER 
		'THE CALL FOR THIS SESSION LIFE SPAN ONLY.
		'#############################################################################
		If Not account.MyAccountCachedPropertyNames.Contains("webspace") Then
			account.MyAccountCachedPropertyNames.Add("webspace")

			'##############
			'Persist state
			'##############
			SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())
		End If



		'################################
		'EXECUTE THE CALL TO THE PROVIDER
		'################################
		Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
		objResponse = CType(iProvider.GetMSWebspaceSummary(objrequest), GetMSWebspaceSummaryResponse)



		If Not (objResponse Is Nothing) Then
			If Not (objResponse.Exception) Then
				If Not (objResponse.packageArray Is Nothing) Then
					If objResponse.packageArray.Length > 0 Then
						For i As Integer = 0 To objResponse.packageArray.GetUpperBound(0)
							Dim lPackage As New BLAccount.BLMember.BLMSPackageInfo

							lPackage.provisioningIdField = objResponse.packageArray(i).provisioningId

							If Not (objResponse.packageArray(i).webspace Is Nothing) Then
								lPackage.webspaceField = objResponse.packageArray(i).webspace
							End If

							'##############################################################
							'SEARCH FOR THE PROVISIONING ID IN THE EXISTING PACKAGES TO SEE 
							'IF ANY OF THEM NEED TO BE UPDATED WITH THESE SECURITY KEYS.
							'##############################################################

							If account Is Nothing Then
								account = New BLAccount
							End If
							If account.User Is Nothing Then
								account.User = New BLAccount.BLMember
							End If
							If account.User.MSPackageInfo Is Nothing Then
								account.User.MSPackageInfo = New List(Of IAccount.IMember.IMemberServicePackageInfo)
							End If
							If account.User.MSPackageInfo.Count > 0 Then
								'############################################
								'MODIFY AN EXISITNG PACKAGE IN THE COLLECTION
								'############################################
								For Each acctPackage As BLAccount.BLMember.BLMSPackageInfo In account.User.MSPackageInfo
									'######################################################################################
									'THIS CONDITION CHECKS TO SEE IF THE SECURITY KEY VALUE IS NOTHING, IF SO, IT WILL 
									'ASSIGN A INSTANTIATED VALUE THAT HAS NO VALUES IN IT, JUST SO ITS NOT NOTHING.  
									'WHEN THE GET SECURITY KEYS METHOD IS CALLED FROM THE PAGE, IT WILL CHECK THIS 
									'VALUE IF ITS NOTHING OR NOT.  IF ITS NOTHING IT WILL MAKE A WEB SERVICE CALL TO GO 
									'AND CHECK IF THERE IS A VALUE. TO AVOID GOING BACK EVERY TIME SINCE ONE OF THE 
									'PACKAGES IN THE COLLECTION MAY HAVE NOT HAVE SECURITY KEYS ALLOWED, GIVING A VALUE OF 
									'SOMETHING OTHER THAN NOTHING SHOULD STOP THAT. THIS IS UNTIL SOMEONE CHANGES THAT 
									'GET SECURITY KEYS METHOD.
									'######################################################################################
									If acctPackage.webspaceField Is Nothing Then
										acctPackage.webspaceField = ""
									End If


									If acctPackage.provisioningIdField.Trim() = lPackage.provisioningIdField.Trim() Then
										acctPackage.webspaceField = lPackage.webspaceField
									End If
								Next
							Else
								'#####################################
								'ADD A NEW PACKAGE TO THE COLLECTION
								'#####################################
								account.User.MSPackageInfo.Add(lPackage)
							End If
						Next




						'##############
						'Persist state
						'##############
						SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())

						Return True
					Else
						Return False
					End If
				Else
					Return False
				End If
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Return False
			End If

		Else
			Return False
		End If
	End Function





	Public Overrides Function ChangeWebSpaceAccountPassword(ByVal trackingid As String, ByVal WebSpaceLogin As String, ByVal newWebSpacePassword As String, ByVal lProvisioningID As String) As Boolean
		Dim objrequest As New EntityMemberServices.ChangeWebSpacePasswordRequest
		Dim objResponse As New EntityMemberServices.TheCommonResponse

		Try
			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)


			objrequest.login = CSRLOGIN
			objrequest.password = CSRPASSWORD
			objrequest.provisionId = lProvisioningID

			'########################################################
			'MODIFICATION   ROD COPELAND    ISSUE ID:7780
			'########################################################
			'PASS THE OSS ACCOUNT NUMBER BACK, THE ACCOUNT NUMBER IS 
			'USED TO GROUP ALL PACKAGES IN THE COLLECTION.
			'########################################################
			objrequest.accountId = account.OSSProvidedAccountNumber

			objrequest.webspaceLogin = WebSpaceLogin
			objrequest.webspacePassword = newWebSpacePassword

			'################################
			'EXECUTE THE CALL TO THE PROVIDER
			'################################
			Dim iProvider As IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
			objResponse = CType(iProvider.ChangeWebSpacePassword(objrequest), TheCommonResponse)



			If Not objResponse.Exception Then
				Return True
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New Exception("Account Manager -Change Account Email Password failed as:" & objResponse.ExceptionMessage), ExceptionSeverity.High)
				Return False
			End If

		Catch ex As Exception
			Common.LogException(ex, ExceptionSeverity.High)
			Throw ex
		Finally
			objrequest = Nothing
			objResponse = Nothing
		End Try
	End Function
#End Region

#Region "Other"

	''' <summary>
	''' Check for Telephone number portability 
	''' </summary>
	''' <param name="areaCode">First three digits of phone number(Area Code)</param>
	''' <param name="prefixCode">Three digits after the Area Code</param>
	''' <returns>Returns boolean which represents portable/ not</returns>
	''' <remarks></remarks>
	Public Overrides Function CheckTelephoneNumberPortability(ByVal trackingid As String, ByVal areaCode As String, ByVal prefixCode As String) As String
		Try

			'##############
			'Restore state
			'##############
			PopulateLocalVariables(trackingid)



			'Dim iProvider As IEBSServicesProvider = providerFactory.CreateProvider(Of IEBSServicesProvider)(Common.AssemblyName)
			'Dim iProvider As IEBSServicesProvider = New EBSServicesProvider.ProviderManager(configdata_ebs)

			'Common.RegisterChannels()
			Dim iProvider As IEBSServicesProvider = CType(Activator.GetObject(GetType(IEBSServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_EBSServicesProvider"))), IEBSServicesProvider)

			Dim providerRequest As EntityEBSServices.GetLerg6ByNpaNxxRequest = New EntityEBSServices.GetLerg6ByNpaNxxRequest()
			providerRequest.NPA = Convert.ToInt32(areaCode)
			providerRequest.NXX = Convert.ToInt32(prefixCode)
			Dim objResponse As EntityEBSServices.GetLerg6ByNpaNxxResponse
			objResponse = DirectCast(iProvider.GetLerg6ByNpaNxx(providerRequest), EntityEBSServices.GetLerg6ByNpaNxxResponse)
			' using only first item in LergItems, because there is going to be only one lerge item if we give 6 digit number.
			' returns multiple lerg items only if 3-digit area code with no prefixcode
			If Not (objResponse Is Nothing OrElse objResponse.Exception) Then
				If objResponse.LergItems(0).Portable.ToLower.Equals("y") Then
					Return TriState.True.ToString
				Else : Return TriState.False.ToString
				End If
			Else
				'##################################################################################
				'##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######
				'#################          MODIFIED BY ROD COPELAND, 5/2/2007     ################ 
				'##################################################################################
				'WRITE THE (IDEALLY) CHARTER FRIENDLY ERROR MESSAGES TO THE PAGE.  
				'THESE MESSAGES ARE MANAGED IN THE CHARTERDOTCOM.ADMIN.ERROR_CODE_MAPPING TABLE.
				'THE UNDERLYING LOGIC WILL DISPLAY THE DATASOURCE ERROR MESSAGE IF A 
				'CHARTERDOTCOM FRIENDLY ERROR MESSAGE IS NOT PRESENT ON THE RECORD.
				'THERE MAY BE MORE THAN ONE ERROR MESSAGE THAT COMES BACK, DISPLAY 
				'ACCORDINGLY.
				'##################################################################################
				Select Case True
					Case Not objResponse.CharterDotCom_Friendly_Messages Is Nothing
						Me._LastCCOMDisplayFriendlyExceptionMessage = objResponse.CharterDotCom_Friendly_Messages
					Case Else
						Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
				End Select
				'##################################################################################


				'##############
				'Persist state
				'##############
				SetSession(Common.AccountManagerKey, Me.ValuesForSetSession())



				Common.LogException(New ApplicationException("Account Manager -Check Telephone Number failed for:" & areaCode & "-" & prefixCode), ExceptionSeverity.High)
				Return TriState.Unspecified.ToString
			End If
		Catch ex As Exception
			Dim aex As New ApplicationException("Account Manager -Check Telephone Number failed ")
			Common.LogException(aex, ExceptionSeverity.High)
			Throw aex
		End Try
	End Function



	Private Function IsAddressSame(ByVal add As IAddress, ByVal street1 As String, ByVal apt As String, ByVal zip As String) As Boolean
		If String.Compare(add.Street1, street1, True) = 0 Then
			'If add.Street2 Is Nothing OrElse add.Street2.Equals(String.Empty) Then
			If (String.Compare(add.Street2, apt, True) = 0) OrElse _
			 (add.Street2 Is Nothing And (apt Is Nothing OrElse apt.Equals(String.Empty))) OrElse _
			 (add.Street2.Equals(String.Empty) And (apt Is Nothing OrElse apt.Equals(String.Empty))) Then
				If String.Compare(add.Zip, zip, True) = 0 Then
					Return True
				End If
			End If
		End If
		Return False
	End Function

#End Region

#Region "Coupon Management"

#Region "CouponProvider Property"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''    Property:  RedemptionService
    ''' 
    ''' Description:  Returns an object for the Coupon remote service provider.
    ''' 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private ReadOnly Property CouponProvider() As ICouponProvider
        Get
            Return CType(Activator.GetObject(GetType(ICouponProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_CouponProvider"))), ICouponProvider)
        End Get
    End Property

#End Region

#Region "RedeemCoupon"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  RedeemCoupon
    ''' 
    ''' Description:  Redeems the specified coupon and returns information
    '''               about the redeemed coupon.
    ''' 
    ''' </summary>
    ''' <param name="accountNumber"></param>
    ''' <param name="couponId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Public Overrides Function RedeemCoupon(ByVal accountNumber As String, ByVal couponId As String) As IRedeemCoupon

        Dim provider As ICouponProvider
        Dim response As New CouponRedemptionResponse
        Dim coupon As New BLRedeemCoupon

        Try

            '-------------------------------------------------------------------
            ' Create request for remote call.
            '-------------------------------------------------------------------
            Dim request As New CouponRedemptionRequest

            With request
                .AccountId = accountNumber
                .CouponId = couponId
            End With

            '-------------------------------------------------------------------
            ' Call remote service to redeem coupon.
            '-------------------------------------------------------------------
            provider = Me.CouponProvider
            response = CType(provider.RedeemCoupon(request), CouponRedemptionResponse)

            '-------------------------------------------------------------------
            ' Validate response.
            '-------------------------------------------------------------------
            Me.ValidateResponse(response)

            '-------------------------------------------------------------------
            ' Assign information for redeemed coupon.
            '-------------------------------------------------------------------
            coupon = Me.Map(response.CouponRedemptionResult)

        Catch ex As Exception
            '-------------------------------------------------------------------
            ' Assign error message.
            '-------------------------------------------------------------------
            If response IsNot Nothing AndAlso _
               Not String.IsNullOrEmpty(response.CharterDotCom_Friendly_Messages) Then
                Me._LastCCOMDisplayFriendlyExceptionMessage = response.CharterDotCom_Friendly_Messages
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
            End If

            '-------------------------------------------------------------------
            ' Log exception and throw to calling program.
            '-------------------------------------------------------------------
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw

        Finally
            provider = Nothing
        End Try

        '-----------------------------------------------------------------------
        ' Return information for redeemed coupon.
        '-----------------------------------------------------------------------
        Return coupon

    End Function

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  ValidateResponse
    ''' 
    ''' Description:  Validates the response from a RedeemCoupon request.
    ''' 
    ''' </summary>
    ''' <param name="response"></param>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private Sub ValidateResponse(ByVal response As CouponRedemptionResponse)

        '-----------------------------------------------------------------------
        ' Check for missing response from remote call.
        '-----------------------------------------------------------------------
        If response Is Nothing OrElse response.Result Is Nothing Then
            Throw New Exception()
        End If

        '-----------------------------------------------------------------------
        ' Check for non-success result.
        '-----------------------------------------------------------------------
        If response.Exception OrElse response.CouponRedemptionResult Is Nothing Then
            Throw New Exception()
        End If

    End Sub

#End Region

#Region "RedeemGiftCard"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  RedeemGiftCard
    ''' 
    ''' Description:  Redeems the specified gift card and returns information
    '''               about the redeemed coupon/card.
    ''' 
    ''' </summary>
    ''' <param name="accountNumber"></param>
    ''' <param name="couponId"></param>
    ''' <param name="address"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Public Overrides Function RedeemGiftCard(ByVal accountNumber As String, ByVal couponId As String, ByVal address As CommonEntities.Library.IAddress) As CommonEntities.Library.IRedeemCoupon

        Dim provider As ICouponProvider
        Dim response As New GiftCardRedemptionResponse
        Dim coupon As New BLRedeemCoupon

        Try

            '-------------------------------------------------------------------
            ' Create request for remote call.
            '-------------------------------------------------------------------
            Dim request As New GiftCardRedemptionRequest

            With request
                .AccountId = accountNumber
                .CouponId = couponId
                .Address = address
            End With

            '-------------------------------------------------------------------
            ' Call remote service to redeem gift card.
            '-------------------------------------------------------------------
            provider = Me.CouponProvider
            response = CType(provider.RedeemGiftCard(request), GiftCardRedemptionResponse)

            '-------------------------------------------------------------------
            ' Validate response.
            '-------------------------------------------------------------------
            Me.ValidateResponse(response)

            '-------------------------------------------------------------------
            ' Assign information for redeemed gift card.
            '-------------------------------------------------------------------
            coupon = Me.Map(response.GiftCardRedemptionResult)

            If response.Address IsNot Nothing Then
                coupon.Address = response.Address
            End If

        Catch ex As Exception
            '-------------------------------------------------------------------
            ' Assign error message.
            '-------------------------------------------------------------------
            If response IsNot Nothing AndAlso _
               Not String.IsNullOrEmpty(response.CharterDotCom_Friendly_Messages) Then
                Me._LastCCOMDisplayFriendlyExceptionMessage = response.CharterDotCom_Friendly_Messages
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
            End If

            '-------------------------------------------------------------------
            ' Log exception and throw to calling program.
            '-------------------------------------------------------------------
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw

        Finally
            provider = Nothing
        End Try

        '-----------------------------------------------------------------------
        ' Return information for redeemed coupon.
        '-----------------------------------------------------------------------
        Return coupon

    End Function

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  ValidateResponse
    ''' 
    ''' Description:  Validates the response from a RedeemGiftCard request.
    ''' 
    ''' </summary>
    ''' <param name="response"></param>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private Sub ValidateResponse(ByVal response As GiftCardRedemptionResponse)

        '-----------------------------------------------------------------------
        ' Check for missing response from remote call.
        '-----------------------------------------------------------------------
        If response Is Nothing OrElse response.Result Is Nothing Then
            Throw New Exception()
        End If

        '-----------------------------------------------------------------------
        ' Check for non-success result.
        '-----------------------------------------------------------------------
        If response.Exception OrElse response.GiftCardRedemptionResult Is Nothing Then
            Throw New Exception()
        End If

    End Sub

#End Region

#Region "GetBillingAddress"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  GetBillingAddress
    ''' 
    ''' Description:  Returns the billing address for the specified account.
    ''' 
    ''' </summary>
    ''' <param name="accountNumber"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Public Overrides Function GetBillingAddress(ByVal accountNumber As String) As CommonEntities.Library.IAddress

        Dim provider As ICouponProvider
        Dim response As New GetCustomerAddressResponse

        Try

            '-------------------------------------------------------------------
            ' Create request for remote call.
            '-------------------------------------------------------------------
            Dim request As New GetCustomerAddressRequest

            With request
                .AccountId = accountNumber
            End With

            '-------------------------------------------------------------------
            ' Call remote service to retrieve account addresses.
            '-------------------------------------------------------------------
            provider = Me.CouponProvider
            response = CType(provider.GetCustomerAddress(request), GetCustomerAddressResponse)

            '-------------------------------------------------------------------
            ' Validate response.
            '-------------------------------------------------------------------
            Me.ValidateResponse(response)

        Catch ex As Exception
            '-------------------------------------------------------------------
            ' Assign error message.
            '-------------------------------------------------------------------
            If response IsNot Nothing AndAlso _
               Not String.IsNullOrEmpty(response.CharterDotCom_Friendly_Messages) Then
                Me._LastCCOMDisplayFriendlyExceptionMessage = response.CharterDotCom_Friendly_Messages
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
            End If

            '-------------------------------------------------------------------
            ' Log exception and throw to calling program.
            '-------------------------------------------------------------------
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw

        Finally
            provider = Nothing
        End Try

        '-----------------------------------------------------------------------
        ' Return billing address, if any.
        '-----------------------------------------------------------------------
        Return response.BillingAddress

    End Function

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  ValidateResponse
    ''' 
    ''' Description:  Validates the response from a GetCustomerAddress request.
    ''' 
    ''' </summary>
    ''' <param name="response"></param>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private Sub ValidateResponse(ByVal response As GetCustomerAddressResponse)

        '-----------------------------------------------------------------------
        ' Check for missing response from remote call.
        '-----------------------------------------------------------------------
        If response Is Nothing OrElse response.Result Is Nothing Then
            Throw New Exception()
        End If

        '-----------------------------------------------------------------------
        ' Check for non-success result.
        '-----------------------------------------------------------------------
        If response.Exception Then
            Throw New Exception()
        End If

    End Sub

#End Region

#Region "GetCouponStatus"

    Public Overrides Function GetCouponStatus(ByVal accountNumber As String, ByVal couponId As String) As List(Of ICouponStatus)
        Try

            Dim objCouponStatus As List(Of ICouponStatus) = CouponStatus(accountNumber, couponId)
            Return objCouponStatus
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw ex
        End Try
    End Function

    Private Function CouponStatus(ByVal accountNumber As String, ByVal couponid As String) As List(Of ICouponStatus)
        Dim lProvider As ICouponProvider
        Dim objrequest As CouponServices.GetCouponStatusRequest
        Dim objresponse As CouponServices.GetCouponStatusResponse
        Try
            'Common.RegisterChannels()
            lProvider = Me.CouponProvider
            objrequest = New CouponServices.GetCouponStatusRequest
            Dim objCouponStatus As List(Of ICouponStatus)

            With objrequest
                .accountId = accountNumber
                .couponID = couponid
            End With
            objresponse = CType(lProvider.GetCouponStatus(objrequest), CouponServices.GetCouponStatusResponse)
            If Not (objresponse Is Nothing) Then
                If (objresponse.Exception) Then
                    '##################################################################################
                    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######

                    Select Case True
                        Case Not objresponse.CharterDotCom_Friendly_Messages Is Nothing
                            Me._LastCCOMDisplayFriendlyExceptionMessage = objresponse.CharterDotCom_Friendly_Messages
                        Case Else
                            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                    End Select
                    '##################################################################################

                    Return Nothing
                Else
                    objCouponStatus = New List(Of ICouponStatus)
                    If Not objresponse.CouponStatusResult Is Nothing Then

                        Dim objCouponStatusResult As New BLCouponStatus()
                        objCouponStatusResult.AccountNumber = objresponse.CouponStatusResult.AccountId
                        objCouponStatusResult.CouponId = objresponse.CouponStatusResult.CouponId
                        objCouponStatusResult.CouponDescription = objresponse.CouponStatusResult.CouponDescription
                        Select Case objresponse.CouponStatusResult.CouponStatus
                            Case CouponServices.CouponStatus.Active
                                objCouponStatusResult.CouponStatus = "0"
                            Case CouponServices.CouponStatus.Expired
                                objCouponStatusResult.CouponStatus = "1"
                            Case CouponServices.CouponStatus.InActive
                                objCouponStatusResult.CouponStatus = "4"
                            Case CouponServices.CouponStatus.Redeemed
                                objCouponStatusResult.CouponStatus = "8"
                            Case Else
                                objCouponStatusResult.CouponStatus = objresponse.CouponStatusResult.CouponStatus.ToString()


                        End Select
                        'objCouponStatusResult.CouponStatus = objresponse.CouponStatusResult.CouponStatus.ToString()

                        'objCouponStatusResult.CouponStatus = objresponse.CouponStatusResult.CouponStatus

                        objCouponStatusResult.CouponOffer = objresponse.CouponStatusResult.CouponOffer
                        objCouponStatusResult.CouponStartDate = objresponse.CouponStatusResult.CouponStartDate
                        objCouponStatusResult.CouponEndDate = objresponse.CouponStatusResult.CouponEndDate
                        objCouponStatusResult.ActivationStartDate = objresponse.CouponStatusResult.ActivationStartDate
                        objCouponStatusResult.ActivationEndDate = objresponse.CouponStatusResult.ActivationEndDate
                        objCouponStatusResult.AllowedRedemptions = objresponse.CouponStatusResult.AllowedRedemptions
                        objCouponStatusResult.NumberOfOrderedEvents = objresponse.CouponStatusResult.NumberOfOrderedEvents
                        objCouponStatusResult.ExclusionType = objresponse.CouponStatusResult.ExclusionType
                        objCouponStatusResult.RedemptionDate = objresponse.CouponStatusResult.RedemptionDate
                        objCouponStatusResult.RedemptionChannel = objresponse.CouponStatusResult.RedemptionChannel
                        objCouponStatusResult.ConfirmationNumber = objresponse.CouponStatusResult.ConfirmationNumber
                        objCouponStatusResult.CSRID = objresponse.CouponStatusResult.CSRID
                        objCouponStatusResult.CSRLocation = objresponse.CouponStatusResult.CSRLocation
                        objCouponStatusResult.CSRRole = objresponse.CouponStatusResult.CSRRole
                        objCouponStatusResult.CSRFirstName = objresponse.CouponStatusResult.CSRFirstName
                        objCouponStatusResult.CSRLastName = objresponse.CouponStatusResult.CSRLastName

                        If Not objresponse.CouponStatusResult.RedeemedEvents Is Nothing Then
                            objCouponStatusResult.RedeemedEvents = New List(Of ICouponRedeemedEvents)
                            For Each objResponseRedeemedEvent As CouponServices.RedeemedEventCouponStatus In objresponse.CouponStatusResult.RedeemedEvents
                                Dim objRedeemedEvent As New BLRedeemedEvents
                                objRedeemedEvent.EventCode = objResponseRedeemedEvent.EventCode
                                objRedeemedEvent.EventTitle = objResponseRedeemedEvent.EventTitle
                                objRedeemedEvent.IsRedeemed = objResponseRedeemedEvent.IsRedeemed
                                objCouponStatusResult.RedeemedEvents.Add(objRedeemedEvent)
                            Next
                        End If

                        If Not (objresponse.CouponStatusResult.RedemptionAttempts Is Nothing) Then
                            objCouponStatusResult.RedemptionAttempts = New List(Of ICouponRedemptionAttempt)
                            For Each objResponseRedemptionAttempts As CouponServices.RedemptionAttemptCouponStatus In objresponse.CouponStatusResult.RedemptionAttempts
                                Dim objRedemptionAttempt As New BLRedemptionAttempt
                                objRedemptionAttempt.Channel = objResponseRedemptionAttempts.Channel
                                objRedemptionAttempt.InvalidMessage = objResponseRedemptionAttempts.InvalidMessage
                                objCouponStatusResult.RedemptionAttempts.Add(objRedemptionAttempt)
                            Next
                        End If
                        objCouponStatus.Add(objCouponStatusResult)
                        Return objCouponStatus
                    End If
                End If
            Else
                Return Nothing
            End If

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        Finally
            objrequest = Nothing
            objresponse = Nothing
            lProvider = Nothing
        End Try
    End Function

#End Region

#Region "GetCustomerRedemptionHistory"

    Public Overrides Function GetCustomerRedemptionHistory(ByVal accountNumber As String) As List(Of ICustomerRedemptionHistory)
        Try
            Dim objCustomerRedemptionHistory As List(Of ICustomerRedemptionHistory) = CustomerRedemptionHistory(accountNumber)
            Return objCustomerRedemptionHistory
        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw ex
        End Try
    End Function

    Private Function CustomerRedemptionHistory(ByVal accountNumber As String) As List(Of ICustomerRedemptionHistory)
        Dim lProvider As ICouponProvider
        Dim objrequest As CouponServices.GetCustomerRedemptionHistoryRequest
        Dim objresponse As CouponServices.GetCustomerRedemptionHistoryResponse
        Try
            'Common.RegisterChannels()
            lProvider = Me.CouponProvider
            objrequest = New CouponServices.GetCustomerRedemptionHistoryRequest
            Dim objCustomerRedemptionHistory As List(Of ICustomerRedemptionHistory)
            Dim objCouponStatus As List(Of ICouponStatus)

            With objrequest
                .accountId = accountNumber
            End With
            objCouponStatus = New List(Of ICouponStatus)
            objCustomerRedemptionHistory = New List(Of ICustomerRedemptionHistory)
            objresponse = CType(lProvider.GetCustomerRedemptionHistory(objrequest), CouponServices.GetCustomerRedemptionHistoryResponse)

            If Not (objresponse Is Nothing) Then
                'If (objresponse.Exception) Then
                '    '##################################################################################
                '    '##########     E R R O R   C O D E   M A P P I N G    S O L U T I O N      #######

                '    Select Case True
                '        Case Not objresponse.CharterDotCom_Friendly_Messages Is Nothing
                '            Me._LastCCOMDisplayFriendlyExceptionMessage = objresponse.CharterDotCom_Friendly_Messages
                '        Case Else
                '            Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
                '    End Select
                '    '##################################################################################

                '    Return Nothing
                'Else
                Dim objCustomerRedemptionHistoryResult As New BLCustomerRedemptionHistory()
                If Not objresponse.CouponRedemptionHistoryResult Is Nothing Then
                    'Dim objCustomerRedemptionHistoryResult As New BLCustomerRedemptionHistory()
                    For Each objResponseCouponStatus As CouponServices.CustomerRedemptionHistoryResult In objresponse.CouponRedemptionHistoryResult
                        Dim objCouponStatusResult As New BLCouponStatus()
                        objCouponStatusResult.AccountNumber = objResponseCouponStatus.AccountId
                        objCouponStatusResult.CouponId = objResponseCouponStatus.CouponId
                        objCouponStatusResult.CouponDescription = objResponseCouponStatus.CouponDescription
                        objCouponStatusResult.CouponStatus = objResponseCouponStatus.CouponStatus.ToString()
                        objCouponStatusResult.CouponOffer = objResponseCouponStatus.CouponOffer
                        objCouponStatusResult.CouponStartDate = objResponseCouponStatus.CouponStartDate
                        objCouponStatusResult.CouponEndDate = objResponseCouponStatus.CouponEndDate
                        objCouponStatusResult.ActivationStartDate = objResponseCouponStatus.ActivationStartDate
                        objCouponStatusResult.ActivationEndDate = objResponseCouponStatus.ActivationEndDate
                        objCouponStatusResult.AllowedRedemptions = objResponseCouponStatus.AllowedRedemptions
                        objCouponStatusResult.NumberOfOrderedEvents = objResponseCouponStatus.NumberOfOrderedEvents
                        objCouponStatusResult.ExclusionType = objResponseCouponStatus.ExclusionType
                        objCouponStatusResult.RedemptionDate = objResponseCouponStatus.RedemptionDate
                        objCouponStatusResult.RedemptionChannel = objResponseCouponStatus.RedemptionChannel
                        objCouponStatusResult.ConfirmationNumber = objResponseCouponStatus.ConfirmationNumber
                        objCouponStatusResult.CSRID = objResponseCouponStatus.CSRID
                        objCouponStatusResult.CSRLocation = objResponseCouponStatus.CSRLocation
                        objCouponStatusResult.CSRRole = objResponseCouponStatus.CSRRole
                        objCouponStatusResult.CSRFirstName = objResponseCouponStatus.CSRFirstName
                        objCouponStatusResult.CSRLastName = objResponseCouponStatus.CSRLastName

                        If Not objResponseCouponStatus.RedeemedEvents Is Nothing Then
                            objCouponStatusResult.RedeemedEvents = New List(Of ICouponRedeemedEvents)
                            For Each objResponseRedeemedEvent As CouponServices.RedeemedEventCustomerRedemptionHistory In objResponseCouponStatus.RedeemedEvents
                                Dim objRedeemedEvent As New BLRedeemedEvents
                                objRedeemedEvent.EventCode = objResponseRedeemedEvent.EventCode
                                objRedeemedEvent.EventTitle = objResponseRedeemedEvent.EventTitle
                                objRedeemedEvent.IsRedeemed = objResponseRedeemedEvent.IsRedeemed
                                objCouponStatusResult.RedeemedEvents.Add(objRedeemedEvent)
                            Next

                        End If
                        If Not objResponseCouponStatus.RedemptionAttempts Is Nothing Then
                            objCouponStatusResult.RedemptionAttempts = New List(Of ICouponRedemptionAttempt)
                            For Each objResponseRedemptionAttempts As CouponServices.RedemptionAttemptCustomerRedemptionHistory In objResponseCouponStatus.RedemptionAttempts
                                Dim objRedemptionAttempt As New BLRedemptionAttempt
                                objRedemptionAttempt.Channel = objResponseRedemptionAttempts.Channel
                                objRedemptionAttempt.InvalidMessage = objResponseRedemptionAttempts.InvalidMessage
                                objCouponStatusResult.RedemptionAttempts.Add(objRedemptionAttempt)
                            Next
                        End If
                        objCouponStatus.Add(objCouponStatusResult)
                    Next
                    'objCustomerRedemptionHistoryResult.CouponStatus = objCouponStatus
                    'If (Not objresponse.Result Is Nothing) Then
                    '    objCustomerRedemptionHistoryResult.ReturnCode = objresponse.Result.ReturnCode.ToString()
                    'End If
                    'objCustomerRedemptionHistory.Add(objCustomerRedemptionHistoryResult)
                    'Return objCustomerRedemptionHistory
                End If
                objCustomerRedemptionHistoryResult.CouponStatus = objCouponStatus
                If (Not objresponse.Result Is Nothing) Then
                    objCustomerRedemptionHistoryResult.ReturnCode = objresponse.Result.ReturnCode.ToString()
                End If
                objCustomerRedemptionHistory.Add(objCustomerRedemptionHistoryResult)
                Return objCustomerRedemptionHistory
                'End If
            Else
                Return Nothing
            End If

        Catch ex As Exception
            Common.LogException(ex, ExceptionSeverity.High)
            Throw ex
        Finally
            objrequest = Nothing
            objresponse = Nothing
            lProvider = Nothing
        End Try
    End Function

#End Region

#Region "IsGiftCard"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  IsGiftCard
    ''' 
    ''' Description:  Returns true if the specified coupon-id represents a gift
    '''               card.
    ''' 
    ''' </summary>
    ''' <param name="accountNumber"></param>
    ''' <param name="couponId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Public Overrides Function IsGiftCard(ByVal accountNumber As String, ByVal couponId As String) As Boolean

        Dim provider As ICouponProvider
        Dim response As New GiftCardLookupResponse

        Try

            '-------------------------------------------------------------------
            ' Create request for remote call.
            '-------------------------------------------------------------------
            Dim request As New GiftCardLookupRequest

            With request
                .AccountId = accountNumber
                .CouponId = couponId
            End With

            '-------------------------------------------------------------------
            ' Call remote service to determine type of coupon.
            '-------------------------------------------------------------------
            provider = Me.CouponProvider
            response = CType(provider.GiftCardLookup(request), GiftCardLookupResponse)

            '-------------------------------------------------------------------
            ' Validate response.
            '-------------------------------------------------------------------
            Me.ValidateResponse(response)

        Catch ex As Exception
            '-------------------------------------------------------------------
            ' Assign error message.
            '-------------------------------------------------------------------
            If response IsNot Nothing AndAlso _
               Not String.IsNullOrEmpty(response.CharterDotCom_Friendly_Messages) Then
                Me._LastCCOMDisplayFriendlyExceptionMessage = response.CharterDotCom_Friendly_Messages
            Else
                Me._LastCCOMDisplayFriendlyExceptionMessage = "Sorry, we're unable to take your request at this time."
            End If

            '-------------------------------------------------------------------
            ' Log exception and throw to calling program.
            '-------------------------------------------------------------------
            Common.LogException(ex, ExceptionSeverity.Fatal)
            Throw

        Finally
            provider = Nothing
        End Try

        '-----------------------------------------------------------------------
        ' Return result based on coupon type.
        '-----------------------------------------------------------------------
        Return (response.CouponType.Trim.ToUpper = "GIFTCARD")

    End Function

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  ValidateResponse
    ''' 
    ''' Description:  Validates the response from a GiftCardLookup request.
    ''' 
    ''' </summary>
    ''' <param name="response"></param>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private Sub ValidateResponse(ByVal response As GiftCardLookupResponse)

        '-----------------------------------------------------------------------
        ' Check for missing response from remote call.
        '-----------------------------------------------------------------------
        If response Is Nothing OrElse response.Result Is Nothing Then
            Throw New Exception()
        End If

        '-----------------------------------------------------------------------
        ' Check for non-success result.
        '-----------------------------------------------------------------------
        If response.Exception Then
            Throw New Exception()
        End If

    End Sub

#End Region

#Region "Map"

    ''' ------------------------------------------------------------------------
    ''' <summary>
    ''' 
    '''      Method:  Map
    ''' 
    ''' Description:  Maps the specified CouponRedemptionResult object to a
    '''               new BLRedeemCoupon object.
    ''' 
    ''' </summary>
    ''' <param name="result"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' ------------------------------------------------------------------------
    Private Function Map(ByVal result As CouponRedemptionResult) As BLRedeemCoupon

        Dim coupon As New BLRedeemCoupon

        '-----------------------------------------------------------------------
        ' Assign information for redeemed coupon or gift card.
        '-----------------------------------------------------------------------
        If result IsNot Nothing Then
            With result

                '---------------------------------------------------------------
                ' Assign coupon information.
                '---------------------------------------------------------------
                coupon.AccountNumber = .AccountId
                coupon.CouponId = .CouponId
                coupon.RedemptionStatus = .RedemptionStatus
                coupon.CouponDescription = .CouponDescription
                coupon.AdjustmentAmount = .AdjustmentAmount
                coupon.RedemptionDate = .RedemptionDate
                coupon.ConfirmationNumber = .ConfirmationNumber
                coupon.ConfirmationMessage = .ConfirmationMessage
                coupon.ValidationErrorMessage = .ValidationFailureMessage

                '---------------------------------------------------------------
                ' Assign redeemed event information.
                '---------------------------------------------------------------
                If Not .RedeemedEvents Is Nothing Then
                    coupon.RedeemedEvents = New List(Of ICouponRedeemedEvents)
                    For Each inEvent As RedeemedEvent In .RedeemedEvents
                        Dim outEvent As New BLRedeemedEvents
                        With inEvent
                            outEvent.EventCode = .EventCode
                            outEvent.EventTitle = .EventTitle
                            outEvent.IsRedeemed = .IsRedeemed
                        End With
                        coupon.RedeemedEvents.Add(outEvent)
                    Next
                End If

            End With
        End If

        '-----------------------------------------------------------------------
        ' Return the redeemed coupon or gift card.
        '-----------------------------------------------------------------------
        Return coupon

    End Function

#End Region

#End Region

End Class