Sign In
Vinayak's WebLog
Things you wanted to know about Microsoft Commerce Server
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
Catalog Search functionality
Hotfixes
New Catalog Features in CS2007
Programming the Catalog System
Archive
Archives
October 2006
(2)
September 2006
(1)
August 2006
(2)
June 2006
(6)
May 2006
(4)
March 2006
(4)
October 2005
(2)
September 2005
(2)
June 2005
(4)
May 2005
(1)
October 2004
(4)
August 2004
(1)
July 2004
(6)
June 2004
(8)
May 2004
(9)
April 2004
(5)
Programming the Commerce Server 2007 catalog system: Creating the CatalogContext
MSDN Blogs
>
Vinayak's WebLog
>
Programming the Commerce Server 2007 catalog system: Creating the CatalogContext
Programming the Commerce Server 2007 catalog system: Creating the CatalogContext
vinayakt
30 Aug 2006 12:15 AM
Comments
3
The objects in the catalog system can now be programmed in two modes. In the first mode the catalog server assembly is loaded in the callers appdomain (aka inproc mode). In the second mode the functionality of the catalog system is available remotely via the catalog web service. The programming model and the methods available in both the modes are the same. The only difference is in the way the CatalogContext object is created. The CatalogContext object is the root object in the catalog system. All other objects are obtained from the CatalogContext object.
1.
The Inproc mode
:
You use this mode when you are running your code on the web server. The CatalogContext code is initialized by specifying the sitename. The following code sample shows how to create a CatalogContext in this mode. You need to add references to the Microsoft.Commerceserver.catalog, Microsoft.CommerceServer.CrossTierTypes and Microsoft.CommerceServer.Shared assemblies. The objects in the catalog system reside in the Microsoft.CommerceServer.Catalog and Microsoft.CommerceServer namespaces.
CatalogSiteAgent
siteInfo =
new
CatalogSiteAgent
();
siteInfo.SiteName =
"StarterSite"
;
siteInfo.AuthorizationMode =
AuthorizationMode
.ThreadContext;
siteInfo.AuthorizationPolicyPath =
@"E:\Inetpub\wwwroot\CatalogWebService\CatalogAuthorizationStore.xml"
;
siteInfo.IgnoreInventorySystem =
false
;
CacheConfiguration
cacheConfiguration
=
new
CacheConfiguration
();
cacheConfiguration.CacheEnabled
=
true
;
cacheConfiguration.SchemaCacheTimeout
=
new
TimeSpan
(0, 10, 0);
CatalogContext
context
=
CatalogContext
.
Create(siteInfo, cacheConfiguration);
Use the
CatalogSiteAgent
class to specify the site name, the authorization information and the inventory usage option.
The
AuthorizationMode
enumeration has the following values
AuthorizationMode
.NoAuthorization : Do not perform any authorization checks. This mode should be used on the runtime sites.
AuthorizationMode
.ThreadContext : Before performing any operation ensure that the user is authorized to perform it. The identity of the user is obtained from the user's thread context. This mode should be used in Console applications.
AuthorizationMode.
HttpContext : Before performing any operation ensure that the user is authorized to perform it. The identity of the user is obtained from the current Http context. This mode should be used in web applications where users update the catalog system.
The
AuthorizationPolicyPath
specifies the location of the
authorization store
. The authorization store is an Xml file which contains which information about the authorized users and the operations they can perform.
Commerce Server 2007 now adds an inventory integration with the catalog system.The inventory system now allows you to store the inventory information like (onhandquantities, status etc) for products and variants in the catalog system. You can use the
IgnoreInventorySystem
parameter to turn off inventory integration.If the inventory resource exists and
IgnoreInventorySystem
parameter is set to false no inventory operations or lookups will be performed by the catalog methods.
Use the
CacheConfiguration
object to specify the
caching configuration
. Note that caching is turned off by default and is enabled by setting the cacheConfiguration.CacheEnabled
property.
If you are using the Microsoft.CommerceServer.Runtime BCL then you can specify the cache configuration and the inventory integration option in the web.config of your runtime site.
2.
The WebService mode:
The CatalogContext object can also be initialized in the webservice mode by passing in the url of the catalog webservice.
CatalogServiceAgent
catalogServiceAgent =
new
CatalogServiceAgent
(
@"http://Servername/CatalogWebservice/CatalogWebservice.asmx"
);
CatalogContext
context =
CatalogContext
.Create(catalogServiceAgent);
Use the CatalogServiceAgent class to specify the url of the catalog web service. The other overloads on this method allow you to specify the authentication methods and a credential prompter.
If you are wondering how to specify the authorization, caching and inventory option this is specified through the
catalogWebService
element in web.config. All the attributes and child elements are documented in the web.config itself.
Note:
Even though the CatalogContext class has the CreateFromConnectionString method, it exists only for backward compatibility and is now deprecated.
3 Comments
Programming the Catalog System
Blog - Comment List MSDN TechNet
Comments
Loading...