SSIS - SQL Server Integration Services - Notifyicon en script task

 
Vista:

Notifyicon en script task

Publicado por Rj45 (1 intervención) el 17/09/2012 23:59:18
Buenas a tod@s,

Tengo un problema al tratar de mostrar un mensaje en un NotifyIcon a traves de un script task de SISS 2008, en el cual puse el siguiente codigo :

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic 2008.
' The ScriptMain is the entry point class of the script.

Imports System
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Data
Imports System.Math

Imports System.IO
Imports System.Windows.Forms
Imports System.Drawing
Imports System.EventArgs
Imports System.Object
Imports System.Reflection
Imports ST_6e1db1aeb859412887e4b7e71aac20bf.vbproj


<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase


Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum


' The execution engine calls this method when the task executes.
' To access the object model, use the Dts property. Connections, variables, events,
' and logging features are available as members of the Dts property as shown in the following examples.
'
' To reference a variable, call Dts.Variables("MyCaseSensitiveVariableName").Value
' To post a log entry, call Dts.Log("This is my log text", 999, Nothing)
' To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, True)
'
' To use the connections collection use something like the following:
' ConnectionManager cm = Dts.Connections.Add("OLEDB")
' cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"
'
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Help, press F1.

'Declaration
Dim NotifyIcon1 As NotifyIcon
Dim e As System.EventArgs
Dim sender As System.Object
Public Sub Main()
' Add your code here
'
'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning

NotifyIcon1.Icon = New Icon("G:\Windows.ico")
NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
NotifyIcon1.BalloonTipTitle = "Titulo"
NotifyIcon1.BalloonTipText = "texto"
NotifyIcon1.ShowBalloonTip(10000)

Dts.TaskResult = ScriptResults.Success
End Sub


Pero no me muestra el mensaje como si no referenciara bien el drawing
¿Alguien sabe que puede estar ocurriendo?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alejandro

Mostrar mensaje en NotifyIcon

Publicado por Alejandro (60 intervenciones) el 23/02/2024 21:27:53
Rj45, el problema que estás experimentando puede deberse a la falta de inicialización del objeto `NotifyIcon1` en tu script. Asegúrate de crear una instancia del objeto antes de intentar acceder a sus propiedades. Además, ten en cuenta que la ejecución de scripts en SSIS puede tener algunas limitaciones en cuanto a la interfaz gráfica.

Modifica tu código de la siguiente manera:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Imports System
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Windows.Forms
Imports System.Drawing
 
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
 
    Enum ScriptResults
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
 
    Public Sub Main()
        Try
            Dim NotifyIcon1 As New NotifyIcon() ' Crea una instancia del objeto NotifyIcon '
 
            NotifyIcon1.Icon = New Icon("G:\Windows.ico")
            NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
            NotifyIcon1.BalloonTipTitle = "Titulo"
            NotifyIcon1.BalloonTipText = "texto"
            NotifyIcon1.Visible = True ' Asegúrate de que el icono sea visible '
 
            NotifyIcon1.ShowBalloonTip(10000)
            Dts.TaskResult = ScriptResults.Success
        Catch ex As Exception
            Dts.Events.FireError(0, "Error en Script Task", ex.Message, String.Empty, 0)
            Dts.TaskResult = ScriptResults.Failure
        End Try
    End Sub
End Class

En este código, he agregado la línea `Dim NotifyIcon1 As New NotifyIcon()` para crear una instancia del objeto `NotifyIcon` antes de intentar acceder a sus propiedades. Además, he agregado `NotifyIcon1.Visible = True` para asegurarme de que el icono sea visible.

Es importante manejar las excepciones para obtener más información sobre cualquier error que pueda ocurrir durante la ejecución del script. Puedes revisar los mensajes de error en el registro de eventos de SSIS para obtener detalles adicionales.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar