Compartilhar via


Classe ScriptObjectModel

Gives the developer of the Script task programmatic access to objects defined in the package through the global Dts object. The Dts object is an instance of the ScriptObjectModel class.

Hierarquia de herança

System. . :: . .Object
  Microsoft.SqlServer.Dts.Tasks.ScriptTask..::..ScriptObjectModel

Namespace:  Microsoft.SqlServer.Dts.Tasks.ScriptTask
Assembly:  Microsoft.SqlServer.ScriptTask (em Microsoft.SqlServer.ScriptTask.dll)

Sintaxe

'Declaração
Public Class ScriptObjectModel
'Uso
Dim instance As ScriptObjectModel
public class ScriptObjectModel
public ref class ScriptObjectModel
type ScriptObjectModel =  class end
public class ScriptObjectModel

O tipo ScriptObjectModel expõe os membros a seguir.

Propriedades

  Nome Descrição
Propriedade pública Connections Returns the Connections collection of existing connections defined in the package that contains the Script task.
Propriedade pública Events Returns the IDTSComponentEvents collection of existing events defined in the package that contains the Script task.
Propriedade pública ExecutionValue Gets or sets a user-defined object that provides additional information about the results of task execution.
Propriedade pública TaskResult Returns the DTSExecResult of the Script task.
Propriedade pública Transaction Returns the transaction associated with the container of the Script task.
Propriedade pública VariableDispenser Returns the VariableDispenser that can be used within the Script task to work with existing variables.
Propriedade pública Variables Returns the Variables collection of existing variables defined in the package that contains the Script task.

Início

Métodos

  Nome Descrição
Método público Equals (Herdado de Object.)
Método protegido Finalize (Herdado de Object.)
Método público GetHashCode (Herdado de Object.)
Método público GetType (Herdado de Object.)
Método público Log Logs an entry to all enabled log providers.
Método protegido MemberwiseClone (Herdado de Object.)
Método público ToString (Herdado de Object.)

Início

Comentários

Within the Microsoft Visual Studio 2008 Tools for Applications (VSTA) scripting environment, the Script task provides the global Dts object, which gives the developer programmatic access to objects defined elsewhere in the package, such as connections, variables, and events, through the properties and methods of the ScriptObjectModel class. The Dts object is an instance of the ScriptObjectModel class.

Exemplos

The following sample of code for use inside a Script task demonstrates the use of the Variables, Events, and TaskResult properties. For more information, see Consultando o Active Directory com a tarefa Script.

Public Sub Main()

    Dim directory As DirectoryServices.DirectorySearcher
    Dim result As DirectoryServices.SearchResult
    Dim email As String

    email = Dts.Variables("email").Value.ToString

    Try
        directory = New _
            DirectoryServices.DirectorySearcher("(mail=" & email & ")")
        result = directory.FindOne
        Dts.Variables("name").Value = _
            result.Properties("displayname").ToString
        Dts.Variables("title").Value = _
            result.Properties("title").ToString
        Dts.TaskResult = ScriptResults.Success
    Catch ex As Exception
        Dts.Events.FireError(0, _
            "Script Task Example", _
            ex.Message & ControlChars.CrLf & ex.StackTrace, _
            String.Empty, 0)
        Dts.TaskResult = ScriptResults.Failure
    End Try

End Sub

Segurança de thread

Qualquer membro público static (Shared no Visual Basic) desse tipo é seguro para threads. Não há garantia de que qualquer membro de instância seja seguro para threads.