다음을 통해 공유


Scripting the Transaction Data Import DTS Task

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

The following script creates and runs the Transaction Data Import DTS task. You can use this script in two ways to create a package that contains the DTS task to run:

  • You can run the package 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.

  • You can copy the script into a Visual Basic script (.vbs) file and run it by using CScript as follows:

    [drive]:cscriptfilename.vbs

For a description of the Transaction Data Import DTS task, see Commerce Server DTS Tasks.

'******************************************************************
' Transaction Data Import DTS Task
' This script creates a DTS package and runs it.
' Note: This DTS task cannot be run on a computer that has only the 
' Commerce Server 2002 Business Analytics stand-alone feature 
' installed. This DTS task gets the required connection strings for 
' both the Commerce Server database and the Data Warehouse from the 
' Admin object, based on the site name set in the script.
'******************************************************************
Dim oPackage 
Dim oTask 
Dim oStep 
Dim oProps 
Dim oTaskProps 

Dim iStatus 
Dim i
Dim DTSStepExecResult_Failure

DTSStepExecResult_Failure  = 1

'On Error GoTo PackageError:


set oPackage = CreateOBject("DTS.Package")

'******************************************************************
' Define package properties.
'******************************************************************
oPackage.Name = "Transaction Data Import DTS Task"
oPackage.Description = "Defines and imports transaction data."

'******************************************************************
' Create a task.
'******************************************************************
Set oTask = oPackage.Tasks.New("Commerce.DTSTransactionImport")
oTask.Name = "Task1"
oTask.Description = "Creates a task for TransactionDataImport DTS"
Set oTaskProps = oTask.Properties

' Set Transaction Data Import DTS properties:
' Incremental import = 100
' Full import= 0
oTaskProps("ProcessingType").value = 0

' Set 0 for the site-level import or 1 for the Data Warehouse level import
oTaskProps("SourceType").value = 1

' Make sure that SourceName is set to the correct Web site or Data Warehouse
' name.
oTaskProps("SourceName").value = "Data Warehouse 1"

' Number of connection retries and the delay between each retry in 
' seconds in case of a connection failure.
oTaskProps("NumRetries").value = 10
oTaskProps("RetryInterval").value = 20
oTaskProps("QueryInterval").value = 25

oPackage.Tasks.Add oTask
'******************************************************************
' Create a step.
'******************************************************************
Set oStep = oPackage.Steps.New
oStep.Name = "Step1"
oStep.TaskName = "Task1"

' For custom tasks written in Visual Basic, 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

See Also

Other Resources

DTSTransactionImport Object

Commerce Server DTS Tasks

Scripting DTS Tasks