Targeting System Task and Object Mapping from COM to .NET

The targeting system includes the campaign management system (ad and discount promotions, including content selection pipelines), the expression evaluator, and the List Manager/Direct Mailer services.

Object mapping

The .NET types in the following table are in the Microsoft.CommerceServer.Runtime.Targeting namespace unless otherwise noted.

ASP ASP.NET
ContentSelector ContentSelector
CacheManager CommerceCache, CommerceCacheCollection

(Microsoft.CommerceServer.Runtime.Caching)

OrderPipeline ContentSelectionPipeline

(Microsoft.CommerceServer.Runtime.Pipelines)

ContentList ContentItemCollection

Ee798363.note(en-US,CS.20).gifNote

  • The COM ContentList object continues to be used internally in the pipeline.
CSF global context dictionary ContentSelectionContext
ExpressionEval ExpressionEvaluator
ExpressionStore ExpressionStore RCW (LISTMANAGERLib.dll, Microsoft.CommerceServer.Interop.Targeting)
ListManager ListManager RCW (Microsoft.CommerceServer.Interop.Targeting)
PredictorClient PredictorClient RCW

(PREDICTORCLIENTLib.dll, Microsoft.CommerceServer.Interop.Targeting)

Task mapping

Configuring the objects required for runtime content selection (including advertising and discounts)

Selecting targeted advertisements or discount promotions for display using a CSF Content Selection Pipeline

Accessing the Order or Pipeline Context dictionaries after a CSF pipeline has been executed by the ContentSelector.GetContent method

Retrieving the details of content items that were selected by a ContentSelector object

Creating an instance of the Expression Evaluator and connect it to an expression store database

Evaluating a single expression using the Expression Evaluator

Evaluating multiple expressions against a static set of profiles

Running a CSF RecordEvent pipeline to record events such as clicks on advertisements or discounts

Performing list operations using the ListManager service

Configuring the objects required for runtime content selection (including advertising and discounts)

ASP ASP.NET
In the Application_OnStart method of global.asa file, create and configure the the CacheManager object, the ExpressionEvaluator object, content selection pipelines, and global Content Selection Framework (CSF) context dictionaries. In the Solution Sites these tasks are broken out in the global_cache_lib.asp and global_csf_lib.asp include files. For more information, see Code to Support the ContentSelector Object. In the <CommerceServer> section of the web.config file, configure the sections for caches, pipelines, and contentSelection. Be sure the appropriate CommerceModules are configured in the HttpModules section. For more information, see the ASP.NET-Based Advertising Sitelet.

Selecting targeted advertisements or discount promotions for display using a CSF Content Selection Pipeline

ASP ASP.NET
Create a ContentSelector object. Set properties on the ContentSelector object 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, see Code to Execute the ContentSelector Object. The Advertising Sitelet in the SDK also contains examples about using the ContentSelector object. For more information about the Advertising Sitelet, see ASP-Based Advertising Sitelet. Retrieve the ContentSelectionContext for the type of content being requested (a ContentSelectionContextCollection object is created at application startup based on configuration in the web.config file). Call the ContentSelectionContext.GetSelector method to retrieve a ContentSelector object. Add targeting profiles to the TargetingProfilesCollection by calling the ContentSelector.Profiles.Add method. Set other selection parameters on the ContentSelector as needed. Call the GetContent method to return a StringCollection of formatted content items. For more information, see ASP.NET-Based Advertising Sitelet.

Accessing the Order or Pipeline Context dictionaries after a CSF pipeline has been executed by the ContentSelector.GetContent method

This can be useful for troubleshooting. In the COM-based model, it is also the only way to access the entire set of properties of the selected content items.

ASP ASP.NET
After the GetContent method has completed, the Order and PipelineContext dictionaries that flowed through the pipeline are available in the ContentSelector object (CSO) dictionary under the keys Order and Context, respectively. After the GetContent method has completed, the Order and PipelineContext dictionaries that flowed through the pipeline are available through the Item property of the CSO, or the indexer. The names to access are Order and Context, respectively.

