DNN 322: UserProfile class enhanced

Posted on 2006-01-19 09:28  深渊呓语  阅读(176)  评论(0)    收藏  举报
Today I upgrade my DNN from 3.1.0 to 3.2.2.
It's all right, but a little problem about web.config.
Steps:
1. Backup my dotnetnuke folder to another place.
2. Backup dotnetnuke database.
3. Unzip the source code of DNN 3.2.2 into dotnetnuke folder and replace dnn 311 files.
4. Open Web.config edit connectionstring part. Just paste the line from my backup folder.
5. Open IE run http://localhost/dotnetnuke/default.aspx to run update code.

DNN core team changed the implementation of UserProfile class. In DNN 310, they use private member to store each property.
In DNN 310 a property named 'City' will look like this:
Private _City as string
Public Property City() as string
    
Get 
        
Return _City
    
End Get
    
Set(ByVal Value as string)
        _City
= Value
    
End Set
End Property
And now, they use Hash table.
Private Const cCity As String = "City"
Public Property City() As String
    
Get
        
If _profileProperties.ContainsKey(cCity) = False OrElse _profileProperties(cCity) Is Nothing Then Return Null.NullString
                
Return _profileProperties(cCity).ToString()
        
End Get
        
Set(ByVal Value As String)
                SetProfileProperty(cCity, Value)
                
If Not ObjectHydrated Then
                    ObjectHydrated 
= True
                
End If
        
End Set
End Property
_profileProperties is the Hash table:
 
Private _profileProperties As System.Collections.Hashtable

The good side of Hashtable is UserController object can fill this object through a For each thing.
In FillUserProfile:
                For Each o As AspNetProfile.SettingsProperty In AspNetProfile.ProfileBase.Properties
                    u.ProfileProperties.Add(o.Name, objProfile.Item(o.Name))
                
Next
And In DNN 310, each property have to be set by Try ... Catch thing.
                Try
                    u.City 
= Convert.ToString(objProfile("City"))
                
Catch
                
End Try
                
Try
                    u.Country 
= Convert.ToString(objProfile("Country"))
                
Catch
End Try
.
So obviously the Usercontroller is clear now in DNN322.

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3