Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2005, 10:33 PM
Authorized User
 
Join Date: Jun 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem writing data provider

Hello,

I am a novice .net user and I am trying to implement a dotnet based messenger application into my site. I am trying to integrate it into my existing database so that users can logon using their existing accounts. The application provides an example for integration into dotnetnuke like this

*******************


Public Overrides Function GetUserDisplayName(ByVal useruniquename As String) As String
     Return GetUser(useruniquename).UserName
End Function

Protected Function GetUser(ByVal uniquename As String) As DotNetNuke.Entities.Users.UserInfo
     Dim userid As Integer = Integer.Parse(uniquename)
     Dim ps As DotNetNuke.Entities.Portals.PortalSettings = CType(System.Web.HttpContext.Current.Items("Portal Settings"), DotNetNuke.Entities.Portals.PortalSettings)
     Return New DotNetNuke.Entities.Users.UserController().GetUser (ps.PortalId, userid)
End Function

Public Overrides Function ListUserUniqueName() As String()
    Dim ps As DotNetNuke.PortalSettings = CType(System.Web.HttpContext.Current.Items("Portal Settings"), DotNetNuke.PortalSettings)
    Dim names As New System.Collections.ArrayList
    For Each user As DotNetNuke.UserInfo In New DotNetNuke.UserController().GetUsers(ps.PortalId, "")
        names.Add(user.UserID.ToString())
    Next
    Return CType(names.ToArray(GetType(String)), String())
End Function


Public Overrides Function IsAdministrator(ByVal useruniquename As String) As Boolean
        Dim user As DotNetNuke.UserInfo = GetUser(useruniquename)
        If user.IsSuperUser Then
            Return True
        End If

        Dim ps As DotNetNuke.PortalSettings = CType(System.Web.HttpContext.Current.Items("Portal Settings"), DotNetNuke.PortalSettings)
        Dim roles() As String = New DotNetNuke.RoleController().GetRolesByUser(user.Us erID, ps.PortalId)

        For Each roleid As String In roles
            Dim role As DotNetNuke.RoleInfo = New DotNetNuke.RoleController().GetRole(Integer.Parse( roleid))
            If (role.RoleName = "Administrators") Then
                Return True
            End If
        Next

        Return False
End Function

public override string[] SearchUserUniqueNameByDisplayName(string userDisplaName)
{
    if(userDisplaName==null||userDisplaName=="")return new string[0];
    userDisplaName = userDisplaName.ToLower();

    AdminDB admin = new AdminDB();
    SqlDataReader reader = admin.GetUsers();

    ArrayList names = new ArrayList();
    while(reader.Read())
    {
       try
       {
          string val= reader.GetString(1);
          if(val.ToLower().IndexOf(userDisplaName)!=-1)
             names.Add(val);
       }
       catch{}
    }
    return (string[])names.ToArray(typeof(string));
}




Now to integrate it inot my system it just says that:


Derive a class from the CuteSoft.Chat.DataProvider abstract base class and name it MyDataProvider.

public class MyDataProvider : CuteSoft.Chat.DataProvider { }

To provide a complete implementation, we will need to provide overrides for all of the methods and properties of the CuteSoft.Chat.DataProvider class as followings:



Method
 Description

public override string GetUserDisplayName(string uniquename)
 Return user's display name.

public override string[] ListUserUniqueName()
 Retrieves all the user's unique names in the database.

public override bool IsAdministrator(string useruniquename)
 Check the user is an administrator or not.

public override string[] SearchUserUniqueNameByDisplayName(string name)
 Return an array of user names containing the input string.



Create a class which implements the CuteSoft.Chat.UserAdapter interface and name it MyUserAdapter.

public class MyUserAdapter : CuteSoft.Chat.UserAdapter { }


To provide a complete implementation, we will need to provide overrides for the method of the CuteSoft.Chat.UserAdapter class as followings:

public override string GetUserUniqueName(System.Web.HttpContext context)




My database name is MainUsers and table is UserInfo. Username field is Username and Password field is Password. Can somebody show me how to write my own dataprovider fo this thing. I have been trying to get this last three weeks now.

Thank you in advance






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem writing listview data to mysql db method Pro VB 6 2 April 10th, 2007 07:17 PM
About data access provider and consumer kimsunshine ADO.NET 0 July 28th, 2006 06:45 AM
problem writing listview data to mysql db method Pro VB Databases 0 May 17th, 2006 06:18 AM
.NET Data Provider pradeep_itguy ADO.NET 0 October 3rd, 2004 04:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.