Profile property Management for. Net PetShop 4.0

Source: Internet
Author: User

. NET 2.0, provides asp.net membership management, ASP. NET role management and ASP.net configuration file properties. In this paper, we focus on the design and implementation of the. Net PetShop 4.0 profile property management.

Profile properties are used to provide personalized service to users. In. Net PetShop 4.0, the same namespace as the profile properties is as follows:

Petshop.iprofiledal
Petshop.oracleprofiledal
Petshop.sqlprofiledal
Petshop.profiledalfactory
Petshop.profile

From their namespaces, you can see that the configuration file property management also uses the factory pattern. Let's look at the contents of each namespace in detail:

First, Petshop.iprofiledal namespaces

The Petshop.iprofiledal namespace provides an interface ipetshopprofileprovider that defines 10 methods, respectively:

Getaccountinfo
Setaccountinfo
Getcartitems
Setcartitems
Updateactivitydates
Getuniqueid
Createprofileforuser
Getinactiveprofiles
DeleteProfile
Getprofileinfo

Some of these methods are for shopping cart processing, some of the account information processing, some of the configuration file processing.

Second, Petshop.oracleprofiledal and Petshop.sqlprofiledal namespaces

The two namespaces each contain a Petshopprofileprovider class, which is an implementation of the interface Ipetshopprofileprovider. Of course, as can be seen from the name of the namespace, Petshop.oracleprofiledal is connected to the Oracle database, Petshop.sqlprofiledal is connected to the SQL Server database.

Three, petshop.profiledalfactory namespaces

Petshop.profiledalfactory provides a self-appointed class dataaccess, which has only one method Createpetshopprofileprovider, according to the Profiledal settings in Web.config, produces a conforming ipetsh Petshopprofileprovider class instance of the Opprofileprovider interface. Of course, this is the typical factory model.

Four, Petshop.profile namespaces

The Petshop.profile namespace provides a human-encapsulated class Petshopprofileprovider that inherits the. NET Framework ProfileProvider classes, overriding initialize, SettingsPropertyValueCollection, Setpropertyvalues, Deleteprofiles, Deleteprofiles, DeleteInactiveProfiles, Findprofilesbyusername, Findinactiveprofilesbyusername, Getallprofiles, Getallinactiveprofiles and Getnumberofinactiveprofiles methods, some static methods are created. A static method is created to implement a call to a method in Petshopprofileprovider through the PetShop.ProfileDALFactory.DataAccess class.

V. Using profile properties

When using profile properties, you first add configuration segments to the profile properties in the Web.config file. The configuration file properties in the Web.config file for. Net PetShop 4.0 are configured as follows: < profile automaticSaveEnabled = "false" defaultprovider = "ShoppingCartProvider" >
< providers >
< add name = "ShoppingCartProvider" connectionStringName = "sqlprofileconnstring" type = " PetShop.Profile.PetShopProfileProvider "ApplicationName =". NET Pet Shop 4.0 "/>
< add name = "WishListProvider" connectionStringName = "sqlprofileconnstring" type = " PetShop.Profile.PetShopProfileProvider "ApplicationName =". NET Pet Shop 4.0 "/>
< add name = "AccountInfoProvider" connectionStringName = "sqlprofileconnstring" type = " PetShop.Profile.PetShopProfileProvider "ApplicationName =". NET Pet Shop 4.0 "/>
</providers >
< properties >
< add name = "ShoppingCart" type = "PetShop.BLL.Cart" allowanonymous = "true" Provider = "ShoppingCartProvider"/>
< add name = "Wishlist" type = "PetShop.BLL.Cart" allowanonymous = "true" Provider = "WishListProvider"/>
< add name = "AccountInfo" type = "PetShop.Model.AddressInfo" allowanonymous = "false" Provider = "AccountInfoProvider" />
</Properties >
</profile >

Once configured, you can use the following methods in the ASP.net web page: profile.accountinfo = addressform.address;
Profile.save ();

In the configuration file properties added above, ShoppingCart and wishlist respectively represent shopping carts and out of stock registrations, their types are the business logic layer of the cart class, AccountInfo represents account information, but because the user name password management is by. NET membership management, the other attributes are address class information, which is PetShop.Model.AddressInfo in the type.

In addition, the Profile_migrateanonymous event in Global.asax, which is used for the transfer of information from anonymous users to registered users, that is, information that is not logged on, is not lost after the registered user logs on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.