Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AppTheory specializes in solutions based on the DotNetNuke platform and has 2 employees on the DotNetNuke Core Team.
  Ads  
OnyakTech
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Forgotten User - Loops through All Users - Unnecessarily?
Previous Previous
 
Next Next
New Post 5/31/2007 8:15 AM
User is offline Rozanne Stoman
59 posts
10th Ranked


Forgotten User - Loops through All Users - Unnecessarily? 

I tracked a bunch of page timeouts through the error log this morning. I believe the error occurs when people use the Forgotten User feature, which is the Spohn Forgotten User module.

Looking at the code, I was surprised to see that, instead of taking the user email and filtering for users with that email, it uses objUsers.GetUsers, then loops through eac user,  compares the email, and calls a function for that user. For 10000 + users, that could explain a timeout.

I'm modifying it to get a shortlist of users with that email via an SP, and then loop through that set, but would like to know - is there anything I'm missing - any good reason this module SHOULD be looping through every user?

Thanks,

  ''Dim objUsers As New UserController
            'Dim UserArray As ArrayList = objUsers.GetUsers(PortalId, True, True)

            ''For Each objUser As UserInfo In UserArray
            'For Each objUser As Entities.Users.UserInfo In UserArray
            '    Dim objMem As Entities.Users.UserMembership = objUser.Membership
            '    If LCase(objMem.Email) = LCase(txtEmail.Text) Then
            '        If ShouldUserBeSent(objUser, SendAdmins) = True Then
            '            If NumberofEmailsSent = 0 Then
            '                UserNames = "" & objMem.Username 
... ect.

 

 

 
New Post 5/31/2007 9:22 AM
User is offline Rodney Joyce
1640 posts
www.smart-thinker.com
5th Ranked




Re: Forgotten User - Loops through All Users - Unnecessarily? 

No, I agree with you - when I am lacking time I sometimes do stuff in the business logic and then turn it into a stored proc later when I am tidying up the module - perhaps it was an oversight, but yes, it is very inefficient.


Thanks,
Rodney
Smart-Thinker - Social Networking modules for DotNetNuke
The DotNetNuke Directory - Are you listed?
PokerDIY - Example Implementation of DNN Social Network
Do use DNN a lot? Try the DotNetNuke Toolbar to save you time!
 
New Post 5/31/2007 11:56 AM
User is offline Rozanne Stoman
59 posts
10th Ranked


Re: Forgotten User - Loops through All Users - Unnecessarily? 

Ok, here's the code for the replacement I've done in my code. You can tidy it up to use the data layer - I leave that out for custom developments. This is good place to use SQLParameters instead of the text, to guard against SQL injections. I've also added a try-catch blocks, the raw error pages my users were getting should never be :-)

If you could work something like this into any future versions you make available to the public, it would be great. The difference in response time is quite significant.

 

Dim UserNames As String = ""Dim objUsers As New DotNetNuke.Entities.Users.UserControllerDim useremail As String

useremail = LCase(txtEmail.Text)

 

Dim theusername As String

 

'Dim AddUser As Boolean = False

 

 

 

Dim sql = "EXEC Spohn_ForgottenUser_GetUsernameByEmail '" & useremail & "', " & PortalId & ""Dim dr As SqlDataReaderTry

dr = SqlHelper.ExecuteReader(System.Configuration.ConfigurationSettings.AppSettings("SiteSqlServer"), CommandType.Text, sql)

 

If dr.HasRows Then

 

theusername = dr("UserName")

 

myuser = objUsers.GetUserByUsername(PortalId, theusername)

 

 

Do While dr.Read()Dim myuser As New DotNetNuke.Entities.Users.UserInfoDim objMem As Entities.Users.UserMembership = myuser.MembershipIf ShouldUserBeSent(myuser, SendAdmins) = True Then

 

If NumberofEmailsSent = 0 Then

UserNames = "" & objMem.Username

 

Else

UserNames = UserNames & ", " & objMem.Username

 

End If

 

'Send it

NumberofEmailsSent += 1

 

End If

 

Loop

 

 

The SQL SP is simply

 

CREATE PROCEDURE dbo.Spohn_ForgottenUser_GetUsernameByEmail

@email nvarchar(255),
@portalid int

 AS


   SELECT  u.UserName, u.userid, m.userid, m.loweredemail
        FROM    dbo.aspnet_Applications a, dbo.aspnet_Users u, dbo.aspnet_Membership m
        WHERE  -- LOWER(@ApplicationName) = a.LoweredApplicationName AND
                u.ApplicationId = a.ApplicationId    AND
                u.UserId = m.UserId AND
                LOWER(@email) =  m.LoweredEmail
  and m.isapproved = 1  
  and ApplicationName = @portalid
GO

End If

 

 

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Forgotten User - Loops through All Users - Unnecessarily?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


DotNetNuke® in Sweden
All service of DotNetNuke® in Sweden.
Olsmar Konsult
Overlook Technology
Website Development, DotNetNuke Consulting, Module Development, Portal Management
OverlookTechnology.com
DeutschNetNuke = DotNetNuke in German
DeutschNetNuke provides all DotNetNuke related services in German (and English).
www.DeutschNetNuke.de

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP