I have a console application in c# that downloads files from a website.
I have created a variable named Filecount
that counts the number of files downloaded in that instance.
In SSIS, I have set the StandardOutputVariable in the Execute process task configuration as User::FileCount
that should pass through the number of files that it has downloaded.
I want to create an SQL task that will truncate the table if the file count is greater than 0
.
However, when I try to evaluate my expression, it always comes back as true however, this should not occur as no counts have been passed through yet meaning it should be evaluated as false.
Can someone explain if I have either written the expression wrong or set the variable incorrectly?
int fileCount = 0;
using (var client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
var response = await client.GetAsync(siteUrl + "/_api/Web/GetFolderByServerRelativeUrl('XXX')/Files");
response.EnsureSuccessStatusCode();
json = await response.Content.ReadAsStringAsync();
Root deserializedResults = JsonConvert.DeserializeObject<Root>(json);
foreach (Result result in deserializedResults.d.results)
{
if (result.TimeCreated > DateTime.Today.AddDays(-7))
{
DownloadFileViaRestAPI(siteUrl, credentials, "XXX", result.Name, "XXX");
fileCount++;
}
}
}
Console.Write(fileCount);
SSIS Execute Process Task;
StandardOutVariable = User::FileCount
SQL Task expression;
Property: Disable
Expression: Len(Trim(@[User::FileCount])) > 0 ? False : True