Training
Certifications
Books
Special Offers
Community




 
Microsoft® Commerce Server 2000 Resource Kit
Author Microsoft Corporation
Pages 624
Disk 1 Companion CD(s)
Level Advanced
Published 01/31/2001
ISBN 9780735611283
ISBN-10 0-7356-1128-9
Price(USD) $69.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 


Chapter 9: Developer Notes



Chapter 9 Developer Notes

The features that you can implement with the Microsoft Commerce Server 2000 software are limited only by your imagination. Many procedures for developing an e-commerce site using Commerce Server are described in Commerce Server 2000 Help, the Commerce Server 2000 Software Development Kit (SDK), and other chapters in this book. This chapter supplements that information with the four sections described in the following table.

SectionDescribes
Gift Certificate FeatureHow to add a Gift Certificate feature to the Retail Solution Site
Profiling System UtilitiesFunctionality and operation of two tools you can use to develop profiles:
  • Profiles Schema Mover
  • Site Terms Viewer
Profiling System: Operational ConsiderationsGuidelines for using the Profiling System
Advertising Scoring and SelectionHow the advertising engine leverages the Content Selection Framework (CSF) to determine which advertisements to display on a Web site

Gift Certificate Feature

This section describes how the Contoso, Ltd. company described in Chapter 2 ("A Retail Scenario") added a Gift Certificate feature to its site. (Before reading this chapter you should be familiar with the basic features and implementation details of the Retail Solution Site described in documentation available at /commerceserver/solutionsites. You should also read Chapter 2, to see how Contoso decided to implement its site.)

Contoso identified the data requirements listed in the following table for its gift certificates.

Data requirementValue and type
Certificate identificationEight-digit alphanumeric code (primary key) (string)
Purchaser informationName and contact information (string)
Value of certificateCurrency value (currency)
RecipientName and contact information (string)
Current balanceCurrency value (currency)
Date of purchaseDate (date)

Contoso's gift certificates can be used only for online shopping. The gift certificates issued by the online store can't be used to make purchases from their mail order catalog. The Contoso team did recognize, however, that when they issued an online gift certificate, they also had to adjust the revenue and liability accounts of their accounting system accordingly.

Contoso decided to add the new gift certificates feature to its online catalog. They set the minimum value for a gift certificate at $20, with value increments of $5 up to a maximum of $300. Each gift certificate contains a unique redemption code that customers use to make purchases. Contoso will mail (or e-mail if the purchaser provides an e-mail address for the recipient) the gift certificate, including the redemption code and instructions for using it to make a purchase, to the recipient.

When recipients log in to use their gift certificates, they can either register or shop as guests. To make purchases with their gift certificates, they simply select the Gift Certificate option on the Order Summary page. When they select this option, they are redirected to the Gift Certificate Redemption page and asked to enter the certificate redemption code. Customers can't use only part of a gift certificate's amount to make a purchase; they must use the full amount on their purchases.

The Contoso team made the implementation decisions listed in the following table for their gift certificate feature.

RequirementImplementation decision
Site managementAdd Commerce Server Business Desk modules to the Orders category.
Site administrationCreate a new site resource to set the connection string for the gift certificates data source.
Profile informationStore contact information and account balance data in Microsoft SQL Server 2000 in a table added to the Contoso_Commerce database.
Site implementationAdd two new pages:

  • A page for buying a gift certificate. Similar to Contoso's shipping address form, but with additional boxes for the e-mail address and for entering a message to include with the gift certificate.
  • A page for purchasing merchandise with a gift certificate. Enables customers to enter their gift certificate redemption codes.
Order processingAdd a new pipeline component to the Checkout pipeline.
Accounting updatesCreate a Component Object Model (COM) object that communicates asynchronously with the accounting system, using Microsoft Host Integration Server 2000.
Management reportsCreate the following dynamic and static reports:
  • Gift Certificate Sales Report
  • Gift Certificate Percentage Report (percentage of total online sales)
  • Number of Gift Certificate Purchases (added to the Order Events report)
  • Gift Certificate Buyers (static)
Targeting requirements Display a gift certificate advertisement to previous gift certificate buyers. This is a house ad.

The modifications Contoso made to implement gift certificates on its site are described in the following sections.

