Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System.Collections.Generic
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports System.Data.Common
Imports System.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


<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
    Inherits System.Web.Services.WebService

    Private _cmd As DbCommand
    Private _db As Database


    Public Sub New()
        Me.DB = DatabaseFactory.CreateDatabase("Charter.Website.WS.CommerceEngineConnectionString")
    End Sub


    Private Property DB() As Database
        Get
            Return _db
        End Get
        Set(ByVal value As Database)
            _db = value
        End Set
    End Property
    Private Property CMD() As DbCommand
        Get
            Return _cmd
        End Get
        Set(ByVal value As DbCommand)
            _cmd = value
        End Set
    End Property



    <WebMethod()> _
    Public Function GetSignInData(ByVal objTempRequest As GetSignInDataRequest) As GetSignInDataResponse
        '#######################################
        'TEMP LOCAL VARIABLES FOR REQUEST OBJECT
        '#######################################
        Dim lMSProvider As New MemberServicesProvider.ProviderManager
        Dim lEBSProvider As New EBSServicesProvider.ProviderManager

        Dim CSRLOGIN As String = ""
        Dim CSRPASSWORD As String = ""
        Dim MSACCOUNTID As String = ""

        '#######################################
        'TEMP LOCAL VARIABLES FOR RESPONSE OBJECT
        '#######################################
        'Dim objTempResponse As New WSMemberServices.WSResult
        Dim objResponse As New GetSignInDataResponse

        Try
            If Not (objTempRequest Is Nothing) Then

                CSRLOGIN = objTempRequest.csrLogin
                CSRPASSWORD = objTempRequest.csrPassword


                '############################################################
                'BUILD REQUEST OBJECT AND CALL THE MEMBER SERVICE PROVIDER AUTHENTICATE METHOD
                '############################################################
                Dim objAuthenticateMsExRequest As New AuthenticateMsExRequest
                Dim objAuthenticateMsExResponse As New AuthenticateMsExResponse

                objAuthenticateMsExRequest.csrLogin = CSRLOGIN
                objAuthenticateMsExRequest.csrPassword = CSRPASSWORD
                objAuthenticateMsExRequest.Login = objTempRequest.Login
                objAuthenticateMsExRequest.Password = objTempRequest.Password

                '################################
                'EXECUTE THE CALL TO THE PROVIDER
                '################################
                objAuthenticateMsExResponse = lMSProvider.AuthenticateMsEx(objAuthenticateMsExRequest)

                '#######################
                '#######################
                '##########################################################
                'ASSIGN RESULT OBJECT TO THE GETSIGNINDATARESPONSE OBJECT
                '##########################################################
                objResponse.MSAuthenticateMsExResponse = objAuthenticateMsExResponse




                If Not objResponse.MSAuthenticateMsExResponse.Exception Then

                    '############################################################
                    'GET THE BILLING SUMMARY INFO FROM THE EBS WEB SERVICE
                    '############################################################
                    If Not (objAuthenticateMsExResponse Is Nothing) Then
                        If Not (objAuthenticateMsExResponse.billingType Is Nothing) Then
                            Select Case objAuthenticateMsExResponse.billingType.Trim().ToLower()
                                Case "csg"
                                    If Not (objResponse Is Nothing) Then
                                        If Not (objResponse.MSAuthenticateMsExResponse Is Nothing) Then
                                            If Not (objResponse.MSAuthenticateMsExResponse.accountNumber Is Nothing) Then
