Aracılığıyla paylaş


Komut dosyası görev olaylarını tetiklemeye

Olayları rapor hataları, uyarıları ve görev ilerleme durumunu veya içeren paket durumu gibi diğer bilgiler için bir yol sağlar.Paket, olay bildirimleri yönetmek için olay işleyicileri sağlar.Komut dosyası görev yöntemlerini çağırarak olayları yükseltebilirsiniz Events özellik Dts nesne.Hakkında daha fazla bilgi için Integration Services paketleri tanıtıcı olayları görmek Tümleştirme Hizmetleri olay işleyicileri.

Paket içinde etkin bir günlük sağlayıcı için olayları günlüğe kaydedilebilir.Günlüğü sağlayıcılarını olaylarla ilgili bilgileri bir veri deposunda saklar.Komut dosyası görev de kullanabilirsiniz Log yöntem bir olayý çaðýrmak olmadan bir günlük sağlayıcı bilgileri günlüğe kaydetmek için.Nasıl kullanılacağı hakkında daha fazla bilgi için Log yöntem, bkz: Oturum açma komut dosyası görev.

Bir olay başlatmak için komut dosyası görev çağıran tarafından gösterilen yöntemlerden birini Events özellik.Aşağıdaki tablo tarafından kullanıma sunulan yöntemleri listeler Events özellik.

Olay

Açıklama

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireCustomEvent(System.String,System.String,System.Object[]@,System.String,System.Boolean@) ]

Kullanıcı tanımlı özel bir olay olarak harekete geçiren paket.

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireError(System.Int32,System.String,System.String,System.String,System.Int32) ]

Bir hata koşulu paket bildirir.

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireInformation(System.Int32,System.String,System.String,System.String,System.Int32,System.Boolean@) ]

Kullanıcıya bilgi sağlar.

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireProgress(System.String,System.Int32,System.Int32,System.Int32,System.String,System.Boolean@) ]

Görev ilerleme paket bildirir.

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireQueryCancel ]

paket görevi kapatmak için gerekli olup olmadığını gösteren bir değeri döndürür kapalı zamanından önce.

[ M:Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents.FireWarning(System.Int32,System.String,System.String,System.String,System.Int32) ]

Görev kullanıcı bildirim garanti eder, ancak bir hata koşulu olmayan bir durumda paket bildirir.

Örnek olaylar

Aşağıdaki örnek komut dosyası görev içinde olayları nasıl göstermektedir.Bu örnek, yerel bir Windows API işlev Internet bağlantısı kullanılabilir olup olmadığını belirlemek için kullanır.Bir bağlantı varsa, bir hata yükseltir.Büyük olasılıkla geçici bir modem bağlantısı kullanılıyorsa, örnek bir uyarı yükseltir.Aksi takdirde, Internet bağlantısı algılandı bir bilgilendirme iletisi döndürür.

Private Declare Function InternetGetConnectedState Lib "wininet" _
    (ByRef dwFlags As Long, ByVal dwReserved As Long) As Long

Private Enum ConnectedStates
    LAN = &H2
    Modem = &H1
    Proxy = &H4
    Offline = &H20
    Configured = &H40
    RasInstalled = &H10
End Enum

Public Sub Main()

    Dim dwFlags As Long
    Dim connectedState As Long
    Dim fireAgain as Boolean

    connectedState = InternetGetConnectedState(dwFlags, 0)

    If connectedState <> 0 Then
        If (dwFlags And ConnectedStates.Modem) = ConnectedStates.Modem Then
            Dts.Events.FireWarning(0, "Script Task Example", _
                "Volatile Internet connection detected.", String.Empty, 0)
        Else
            Dts.Events.FireInformation(0, "Script Task Example", _
                "Internet connection detected.", String.Empty, 0, fireAgain)
        End If
    Else
        ' If not connected to the Internet, raise an error.
        Dts.Events.FireError(0, "Script Task Example", _
            "Internet connection not available.", String.Empty, 0)
    End If

    Dts.TaskResult = ScriptResults.Success

End Sub
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class ScriptMain
{


[DllImport("wininet")]
        private extern static long InternetGetConnectedState(ref long dwFlags, long dwReserved);

        private enum ConnectedStates
        {
            LAN = 0x2,
            Modem = 0x1,
            Proxy = 0x4,
            Offline = 0x20,
            Configured = 0x40,
            RasInstalled = 0x10
        };

        public void Main()
        {
            //
            long dwFlags = 0;
            long connectedState;
            bool fireAgain = true;
            int state;

            connectedState = InternetGetConnectedState(ref dwFlags, 0);
            state = (int)ConnectedStates.Modem;
            if (connectedState != 0)
            {
                if ((dwFlags & state) == state)
                {
                    Dts.Events.FireWarning(0, "Script Task Example", "Volatile Internet connection detected.", String.Empty, 0);
                }
                else
                {
                    Dts.Events.FireInformation(0, "Script Task Example", "Internet connection detected.", String.Empty, 0, ref fireAgain);
                }
            }
            else
            {
                // If not connected to the Internet, raise an error.
                Dts.Events.FireError(0, "Script Task Example", "Internet connection not available.", String.Empty, 0);
            }

            Dts.TaskResult = (int)ScriptResults.Success;

        }
Integration Services simgesi (küçük)Integration Services ile güncel kalın

En son karşıdan yüklemeler, makaleler, örnekler ve seçilen topluluk çözümleri yanı sıra Microsoft videolar için ziyaret Integration Services sayfa msdn veya TechNet:

Bu güncelleştirmelerle ilgili otomatik bildirim almak için, sayfadaki RSS akışlarına abone olun.