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 System.Xml

Partial Class TestMemberServices
    Inherits System.Web.UI.Page

    Private _provider As IMemberServicesProvider
    ' UAT  values
    Private m_Login As String = "nextit114"  '"john.smith"
    Private m_Password As String = "Pass2word" '"Testing@159"

    Private m_AccountNumber As String = "8245125101276668" '"8345780590154948"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            'Dim lProvider As CharterDotCom.CommonEntities.Library.IMemberServicesProvider = CType(Activator.GetObject(GetType(IMemberServicesProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_MemberServicesProvider"))), IMemberServicesProvider)
            Dim lProvider As New MemberServicesProvider.ProviderManager

            Me.Provider = lProvider
        End If
    End Sub
    Private Property Provider() As IMemberServicesProvider
        Get
            Return _provider
        End Get
        Set(ByVal value As IMemberServicesProvider)
            _provider = value
        End Set
    End Property

    Protected Sub btnAuthenticate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAuthenticate.Click
        Try
            Dim objRequest As New AuthenticateRequest
            Dim objresult As New AuthenticateResponse
            Dim sError As String = ""

            objRequest.csrLogin = txtCSRLogin.Text
            objRequest.csrPassword = txtCSRPassword.Text

            objRequest.Login = m_Login
            objRequest.Password = m_Password
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

            objresult = Me.Provider.Authenticate(objRequest)

            If objresult.Exception Then
                sError = objresult.ExceptionMessage
                If objresult.ExceptionStackTrace IsNot Nothing Then
                    sError &= "<br/>" & objresult.ExceptionStackTrace.ToString()
                End If
                Response.Write("Authenticate Fail, message: " & sError)
            Else
                Response.Write("Authenticate has Success, Account ID: " & objresult.AccountID)
            End If
        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try
    End Sub

    Protected Sub btnCreateMemberService_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreateMemberService.Click
        Dim objRequest As New CreateMemberServiceRequest
        Dim objresult As New TheCommonResponse

        objRequest.accountNumber = m_AccountNumber
        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text

        objRequest.userName = m_Login
        objRequest.password = m_Password
        objRequest.securityQuestion = "Father's middle name?"
        objRequest.securityAnswer = "Jack"
        objRequest.preferedEmailId = "dacyrus@test.com"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.CreateMemberService(objRequest)
    End Sub

    Protected Sub btnCreateWebspace_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreateWebspace.Click
        Dim objRequest As New CreateWebspaceRequest
        Dim objresult As New TheCommonResponse

        objRequest.accountId = m_AccountNumber
        objRequest.login = m_Login
        objRequest.password = m_Password
        'objRequest.provisionId = "61907603" 'based on sia's email to rod 6/7/2006, this looks like its an optional parm
        objRequest.webspaceLogin = "sperficient1000"
        objRequest.webspacePassword = "password1000"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.CreateWebspace(objRequest)
    End Sub

    Protected Sub btnChangeMSLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeMSLogin.Click
        Dim objRequest As New ChangeMSLoginRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.newUserName = "jmahar1"
        objRequest.userName = "jmahar2"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.ChangeMSLogin(objRequest)
    End Sub

    Protected Sub btnChangeMSPassword_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeMSPassword.Click
        Dim objRequest As New ChangeMSPasswordRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text

        objRequest.userName = "jmahar1"
        objRequest.password = txtCSRPassword.Text
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.ChangeMSPassword(objRequest)
    End Sub

    Protected Sub btnChangeMSSecurityQA_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchangeMSSecurityQA.Click
        Dim objRequest As New ChangeMSSecurityQARequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.securityAnswer = "the movie"
        objRequest.securityQuestion = "Favorite movie?"
        objRequest.userName = "jmahar1"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.changeMSSecurityQA(objRequest)
    End Sub

    Protected Sub btnChangeMSContactEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeMSContactEmail.Click
        Dim objRequest As New ChangeMAContactEmailRequest
        Dim objResponse As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.preferedEmailId = "newemail@gmail.com"
        objRequest.userName = "jmahar1"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objResponse = Me.Provider.ChangeMSContactEmail(objRequest)
    End Sub

    Protected Sub btnRemoveEmailAccount_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemoveEmailAccount.Click
        Dim objRequest As New RemoveEmailAccountRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.preferedEmailId = "jgildea@charter.net"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.RemoveEmailAccount(objRequest)
    End Sub

    Protected Sub btnChangeEmailLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeEmailLogin.Click
        Dim objRequest As New ChangeEmailLoginRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text

        objRequest.emailAddress = "superficient0100@charter.net"
        objRequest.newEmailLogin = "superficient0110"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))


        objresult = Me.Provider.ChangeEmailLogin(objRequest)
    End Sub

    Protected Sub btnChangeEmailPassword_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeEmailPassword.Click
        Dim objRequest As New ChangeEmailPasswordRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.emailAddress = "superficient0110@charter.net"
        objRequest.emailPassword = txtCSRPassword.Text
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.ChangeEmailPassword(objRequest)
    End Sub

    Protected Sub btnGetMSWebspaceSummary_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMSWebspaceSummary.Click
        Dim objRequest As New GetMSWebspaceSummaryRequest
        Dim objresult As New GetMSWebspaceSummaryResponse

        objRequest.accountId = m_AccountNumber
        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.type = "WEBSPACE"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetMSWebspaceSummary(objRequest)
    End Sub

    Protected Sub btnCreateEmailAccount_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreateEmailAccount.Click
        Dim objRequest As New CreateEmailAccountRequest
        Dim objresult As New TheCommonResponse

        objRequest.accountId = m_AccountNumber
        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text
        objRequest.emailLogin = "dacyrus99s020"
        objRequest.emailPassword = "password12345"
        objRequest.emailDomain = "charter.net"
        objRequest.provisionId = "120217348"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.CreateEmailAccount(objRequest)
    End Sub

    Protected Sub btnChangeMSEmailToPrimary_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChangeMSEmailToPrimary.Click
        Dim objRequest As New ChangeMSEmailToPrimaryRequest
        Dim objresult As New TheCommonResponse

        objRequest.csrlogin = txtCSRLogin.Text
        objRequest.csrpassword = txtCSRPassword.Text

        objRequest.emailAddress = "rod.copeland1@charter.net"
        objRequest.userName = "bsmith17"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.ChangeMSEmailToPrimary(objRequest)
    End Sub

    Protected Sub btnGetEmailAddressListForLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetEmailAddressListForLogin.Click
        Dim objRequest As New GetEmailAddressListForLoginRequest
        Dim objresult As New GetEmailAddressListForLoginResponse

        objRequest.csrLogin = txtCSRLogin.Text
        objRequest.csrPassword = txtCSRPassword.Text
        objRequest.userName = "modret2"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetEmailAddressListForLogin(objRequest)
    End Sub

    Protected Sub btnGetMSSecurityQAForAccount_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMSSecurityQAForAccount.Click
        Dim objRequest As New GetMSSecurityQAForAccountRequest
        Dim objresult As New GetMSSecurityQAForAccountResponse

        objRequest.accountId = m_AccountNumber
        objRequest.csrLogin = txtCSRLogin.Text
        objRequest.csrPassword = txtCSRPassword.Text
        objRequest.type = "SECURITYQA"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        '
        objresult = Me.Provider.GetMSSecurityQAForAccount(objRequest)
    End Sub
    Protected Sub btnGetMSSecurityQA_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMSSecurityQA.Click
        Dim objRequest As New GetMSSecurityQARequest
        Dim objresult As New GetMSSecurityQAResponse

        objRequest.csrLogin = txtCSRLogin.Text
        objRequest.csrPassword = txtCSRPassword.Text
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetMSSecurityQA(objRequest)
    End Sub


    Protected Sub btnforgotMSPassword_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnforgotMSPassword.Click
        Dim objRequest As New forgotMSPasswordRequest
        Dim objresult As New TheCommonResponse

        objRequest.MSContactEmail = "test123456@chartercom.com" '"rod.copeland@chartercom.com" 'my e-address is associated with the MS Login superficient
        objRequest.AccountID = ""

        objRequest.CSRLogin = txtCSRLogin.Text
        objRequest.CSRPassword = txtCSRPassword.Text
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        'objresult = Me.Provider.forgotMSPassword(objRequest)
    End Sub

    Protected Sub btnGetMSBillingSystemLink_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMSBillingSystemLink.Click
        Dim objRequest As New GetMSBillingSystemLinkRequest
        Dim objresult As New GetMSBillingSystemLinkResponse

        objRequest.accountId = m_AccountNumber
        objRequest.login = txtCSRLogin.Text
        objRequest.password = txtCSRPassword.Text
        objRequest.successPage = "servicessummary"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetMSBillingSystemLink(objRequest)

    End Sub

    Protected Sub btnGetMSSecurityKeys_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMSSecurityKeys.Click
        Dim objRequest As New GetMSSecurityKeysRequest
        Dim objresult As New GetMSSecurityKeysResponse

        objRequest.accountId = m_AccountNumber
        objRequest.csrLogin = txtCSRLogin.Text
        objRequest.csrPassword = txtCSRPassword.Text
        'objRequest.type = "SECURITYKEY"
        objRequest.type = "PACKAGE"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetMSSecurityKeys(objRequest)
    End Sub

    Protected Sub btnActivateSecurityKey_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnActivateSecurityKey.Click
        Dim objRequest As New ActivateMSSecurityKeyRequest
        Dim objresult As New ActivateMSSecurityKeyResponse

        objRequest.CSRlogin = txtCSRLogin.Text
        objRequest.CSRpassword = txtCSRPassword.Text
        objRequest.accountId = m_AccountNumber
        objRequest.provisioningId = "101235308"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.ActivateMSSecurityKey(objRequest)
    End Sub

    Protected Sub btnRemoveWebspace_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemoveWebspace.Click
        Dim objRequest As New RemoveWebspaceRequest
        Dim objresult As New TheCommonResponse

        objRequest.accountId = m_AccountNumber
        objRequest.CSRlogin = txtCSRLogin.Text
        objRequest.CSRpassword = txtCSRPassword.Text
        objRequest.provisionId = "58043049"
        objRequest.webspaceLogin = "rod.copeland100"
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.RemoveWebspace(objRequest)
    End Sub

    Protected Sub btnGetSignInData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetSignInData.Click
        Dim objRequest As New GetSignInDataRequest
        Dim objresult As New GetSignInDataResponse
        Dim sError As String = ""

        objRequest.csrLogin = txtCSRLogin.Text
        objRequest.csrPassword = txtCSRPassword.Text

        objRequest.Login = m_Login
        objRequest.Password = m_Password
        objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        objresult = Me.Provider.GetSignInData(objRequest)

        If objresult.Exception Then
            sError = objresult.ExceptionMessage
            If objresult.ExceptionStackTrace IsNot Nothing Then
                sError &= "<br/>" & objresult.ExceptionStackTrace.ToString()
            End If
            Response.Write("Sign In Fail, message: " & sError)
        Else
            Response.Write("Sign In has Success, Account ID: " & objresult.MSAuthenticateMsExResponse.accountNumber)
        End If

    End Sub

    Protected Sub btnAuthenticateMsEx_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAuthenticateMsEx.Click
        Try
            Dim objRequest As New AuthenticateMsExRequest
            Dim objresult As New AuthenticateMsExResponse
            Dim sError As String = ""
            objRequest.csrLogin = txtCSRLogin.Text
            objRequest.csrPassword = txtCSRPassword.Text

            objRequest.Login = txtCustomerID.Text  'm_Login
            objRequest.Password = txtCustomerPassword.Text '  m_Password
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

            objresult = Me.Provider.AuthenticateMsEx(objRequest)
            If objresult.Exception Then
                sError = objresult.ExceptionMessage
                If objresult.ExceptionStackTrace IsNot Nothing Then
                    sError &= "<br/>" & objresult.ExceptionStackTrace.ToString()
                End If
                Response.Write("Authenticate Fail, message: " & sError)
                Response.Write("<BR/>csr login: " & txtCSRLogin.Text)
                Response.Write("<BR/>csr password: " & txtCSRPassword.Text)
            Else
                Response.Write("Authenticate has Success, Account ID: " & objresult.accountNumber)
            End If
        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try
    End Sub

    Protected Sub btnAuthenticateQA_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAuthenticateQA.Click
        Try
            Dim objRequest As New AuthenticateLoginSecretQARequest
            Dim objresult As New AuthenticateLoginSecretQAResponse
            Dim sError As String = ""

            objRequest.csrLogin = txtCSRLogin.Text
            objRequest.csrPassword = txtCSRPassword.Text

            objRequest.LoginID = "srenaud"
            objRequest.SecurityAnswer = "oscar"
            objRequest.SecurityQuestion = "Favorite pet's name?"
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

            objresult = Me.Provider.AuthenticateLoginSecretQA(objRequest)
            If objresult.Exception Then
                sError = objresult.ExceptionMessage
                If objresult.ExceptionStackTrace IsNot Nothing Then
                    sError &= "<br/>" & objresult.ExceptionStackTrace.ToString()
                End If
                Response.Write("Authenticate Fail, message: " & sError)
            Else
                Response.Write("Authenticate has Success")
            End If
        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try
    End Sub


    

    Protected Sub btngetLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btngetLogin.Click
        Try
            Dim objTempRequest As New GetLoginRequest
            Dim objresult As New GetLoginResponse
            Dim sError As String = ""




            objTempRequest.getAnswer = "true"
            objTempRequest.System = "mslogin"
            objTempRequest.method = "getLogin"
            objTempRequest.AccountNumber = m_AccountNumber

            objresult = Me.Provider.GetLoginID(objTempRequest)

            If Not (objresult.UserName Is Nothing) Then
                Response.Write("user name is " + objresult.UserName)
                If Not (objresult.SecretQuestion Is Nothing) Then
                    Response.Write("Sec Question is " + objresult.SecretQuestion.ToString)
                End If
            Else
                Response.Write("getLogin Fail, message: " + objresult.CharterDotCom_Friendly_Messages)
            End If
        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try
    End Sub

    Protected Sub btnGetLoginByUserName_Click(sender As Object, e As System.EventArgs) Handles btnGetLoginByUserName.Click
        Try
            Dim objTempRequest As New GetLoginRequest
            Dim objresult As New GetLoginResponse
            Dim sError As String = ""




            objTempRequest.getAnswer = "true"
            objTempRequest.System = "mslogin"
            objTempRequest.method = "getLogin"
            objTempRequest.AccountNumber = "cycletest1"

            objresult = Me.Provider.GetLoginIDByUserName(objTempRequest)

            If Not (objresult.UserName Is Nothing) Then
                Response.Write("user name is " + objresult.UserName)
                If Not (objresult.SecretQuestion Is Nothing) Then
                    Response.Write("Sec Question is " + objresult.SecretQuestion.ToString)
                End If
            Else
                Response.Write("getLogin Fail, message: " + objresult.CharterDotCom_Friendly_Messages)
            End If
        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try

    End Sub
End Class