Hi Terry,
My Complete code looks like this now:
- <%@ Application Codebehind="Global.asax.vb" Inherits="SiennEngine.Global_asax" Language="vb" %>
- <%@ Import Namespace="System" %>
- <%@ Import Namespace="System.Collections" %>
- <%@ Import Namespace="System.ComponentModel" %>
- <%@ Import Namespace="System.Web" %>
- <%@ Import Namespace="System.Web.SessionState" %>
- <%@ Import Namespace="System.Security.Principal" %>
- <%@ Import Namespace="System.Data" %>
- <%@ Import Namespace="System.Data.SqlClient" %>
-
- <%@ Import Namespace="CuteChat" %>
-
- <script runat="server" Language="vb">
-
- Public Overloads Overrides Sub Init()
- MyBase.Init()
-
- SyncLock GetType(CuteChat.ChatSystem)
- If Not CuteChat.ChatSystem.HasStarted Then
- CuteChat.ChatProvider.Instance = New MyChatProvider()
- CuteChat.ChatSystem.Start(New CuteChat.AppSystem())
- End If
- End SyncLock
- End Sub
-
- Public Class MyChatProvider
- Inherits CuteChat.ChatProvider
- Dim pbw As New SiennEngine.PBW
- Dim Constring As String = pbw.get_constring()
- Dim Cid As String = pbw.get_cid_currentdomain()
-
- Dim prefix As String = Cid & "U_"
- Dim userId as string = ""
-
- Public Overloads Overrides Function GetConnectionString() As String
- Dim Retstring As String = Constring
- Return Retstring
- End Function
- Public Overloads Overrides Function FindUserLoginName(ByVal nickName As String) As String
- try
- userId = httpcontext.current.request.Cookies("UserId").Value
- catch
- end try
- Dim Retstring As String = ""
- Dim Query As String = "Select UserName from " & prefix & "users where Id = " & UserId
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- Try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- While Reader.Read()
- Retstring = reader(0)
- End While
- Catch
- End Try
- Con.Close()
- Return Retstring
- End Function
- Public Overloads Overrides Function GetLogonIdentity() As AppChatIdentity
-
- try
- userId = httpcontext.current.request.Cookies("UserId").Value
- catch
- end try
-
- Dim loginname As String = ""
- Dim nickname As String = ""
- Dim Query As String = "Select UserName, NickName from " & prefix & "users where Id = " & UserId
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- Try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- While Reader.Read()
- loginname = reader(0)
- nickname = Reader(1)
- If Nickname Is Nothing Or nickname = "" Then nickname = loginname
- End While
- Catch
- nickname = loginname
- End Try
- Con.Close()
-
- Return New AppChatIdentity(nickname, False, ToUserId(loginname), HttpContext.Current.Request.UserHostAddress)
- End Function
- Public Overloads Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
-
-
- try
- userId = httpcontext.current.request.Cookies("UserId").Value
- catch
- end try
- Dim userType As Integer = 0
-
- Dim Query As String = "Select NickName,UserType from " & prefix & "users where username='" & loginName & "'"
- Dim Con As New SqlConnection(constring)
-
- Dim Com As New SqlCommand(Query, Con)
- Try
- Con.Open()
- Dim Reader As SqlDataReader = Com.ExecuteReader()
- While Reader.Read()
- UserType = reader(1)
- nickname = Reader(0)
-
-
- If Nickname Is Nothing Or nickname = "" Then nickname = loginname
- End While
- Catch
- nickname = loginname
- End Try
- Con.Close()
- If UserType = 1 Then
- isAdmin = True
- Else
- isAdmin = False
- End If
- Return True
- End Function
- Public Overloads Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean
-
-
- Return True
- End Function
- End Class
-
- </script>
Regards
pbwbart