Jiri Zahradka
Guest
|
Posted:
Fri Nov 12, 2004 4:25 am Post subject:
Creating profiles from outside ASP.NET application |
|
|
Hi all,
have you ever tried to create or update user profiles from outside ASP.NET
application?
I was inspired with topic at
http://www.publicvoid.dk/CommentView,guid,9855cb2c-3827-4943-aa66-b0991c02f29c.aspx
and wrote console application which creates new user profiles and having
some problems.
First, it takes too much time to execute following tasks: reading
configuration strings from Profile Resources,
getting ProfileContext and creating first profile.
Second, it runs without an error only in debug mode.
Here is an example code for reading connection strings.
// Get the profile connection string from the system configuration
AppConfig appConfig = new AppConfigClass();
appConfig.Initialize((string)ConfigurationSettings.AppSettings["SiteName"]);
Microsoft.CommerceServer.Runtime.IDictionary configDictionary =
appConfig.GetOptionsDictionary("");
string profileConnectionString =
Convert.ToString(configDictionary["s_ProfileServiceConnectionString"]);
string
commerceServerProvider=Convert.ToString(configDictionary["s_CommerceProviderConnectionString"]);
string
bizDataString=Convert.ToString(configDictionary["s_BizDataStoreConnectionString"]);
Here is an example code for getting profile context.
profileContext= new ProfileContext(this.profileConnectionString,
this.commerceProvider,
this.bizDataStoreString, new ConsoleDebugContext(DebugMode.Debug));
Has anyone some experiences with this?
If so, please give me an advice. Thank you.
Jiri |
|
David Messner [MSFT]
Guest
|
Posted:
Sun Nov 14, 2004 12:55 am Post subject:
RE: Creating profiles from outside ASP.NET application |
|
|
Reading commerce server configuration is an expensive operation as is
creating a ProfileContext. You would definitely want to do both of these
only once within the lifetime of an application. You can also simplify
that code a bit by using the CommerceResourceCollection type - just pass it
the site name in the constructor and it will read and cache all site
settings from the admin DB.
sitename = "mySite";
resources = new CommerceResourceCollection(siteName);
profilesResource = resources["Biz Data Service"];
string profilesvcConnstr =
profilesResource["s_ProfileServiceConnectionString"].ToString();
string providerConnstr =
profilesResource["s_CommerceProviderConnectionString"].ToString();
string bizdataConnstr =
profilesResource["s_BizDataStoreConnectionString"].ToString();
profileContext= new ProfileContext(profilesvcConnstr, providerConnstr,
bizdataConnstr,
new ConsoleDebugContext(DebugMode.Debug));
You also mentioned something went down when you tried to pass
DebugMode.Production? What was the issue/exception details?
regards
-djm
--
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2004 Microsoft Corporation. All rights
reserved.
--------------------
From: "Jiri Zahradka" <jiri.zahradka@logos.cz>
Subject: Creating profiles from outside ASP.NET application
Date: Thu, 11 Nov 2004 23:25:07 +0100
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#rZiH1DyEHA.2676@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.commerceserver.general
NNTP-Posting-Host: gprs40-129.eurotel.cz 160.218.40.129
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.commerceserver.general:15092
X-Tomcat-NG: microsoft.public.commerceserver.general
Hi all,
have you ever tried to create or update user profiles from outside ASP.NET
application?
I was inspired with topic at
http://www.publicvoid.dk/CommentView,guid,9855cb2c-3827-4943-aa66-b0991c02f2
9c.aspx
and wrote console application which creates new user profiles and having
some problems.
First, it takes too much time to execute following tasks: reading
configuration strings from Profile Resources,
getting ProfileContext and creating first profile.
Second, it runs without an error only in debug mode.
Here is an example code for reading connection strings.
// Get the profile connection string from the system configuration
AppConfig appConfig = new AppConfigClass();
appConfig.Initialize((string)ConfigurationSettings.AppSettings["SiteName"]);
Microsoft.CommerceServer.Runtime.IDictionary configDictionary =
appConfig.GetOptionsDictionary("");
string profileConnectionString =
Convert.ToString(configDictionary["s_ProfileServiceConnectionString"]);
string
commerceServerProvider=Convert.ToString(configDictionary["s_CommerceProvider
ConnectionString"]);
string
bizDataString=Convert.ToString(configDictionary["s_BizDataStoreConnectionStr
ing"]);
Here is an example code for getting profile context.
profileContext= new ProfileContext(this.profileConnectionString,
this.commerceProvider,
this.bizDataStoreString, new ConsoleDebugContext(DebugMode.Debug));
Has anyone some experiences with this?
If so, please give me an advice. Thank you.
Jiri |
|