Jump to content
rony2006

Inetget timeout problem

Recommended Posts

rony2006

Hello,

I have a problem using InetGet for downloading a report from a site. The problem is that report is generated each time based on url parameters (startdate and endtime).

Here is the url:

http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_RTPD_LMP&startdatetime=20171024T15:00-
0000&enddatetime=20171025T00:00-0000&version=1&market_run_id=RTPD&node=TJI-230_2_N101

 

Here is the code that I use:

; Save the downloaded file to the temporary folder.
    Local  $sFilePath = @ScriptDir &  "/raport1.zip"


    $StartDate = StringReplace(_NowCalcDate(),"/", "")

;Msgbox(0, "StartDate", $StartDate)


Local $sNewDate = _DateAdd('d', 1, _NowCalcDate())


$EndDate = StringReplace($sNewDate,"/", "")

;Msgbox(0, "StartDate", $EndDate)

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_RTPD_LMP&startdatetime=" & $StartDate &"T15:00-0000&enddatetime=" & $EndDate &"T00:00-0000&version=1&market_run_id=RTPD&node=TJI-230_2_N101", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)



    Do
        Sleep(1000)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

msgbox(0, "", "stop")
    sleep(10000)

 

The problem is that sometimes the generation of report is taking about 40-60 seconds and my script doesn't care about   :

Do
        Sleep(1000)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

 

 

How I can solve this problem please?

Share this post


Link to post
Share on other sites
BetaLeaf

Can you clarify the issue? I don't understand what you are wanting. What are you expecting it to do and what is it actually doing instead. 


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites
rony2006

I expect that I get a .zip file downloaded in script dir using the above code.

 

caiso.com can generate any report, in a .zip file based on the values that url contains.

The problem is that sometimes after you manually access the url, the downloading process doesn't start quick. Usually it takes 20-30 seconds until download starts.

 

My script is working but some of the time, it didn't waits until caiso.com generates the report. So my code jumps directly at msgbox(0, "", "stop") and I don't get any file downloaded in my script dir.

 

 

Share this post


Link to post
Share on other sites
BetaLeaf

Got it. Away from PC atm, when i get back, ill post some example code.


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.