ProfileContext
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Commerce Server > Commerce Server General > ProfileContext




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    ProfileContext  
Xcel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-13-06 06:20 PM

I can't seem to get the following code to run - which is directly from the
documentation.  The code seem to fail when it tries to create the
ProfileContext - stating there is a null instance.  My ulitimate goal here i
s
to retrieve a User Profile and get the Credit Card number and decrypt for us
e
in a integration process.

Please Advise.



ProfileContext profiles = CommerceContext.Current.ProfileSystem;

// To make the example work, create a new instance of a
// profile, so that we know its profileID.

string profileID = Guid.NewGuid().ToString();
CommerceProfile newProfile = profiles.CreateProfile(profileID,
"Address");
newProfile["GeneralInfo.address_name"].Value = "Home";
newProfile["GeneralInfo.address_line1"].Value = "street";
newProfile["GeneralInfo.region_code"].Value = "region";
newProfile["GeneralInfo.postal_code"].Value = "code";
newProfile["GeneralInfo.country_code"].Value = "country";
newProfile.Update();

// Retrieve the profile instance.

Profile myProfile = profiles.GetProfile(profileID, "Address");

// Get the value of a property of the profile instance.

string postalCode =
myProfile["GeneralInfo.postal_code"].Value.ToString();

// Set the value of a property of the profile instance.

myProfile["GeneralInfo.postal_code"].Value = "12345";

// Commit the changed postal code to the underlying data
// storage.

myProfile.Update();

// Delete the instance of the profile.

profiles.DeleteProfile(profileID, "Address");






[ Post a follow-up to this message ]



    Re: ProfileContext  
Joseph Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-14-06 12:33 AM

Xcel,

The segment of code:

CommerceContext.Current.ProfileSystem;

Cannot be accessed outside of an established http context, so you can't use
this code from a console application, it will only work in a correctly
configured asp.net application.

You should be able to create a ProfileContext/ProfileManagementContext using
an agent pattern to "hook into" the Commerce Server system.  Nihit Kaul has
a blog entry from May that explains how to use this agent pattern to create
an order context, so I'm assuming you could do something similiar to get a
profile context.

http://blogs.msdn.com/nihitk/Default.aspx?p=2

Joe

"Xcel" <Xcel@discussions.microsoft.com> wrote in message
news:34583408-D755-467E-A02D-C75ECDB503F3@microsoft.com...
>I can't seem to get the following code to run - which is directly from the
> documentation.  The code seem to fail when it tries to create the
> ProfileContext - stating there is a null instance.  My ulitimate goal here
> is
> to retrieve a User Profile and get the Credit Card number and decrypt for
> use
> in a integration process.
>
> Please Advise.
>
>
>
> ProfileContext profiles = CommerceContext.Current.ProfileSystem;
>
>            // To make the example work, create a new instance of a
>            // profile, so that we know its profileID.
>
>            string profileID = Guid.NewGuid().ToString();
>            CommerceProfile newProfile = profiles.CreateProfile(profileID,
> "Address");
>            newProfile["GeneralInfo.address_name"].Value = "Home";
>            newProfile["GeneralInfo.address_line1"].Value = "street";
>            newProfile["GeneralInfo.region_code"].Value = "region";
>            newProfile["GeneralInfo.postal_code"].Value = "code";
>            newProfile["GeneralInfo.country_code"].Value = "country";
>            newProfile.Update();
>
>            // Retrieve the profile instance.
>
>            Profile myProfile = profiles.GetProfile(profileID, "Address");
>
>            // Get the value of a property of the profile instance.
>
>            string postalCode =
> myProfile["GeneralInfo.postal_code"].Value.ToString();
>
>            // Set the value of a property of the profile instance.
>
>            myProfile["GeneralInfo.postal_code"].Value = "12345";
>
>            // Commit the changed postal code to the underlying data
>            // storage.
>
>            myProfile.Update();
>
>            // Delete the instance of the profile.
>
>            profiles.DeleteProfile(profileID, "Address");
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:15 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register