Retrieving the details of content items that were selected by a ContentSelector object

ASP ASP.NET
After the GetContent method has completed, access the Order dictionary as described in the Accessing the Order or Pipeline Context dictionaries after a CSF pipeline has been executed by the ContentSelector.GetContent method table. Then access the ContentList containing the item data by retrieving the value for the _Content key. The _WinnerIndexes key contains a SimpleList of 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 allows access to the content item properties as name/value pairs. After the GetContent method has completed, access the SelectedContentItems property of the CSO. Each item in the collection is a System.Collections.IDictionary object, making it easy to access the properties of the selected content items as name/value pairs.

Creating an instance of the Expression Evaluator and connecting it to an expression store database

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

Expressions are typically stored in the BizDataStore database. The connection string for the BizDataStore database can be retrieved by accessing the s_BizDataStoreConnectionString key of the AppConfig options dictionary (as returned by the AppConfig.GetOptionsDictionary method).

Create an instance of the ExpressionEvaluator class and pass the connection string as the first parameter to the constructor. If you are running in the context of the NETAPPFW, then one is created for you automatically.

Expressions are typically stored in the BizDataStore database. The connection string for the BizDataStore database can be retrieved by accessing the Biz Data Service Resource (from the site's CommerceResourceCollection) and then accessing the s_BizDataStoreConnectionString property.

Evaluating a single expression using the Expression Evaluator

ASP ASP.NET
Use 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 (meaning that the result of the expression is undefined because a referenced profile or profile property was unavailable for evaluation). Use the ExpressionEvaluator.Evaluate method, passing a TargetingProfileCollection and the ID of the expression to be evaluated. The result is an ExpressionResult enumerator member.

Evaluating multiple expressions against a static set of profiles

This is the most efficient way to evaluate many expressions against a static set of profiles, as the expression evaluator will cache profile properties and expression results within the context. Note that in both cases, the context object that you get back should be treated as an opaque handle (you do not invoke methods on it).

ASP ASP.NET
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 EvaluationContextHandle by passing a TargetingProfileCollection to the ExpressionEvaluator.CreateEvaluationContextHandle method. Evaluate the expressions by calling the ExpressionEvaluator.EvaluateInContext method, passing the ID of the expression to evaluate and the EvaluationContextHandle object.

Running a CSF RecordEvent pipeline to record events such as clicks on advertisements or discounts

ASP ASP.NET
Create Order and Context dictionaries to pass through the pipeline. Set the _winners, _event, _eventcount, _content, and _performance keys in the Order dictionary (the latter two 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(s) using the process configured in the pipeline. See the redir.asp page in the Solution Sites or Advertising Sitelet in the SDK for an example of this functionality. 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 for ASP.NET.

Create the dictionaries using the Primary Interop Assembly (PIA) for the dictionary (Microsoft.CommerceServer.Runtime.DictionaryClass). Retrieve the pipeline to execute directly from the pipelines collection (CommerceContent.Current.Pipelines). The Retail2002 site in the SDK contains the Redir.aspx page, which is an example of executing the RecordEvent pipeline from an ASP.NET page. The Redir.aspx file is located in the <drive>:\Inetpub\wwwroot\<Solution Site>\Redir.aspx directory. This file is only available if the Retail2002 - International Retail Site has been unpacked.

Ee798363.note(en-US,CS.20).gif Important

  • We recommend that you do not develop a production-quality site based on the Retail2002 Site. We recommend that you use the Commerce Server 2002 Starter Site to develop a production quality site. You can download the Starter Site from https://go.microsoft.com/fwlink/?linkid=37800.

Performing list operations using the List Manager service

ASP ASP.NET
Create an instance of the Commerce.ListManager object. If the service is enabled but not running, it will be started by the Service Control Manager (SCM) 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. Add a reference to the ListManagerLIB.dll PIA. Create an instance of the ListManagerClass object. If the service is enabled but not running, it will be started by the Service Control Manager (SCM) 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.

Copyright © 2005 Microsoft Corporation.
All rights reserved.