Delen via


Marketing System Task and Object Mapping from COM to the .NET Framework

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

This topic describes how Marketing System objects implemented by using the Component Object Model (COM) for Commerce Server 2002 and earlier releases map to similar objects in the Commerce Server 2007 Class Library based on the .NET Framework. The Commerce Server 2007 Marketing System includes the Marketing Management System (ad and discount promotions, and content selection pipelines), the expression evaluator, and the List Manager and Direct Mailer services.

Note

In earlier versions of Commerce Server, the Marketing System was referred to as the Targeting System.

Object Mapping

The .NET Framework types in the following table are in the Microsoft.CommerceServer.Runtime namespace.

COM

.NET Framework

ContentSelector

ContentSelector

CacheManager

CommerceCache, CommerceCacheCollection

(Microsoft.CommerceServer.Runtime.Caching)

OrderPipeline

ContentSelectionPipeline

(Microsoft.CommerceServer.Runtime.Pipelines)

ContentList

ContentItemCollection

(Microsoft.CommerceServer.Runtime.Targeting)

DiscountItemCollection

(Microsoft.CommerceServer.Runtime.Marketing)

DiscountItem

(Microsoft.CommerceServer.Runtime.Marketing)

ms956374.alert_note(en-US,CS.70).gifNote:
The COM ContentList object continues to be used internally in the pipeline.

Content Selection Framework (CSF) global context dictionary

ContentSelectionContext

(Microsoft.CommerceServer.Runtime.Targeting)

ExpressionEval

ExpressionEvaluator

(Microsoft.CommerceServer.Runtime.Targeting)

MailingListManager

MailingListManager

(Microsoft.CommerceServer.Runtime.Marketing)

MailingLists

PredictorClient

Predictor has been removed from Commerce Server 2007.

Task Mapping

The following sections contain common coding tasks and show you the COM and the .NET Framework approach to coding the solution.

Configuring the Objects Required for Run-time Content Selection

The technique described here includes advertising and discounts.

COM

.NET Framework

In the Application_OnStart method of the Global.asa file, create and configure the CacheManager object, the ExpressionEvaluator object, content selection pipelines, and global CSF context dictionaries. In Solution Sites, these tasks are broken out in the global_cache_lib.asp and global_csf_lib.asp include files.

In the <CommerceServer> section of the Web.config file, configure the sections for caches, pipelines, and contentSelection. Make sure that the appropriate CommerceModules are configured in the <HttpModules> section.

Selecting Targeted Advertisements or Discount Promotions for Display by Using a CSF Content Selection Pipeline

COM

.NET Framework

Create a ContentSelector object and set properties for targeting and other selection parameters. Call the GetContent method, passing the appropriate CSF global context dictionary. The results are returned as a SimpleList of strings. For more information about how to use the ContentSelector object, see the examples in the Advertising Sitelet in the Commerce Server SDK.

Retrieve the ContentSelectionContext object for the type of content that you are requesting. (A ContentSelectionContextCollection object is created at application startup based on configuration in the Web.config file.) Call the GetSelector method to retrieve a ContentSelector object. Set other selection parameters on the ContentSelector object as needed. Call the GetContent method to return a StringCollection object of formatted content items.

Accessing the Order or Pipeline Context Dictionaries After a CSF Pipeline has been Executed by the ContentSelector.GetContent Method

Accessing the Order or Pipeline Context dictionaries after a CSF pipeline has been executed can be useful for troubleshooting. In the COM-based model, it is the only way to access the complete set of properties of the selected content items.

COM

.NET Framework

After you call the GetContent method, the Order and Pipeline Context dictionaries that flowed through the pipeline are available in the ContentSelector object (CSO) dictionary under the keys Order and Context, respectively.

After you call the GetContent method, the Order and Pipeline Context dictionaries that flowed through the pipeline are available through the Item property of the CSO, or through the indexer. The names to access are Order and Context, respectively.

Retrieving the Details of Content Items Selected by a ContentSelector Object

COM

.NET Framework

