Scripting the Report Caching DTS Task

The following script creates and runs the Report Caching DTS task. This script can be used to create a package containing the DTS task to be run. Unlike the other DTS task scripts, this script can only be run from the command line by using the command DTSRun.exe or by embedding the sample code in a Visual Basic application, and then calling it from command line. The file DTSRun.exe is automatically installed on your server when you install SQL Server.

To successfully complete the import of data into the Data Warehouse, run the DTS tasks in the following order:

  1. Configuration Synchronization
  2. Web Server Log Import
  3. Transaction Data Import
  4. Product Catalog Import
  5. Profile Data Import
  6. Campaign Data Import
  7. Data Deletion
  8. Model Builder
  9. IP Resolution
  10. Report Preparation
  11. Report caching

For more information about the DTSCacheWarmer object, see DTSCacheWarmer Object.

For a description of this DTS task, see Commerce Server DTS Tasks.

Code to create the DTS package using the DTSRun.exe command

'*********************************************************************
' Report Caching DTS Task
' This script creates a DTS package and runs it.
'*********************************************************************
Dim oPackage 
Dim oTask 
Dim oStep 
Dim oTaskProps 

Set oPackage = WScript.CreateObject("DTS.Package")
oPackage.Name = "cachewamer package"
oPackage.Description = "Cachewarmer Package"
oPackage.FailOnError = True

'*********************************************************************
' Create a task.
'*********************************************************************
Set oTask = oPackage.Tasks.New("commerce.DTSCacheWarmer")
oTask.Name = "thetask"
oTask.Description = "Creates a task for CacheWarmer DTS"
Set oTaskProps = oTask.Properties

oTaskProps("SourceName").Value = "Data Warehouse 1"
oTaskProps("SourceType").Value = 1
oTaskProps("TaskName").Value = "thetask"
oTaskProps("NumRetries").Value = 1
oTaskProps("RetryInterval").Value = 30

oPackage.Tasks.Add oTask

'*********************************************************************
' Create a step.
'*********************************************************************
Set oStep = oPackage.Steps.New
oStep.Name = "step1"
oStep.TaskName = "thetask"
oStep.ExecuteInMainThread = True
oPackage.Steps.Add oStep

' ******************************************************************
' Execute the package.
' ******************************************************************
oPackage.Execute
    For I = 1 To oPackage.Steps.Count
        If oPackage.Steps(I).ExecutionResult = 1 Then
            iStatus = False
            MsgBox oPackage.Steps(I).Name + " in the " + _
            oPackage.Name + " failed."
        End If
    Next 

MsgBox oPackage.Name + " Done"

Set oStep = Nothing
Set oTaskProps = Nothing
Set oProps = Nothing
Set oTaskProps = Nothing
Set oPackage = Nothing

Code to create the DTS package using a Visual Basic executable

To call this executable from the command line, type the project name followed by the site name, for example CacheWarmerProject Retail.

'*********************************************************************
' Cache Warmer DTS Task
' This code creates a DTS package and runs it.
'*********************************************************************
public sub main()

On Error Resume Next
   Dim sArray() As String
   Dim  sSiteName as string
   Call GetCmdLine(sArray(), Trim$(Command$))
   sSiteName = sArray(1)

   Dim oPackage 
           Dim oTask 
           Dim oStep 
           Dim oTaskProps 
           Dim ObjSiteCfg
   Dim sDWName 

   'Get the DW associated with the site.
   Set ObjSiteCfg = CreateObject("Commerce.SiteConfig")
       ObjSiteCfg.Initialize (sSiteName)
   sDWName = ObjSiteCfg.Fields("Global Data Warehouse").Value.Fields("s_RefResource").Value
   
   Set oPackage = CreateObject("DTS.Package")
   oPackage.Name = "cachewamer package"
           oPackage.Description = "Cache Warmer BVT"
           oPackage.FailOnError = True

'*********************************************************************
' Create a task.
'*********************************************************************
        
    Set oTask = oPackage.Tasks.New("CS_DWCacheWarm.DTSCacheWarmer")
           oTask.Name = "thetask"
        
   Set oTaskProps = oTask.Properties
           oTaskProps("SourceName").Value = sDWName 
           oTaskProps("SourceType").Value = 1
           oTaskProps("TaskName").Value = "thetask"
           oTaskProps("NumRetries").Value = 1
           oTaskProps("RetryInterval").Value = 30
        
   oPackage.Tasks.Add oTask
       
'*********************************************************************
' Create a step.
'*********************************************************************
   Set oStep = oPackage.Steps.New
           oStep.Name = "step1"
           oStep.TaskName = "thetask"
           oStep.ExecuteInMainThread = True
        
   oPackage.Steps.Add oStep
' ******************************************************************
' Execute the package.
' ******************************************************************
       oPackage.Execute
    
       Set oPackage    = Nothing
       Set oTask    = Nothing
       Set oStep   = Nothing
       Set oTaskProps    = Nothing
       Set ObjSiteCfg    = Nothing
   
End Sub

See Also

ETL Process for the Report Caching DTS Task

Copyright © 2005 Microsoft Corporation.
All rights reserved.