Business Desk Modifications

The development team decided to add three Business Desk modules to manage gift certificate sales. They placed these modules in the Orders category in the Business Desk navigation pane, and provided the features listed in the following table.

FeatureImplementation
List and delete current gift certificates List sheet
Create and edit gift certificatesEdit sheet
Update gift certificate cachesRefresh

To implement the necessary changes in their Business Desk, the development team followed the steps outlined in the "Building Business Desk Modules" section of Commerce Server 2000 Help. The following steps summarize what the development team did:


NOTE:
These steps are also summarized in the Instructions.inc file, located in the path <installation location>\SDK\Samples\Management\BizDesk\Instructions.inc.

  1. Add a new configuration file.
  2. The team first added a new configuration file, named GiftCerts.xml, to the ContosoBD\config directory. The following excerpt from the file shows the action "View Certificates" and the ASP files associated with this new module:

    <config xmlns="x-schema:bdmodule-schema.xml">
      <actions>
    <action id='orders/cert_list.asp''helptopic=''cs_ft_certs_EXTN.htm''>
    <name>Certificate List</name>
    <tooltip>View Certificates</tooltip>
      <tasks>
        <task icon=''taskopen.gif'' id=''open''>
          <postto action=''orders/certstatus_view.asp''   formname=''selectform'' />
    <name>&lt;U&gt;O&lt;/U&gt;pen</name>
    <key>o</key>
    <tooltip>Open Certificate</tooltip>
    </task>
    </tasks>
    </action>

  3. Add a module entry to the master configuration file.
  4. Because the Contoso team decided to add the new modules to the Orders category, they had to add the following module entry to the moduleconfigs section of the master configuration file, Bizdesk.xml:

    <moduleconfig id="GiftCerts.xml" category="orders" />

  5. Implement list sheet, edit sheet, and refresh functions.
  6. The team implemented the three functions in the following Active Server Pages (ASP) files:

    • Cert_list.asp. This file implements a list sheet and is based on the Orderstatus_view.asp file included with Commerce Server.
    • Cert_edit.asp. This file implements an edit sheet and is based on the Orderstatus_list.asp file included with Commerce Server.
    • Refresh.asp. This file refreshes the cache provided by the Retail Solution Site and is included with Commerce Server.

  7. Extend Business Desk Help.
  8. The team created four new Help files to extend the Business Desk Help system delivered by Commerce Server. They also extended the index and table of contents of the Business Desk Help system to make it easier for business managers to find the new Help topics. They made the following additions to the Bizdesk.hhc and Bizdesk.hhk files, which are installed in the Business Desk\docs folder (for example, Retailbizdesk\docs):

    • Added content to Business Desk Help.
    • The development team decided that the Help topics should appear in the "Orders" section of the Business Desk Help system, so they added their entries after the Object entry for the Orders topics. They also decided to follow the same organizational scheme employed in the Help system, so that their topic structure would appear consistent with the Help topics delivered by Commerce Server.

      The following entries are a sub-set of the values they added to the Bizdesk.hhc file:

      <LI>
      <OBJECT type="text/sitemap">
      <param name="Name" value="Workflow for Gift Certificate Management">
      <param name="Local" value="htm/cs_bd_orders_xygh.htm">
      </OBJECT>
      <LI>
      <OBJECT type="text/sitemap">
      <param name="Name" value="About Certificates">
      <param name="Local" value="htm/cs_bd_orders_iaaz.htm">
      </OBJECT>
      ….
      
      

    • Added index entries for new Help topics.
    • To make sure that new topics are referenced in the Business Desk Help index, they added the following entries to the Bizdesk.hhk file:

      <LI> <OBJECT type="text/sitemap">
      	<param name="Name" value="gift certificates">
      	<param name="Name" value="Certificate Workflow">
      	<param name="Local" value="htm/cs_bd_orders_xygh.htm">
      	</OBJECT>
      <OBJECT type="text/sitemap">
      	<param name="Name" value="gift certificates">
      	<param name="Name" value="About">
      	<param name="Local" value="htm/cs_bd_orders_iaaz.htm">
      	</OBJECT>

Site Resource Modifications

