Web Messenger 5 Integration (Contact List)

Last post 08-25-2009, 9:49 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  08-22-2009, 9:00 PM 54921

    Web Messenger 5 Integration (Contact List)

    Hello,
    I recently purchased Web Messenger 5, and am struggling to override the GetContacts() function
     
    I have a custom database and am using Cute Web Messenger standalone
    THe table below (_UFriend) contains a list of paired id's (Profile, Friend)
    Please help!
     
    This is my code

     
        Public Overrides Function GetContacts(ByVal identity As CuteChat.ChatIdentity) As CuteChat.IChatUserInfo()
            Dim MyConnection As SqlConnection = New SqlConnection(sitewide.GetWriteConnectionString)
            Dim MyCommand As SqlCommand = New SqlCommand("SELECT * FROM _UFriend WHERE Profile = " & HttpContext.Current.Session("UID"), MyConnection)
            MyCommand.CommandType = CommandType.Text
            Dim res As New ArrayList

            MyConnection.Open()
            Dim MyReader As SqlDataReader = MyCommand.ExecuteReader
            If MyReader.HasRows Then
                While MyReader.Read
                    res.Add("User:" & MyReader(1))
                End While
            End If
            MyConnection.Close()

            Return res.ToArray(GetType(CuteChat.IChatUserInfo))

        End Function
     
    Thanks
  •  08-25-2009, 9:49 AM 55022 in reply to 54921

    Re: Web Messenger 5 Integration (Contact List)

    Hi,
     
    do not use HttpContext.Current.Session("UID"),  use the identity object.
     
    Here is code of DotNetNuke, you can learn from it :
     
    1.    Public Overrides Function GetContacts(ByVal identity As CuteChat.ChatIdentity) As CuteChat.IChatUserInfo()   
    2.   
    3.        Dim portalid As Integer = 0   
    4.   
    5.        Dim list As ArrayList = DotNetNuke.Entities.Users.UserController.GetUsers(portalid)   
    6.   
    7.        Dim res As New ArrayList   
    8.   
    9.        Dim provider As CuteChat.ChatProvider = CuteChat.ChatProvider.Instance   
    10.   
    11.        Dim myname As String = provider.FromUserId(identity.UniqueId)   
    12.   
    13.        For Each info As DotNetNuke.Entities.Users.UserInfo In list   
    14.   
    15. Not String.Equals(info.Username, myname, StringComparison.OrdinalIgnoreCase) Then  
    16.   
    17. res.Add(Me.GetUserInfo(provider.ToUserId(info.Username)))   
    18.   
    19. nd If  
    20.   
    21.        Next  
    22.   
    23.        Return res.ToArray(GetType(CuteChat.IChatUserInfo))   
    24.   
    25.    End Function  
     
    Regards,
    Terry
     
View as RSS news feed in XML