SSIS包将在用vb编写的脚本任务中的断点处停止,但不会在c#中对应的一个断点处停止

时间:2020-05-13 15:16:48

标签: ssis

我有一个带有现有vb脚本任务的ssis软件包,用于发送电子邮件。

我正在用c#重写它。

我可以看到,vb版本有效,c#版本无效,但也没有失败或错误。

如果我在两者中都设置了断点,则在运行程序包进行调试时,它会破坏vb脚本,但不会破坏c#脚本。

我在下面都包含了代码。

它们非常相似,所以我想知道是否有一个任务设置可以控制我忽略的任务。

预先感谢

vb脚本如下。

...

Public Sub Main()

    Dim htmlMessageFrom As String = Dts.Variables("SSISErrorEmailFrom").Value.ToString
    Dim htmlMessageTo As String = Dts.Variables("SSISErrorEmailTo").Value.ToString
    Dim htmlMessageSubject As String = Dts.Variables("SSISErrorEmailSubject").Value.ToString
    Dim htmlMessageBody As String = Dts.Variables("SSISErrorEmailBody").Value.ToString
    Dim SSISErrorTable As String = Dts.Variables("SSISErrorTable").Value.ToString
    Dim smtpConnectionString As String = DirectCast(Dts.Connections("SMTP Connection").AcquireConnection(Dts.Transaction), String)
    Dim smtpServer As String = "smtprelay.white01.babcockgroup.co.uk"

    htmlMessageBody = htmlMessageBody.Replace("###subject###", htmlMessageSubject)
    htmlMessageBody = htmlMessageBody.Replace("###SSISErrorTable###", SSISErrorTable)

    SendMailMessage(
  htmlMessageFrom, htmlMessageTo,
  htmlMessageSubject, htmlMessageBody,
  True, smtpServer)

    Dts.TaskResult = ScriptResults.Success

End Sub

Private Sub SendMailMessage(
ByVal From As String, ByVal SendTo As String,
ByVal Subject As String, ByVal Body As String,
ByVal IsBodyHtml As Boolean, ByVal Server As String)

    Dim htmlMessage As MailMessage
    Dim mySmtpClient As SmtpClient

    htmlMessage = New MailMessage(
From, SendTo, Subject, Body)
    htmlMessage.IsBodyHtml = IsBodyHtml

    mySmtpClient = New SmtpClient(Server)
    mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
    mySmtpClient.Send(htmlMessage)

End Sub

...

c#的密码如下

...

    public void Main()
    {
        sendEmail();
    }

    private void sendEmail()
    {

        var noBytes = new byte[0];
        // TODO: Add your code here
        try
        {
            string SSISErrorEmailTo = Dts.Variables["SSISErrorEmailTo"].Value.ToString();
            string SSISErrorEmailFrom = Dts.Variables["SSISErrorEmailFrom"].Value.ToString();
            string SSISErrorEmailSubject = Dts.Variables["SSISErrorSubject"].Value.ToString();
            string SSISErrorEmailBody = Dts.Variables["SSISErrorEmailBody"].Value.ToString();
            string SSISErrorTable = Dts.Variables["SSISErrorTable"].Value.ToString();

            SSISErrorEmailBody.Replace("###subject###", SSISErrorEmailSubject);
            SSISErrorEmailBody.Replace("###SSISErrorTable###", SSISErrorTable);

            string SmtpServer = "smtprelay.white01.babcockgroup.co.uk"; 

            MailMessage msg = new MailMessage(SSISErrorEmailFrom, SSISErrorEmailTo, SSISErrorEmailSubject, SSISErrorEmailBody);
            msg.IsBodyHtml = true;

            SmtpClient smtpClient = new SmtpClient(SmtpServer);
            smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
            smtpClient.Send(msg);

            Dts.TaskResult = (int)ScriptResults.Success;
            Dts.Log("OnError script completed", -1, noBytes);
        }
        catch (Exception e)
        {
            Dts.TaskResult = (int)ScriptResults.Failure;
            Dts.Log(e.InnerException.Message, -1, noBytes);
        }
    }

...

0 个答案:

没有答案