Implement IHttpApplicationDataProvider interface and Let CuteChat know your
membership database information
In this step, you need to implement five methods:
'Check the user is an administrator or not.
Public Function IsAdministrator(ByVal useruniquename As String) As
Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsAdministrator
Code Example
Public Function IsAdministrator(ByVal useruniquename As String) As Boolean
Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsAdministrator
Dim udb As New
UsersDB
Dim email As String = useruniquename
Dim roles As
String() = udb.GetRoles(email)
Return Array.IndexOf(roles,
"Admins") <> -1
End Function
'Return user's display name
Public Function GetUserDisplayName(ByVal useruniquename As String) As
String Implements CuteSoft.Chat.IHttpApplicationDataProvider.GetUserDisplayName
Code Example
Public Function GetUserDisplayName(ByVal useruniquename As String) As String
Implements CuteSoft.Chat.IHttpApplicationDataProvider.GetUserDisplayName
Dim udb As New
UsersDB
Dim email As String = useruniquename
Dim sdr As
SqlDataReader = udb.GetSingleUser(email)
Try
Dim
hasrecord = sdr.Read()
If
(hasrecord) Then
Return sdr.GetString(sdr.GetOrdinal("Name"))
End If
Finally
sdr.Close()
End Try
Return "(Unknown)"
End Function
'Retrieves all the user's unique names in the database.
Public Function ListUserUniqueName() As String() Implements
CuteSoft.Chat.IHttpApplicationDataProvider.ListUserUniqueName
Code Example
Public Function ListUserUniqueName()
As String() Implements
CuteSoft.Chat.IHttpApplicationDataProvider.ListUserUniqueName
Dim udb As New
AdminDB
Dim sdr As SqlDataReader =
udb.GetUsers()
Try
Dim list As
New ArrayList
Dim pos As
Integer = sdr.GetOrdinal("Email")
Do While
sdr.Read
list.Add(sdr.GetString(pos))
Loop
Return
CType(list.ToArray(GetType(String)), String())
Finally
sdr.Close()
End Try
End Function
'Return an array of user names containing the input string.
Public Function SearchUserUniqueNameByDisplayName(ByVal userDisplaName
As String) As String() Implements
CuteSoft.Chat.IHttpApplicationDataProvider.SearchUserUniqueNameByDisplayName
Code Example
Public Function SearchUserUniqueNameByDisplayName(ByVal
userDisplaName As String) As String() Implements
CuteSoft.Chat.IHttpApplicationDataProvider.SearchUserUniqueNameByDisplayName
Dim emptystrings(0)
As String
If userDisplaName
Is Nothing Then
Return New
String(0) {}
End If
userDisplaName =
userDisplaName.ToLower()
If userDisplaName =
String.Empty Then
Return
emptystrings
End If
Dim names As New
System.Collections.ArrayList
Dim cmd As New
SqlCommand
cmd.Connection = New
SqlConnection(GetConnectionString(Nothing))
cmd.CommandText = "SELECT email FROM
Users WHERE Name LIKE '%'+@p0+'%'"
cmd.Parameters.Add("@p0",
SqlDbType.NVarChar, 100)
cmd.Parameters("@p0").Value =
userDisplaName
cmd.Connection.Open()
Try
Dim sdr As
SqlDataReader = cmd.ExecuteReader()
Try
Do While sdr.Read()
names.Add(sdr.GetString(0)) '0-Email
Loop
Finally
sdr.Close()
End Try
Finally
cmd.Connection.Close()
End Try
Return
CType(names.ToArray(GetType(String)), String())
End Function
'Check the user is a lobby admin or not (only for integrated
room).
Public Function IsLobbyAdmin(ByVal useruniquename As String, ByVal lobby
As CuteSoft.Chat.CuteChatLobby) As Boolean Implements
CuteSoft.Chat.IHttpApplicationDataProvider.IsLobbyAdmin
Code Example
Public Function IsLobbyAdmin(ByVal
useruniquename As String, ByVal lobby As CuteSoft.Chat.CuteChatLobby) As
Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsLobbyAdmin
Return False
End Function
|