How to auto add DNN users into Cute Messenger Users Contact

Last post 12-31-2008, 12:57 PM by hyang. 2 replies.
Sort Posts: Previous Next
  •  12-31-2008, 11:53 AM 47326

    How to auto add DNN users into Cute Messenger Users Contact

    Hi,
    I have installed Cute Web Messenger.
    I want to write a sql script (other way is fine too.  only do it one time)    to get all DNN users and then add these users to Cute Web Messenger User's contact list
     
    I checked inside of database. Looks like I only need insert/update the [CuteChat4_User].BuildinContacts 
     
    But the data in this field is so hard to figure out.
    For example:
     
    I saw this: 
    arr,S-3=10=User:hyang;,11=User:hesper;,11=User:tammyn;
    arr,S-4=14=User:hostcrest;,11=User:hesper;,14=User:mratcliff;,10=User:admin;
     
    I don't know how to decide s-3, s-4,   11, 10, 14
     
    Anybody can tell me how to I put the value here?  Appreciate your help
  •  12-31-2008, 12:08 PM 47327 in reply to 47326

    Re: How to auto add DNN users into Cute Messenger Users Contact

    Please open DNNChatProvider.vb and post the following code:
     

    Imports System.IO

    Imports System.Security

    Imports System.Security.Principal

    Imports System.Threading

    Imports System.Web

    Imports System.Web.Security

    Imports DotNetNuke.Common.Utilities

    Imports DotNetNuke.Entities.Portals

    Imports DotNetNuke.Security.Roles

    Imports DotNetNuke.Services.Exceptions

    Imports DotNetNuke.Services.Log.EventLog

    Imports DotNetNuke.Services.Scheduling

    Imports DotNetNuke.Services.Upgrade

    Imports Microsoft.VisualBasic

    Public Class DNNChatProvider

    Inherits CuteChat.ChatProvider

    Protected Function CurrentPortal() As DotNetNuke.Entities.Portals.PortalSettings

    Dim ps As DotNetNuke.Entities.Portals.PortalSettings

    ps = PortalController.GetCurrentPortalSettings()

    If ps Is Nothing Then

    Throw (New Exception("PortalSettings Not Ready"))

    End If

    Return ps

    End Function

    Public Function GetLogonUser() As DotNetNuke.Entities.Users.UserInfo

    If Not HttpContext.Current.Request.IsAuthenticated Then

    Return Nothing

    End If

    Dim username As String = HttpContext.Current.User.Identity.Name

    Return DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, username)

    End Function

    Public Overrides Function GetConnectionString() As String

    Return System.Configuration.ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString

    End Function

    Public Overrides Function GetLogonIdentity() As CuteChat.AppChatIdentity

    Dim user As DotNetNuke.Entities.Users.UserInfo = GetLogonUser()

    If user Is Nothing Then

    Return Nothing

    End If

    Return New CuteChat.AppChatIdentity(user.Username, False, ToUserId(user.Username), HttpContext.Current.Request.UserHostAddress)

    End Function

    Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean

    Try

    Dim user As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, loginName)

    If user Is Nothing Then

    Return False

    End If

    nickName = user.Username

    isAdmin = user.IsInRole("Administrators") Or (user.Username = "admin")

    Return True

    Catch ex As Exception

    Return False

    End Try

    End Function

    Public Overrides Function FindUserLoginName(ByVal nickName As String) As String

    Try

    Dim totalRecords As Integer

    For Each user As DotNetNuke.Entities.Users.UserInfo In DotNetNuke.Entities.Users.UserController.GetUsersByUserName(CurrentPortal().PortalId, nickName, 0, 100, totalRecords)

    If String.Equals(user.Username, nickName, StringComparison.OrdinalIgnoreCase) Then

    Return user.Username

    End If

    Next

    Return Nothing

    Catch ex As Exception

    Return Nothing

    End Try

    End Function

    Public Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean

    If System.Web.Security.Membership.ValidateUser(loginName, password) Then

    System.Web.Security.FormsAuthentication.SetAuthCookie(loginName, False)

    Return True

    End If

    End Function

    Public Class MyDataManager

    Inherits CuteChat.AppDataManager

    Public Sub New(ByVal portal As CuteChat.AppPortal)

    MyBase.New(portal)

    End Sub

    Public Overrides Sub AddContact(ByVal identity As CuteChat.ChatIdentity, ByVal userid As String)

    End Sub

    Public Overrides Sub RemoveContact(ByVal identity As CuteChat.ChatIdentity, ByVal userid As String)

    End Sub

    Public Overrides Function GetContacts(ByVal identity As CuteChat.ChatIdentity) As CuteChat.IChatUserInfo()

    Dim portalid As Integer = 0

    Dim list As ArrayList = DotNetNuke.Entities.Users.UserController.GetUsers(portalid)

    Dim res As New ArrayList

    Dim provider As CuteChat.ChatProvider = CuteChat.ChatProvider.Instance

    Dim myname As String = provider.FromUserId(identity.UniqueId)

    For Each info As DotNetNuke.Entities.Users.UserInfo In list

    If String.CompareOrdinal(myname, info.Username) <> 0 Then

    res.Add(Me.GetUserInfo(provider.ToUserId(info.Username)))

    End If

    Next

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

    End Function

    End Class

     

    Public Overrides Function CreateDataManagerInstance(ByVal portal As CuteChat.AppPortal) As CuteChat.AppDataManager

    Return New MyDataManager(portal)

    End Function

    End Class


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  12-31-2008, 12:57 PM 47329 in reply to 47327

    Re: How to auto add DNN users into Cute Messenger Users Contact

    It works great!   Really appreciate your help
View as RSS news feed in XML