使用SSIS中的脚本任务的Web身份验证问题

时间:2014-11-28 15:37:59

标签: c# vb.net web ssis ssis-2012

您好我正在使用脚本任务从网站下载文件,但我似乎遇到了问题。我无法通过要求输入用户名和密码的网页。在Connection Manager Editor中,我列出了URL地址,用户名和密码以及测试连接成功。所以我不确定问题是什么。任何帮助表示赞赏。

namespace ST_054ab1f1837a4b9d8f167cfd91109f9b
{
/// <summary>
/// ScriptMain is the entry point class of the script.  Do not change the name, attributes,
/// or parent of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
    public void Main()
    {
        try
        {
            // Logging start of download
            bool fireAgain = true;
            Dts.Events.FireInformation(0, "Download File", "Start downloading " + Dts.Connections["HTTP"].ConnectionString, string.Empty, 0, ref fireAgain);

            // Get your newly added HTTP Connection Manager
            Object mySSISConnection = Dts.Connections["HTTP"].AcquireConnection(null);

            // Create a new connection
            HttpClientConnection myConnection = new HttpClientConnection(mySSISConnection);

            // Download file and use the Flat File Connectionstring (D:\SourceFiles\Products.csv)
            // to save the file (and replace the existing file)
            myConnection.DownloadFile(Dts.Connections["FileName"].ConnectionString, true);

            // Logging end of download
            Dts.Events.FireInformation(0, "Download File", "Finished downloading " + Dts.Connections["FileName"].ConnectionString, string.Empty, 0, ref fireAgain);

            // Quit Script Task succesful
            Dts.TaskResult = (int)ScriptResults.Success;
        }
        catch (Exception ex)
        {
            // Logging why download failed
            Dts.Events.FireError(0, "Download File", "Download failed: " + ex.Message, string.Empty, 0);

            // Quit Script Task unsuccesful
            Dts.TaskResult = (int)ScriptResults.Failure;
        }
    }
}

}

0 个答案:

没有答案