Jaa


Scripting the Data Deletion DTS Task

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

The following script creates and runs the Data Deletion 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 Data Deletion DTS task, see Commerce Server DTS Tasks.

'******************************************************************
' Data Deletion DTS Task
' This script creates a DTS package and runs it.
'******************************************************************
set oPackage = WScript.CreateOBject("DTS.Package")

'******************************************************************
' Define package properties.
'******************************************************************
oPackage.Name = "Data Deletion DTS Task"
oPackage.Description = "Deletes detailed log file data and summarized data for a site in the Data Warehouse or from the entire Data Warehouse."

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

'*******************************************************************
' Set Data Deletion DTS task properties to remove all the logs for the site.
'*******************************************************************
oTaskProps("SourceType").value= 0
oTaskProps("SourceName").value="BlankSite"
oTaskProps("DeleteType").value= 1
oTaskProps("WebLogDeleteType").value= 1
oTaskProps("Interval").value=0
oTaskProps("DeleteLevel").value=1
oTaskProps("Count").value=0

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
MsgBox oPackage.Description + " Execute is called"
' ******************************************************************
' 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

You can replace the code between the comments "Set DataDeletion DTS task properties to remove all the logs for the site" and "Create a step" with the following code to remove only the specified log files.

oTaskProps("SourceType").value= 0
oTaskProps("SourceName").value="BlankSite"
oTaskProps("DeleteType").value= 1
oTaskProps("WebLogDeleteType").value= 1
' The ListofLogs property must be set to valid task IDs in the 
' Task History table.
oTaskProps("ListofLogs").value= "1058,1059"
oPackage.Tasks.Add oTask

See Also

Other Resources

DTSDeleteImport Object

Commerce Server DTS Tasks

Scripting DTS Tasks