The development team decided to add a new resource for system administrators to use to manage the databases in which gift certificate information is stored. They named this resource Certificates. The Certificates resource uses the Generic Properties dialog box as described in "Levels of Integration" in Commerce Server 2000 Help.

The only configuration information required for the Certificates resource is the connection string for the Certificates database. To add this resource, the development team created the SQL script CertificatesInit.sql, which they based on the SiteStatusInit.sql file included with the Commerce Server 2000 SDK. This SQL script makes the changes needed to include the Certificates resource in the Commerce Server Site Packager file (with a .pup extension) that the team used to move the finished site from the development environment to the test and production environments.

The following excerpt is from the CertificatesInit.sql script:

IF NOT EXISTS(SELECT s_ClassName FROM SystemProps WHERE s_ClassName = ''Certificates'' )
insert into SystemProps (s_Name, s_ClassName, s_ResourceType, f_ResourceFlags, f_PupFlags, s_ProgIDSnapin)
VALUES ('''',''Certificates'',''Certficates'',6,0,''Shoesnet.CertResource'')

IF NOT EXISTS(SELECT s_PropertyName FROM ExtendedProps WHERE s_PropertyName = ''s_AppName'' )
insert into ExtendedProps VALUES (''Certificates'',''s_AppName'',0,1,0,''Contoso'',8200,'''',''s_AppName'')

Site Page Modifications

The development team consulted the marketing team to decide on the best way to position the new gift certificate feature. They consulted the site designers to see how to best present it. This consultation concluded with the following decisions:

  • The team added a Gift Certificate page on which customers can purchase new gift certificates.
  • The marketing team created an advertisement for gift certificates to display to registered users who had previously purchased gift certificates. This advertisement was displayed on the home page.
  • The link to the new Gift Certificate page appeared on the menu that is displayed on all pages, and the advertising banner included a click-through link to the Gift Certificate page.
  • The team integrated purchases made with a gift certificate into the checkout process by including an option button on the Summary page.
  • Gift certificates were added to the Contoso online catalog. These items included a not-taxable property that the tax component checked to calculate the tax for orders that include gift certificates.

Checkout Pipeline Modifications

The development team decided to create a new pipeline component, called GiftCert, to reduce the billing amount on the order form when a purchase is made with a gift certificate. They added this new pipeline component to the Payment stage of the Checkout pipeline. The following table summarizes the values read and values written by the GiftCert component (three values read and one value written).

Values readValues written
certificate_codeBilling_amount
redemption_amount 
billing_amount 

COM Object Development The development team identified the following requirements for a new COM object they created:

  • Create a unique identifier for each new online certificate.
  • Update the online and back-end databases with new balance information when a gift certificate is created or used to make a purchase.

The development team implemented the new COM object with the following attributes:

  • It creates the unique identifier by first generating a globally unique identifier (GUID) and using a hashing algorithm to develop a four-digit alphanumeric code to append to the first four characters of the recipient's last name.
  • It updates the back-end system asynchronously by calling a Host Integration Server connector object and passing in the sales and gift certificate information.
  • It uses COM+ queuing.
  • It implements the "Both" threading model and aggregates the Free Threaded Marshaller object.

Profile Modifications

The Contoso development team decided to create a new profile for the gift certificates. The gift certificate profile stores recipient identification, including the recipient's address. The profile is stored in Contoso's SQL Server database.

Report Modifications

The development team based the new dynamic reports on a SQL Server Analysis cube. The static report, Gift Certificate Buyers, is based on a SQL query. They also created a new cube named Certificates. The development team then created the Extensible Markup Language (XML) framework for the new dynamic reports, in the manner described in "Creating Dynamic Reports Using Cubes" in Commerce Server 2000 Help.

After adding the new Analysis cube and XML framework, the development team used the Analysis – New Dynamic OLAP Report.sql script provided in the SDK\Samples\Business Analytics\Scripts directory to add the report definition to their Commerce Server Data Warehouse.

The team also created the SQL script for generating the static reports, based on the example in "Creating Custom Reports" in Commerce Server 2000 Help.

Site Term Modifications

To display the Certificates advertisement to customers who previously purchased gift certificates, the development team added a new site term, called Certificate Buyer. They used the Site Terms Editor module in Business Desk to do this. The new site term has the properties listed in the following table.

PropertyValues
NameCertificate_Buyer
Display NameCertificate Buyer
Term NamesNo, Yes
Term Display NameNo, Yes

The development team mapped the new Certificate Buyer site term to one of the custom properties of the User object.

Campaign Modifications

The development team used the Campaigns modules in Business Desk to create a new advertising campaign for the gift certificates. The campaign contained a single house ad targeted to customers for whom the expression Certificate_Buyer = Yes evaluates to True. They added registered users to the Certificate_Buyer group by exporting the Gift Certificate Buyers static report to the List Manager module, and then targeting the certificates ad to this group. The click Uniform Resource Locator (URL) for this new advertisement is the Certificates page.

Deployment Summary

The Contoso development team used the tools listed in the following table to deploy and replicate the new gift certificate feature.

Feature elementsDeployment toolReplication tool
New site pagesSite PackagerMicrosoft Application Center 2000
New Business Desk modulesSite PackagerApplication Center
New pipeline componentSetup programSetup program
New databaseSite PackagerSQL Server replication
New COM componentCOM+ applicationApplication Center

After the team finished testing the new gift certificate feature, they deployed the changes in their production environment by packaging the new version of the site using Site Packager. This new package included the site pages, Business Desk modules, and site data. They created a Microsoft Windows Installer file to set up the new GiftCert pipeline component on the servers in their Web farm. Because the COM+ object is implemented as a COM+ Queued Component, they added the object to a COM+ application. This made it possible to use the Application Center Deployment Wizard to deploy the object to all of the servers in the Web farm. (For more information about using the Application Center Deployment Wizard, see Chapter 15, "Deploying Content.")

Profiling System Utilities

The profile schema for a Commerce Server site is stored and maintained in the Profiles database. By default, this database is named <SiteName>_COMMERCE when you unpack a site. A profile schema is a hierarchy made up of the following nodes:

Catalog
Business Object Profile
   Business Object Profile Attribute (to store Data Warehouse class name)
   Group
   Property
   Property Attribute
   Data Ref (to store linked Data Member name)
   Data Source
      Source Info (to store Data Source Partition settings such as default partition flag and connection string)
         Source Info Attribute
            Data Object
            Data Member
The root node is named Catalog, and you must have a minimum of two catalogs for the Profiling System in any Commerce Server site:

  • Profile Definitions catalog
  • Site Terms catalog

The nodes are provided by default in the Site Packager file for the Blank Solution Site. The Profile Definitions catalog stores the business object profile schemas, such as User Object, Address, and Organization, as well as the data source settings. The Site Terms catalog stores the site term definitions.

The Commerce Server 2000 Resource Kit CD contains the tools listed in the following table to help you develop profiles.

ToolDescription
Profiles Schema MoverA compiled Microsoft Visual Basic application that enables you to define and configure the profile schema in one Commerce Server environment (such as your development environment), then migrate it to another (such as your test or production environment). You can also use this tool to change the data source connection strings for the target environment when you migrate the schema.
Site Terms ViewerThe Site Terms Viewer is a Visual Basic script that shows how to access site terms programmatically.

This section describes the architecture of these two tools and describes how to use the Profiles Schema Mover to import and export a profile schema.


NOTE:
The term profile schema represents the entire set of schemas for a site's Profiling System and does not denote the schema for an individual profile, such as user object, address, and organization, which represent the business entities of the site. Schemas for individual business entities are always called business object profile schemas.

Profiles Schema Mover

You use the Profiles Schema Mover tool to migrate the profile schema you configured in one Commerce Server site environment to another Commerce Server site environment.


NOTE:
The Profiles Schema Mover tool does not migrate the business object profile data or the physical database tables and Lightweight Directory Access Protocol (LDAP) classes used to store the business object profile data. It simply automates the process of manually creating the profile schema (profile definitions, data sources, and data members) using Commerce Server Manager.

If you create a data object or a data member through Commerce Server Manager, the specific database table/column or LDAP class/attribute is visible only to the Profiling System. You must create the necessary database tables or LDAP classes to expose them before you migrate the data objects and members.


Installation

The Profiles Schema Mover tool is a stand-alone application (.exe file), and there are no additional resource files or dynamic-link libraries (DLLs) that you need to install. To use it, copy the executable file to the server on which Commerce Server is installed.

The Profiles Schema Mover tool is written in Visual Basic and references the following type libraries:

  • Microsoft Commerce 2000 Configuration Type Library
  • Microsoft Commerce 2000 BizData Admin Type Library
  • Microsoft XML, version 2.0
  • Microsoft ActiveX Data Objects 2.5 Type Library
  • Microsoft OLE DB Service Component 1.0 Type Library
  • Active DS Type Library


NOTE:
The type libraries provided by Commerce Server are automatically installed and registered on the server where Commerce Server is installed.

Operation

You run the Profiles Schema Mover tool on the server on which Commerce Server is installed because it must interact directly with the run-time services and components that Commerce Server provides. You must run the Profiles Schema Mover tool in the environment in which the profile schema is located. If you want to copy the profile schema from one environment to another, you must first run the Profiles Schema Mover tool in the source environment to export the schema, and then run the tool in the destination environment to perform the import.

Figure 9.1 shows the user interface (UI) for the Profiles Schema Mover tool.

Click to view graphic
Click to view graphic

Figure 9.1 Profiles Schema dialog box

The following sections provide a detailed description of how to export and then import catalogs.

Exporting a Catalog

Clicking the Export Catalog button in the Profiles Schema dialog box shown in Figure 9.1 generates a single XML file describing the profile schema settings for the Commerce Server site selected in the Site Name box. The XML file generated follows the Commerce Server profiles XML schema format. To export a catalog, the tool does the following:

  1. Obtains a list of sites.
  2. Connects to the data store.
  3. Obtains profile and data source names.
  4. Obtains profile definitions.
  5. Obtains the Site Terms catalog.
  6. Saves the profile schema XML document.

Obtaining a List of Sites

The Site Name box in the Profiles Schema dialog box contains the names of sites found in the Administration database for the Commerce Server environment in which the Profiles Schema Mover tool is running. The tool obtains a list of sites by using the Commerce.GlobalConfig object to retrieve global configuration settings stored in the Administration database. The following code demonstrates how to retrieve the settings:

Dim oGlblCfg As New GlobalConfig
    	Dim rsSites As New Recordset
    	oGlblCfg.Initialize
    	Set rsSites = oGlblCfg.Sites
    	For Each Site In rsSites.Fields
       		SitesList.AddItem Site.Name
    	Next      

The tool uses the Commerce.SiteConfigReadOnly object to access the site configuration settings for the selected site. It calls the Initialize method of the Commerce.SiteConfigReadOnly object to load the configuration settings for the site and site resources from the Administration database and return them in the Fields property of the SiteConfigReadOnly object instance.

The tool then reads this property and retrieves the connection string from the Profiles data store (defined in the _BizDataStoreConnectionString property of the Profiles global resource in Commerce Server Manager).


IMPORTANT:
The Profiles Schema Mover tool manipulates the site schema programmatically by using the Commerce.BusinessDataAdmin object (BDAO). The Commerce.BusinessDataAdmin object is provided in the Microsoft Commerce 2000 BizData Admin Type Library (BizDataManager.dll), but is currently not documented.

Using the Commerce.BusinessDataAdmin object to modify the profile schema is not supported; at this time the only supported approach for modifying the profile schema is to use the Profile Designer UI in either Commerce Server Manager or in Business Desk. The UI enforces the appropriate validation rules during the creation and modification of a profile schema. If you bypass these validation rules by using the Commerce.BusinessDataAdmin object, your profile schema may be corrupted, preventing your site's Profiling System from working properly.


Connecting to the Data Store

After the Profiles Schema Mover has obtained a connection string to the Profiles data store, it calls the Connect method for the Commerce.BusinessDataAdmin object, passing in the connection string to establish a connection to the data store. The following code demonstrates how to connect to the data store:

Public Function LoadBDAO(sSiteName As String) As BusinessDataAdmin
  Dim objSiteCFG As New SiteConfigReadOnly
  Dim objBDAO As New BusinessDataAdmin
  Dim sDSN As String
  objSiteCFG.Initialize gSiteName
  sDSN = objSiteCFG.Fields("Biz Data_
Service").Value.Fields_
("s_BizDataStoreConnectionString").Value_
                            objBDAO.Connect sDSN
  Set LoadBDAO = objBDAO
End Function

The Commerce.BusinessDataAdmin object interface exposes and describes the internal structure of the profile schema in XML format. The Microsoft Extensible Markup Language (MSXML) version 2.0 parser handles the XML Document Object Model (DOM) manipulation, though this can be changed to use the later version of the MSXML parser.

Obtaining Profile and Data Source Names

To export a profile schema from its data source, the Profiles Schema Mover tool first calls the GetCatalog method for the Commerce.BusinessDataAdmin object. This method returns an XML DOM object that contains a list of catalogs, as well as a list of business object profiles and data sources belonging to each of the catalogs, as defined in the following profile schema for the site:

Set objBDAO = LoadBDAO(gSiteName)
Set CatalogsDoc = objBDAO.GetCatalogs

For example, if you use the Profile Schema Mover tool to export a schema for the Retail Solution Site, the following XML would be returned:

<Document xmlns="urn:schemas-microsoft-com:bizdata-profile-schema">
    <Catalog name="Profile Definitions" displayName="Profile Catalog"     description="Profile Definitions">
       <Profile name="Address" displayName="Address" description="Addresses"/>
       <Profile name="BlanketPOs" displayName="BlanketPOs" description="Blanket Purchase Orders"/>
       <Profile name="Organization" displayName="Organization" description="Organization Object"/>
       <Profile name="UserObject" displayName="User Object" description="User Object"/>
       <Profile name="TargetingContext" displayName="Targeting Context" description="CSF Targeting Context"/>
       <DataSource name="UPM_SQLSource" displayName="ProfileService_SQLSource" description="Source" sourceType="OLEDB-ANSI"/>
    </Catalog>
    <Catalog name="Site Terms" displayName="Site Terms">
       <Profile name="MSCommerce" displayName="Site Terms" description="Site Terms for Microsoft Commerce Server" isProfile="0"/>
    </Catalog>
</Document>

Obtaining Profile Definitions

The GetCatalog method returns only the Catalog node and its immediate child nodes, Profile and DataSource. To generate an XML document representing the entire definition of the profile schema, the tools adds the remaining child nodes (such as Group, Property, Attribute, Data Object, and Data Member) to the XML document. To do this, the Profiles Schema Mover tool iterates through each Profile node and retrieves all of its child nodes as well as the elements beneath the child nodes.

The tool obtains an XML DOM object representing each individual Profile node and its child nodes by calling the GetProfile method for the Commerce.BusinessDataAdmin object, passing in the Profile name. The profile is passed in the <Catalog Name>.<Profile Name> format (for example, Profile Definitions.Address). After a complete structure is obtained, the tool replaces each Profile node represented as <Profile … /> in the XML DOM document obtained by the BDAO.GetCatalog method, as follows:

<Profile …>
	<Attribute …/>
	<Group …>
		<Property …>
			<DataRef …/>
			<Attribute …/>
<Attribute …/>
		</Property>
		<Property …>
		</Property>
	</Group>
	<Group …>
	</Group>
</Profile>

The Profiles Schema Mover tool performs the same operation on each DataSource node in the Profile Definitions catalog.

Obtaining the Site Terms Catalog

After the Profiles Schema Mover tool has obtained the catalog for each data source, it must process the Site Terms catalog to carry out the same operation on its Profile nodes. It uses the following code to do this:

' Process each catalog
Set Catalogs = CatalogsDoc.selectNodes("//Catalog")
  For Each Catalog In Catalogs    
  ' Get the catalog name
    CatalogName = Catalog.getAttribute("name")
  ' Get each profile and add it to the XML document
    sProfileXSL = "//Catalog[@name='" & CatalogName & "']/Profile"
    Set Profiles = CatalogsDoc.selectNodes(sProfileXSL)
      For Each Profile In Profiles
         ProfileName = CatalogName & "." & Profile.getAttribute("name")
           Set ProfileDoc = objBDAO.GetProfile(CStr(ProfileName))
           Set ProfileNode = ProfileDoc.selectSingleNode("//Profile")
           Set NewChild = Catalog.replaceChild(ProfileNode, Profile)
      Next
  ' Get each data source and add it to the XML document
    sDataSourceXSL = "//Catalog[@name='" & CatalogName & "']/DataSource"
    Set Datasources = CatalogsDoc.selectNodes(sDataSourceXSL)
      For Each DataSource In Datasources
        DataSourceName = CatalogName & "." _
        & DataSource.getAttribute("name")
        Set DataSourceDoc = objBDAO.GetDataSource(CStr(DataSourceName))
        Set DataSourceNode =   DataSourceDoc.selectSingleNode("//DataSource")
        Set NewChild = Catalog.replaceChild(DataSourceNode, DataSource)
      Next
  Next

Saving the Profile Schema XML Document

Finally, the Profiles Schema Mover tool calls the CatalogsDoc.Save method to save the profile schema XML document.


NOTE:
The Commerce.BusinessDataAdmin object also exposes the method ExportCatalog to export the profile schema in XML format. This method works specifically with Site Packager to generate and package the profiles XML schema in a Site Packager file.

For this reason, the ExportCatalog method includes the primary partition setting for the site data source, but leaves out the settings for any other partitions from the profiles XML schema it generates. The Profiles Schema Mover tool implements its own logic (described in the previous "Obtaining the Site Terms Catalog" topic) to include the settings for all data source partitions and to export the complete "picture" of the site profile catalog in the generated profiles XML schema.


Importing a Catalog

When you click the Import Catalog button in the Profiles Schema dialog box shown previously in Figure 9.1, the selected profile schema settings for the Commerce Server site selected in the Site Name box are loaded. To import catalog code, the Profiles SchemaMover tool:

  1. Loads and validates the XML document.
  2. Selects a data source for the import.

Loading and Validating the XML Document

The Profiles Schema Mover tool parses the content of the selected file and loads it into the XML DOM object for processing. If the file loads properly, the tool next verifies that the loaded XML document is correctly formatted, by ensuring that the namespace Uniform Resource Identifier (URI) element of the loaded XML document is set to the following address: urn:scheams-microsoft-com:bizdata-profile-schema.

Before initiating the import process, you can use the Profiles Schema Mover tool to change the data source connection strings specified in the import profiles XML schema to match the configuration settings used in the target site environment. A data source connection string is specified in the connStr attribute of the SourceInfo element in the import profiles XML schema. In the partitioned data source environment, the SourceInfo element is created for each partition. The connection string attribute is also specified for each partition.

For example, you could represent the import profiles XML schema for a site with two SQL data sources and two partitions created on the first SQL data source, as follows:

<DataSource name="UPM_SQLSource" displayName="ProfileService_SQLSource"
description="Source" sourceType="OLEDB-ANSI">
<SourceInfo name="SQLSource_Partition1" isDefault="1"
connStr="Provider=SQLOLEDB; Data Source=CSITS;Initial Catalog=RETAIL_COMMERCE;User ID=SA;Password=;Extended
Properties=;Network Library=DBMSSOCN" />
<SourceInfo name="UPM_SQLSource_Partition2"  connStr="Provider=SQLOLEDB.1;Password="";Persist
Security Info=True;User ID=SA;Initial Catalog=RETAIL_COMMERCE2;Data Source=CSITS">
  <Attribute name="Username" displayName="" /> 
    	<Attribute name="Password" displayName="" /> 
</SourceInfo>
</DataSource>
  <DataSource name="UPM_SQLSource2"   displayName="ProfileService_SQLSource2" sourceType="OLEDB-ANSI">
</DataSource>

Selecting a Data Source for the Import

The Profiles Schema Mover tool iterates through each DataSource node in the import profiles XML schema, reads the connection string attribute (connStr) of each partition element under the DataSource node (SourceInfo), and then displays the results. Figure 9.2 shows how the Profiles Schema Mover tool displays the data sources.

Click to view graphic
Click to view graphic

Figure 9.2 Import Profiles Schema dialog box

You can select a specific data source partition in the tree view control to display the connection string currently specified in the import profiles XML schema. Click the Edit button to open a dialog box in which you can edit the connection string for the selected data source partition.

The Profiles Schema Mover tool determines the appropriate dialog box to display, based on the type of data source (OLEDB-ANSI SQL source or LDAP directory) you select. The following code sample illustrates how the tool determines which dialog box to display:

Dim oDataLinks As DataLinks, oConn As ADODB.Connection
Dim SourceInfo As IXMLDOMElement, Source As IXMLDOMElement
Set SourceInfo = gXMLDoc.selectSingleNode("//DataSource[@name='" &    sSourceName & "']/SourceInfo[@name='" &
sSourceInfoName & "']")
  If Not SourceInfo Is Nothing Then
    sConnStr = SourceInfo.getAttribute("connStr")
    Set Source = SourceInfo.parentNode
    sSourceType = Source.getAttribute("sourceType")
      If StrComp("OLEDB-ANSI", sSourceType, vbTextCompare) = 0 Then
        Set oDataLinks = New DataLinks
        Set oConn = New ADODB.Connection
        oConn.ConnectionString = sConnStr
        oConn.Properties.Item("Persist Security Info").Value = True
        oDataLinks.hWnd = Me.hWnd
       'PROMPTAGAIN:
        If oDataLinks.PromptEdit(oConn) Then
        	oConn.Properties.Item("Persist Security Info").Value = True
        	sConnStr = oConn.ConnectionString
        	  If InStr(1,sConnStr,"Integrated Security", vbTextCompare) > 0 _             Then
              MsgBox "Windows NT Integrated security is not supported._ You_must use 
SQL Server authentication. Use a specific_ user name and password.", vbCritical, "Profile schema"
               'GoTo PROMPTAGAIN:
            End If
          SourceInfo.setAttribute "connStr", sConnStr
         End If     
        ElseIf StrComp("LDAPv3", sSourceType, vbTextCompare) = 0 Then
         Set gXMLNode = SourceInfo DlgLDAP.Show 1, Me
        End If
      End If
  End If

After you have adjusted the data source connection strings in the import profiles XML schema to match the target Commerce Server site environment, you click the Import button in the Import Profiles Schema dialog box (Figure 9.2) to begin the import.

Once again, a programmatic manipulation of the site profile schema is done using the Commerce.BusinessDataAdmin object, and its ImportCatalog method is made available to update the profile schema by importing the XML document, as shown in the following code:

Dim objBDAO As New BusinessDataAdmin
Set objBDAO = LoadBDAO(gSiteName)
objBDAO.ImportCatalog gXMLFileName

Deployment Scenarios

The scenarios in this section describe how to migrate a profile schema from one site to another. Note that the term Commerce Server environment denotes one instance of Microsoft Windows 2000 Server on which Commerce Server is installed.

Migration Across Multiple Commerce Server Environments

In this scenario, two Commerce Server sites (Site A and Site B) are installed in two different Commerce Server environments. The Profiles Schema Mover tool is used to migrate the profile schema from Site A into the Profiles data source of Site B. The tool is installed in both Commerce Server environments. The installation in the environment of Site A is used to generate the profile XML schema file, and the installation in the environment of Site B is used to import the XML file into the Profiles data store of Site B. Figure 9.3 shows an example of migration across multiple Commerce Server environments.

Click to view graphic
Click to view graphic

Figure 9.3 Migration across multiple Commerce Server environments

This scenario represents a project environment in which a site's profile schema is maintained in the development environment and any schema changes made in the development environment are then migrated to the other environments, such as the test environment, staging environment, and production environment.

The Profiles Schema Mover tool is especially useful if you make a large number of changes to the profile schema, because it eliminates the time you would otherwise have to spend applying the same changes manually in the different environments, using Commerce Server Manager or Business Desk. The Profiles Schema Mover tool enables you to generate a single XML file that represents the entire profiles schema of the site, and then migrate the changes to multiple environments, without errors, by simply importing a XML file.

Migration Within a Single Commerce Server Environment

In this scenario, both Site A and Site B are installed in a single Commerce Server environment, thus sharing the same Administration database. This scenario is possible because each individual site in the Commerce Server environment has its own Profiles data store. Changing the profile schema for Site A does not impact the profile schema for Site B. In the Administration database, the global configuration data is maintained once and shared by both sites, but site configuration data, such as the connection string for the Profiles data store, is maintained separately for each site. Figure 9.4 shows migration within a single Commerce Server environment.

Click to view graphic
Click to view graphic

Figure 9.4 Migration within a single Commerce Server environment


Next




Top of Page


Last Updated: Friday, July 6, 2001