July 7, 2016 at 8:55 am
I have a c# script task that works fine in BIDs, but is not completing when attempting to use the SSIS package on the server. it connects to a URL, reads the file it recieves in, then writes the file to a CSV.
When running from integration services on the server, it downloads the data to the CSV, but does not seem to actually finish
In the Messages report in SSMS, I only haveup to On Pre-execute message for the script task. Is there something I failed to do in my c# script task to tell it to finish?
Below is the code that I am running (slightly obfuscated to hide client names) .
public void Main()
{
// TODO: Add your code here
Dts.Variables["User::datadlURL"].Value.ToString();
string sURL;
sURL = Dts.Variables["User::datadlURL"].Value.ToString();
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
string derp = objReader.ReadToEnd();
string sLine = "";
int i = 0;
while (sLine != null)
{
i++;
sLine = objReader.ReadLine();
if (sLine != null)
Console.WriteLine("{0}:{1}", i, sLine);
}
StreamWriter wtr = new StreamWriter(@"\\uncpath\client\Staging_inbound\Omnique\clientdata_Raw.csv");
wtr.Write(derp /*+ "\r" /*That \r may or may not be necessary*/);
wtr.Close();
wtr.Dispose();
Console.ReadLine();
Dts.TaskResult = (int)ScriptResults.Success;
}
July 7, 2016 at 9:25 am
It's probably not finishing because there's a permissions issue somewhere (either in accessing the data or in writing the file).
You don't have to do anything special to make it finish just because it's running as a job rather than interactively (other than allowing for the fact that the user context is different and that there can be no interactive I/O).
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 7, 2016 at 10:00 am
The odd part is that it is writing to the CSV file successfully. I ended up copying the CSV file generated when running it from the server and the CSV file created when running from BIDs, and they are identical, which makes me think it wouldn't be a permissions issue. The script task is just not getting to on post execute.
July 7, 2016 at 11:14 am
What is the purpose of console.ReadLine ()? That looks interactive to me.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 7, 2016 at 2:03 pm
The console readline was the problem. Honestly can't remember why that was in there
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply