Share via


Scripting the Model Builder DTS Task

The following script creates and runs the Model Builder DTS task. This script can be used to create a package containing the DTS task to be run. The sample script can be run in two different ways. You can run the task on the command line by using the command DTSRun.exe. The file DTSRun.exe is automatically installed on your server when you install SQL Server. Or you can copy the script into a Visual Basic script file (.vbs) and run it by using cscript, for example, <drive>:cscript <filename>.vbs.

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 DTSPredictor object, see DTSPredictor Object.

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

'*********************************************************************
' Model Builder DTS Task
' This script creates a DTS package and runs it.
'**********************************************************************
const strDWConn = "Provider=SQLOLEDB.1;Integrated Security='SSPI';Initial Catalog=PredictorDemo_dw;DataSource=local"
const description = "Model Builder task"
const sModelName = "dfgdfggetrg efgedfg"
const sModelCfgName = "DemoTransactions"
const sSiteName = "PredictorDemo"
const sDWName = "Data Warehouse 1"

'******************************************************************
' Invokes the Model Builder DTS task.
'******************************************************************
Dim oPackage 
Dim oTask 
Dim oStep 
Dim oProps 
Dim oTaskProps 
Dim oPred
Dim slModels
Dim dModel
Dim iStatus 
Set oPred = CreateObject("Commerce.PredictorServiceAdmin")
set oPackage = CreateOBject("DTS.Package2")

'******************************************************************
' Define package properties.
'******************************************************************
oPackage.Name = "Model Builder Package"

'******************************************************************
' Create a task.
'******************************************************************
Set oTask = oPackage.Tasks.New("CS_CSDTSPredictor.DTSPredictor")
Set oTaskProps = oTask.Properties

oTaskProps("DWConnStr").value = strDWConn
oTaskProps("ModelName").value = sModelName
oTaskProps("ModelCfgName").value = sModelCfgName
oTaskProps("ArchiveType").value = 2
oTaskProps("CustomRename").value = "CustomRenameTest"
oTaskProps("NumRetries").value = 0
oTaskProps("RetryInterval").value = 0
oTaskProps("SourceType").value = 0
oTaskProps("SourceName").value = sSiteName
oTask.Name = "Building model """ & oTaskProps("ModelName").value & """"
oTask.Description = "Creates a task for ModelBuilder DTS"
oPackage.Tasks.Add oTask
oPackage.Description = oTask.Name
'******************************************************************
' Create a step.
'******************************************************************
Set oStep = oPackage.Steps.New
oStep.Name = "Step1"
oStep.TaskName = oTask.Name

' For custom tasks written in VB, the steps cannot run on a secondary
' thread.
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 

Copyright © 2005 Microsoft Corporation.
All rights reserved.