Call the GetContent method and read the Order dictionary. Then access the ContentList object that contains the item data by reading the value of the _Content key. The _WinnerIndexes key contains a SimpleList object that contains the row indexes of the selected items. Use the ContentList.Fields property to access the Fields collection for a given content item by passing its row index. The Fields collection provides access to the content item properties as name/value pairs.

Call the GetContent method and then read the SelectedContentItems property of the CSO. To read properties of selected items as name/value pairs, read the items in the System.Collections.IDictionary collection.

Creating an Instance of the Expression Evaluator and Connecting it to an Expression Store Database

COM

.NET Framework

Create an instance of the Commerce.ExpressionEval object and call the Connect method.

Expressions are typically stored in the BizDataStore database.

Create an instance of the ExpressionEvaluator class and pass the connection string to the constructor. If you are running in the context of the .NET Framework, an instance is created for you automatically.

In Commerce Server 2002, all expressions are typically stored in the BizDataStore database. In Commerce Server 2007, the marketing expressions are stored in the Marketing Expression Store. The Upgrade Wizard migrates existing marketing expressions from the BizDataStore to the Marketing Expression Store.

Evaluating a Single Expression by Using the Expression Evaluator

COM

.NET Framework

Call the ExpressionEval.Eval method, passing a dictionary of profiles to evaluate against and the ID of the expression to evaluate. The result is a VARIANT. It is either of type VT_BOOL (with value VARIANT_TRUE or VARIANT_FALSE) or VT_NULL if a referenced profile or profile property is unavailable for evaluation.

Call the Evaluate method, passing a TargetingProfileCollection object and the ID of the expression to be evaluated. The method returns an ExpressionEvaluator..::.ExpressionResult enumerator member.

Evaluating Multiple Expressions Against a Static Set of Profiles

Evaluating multiple expressions against a static set of profiles is more efficient than evaluating expressions individually, because the expression evaluator will cache profile properties and expression results within the context. Whether you evaluate a single expression or multiple expressions, treat the context object that is returned as an opaque handle and do not call methods on it.

COM

.NET Framework

Create an ExprEvalContext object by passing a dictionary of profiles to the ExpressionEval.CreateEvalContext method. Evaluate the expressions by calling the ExpressionEval.EvalInContext method, passing the ID of the expression to evaluate and the ExprEvalContext object.

Create an CreateEvaluationContextHandle by passing a TargetingProfileCollection object to the CreateEvaluationContextHandle method. Evaluate the expressions by calling the EvaluateInContext method, passing the ID of the expression to evaluate and the CreateEvaluationContextHandle object.

Running a CSF RecordEvent Pipeline to Record Events such as Clicks on Advertisements or Discounts

COM

.NET Framework

Create Order and Context dictionaries to pass through the pipeline. Set the _winners, _event, _eventcount, _content, and _performance keys in the Order dictionary (the _content and _performance keys should come from the content cache for ads or discounts). Optionally set the SiteName and PageGroupId keys in the context dictionary. Retrieve the pipeline instance from the application collection [Application("CampaignsCSFEventPipe")]. Execute the pipeline to record the event or events by using the process configured in the pipeline. For more information, see the redir.asp page in the Solution Sites or Advertising Sitelet in the SDK. The redir.asp file is located in the <drive>:\Inetpub\wwwroot\<Solution Site> directory. This file is only available if the Retail or Supplier Solution Site has been unpacked.

The model is the same as in the COM model.

Create the dictionaries by using the Primary Interop Assembly (PIA) for the dictionary (Microsoft.CommerceServer.DictionaryClass). Retrieve the pipeline to execute directly from the pipelines collection (Pipelines).

Performing List Operations with the List Manager Service

COM

.NET Framework

Create an instance of the Commerce.ListManager object. If the service is enabled but not running, the Service Control Manager (SCM) starts it automatically. Call the Initialize method, passing the connection string for the campaigns database (or other target database). Call other methods to perform list operations as needed.

Use the StaticList, ExpressionList, and MailingListManager objects to perform list operations.

See Also

Other Resources

Task and Object Mapping from COM to the .NET Framework