'################################################################################################
'MODIFICATION	ROD COPELAND	ISSUE ID 6661	CSG Multi-Statement - My Account Overview Page
'################################################################################################
                                                '################################################################################################
                                                Dim objGetCustomerStatementsRequest As New GetCustomerStatementsRequest()
                                                Dim objGetCustomerStatementsResponse As New GetCustomerStatementsResponse()
                                                objGetCustomerStatementsRequest.CsgHeaderInfo = New CsgHeaderInfo()

                                                objGetCustomerStatementsRequest.AccountId = objResponse.MSAuthenticateMsExResponse.accountNumber
                                                objGetCustomerStatementsRequest.CsgHeaderInfo.ConversationId = ""
                                                objGetCustomerStatementsRequest.CsgHeaderInfo.Region = ""
                                                objGetCustomerStatementsRequest.CsgHeaderInfo.RoutingArea = objResponse.MSAuthenticateMsExResponse.accountNumber.Substring(0, 6) & "00"

                                                ''########################################################################
                                                ''MAKE CALL TO THE PROVIDER WHICH IN TURN WILL CALL THE EBS WEB SERVICE
                                                ''########################################################################
                                                objGetCustomerStatementsResponse = CType(lEBSProvider.GetCustomerStatements(objGetCustomerStatementsRequest), GetCustomerStatementsResponse)

                                                objResponse.EAICustomerStatementsResponse = objGetCustomerStatementsResponse
                                                '################################################################################################
                                                '################################################################################################
                                                '################################################################################################
                                            End If

                                        End If
                                    End If

                                Case "icoms"
                                    If Not (objResponse Is Nothing) Then
                                        If Not (objResponse.MSAuthenticateMsExResponse Is Nothing) Then
                                            If Not (objResponse.MSAuthenticateMsExResponse.accountNumber Is Nothing) Then
                                                Dim objGetAccountStatementsAllRequest As GetAccountStatementsAllRequestICOMS
                                                Dim objGetAccountStatementsAllResponse As GetAccountStatementsAllResponseICOMS
                                                Dim objHeader As New IcomsHeaderInfo

                                                Select Case Left(objResponse.MSAuthenticateMsExResponse.accountNumber, 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 = objResponse.MSAuthenticateMsExResponse.accountNumber.Substring(3, 9)
                                                objGetAccountStatementsAllRequest = New GetAccountStatementsAllRequestICOMS(objHeader, lstrAccountNumber)

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


                                                objResponse.EBSGetAccountStatementsAllResponseICOMS = objGetAccountStatementsAllResponse



                                            End If
                                        End If
                                    End If
                            End Select
                        End If

                    End If











                End If

            End If



            Return objResponse

        Catch ex As Exception
            objResponse.Exception = True
            objResponse.ExceptionMessage = ex.Message
            objResponse.ExceptionStackTrace = ex.StackTrace
            Return objResponse
        Finally

        End Try

    End Function



    <WebMethod()> _
    Public Function GetWebConfig(ByVal ConfigLocation As String) As System.Data.DataSet
        Try
            Dim strSQL As String = "SELECT [ID],[Key],XMLdata FROM ADMIN.WebConfig WHERE CONFIGLOCATION = '" & ConfigLocation & "'"
            strSQL = strSQL & ";SELECT * FROM Admin.ERROR_CODE_MAPPING"
            strSQL = strSQL & ";SELECT * FROM Admin.PAGE_MANAGEMENT ORDER BY PAGE_URL, HBX_PAGE_CATEGORY, HBX_PAGE_NAME"
            strSQL = strSQL & ";SELECT * FROM Admin.URL_REDIRECT_MAPPING ORDER BY REQUEST_URL"
            strSQL = strSQL & ";SELECT * FROM Admin.XSSConfig ORDER BY ID"
            Me.CMD = Me.DB.GetSqlStringCommand(strSQL)
            Dim DS As DataSet = DB.ExecuteDataSet(Me.CMD)

            DS.Tables.Add(GetSecretQuestionTable(ConfigLocation))


            Return DS

        Catch ex As Exception
            Throw ex
        End Try

    End Function


    Private Function GetSecretQuestionTable(ByVal ConfigLocation As String) As DataTable
        Dim Q1 As String = "My favorite movie?"
        Dim Q2 As String = "My favorite pet’s name?"
        Dim Q3 As String = "My favorite teacher’s name?"
        Dim Q4 As String = "My favorite sports team?"
        Dim Q5 As String = "What was the color or make of your first car?"

        Dim Q6 As String = ""
        Dim Q7 As String = ""
        Dim Q8 As String = ""
        Dim Q9 As String = ""
        Dim Q10 As String = ""
        Dim Q11 As String = ""

        Try

            '##################################################################################
            'GET THE VALUES OF THE CSR USER ID AND CSR PASSWORD, THEN USE THEM TO MAKE A CALL 
            'TO THE MSPROVIDER LOOKING FOR THE SECRET QUESTION LIST
            '##################################################################################
            Dim strSQL2 As String = "SELECT [ID],[Key],[XMLdata] FROM ADMIN.WebConfig WHERE CONFIGLOCATION = '" & ConfigLocation.Replace("REMOTINGHOST", "WEBSERVER") & "' AND [KEY]  IN ( 'CSR_LOGIN', 'CSR_PASSWORD') ORDER BY [KEY]"
            Me.CMD = Me.DB.GetSqlStringCommand(strSQL2)
            Dim CSRCredentials_DS As DataSet = DB.ExecuteDataSet(Me.CMD)



            '##################################################################################
            'GET THE DETAULT SECRET QUESTIONS IN CASE THE WS FAILS TO GET THE QUESTION LIST
            'IF ANY EXCEPTION CONDITION HAPPENS, ASSIGN THE DEFAULT QUESTIONS 
            '##################################################################################
            Dim strSQL3 As String = "SELECT [ID],[Key],[XMLdata] FROM ADMIN.WebConfig WHERE CONFIGLOCATION = '" & ConfigLocation & "' AND [KEY]  IN ('DEFAULT_SECRET_QUESTION_1','DEFAULT_SECRET_QUESTION_2','DEFAULT_SECRET_QUESTION_3','DEFAULT_SECRET_QUESTION_4','DEFAULT_SECRET_QUESTION_5','DEFAULT_SECRET_QUESTION_6','DEFAULT_SECRET_QUESTION_7','DEFAULT_SECRET_QUESTION_8','DEFAULT_SECRET_QUESTION_9','DEFAULT_SECRET_QUESTION_10') ORDER BY ID"
            Me.CMD = Me.DB.GetSqlStringCommand(strSQL3)
            Dim SecretQuestionList_DS As DataSet = DB.ExecuteDataSet(Me.CMD)

            Q1 = SecretQuestionList_DS.Tables(0).Rows(0)("xmlData")
            Q2 = SecretQuestionList_DS.Tables(0).Rows(1)("xmlData")
            Q3 = SecretQuestionList_DS.Tables(0).Rows(2)("xmlData")
            Q4 = SecretQuestionList_DS.Tables(0).Rows(3)("xmlData")
            Q5 = SecretQuestionList_DS.Tables(0).Rows(4)("xmlData")

            Q6 = SecretQuestionList_DS.Tables(0).Rows(5)("xmlData")
            Q7 = SecretQuestionList_DS.Tables(0).Rows(6)("xmlData")
            Q8 = SecretQuestionList_DS.Tables(0).Rows(7)("xmlData")
            Q9 = SecretQuestionList_DS.Tables(0).Rows(8)("xmlData")
            Q10 = SecretQuestionList_DS.Tables(0).Rows(9)("xmlData")




            '##################################################################################
            'GET VALUES SO THE PROVIDER IS ABLE TO CREATE A NEW INSTANCE OF ITSELF
            '##################################################################################
            '##################################################################################################
            'SHEILA SHAHPARI 09/02/2009
            'MODIFY SQL TO FILTER ONLY WEBSERVICE SETTINGS (ADDITIONAL OSSWEBSERVICE SETTINGS SHOULD BE EXCLUDED FROM RESULTSET)
            '###################################################################################################
            Dim strProviderSettionsSQL As String = "SELECT SettingName, SettingValue  FROM Admin.Provider_Settings WHERE ENVIRONMENTNAME = '" & ConfigLocation.Replace("WEBSERVER", "REMOTINGHOST") & "' AND [PROVIDERNAME] = 'MemberServicesProvider' AND settingname LIKE 'WebService%' order by settingname"

            Me.CMD = Me.DB.GetSqlStringCommand(strProviderSettionsSQL)
            Dim DSProviderSettions As DataSet = DB.ExecuteDataSet(Me.CMD)
            Dim Provider_WS_AuthenticationRequired As String = DSProviderSettions.Tables(0).Rows(0)("SettingValue")
            Dim Provider_WS_Password As String = DSProviderSettions.Tables(0).Rows(1)("SettingValue")
            Dim Provider_WS_URL As String = DSProviderSettions.Tables(0).Rows(2)("SettingValue")
            Dim Provider_User As String = DSProviderSettions.Tables(0).Rows(3)("SettingValue")

            '#############################################
            'SET VALUES NEEDED BY THE PROVIDER TO CREATE A 
            'NEW INSTANCE OF ITSELF.
            '#############################################
            Application(MemberServicesProvider.Constant.MEMBERSERVICESPROVIDER_WEBSERVICE_AUTHENTICATIONREQUIRED) = Provider_WS_AuthenticationRequired
            Application(MemberServicesProvider.Constant.MEMBERSERVICESPROVIDER_WEBSERVICE_PASSWORD) = Provider_WS_Password
            Application(MemberServicesProvider.Constant.MEMBERSERVICESPROVIDER_WEBSERVICE_URL) = Provider_WS_URL
            Application(MemberServicesProvider.Constant.MEMBERSERVICESPROVIDER_WEBSERVICE_USER) = Provider_User
            Dim lMSProvider As New MemberServicesProvider.ProviderManager


            '############################################################
            'BUILD REQUEST OBJECT AND CALL THE MEMBER SERVICE PROVIDER TO 
            'GET THE LIST OF SECRET QUESTIONS
            '############################################################
            Dim objMSSecurityQARequest As New GetMSSecurityQARequest
            Dim objMSSecurityQAResponse As New GetMSSecurityQAResponse
            If CSRCredentials_DS.Tables.Count > 0 Then
                objMSSecurityQARequest.csrLogin = CSRCredentials_DS.Tables(0).Rows(0)("XMLData")
                objMSSecurityQARequest.csrPassword = CSRCredentials_DS.Tables(0).Rows(1)("XMLData")

                '################################
                'EXECUTE THE CALL TO THE PROVIDER
                '################################
                objMSSecurityQAResponse = lMSProvider.GetMSSecurityQA(objMSSecurityQARequest)
            Else
                Throw New Exception("CSR Login and Password are not returning from webconfig table.  unable to get secret questions list from MSProvider")
            End If


            Dim lQuestionTable As DataTable
            lQuestionTable = New DataTable("SecretQuestionTable")
            Dim QuestionsClm As DataColumn = New DataColumn("Question")
            QuestionsClm.DataType = System.Type.GetType("System.String")
            lQuestionTable.Columns.Add(QuestionsClm)
            If Not (objMSSecurityQAResponse Is Nothing) Then
                If Not objMSSecurityQAResponse.Exception Then
                    '####################################################
                    'ADD THE QUESTIONS TO THE RESPONSE FROM THE PROVIDER
                    '####################################################
                    For Each providerQuestion As String In objMSSecurityQAResponse.securityQuestionArray
                        Dim aQuestionRow As DataRow = lQuestionTable.NewRow()
                        aQuestionRow.Item("Question") = providerQuestion
                        lQuestionTable.Rows.Add(aQuestionRow)
                    Next
                Else
                    Throw New Exception(objMSSecurityQAResponse.ExceptionMessage & ".  Unable to get secret questions list from MSProvider")
                End If
            Else
                Throw New Exception("Provider response came back as nothing.  unable to get secret questions list from MSProvider")
            End If

            Return lQuestionTable

        Catch ex As Exception
            Dim lQuestionTable As DataTable
            lQuestionTable = New DataTable("SecretQuestionTable")
            Dim QuestionsClm As DataColumn = New DataColumn("Question")
            QuestionsClm.DataType = System.Type.GetType("System.String")
            lQuestionTable.Columns.Add(QuestionsClm)

            '##############################################################################
            'ADD THE DEFAULT QUESTIONS SINCE SOMETHING FAILED WHEN ADDING FROM THE PROVIDER
            '##############################################################################
            If Not (Q1 Is Nothing) Then
                If Q1.Trim <> "" Then
                    Dim aQuestionRow1 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow1.Item("Question") = Q1 '"My favorite movie?"
                    lQuestionTable.Rows.Add(aQuestionRow1)
                End If
            End If
            If Not (Q2 Is Nothing) Then
                If Q2.Trim <> "" Then
                    Dim aQuestionRow2 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow2.Item("Question") = Q2 '"My favorite pet’s name?"
                    lQuestionTable.Rows.Add(aQuestionRow2)
                End If
            End If
            If Not (Q3 Is Nothing) Then
                If Q3.Trim <> "" Then
                    Dim aQuestionRow3 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow3.Item("Question") = Q3 '"My favorite teacher’s name?"
                    lQuestionTable.Rows.Add(aQuestionRow3)
                End If
            End If
            If Not (Q4 Is Nothing) Then
                If Q4.Trim <> "" Then
                    Dim aQuestionRow4 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow4.Item("Question") = Q4 '"My favorite sports team?"
                    lQuestionTable.Rows.Add(aQuestionRow4)
                End If
            End If
            If Not (Q5 Is Nothing) Then
                If Q5.Trim <> "" Then
                    Dim aQuestionRow5 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow5.Item("Question") = Q5 '"What was the color or make of your first car?"
                    lQuestionTable.Rows.Add(aQuestionRow5)
                End If
            End If
            If Not (Q6 Is Nothing) Then
                If Q6.Trim <> "" Then
                    Dim aQuestionRow6 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow6.Item("Question") = Q6 '"My favorite movie?"
                    lQuestionTable.Rows.Add(aQuestionRow6)
                End If
            End If
            If Not (Q7 Is Nothing) Then
                If Q7.Trim <> "" Then
                    Dim aQuestionRow7 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow7.Item("Question") = Q7 '"My favorite pet’s name?"
                    lQuestionTable.Rows.Add(aQuestionRow7)
                End If
            End If
            If Not (Q8 Is Nothing) Then
                If Q8.Trim <> "" Then
                    Dim aQuestionRow8 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow8.Item("Question") = Q8 '"My favorite teacher’s name?"
                    lQuestionTable.Rows.Add(aQuestionRow8)
                End If
            End If
            If Not (Q9 Is Nothing) Then
                If Q9.Trim <> "" Then
                    Dim aQuestionRow9 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow9.Item("Question") = Q9 '"My favorite sports team?"
                    lQuestionTable.Rows.Add(aQuestionRow9)
                End If
            End If
            If Not (Q10 Is Nothing) Then
                If Q10.Trim <> "" Then
                    Dim aQuestionRow10 As DataRow = lQuestionTable.NewRow()
                    aQuestionRow10.Item("Question") = Q10 '"What was the color or make of your first car?"
                    lQuestionTable.Rows.Add(aQuestionRow10)
                End If
            End If



            Return lQuestionTable

        End Try



    End Function

    <WebMethod()> _
  Public Function GetProviderSettings(ByVal ConfigLocation As String) As System.Data.DataTable
        Try
            Dim strSQL As String = "SELECT UPPER(ProviderName + '_' + SettingName) as [key], Settingvalue FROM ADMIN.Provider_Settings WHERE EnvironmentName = '" & ConfigLocation & "'"
            Me.CMD = Me.DB.GetSqlStringCommand(strSQL)
            Dim DS As DataSet = DB.ExecuteDataSet(Me.CMD)

            Return DS.Tables(0)

        Catch ex As Exception
            Throw ex
        End Try
    End Function

    <WebMethod()> _
    Public Function GetAllFolders() As Data.DataSet
        Try
            Me.CMD = Me.DB.GetStoredProcCommand("SUPPORT.GET_ALL_FOLDERS")
            Dim DS As DataSet = DB.ExecuteDataSet(Me.CMD)

            Return DS

        Catch ex As Exception
            Throw ex
        End Try

    End Function

    <WebMethod()> _
   Public Function GetAllDocuments() As Data.DataSet
        Try
            Me.CMD = Me.DB.GetStoredProcCommand("SUPPORT.GET_ALL_DOCUMENTS")
            Dim DS As DataSet = DB.ExecuteDataSet(Me.CMD)

            Return DS

        Catch ex As Exception
            Throw ex
        End Try

    End Function

    Public Function GetCMSContent() As String

        Dim ds As Data.DataSet
        Dim DB As Database
        Dim CMD As Data.Common.DbCommand

        Try

            DB = DatabaseFactory.CreateDatabase("Charter.Website.WS.CommerceEngineConnectionString")
            CMD = DB.GetSqlStringCommand("Select contenttext " & _
                " from charterdotcom_cms.content.content_version " & _
                " where content_name = 'myaccount:login:unavailable' ")
            ds = DB.ExecuteDataSet(CMD)

            If (ds.Tables.Count = 0) OrElse (ds.Tables(0).Rows.Count = 0) Then
                Return ""
            End If

            Return ds.Tables(0).Rows(0).Item("contenttext")

        Catch ex As Exception
            Throw ex
        Finally
            CMD = Nothing
            If Not CMD Is Nothing Then
                CMD.Dispose()
            End If
        End Try
    End Function

    Public Function GetSiteMessageSetting() As String

        Dim webserverkey As String = ConfigurationManager.AppSettings(ApplicationKey.WebServers)

        Dim ds As Data.DataSet
        Dim DB As Database
        Dim CMD As Data.Common.DbCommand
    
        Try

            DB = DatabaseFactory.CreateDatabase("Charter.Website.WS.CommerceEngineConnectionString")
            CMD = DB.GetSqlStringCommand("SELECT ID, XMLData " & _
        " FROM [ADMIN].[WebConfig] c " & _
        " where c.configlocation = '" & webserverkey & "'" & _
        " and [Key] = 'DISABLE_CHARTERDOTCOM_MYACCOUNT_LOGIN'")
            ds = DB.ExecuteDataSet(CMD)

            If (ds.Tables.Count = 0) OrElse (ds.Tables(0).Rows.Count = 0) Then
                Return "F"
            End If

            If (String.Compare(ds.Tables(0).Rows(0).Item("XMLData"), "T", True)) = 0 Then
                Return "T"
            Else
                Return "F"
            End If

        Catch ex As Exception
            Throw ex
        Finally
            CMD = Nothing
            If Not CMD Is Nothing Then
                CMD.Dispose()
            End If
        End Try
    End Function

    Public Sub SetSiteMessageSetting(psValue As String)

        Dim webserverkey As String = ConfigurationManager.AppSettings(ApplicationKey.WebServers)

        Dim iReturn As Integer
        Dim DB As Database
        Dim CMD As Data.Common.DbCommand

        Try
            DB = DatabaseFactory.CreateDatabase("Charter.Website.WS.CommerceEngineConnectionString")
            CMD = DB.GetSqlStringCommand("update [ADMIN].[WebConfig] " & _
                " set XMLData='" & psValue & "' " & _
                " where configlocation = '" & webserverkey & "'" & _
                " and [Key] = 'DISABLE_CHARTERDOTCOM_MYACCOUNT_LOGIN'")

            iReturn = DB.ExecuteNonQuery(CMD)

        Catch ex As Exception
            Throw ex
        Finally
            CMD = Nothing
            If Not CMD Is Nothing Then
                CMD.Dispose()
            End If
        End Try
    End Sub

    Public Sub GetServerConfig()
        Dim lsAppServer As New List(Of String)
        Dim lsWebServer As New List(Of String)

        Dim appserverkey As String = ConfigurationManager.AppSettings(ApplicationKey.AppServers)
        Dim webserverkey As String = ConfigurationManager.AppSettings(ApplicationKey.WebServers)

        Dim ds As Data.DataSet
        Dim DB As Database
        Dim CMD As Data.Common.DbCommand
        Try

            DB = DatabaseFactory.CreateDatabase("Charter.Website.WS.CommerceEngineConnectionString")
            CMD = DB.GetSqlStringCommand("SELECT ServerLocation,ServerName FROM ADMIN.SERVERCONFIG WHERE ServerLocation IN ('" & appserverkey & "','" & webserverkey & "')")
            ds = DB.ExecuteDataSet(CMD)
            If Not ds Is Nothing AndAlso ds.Tables.Count = 1 Then
                For Each dr As Data.DataRow In ds.Tables(0).Rows
                    Select Case dr.Item(0)
                        Case appserverkey
                            lsAppServer.Add(dr.Item(1))
                        Case webserverkey
                            lsWebServer.Add(dr.Item(1))
                    End Select
                Next
                With HttpContext.Current
                    .Application.Lock()
                    .Application.Add(ApplicationKey.AppServers, lsAppServer)
                    .Application.Add(ApplicationKey.WebServers, lsWebServer)
                    .Application.UnLock()
                End With

            End If
        Catch ex As Exception
            Throw ex
        Finally
            lsAppServer = Nothing
            lsWebServer = Nothing
            CMD = Nothing
            If Not CMD Is Nothing Then
                CMD.Dispose()
            End If
        End Try
    End Sub

End Class
