Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


JohnMarks
2013-03-15T03:39:38Z
I am looking to see if Visual cron might work for a automated task

Every day at 4am I need to download a report file from a remote web server for the previous day report.

eg if today is the 27th I would need to download yesterdays file from the server by calling this url

websitedotcom/Download.aspx?reportDate=2013-02-26


When I hit this url a CSV file is pushed to the browser and you are asked to save the file.


Could visualcron be setup to download these daily files and save them to a local folder
Sponsor
Forum information
Support
2013-03-15T08:29:41Z
Yes, you can easily do that with the help of Variables. For example, you could use this Variable:

websitedotcom/Download.aspx?reportDate={DATENOWADD(Days|-1|yyyy-MM-dd)}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
JohnMarks
2013-03-19T01:23:38Z
Thank you support that was easy and now the file is downloaded and saved as a csv file, As the file that is downloaded is a CSV file I was able to create another task that inserted it directly in to a database (very cool)

If for some reason there is a problem download loading the file a normal html page is show on the webserver. The problem I can see happening is if this happens the task will download that file and then try and insert that html file in to the database.

Is there a easy way to validate that the file downloaded is in fact a CSV file and not a html file with a csv extension ?
Support
2013-03-19T08:26:14Z
Quote:

The problem I can see happening is if this happens the task will download that file and then try and insert that html file in to the database.



Why do you think the above will happen? I think it is best to prepare the script so that it returns a http error code if something is missing or goes wrong. If you do this the Task will also return an error and you can control flow based on that.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
JohnMarks
2013-03-20T00:19:59Z
Support I don't understand your reply

The task will download what ever the website shows if it shows a csv file it will download that if it shows a http error message it will download that.

The next task will try and insert the downloaded file in to the database so I need to check that I do in fact have a valid CSV file

I used this powershell script to grab the header line of the downloaded file

Quote:


Get-Content "C:\Downloads\CSV\{DATENOWADD(Days|-1|yyyy-MM-dd)}" -totalcount 1



This then puts the first line in to the output of that task could I then check the output is create and has the 4 headers that I am expecting ?
Support
2013-03-20T08:35:11Z
Maybe I am not understanding what your script does. You wrote that:

Quote:

When I hit this url a CSV file is pushed to the browser and you are asked to save the file.



Then I was asking - why would it be something else than a CSV file - why do you need to check that?


Also, you mentioned Get-Content method but as far as I know it only reads the file and has nothing to do with headers.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
JohnMarks
2013-03-20T22:57:13Z
The url that I am calling will generate a CSV file I download it and save it with a CSV extension.

If for some reason I call the url and there is a problem eg a 404 error on in this case the 3rd party web site will show a web page that says error no records found the task will still download this file.

The next task is a SQL insert if I download a html file and try and insert this it could cause problems.


That is why I tried to use a powershell script that would read the first line of the csv file and list the headers in the CSV I then wanted to check them and see if they where all there and valid if so I then wanted to try and insert them.
Support
2013-03-21T08:08:35Z
Great, if the URL returns 404 the VisualCron HTTP Task will intercept it and the Task will fail. This means that the next Task will not run. In combination with an Email Notification for example you have the option to be notified when this happens.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top