Script Task

  • Hi there,

    We get download link from a client that spits an excel file. Currently, we have a SSIS package set up to get the file every day. This link has a job name which is used to get the file. The problem is the link with this job is expired after 30 days - so if the job runs with this job name, nothing results out. The jobname is appended to the end of the url as a parameter.

    Now, this can be fixed which currently we do this manually. There is a request url where you append the same jobname at the end. All this does is it invokes the job and make this active. So, when you now use the download url, the file comes through. We want to include this request url in the package so everytime the download url is called, this request url is process which invokes the jobname and we don't have to do this manually after 30 days.

    There is a script task set up in the package that processes the download url and the file is downloaded. I am not sure where and how to include the request url so it gets invoked before the download url. Here is what I have on my script task. Please let me know if you guys need more clarification.

    Public Sub Main()

    Dim wr As HttpWebRequest = CType(WebRequest.Create("http://client.com/eport/download/?login_id=userid&api_key=apikey&job_name=SAREP"), HttpWebRequest)

    Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)

    Dim str As Stream = ws.GetResponseStream()

    Dim inBuf(100000) As Byte

    Dim bytesToRead As Integer = CInt(inBuf.Length)

    Dim bytesRead As Integer = 0

    While bytesToRead > 0

    Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)

    If n = 0 Then

    Exit While

    End If

    bytesRead += n

    bytesToRead -= n

    End While

    Dim filename As String = "\\fileserver\folder\folder1\clientfolder\download.xls"

    Dim fstr As New FileStream("\\fileserver\folder\folder1\clientfolder\download.xls", FileMode.OpenOrCreate, FileAccess.Write)

    fstr.Write(inBuf, 0, bytesRead)

    str.Close()

    fstr.Close()

    Dts.TaskResult = Dts.Results.Success

    End Sub

    So, the request url would be something like "http://client.com/eport/request/?login_id=userid&api_key=apikey&report_name=summaryreport&job_name=SAREP"

  • This is solved.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply