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 October 8th, 2007, 07:31 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default user profile trouble

Hello!

Please, any of you who have TheBeerHouse working ok, please go to admin area, and edit some user profiles settings!
Then see the lastActivity for this user!

In My TBH the last activity is the current date... :(

This is wrong! Very wrong!
When an administrator change an user setting, the UserLastActivicty should stain intact!

One consequence of this is the MembersOnlineNbr increase by 1

 
Old October 9th, 2007, 02:26 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Maxxim,

This is not done by TBH, but by ASP.NET's profile settings.

Try browsing to C:<%Windir%>\Microsoft.NET\Framework\v2.0.50727, and look at the script called InstallProfile.sql.

This is the definition for the table that stores all the profile information. If you look at the bit of procedure called aspnet_Profile_SetProperties, you will see that that's where the date is being updated. In other words, while TBH offers you as an admin the ability to alter a user's profile, it uses the exact same settings as when a user would be doing the edit/update.

(Note, I'm at work at the moment, and cannot access my actual code to verify this is what happens, but that seems to be the most likely solution if you ask me).

If this is the case, and you prefer other functionality, I am afraid there's no other way than to code your own membership/user/profile settings. Luckily, from what I have read so far, that's not that tough to do, really. There's lots of information available to help you out.

IIRC, you also asked a while ago about the number of posts. In that thread I linked to a script created by someone from Microsoft which allows you to store data in seperate columns. Perhaps that's the easiest approach for you?

Update: Found the link for you. Click here:http://www.asp.net/downloads/sandbox...vider-samples/
HTH.

Cheers.

Peter

http://entropia-online.blogspot.com/
 
Old October 9th, 2007, 07:04 AM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I consider that it's a serial bug from aspnet...

If you see one of the tables there are:

"LastUpdatedDate"

and on another table
"LastActivityDate"

Using good sense, the only filled who should be update if an administrator edit some userProfile should be "LastUpdateDate"

If you log into your site, and nobody else is logged in, try to change 5 members profile, and then'll see the number of UsersOnline increaso from 1 to 5... (It's normal, this procedure compare lastactivityDate)

I consider this a serial bug!
Beucause if i want to resolve it I need to make my own accounts classes!

I already had seen your link, but thank you one more time to share it!
It's a good article but i don't have time to change my code right now!

 
Old October 9th, 2007, 08:56 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

I agree with you, Maxxim. It seems MS assumes every change to a profile would be by a user him or herself.

Cheers,

Peter

http://entropia-online.blogspot.com/
 
Old October 9th, 2007, 11:44 AM
Authorized User
 
Join Date: Mar 2007
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
Default

Whenever you access a user's profile property the LastActivityDate is updated, so simply viewing a user's profile will update their activity date, and also cause them to appear to be online. To clarify, at least one property value must contain actual data, if the properties have not be set yet (ie: is null) then the activity date is unchanged. So you may see some users activity dates changing, while others do not. This really confused me until I realized what was going on.

Anyway, the solution is fairly easy. Just save the LastActivityDate before reading any profile properties, and then restore it again after.

Code:
If Not Me.IsPostBack Then
   UserName = Me.Request.QueryString("UserName")

   Dim profile As ProfileCommon = Me.Profile
   Dim member As MembershipUser = Membership.GetUser

   If Me.UserName.Length > 0 Then
      'used passed in user instead
      profile = Me.Profile.GetProfile(UserName)
      member = Membership.GetUser(UserName)
   End If

   'save LastActivityDate so it can be restore again below.
   Dim LastActivityDate As DateTime = member.LastActivityDate

   txtUsername.Text = member.UserName
   txtFirstName.Text = profile.FirstName
   txtLastName.Text = profile.LastName
   CheckBox_SendEmail.Checked = profile.SendEmail

   member.LastActivityDate = LastActivityDate
   Membership.UpdateUser(member)
End If
This will cause a few extra SQL hits, but this should not be a problem if limited to admin pages.

Oddly enough, if you edit the user's profile, and then use Profile.Save() to save the profile the activity date is not changed, so you won't have to worry about restoring the LastActivityDate for profile saves.

Hope this helps.

- Scott.

 
Old October 9th, 2007, 04:12 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for that scott!

I worked in something identical...
I made a property on this usercontrol,
From admin page I defined this property as userprofile1.iseditedbyAdmin = 1

then, everytime this control opens, I save the lastactivity!
After the save i check is iseditedbyAdmin > 0 and if it is update the old lastactivity!

Thanks a lot because your version is much cleaner... I don't need to add more properties!
I didn't know that everytime I see a profile information I update his lastactivity!!
 
Old October 9th, 2007, 04:50 PM
Authorized User
 
Join Date: Mar 2007
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
Default

I started down the same path of tracking if an administrator is viewing the profile as opposed to the user. But it really doesn't matter because if the user is viewing or editing his own profile the LastActivityDate will update anyway when the page refreshes.


 
Old October 9th, 2007, 06:24 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But Scott, if a user is seeing or editing his own profile that's make all the sense that lastAvitivityDate be updated to the currentdate!

My problem now is that I want to make some page like:
http://p2p.wrox.com/pop_profile.asp?...splay&id=42867

If everytime that I retrieve Profile.LastName... etc ASPNETDB update LastActivity! I'm in trouble because, as you said this isn't bad if only administrator see the profile but I want to make a page with profile contacts, etc. This page will be accessed from any user! I mean, any user will have the possibility to see a page with some profile contacts of any user that he want...

In the last case I'll use the same code...

I'm going to build some code to add to my forum.masterPage that insert on DB where the current user is in forum!
Something like:

Membername|ForumID|ThreadID|OtherLocalization(Stri ng)|Login|LastActivity|

OtherLocalization could be:
  "Is consulting him privateMessages List"
  "Is consulting him privateMessage"
  "Is consulting members Page"
  "Is writing a post to the forum xxx"
  etc

Then, everytime I(or other user) call this procedure, SQL do a routine to see if any getDATE - LastActivity >7 minutes. If > 7 delete this user from the Forums_Active Table and select all others!

With that I can show the forumUsersOnline!

So, it's not so bad if I update lastActivityDate of membership table everytime one user see a profilePage of anotherUser! I'll update my DB everytime a user make a "NOT postBack"

But now i'm thinking:
I used this for version 1!
I would gain some benefits if i made all this ForumsOnlineusers with a list(of Active) cached in server!
Forgive me... Just thinking high...

But maybe i'll add some code to just update this value!
Because if you use:
   member.LastActivityDate = LastActivityDate
   Membership.UpdateUser(member)

You are retrieving all membership settings from this user and then update them again!
I really think that 2 ou 3 single functions and another procedure just to update this date it's possible a good idea (if you understand my bad english...)






Similar Threads
Thread Thread Starter Forum Replies Last Post
profile object davyquyo ASP.NET 2.0 Basics 6 December 28th, 2006 07:50 AM
user profile creation problem yasminnnnn BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 6 December 11th, 2006 09:13 AM
Edit User Profile - email garydarling BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 7 September 29th, 2006 06:58 AM
New User having trouble with Zero Values AngelaR Pro VB 6 1 January 8th, 2006 09:15 PM
User Profile edgelogix Pro PHP 1 December 3rd, 2005 04:17 PM





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