Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 December 29th, 2008, 06:11 AM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default GetNumberOfUsersOnline

I have the following problem while using the GetNumberOfUsersOnline method of the Membership class: The function returns the total number of users instead.

On page 172, this function is used to display the number of users online. I have changed this example to display only users working for a particular company. This information is stored into the Profile of each user. So after executing the GetAllUsers() function to populate allUsers, I pass this value into another function, called GetMSSUsersFromUserCollection:

privateMembershipUserCollection GetMSSUsersFromUserCollection(MembershipUserCollection everyone)
{
foreach (MembershipUser user in everyone)
{
ProfileCommon prof = Profile.GetProfile(user.UserName);
if (prof.CompanyCode == "MyCompany") allMSSUsers.Add(user);
}
return allMSSUsers;
}

This returns only the users belonging to the "MyCompany" company.

In retrieving each user's profile however also updates the user's LastActivityDate field. When the next statement is called to GetNumberOfUsersOnline, this returns all users belonging to the "MyCompany", since it returns those users whose LastAcitivityDate is within the current date and time minus the userIsOnlineTimeWindow period defined in web.config. This obviously gives me the wrong number.

How else could I implement this functionality?

Thanks

Chris
 
Old December 29th, 2008, 04:32 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

How to Prevent Profile Properties From Updating a User's Last Activity Date

http://leedumond.com/blog/how-to-pre...activity-date/
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}

Last edited by Lee Dumond; December 29th, 2008 at 04:34 PM..
 
Old December 29th, 2008, 05:34 PM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default GetNumberOfUsersOnline

Hi Lee

Thanks for your posting.

I have used a different table in which the username and company are also present in deducing whether a user works for the company or not without fetching information from the profile class.

I nevertheless like your method very much and thank you for posting it.

Regards

Chris









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