PACKAGESTART and PACKAGEEND Not Logging
- From: A. Robinson <ARobinson@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 May 2007 12:53:00 -0700
I have a DTS package that performs some custom logging of othe rchild SSIS
packages. Everything is being logged as it should be, except for the
PACAKGESTART and PACKAGEEND events.
The pacakage executes a series of child packages, but even the main - or
parent - package doesn't log the PACKAGESTART and PACKAGEEND events.
I've attached the script for review:
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables,
events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to
indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
'
' Add your code here
'
Dim strPathPkg As String
Dim pkgChild As New Package
Dim app As New Application
Dim execCtrl As Executable ' An Executable is a Work Flow control in
DTS
' Load package
strPathPkg = Dts.Variables("PackageFolder").Value.ToString +
Dts.Variables("ChildPkgName").Value.ToString
app.PackagePassword =
Dts.Variables("PackagePassword").Value.ToString()
pkgChild = app.LoadPackage(strPathPkg, Nothing)
pkgChild.FailParentOnFailure = True
pkgChild.MaximumErrorCount = 1
' Set vairables
If Dts.Variables("parmInt1Name").Value.ToString <> "" Then
pkgChild.Variables(Dts.Variables("parmInt1Name").Value.ToString).Value =
Dts.Variables("parmInt1Val").Value
End If
If Dts.Variables("parmInt2Name").Value.ToString <> "" Then
pkgChild.Variables(Dts.Variables("parmInt2Name").Value.ToString).Value =
Dts.Variables("parmInt2Val").Value
End If
If Dts.Variables("parmSTR1Name").Value.ToString <> "" Then
pkgChild.Variables(Dts.Variables("parmSTR1Name").Value.ToString).Value =
Dts.Variables("parmSTR1Val").Value
End If
If Dts.Variables("parmSTR2Name").Value.ToString <> "" Then
pkgChild.Variables(Dts.Variables("parmSTR2Name").Value.ToString).Value =
Dts.Variables("parmSTR2Val").Value
End If
' We do not use Serializable, because it is too system intensive.
If the developer has left
' the default options, change them
If pkgChild.IsolationLevel = IsolationLevel.Serializable Then
pkgChild.IsolationLevel = IsolationLevel.ReadUncommitted
pkgChild.TransactionOption = DTSTransactionOption.Supported
End If
' Set Checkpoint to be used
'pkgChild.CheckpointFileName =
Dts.Variables("PackageFolder").Value.ToString + "CheckPoint\" +
Dts.Variables("ChildPkgName").Value.ToString.Replace(".dtsx", ".chkpoint")
'pkgChild.CheckpointUsage = DTSCheckpointUsage.IfExists
'pkgChild.SaveCheckpoints = True
pkgChild.CheckpointUsage = DTSCheckpointUsage.Never
pkgChild.SaveCheckpoints = False
' Initialize Logging
Dim logClass As LogClass = New LogClass()
pkgChild.LoggingMode = DTSLoggingMode.Enabled
pkgChild.LoggingOptions.EventFilterKind = DTSEventFilterKind.Inclusion
pkgChild.LoggingOptions.EventFilter = New String() {"PackageStart",
"PackageEnd", "OnProgress", "OnPreExecute", "OnPostExecute", "OnError",
"OnWarning", "OnInformation", "Diagnostic"}
' Set each task in package to Log
Dim evProvider As EventsProvider
For Each ex As Executable In pkgChild.Executables
evProvider = CType(ex, EventsProvider)
evProvider.LoggingMode = DTSLoggingMode.UseParentSetting
evProvider.FailPackageOnFailure = True ' For CheckPoint
' We do not use Serializable, because it is too system
intensive.
evProvider.IsolationLevel = IsolationLevel.ReadUncommitted
Next
' Run child package
logClass.StartLogging(Dts.Variables("ChildPkgName").Value.ToString, _
Convert.ToInt32(Dts.Variables("RunPackageID").Value), _
pkgChild.ID)
pkgChild.Execute(Nothing, Nothing, Nothing, logClass, Nothing)
If pkgChild.Errors.Count > 0 Then
logClass.EndLogging("Failure", pkgChild.ID)
Else
logClass.EndLogging("Success", pkgChild.ID)
End If
If pkgChild.Errors.Count > 0 Then
Dts.TaskResult = Dts.Results.Failure
Else
Dts.TaskResult = Dts.Results.Success
End If
End Sub
End Class
Public Sub Log(ByVal logEntryName As String, ByVal computerName As String,
ByVal operatorName As String, _
ByVal sourceName As String, ByVal sourceID As String, ByVal
executionID As String, ByVal messageText As String, _
ByVal startTime As Date, ByVal endTime As Date, ByVal dataCode
As Integer, ByRef dataBytes() As Byte) Implements IDTSLogging.Log
If String.Compare(_PackageName, sourceName, True) <> 0 Then
Select Case logEntryName
Case "PackageStart", "PackageEnd"
LogStep(logEntryName, sourceName, startTime,
messageText, sourceID, dataCode)
Case "PackageStart", "PackageEnd", "OnPreExecute",
"OnPostExecute", "OnProgress"
LogStep(logEntryName, sourceName, startTime,
messageText, sourceID, dataCode)
Case "OnError", "OnWarning", "Diagnostic"
LogStep(logEntryName, sourceName, startTime,
messageText, sourceID, dataCode)
Case "OnInformation"
If messageText.IndexOf(" wrote ",
StringComparison.CurrentCultureIgnoreCase) >= 0 _
AndAlso messageText.IndexOf(" rows",
StringComparison.CurrentCultureIgnoreCase) >= 0 Then
LogStep(logEntryName, sourceName, startTime,
messageText, sourceID, dataCode)
End If
End Select
End If
MyBase.Log(logEntryName, computerName, operatorName, sourceName,
sourceID, executionID, messageText, startTime, endTime, dataCode, dataBytes)
End Sub
Thanks in advance...
.
- Prev by Date: How to use file loop with a file and avoid file that currently has a lock on it
- Next by Date: Re: SS Import/Export
- Previous by thread: How to use file loop with a file and avoid file that currently has a lock on it
- Next by thread: Re: SS Import/Export
- Index(es):
Relevant Pages
|