Summary of the invention
Technical problem to be solved by this invention is to provide a kind of method that easy rapid batch being easy to realize downloads recording file.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: a kind of batch downloads the method for recording file, comprises the following steps:
Step 1, loads ActiveX control in Web page;
Step 2, in the self defining programm of ActiveX control, creates browser and is connected with the FTP of file server;
Step 3, is connected by described FTP, is downloaded by the recording file of file server and is stored into client.
The invention has the beneficial effects as follows: in B/S framework, load ActiveX control, control method is directly called in Javascript, send some call parameters in control method, recording file is downloaded by the direct access file server of FTP according to condition in control, path is client-> file server-> client, realize recording file batch fast to download, also mitigate the pressure of Web server.
On the basis of technique scheme, the present invention can also do following improvement:
Further, before the described step 2 of execution, user first filters out in Web page the information that will download in batches.The beneficial effect of above-mentioned further scheme is adopted to be search the data needing to download; In addition, unnecessary download can also be reduced.
Further, described step 2 specifically comprises the steps:
Step 21, in the self defining programm of ActiveX control, starts event handling thread;
Step 22, in the self defining programm of ActiveX control, judges current whether existing downloading task, if current existing downloading task, then performs step 23, do not have downloading task if current, then perform step 24;
Step 23, sends the information of existing downloading task, terminates to described event handling thread;
Step 24, creates browser and is connected with the FTP of file server;
Step 25, judges that whether described FTP connects successful, if described FTP connection failure, then performs step 26; If described FTP successful connection, then perform step 3;
Step 26, sends the information of connection failure to described event handling thread, terminate.
The beneficial effect of above-mentioned further scheme is adopted to be prevent multiple downloading task, influential system; Also send to by event handling thread process to the situation of FTP connection failure, perfect further system.
Further, described step 3 specifically comprises the steps:
Step 31, is connected by described FTP, is downloaded by the recording file of file server and is stored into client;
Whether step 32, judge that recording file is downloaded and complete, do not complete, then perform step 31 if recording file is downloaded; If recording file is downloaded and completed, then perform step 33;
Step 33, sends to described event handling thread and downloads completed information, terminate.
The beneficial effect of above-mentioned further scheme is adopted to be give event handling thread by produced problem in download, perfect further system.
Further, described event handling thread is used for the information received to send to Web page.
Adopt the beneficial effect of above-mentioned further scheme to be that current system conditions is informed user, determine next how to process, flexibility is good by user.
Embodiment
Be described principle of the present invention and feature below in conjunction with accompanying drawing, example, only for explaining the present invention, is not intended to limit scope of the present invention.
Technical scheme of the present invention is realized by JS, C++, and mainly can be divided into ActiveX control, Web page is shown, Web page calls ActiveX method by javascript, and ActiveX control is connected on file server by FTP and downloads.When file download to completing, ActiveX control can give Web return state event, and Web points out user's failed download or the information such as to complete after receiving this event.The inventive method is mainly: load ActiveX control in Web page; In the self defining programm of ActiveX control, create browser and be connected with the FTP of file server; Connected by described FTP, the recording file of file server is downloaded and is stored into client.
Fig. 1 is the flow chart of a kind of preferred implementation of the present invention, is described below to Fig. 1:
Step 1, loads ActiveX control in Web page.User can screen batch Download Info in advance, and then clicks batch download in Web page.
Step 2, in the self defining programm of ActiveX control, starts event handling thread;
Step 3, in the self defining programm of ActiveX control, judges current whether existing downloading task, if current existing downloading task, then performs step 4; There is no downloading task if current, then perform step 5;
Step 4, then send the information of existing downloading task, terminate to described event handling thread;
Step 5, creates browser and is connected with the FTP of file server;
Step 6, judges that whether described FTP connects successful, if described FTP connection failure, then performs step 7; If described FTP successful connection, then perform step 8;
Step 7, sends the information of connection failure to described event handling thread, terminate;
Step 8, is connected by described FTP, is downloaded by the recording file of file server and is stored into client;
Whether step 9, judge that recording file is downloaded and complete, do not complete, then perform step 8 if recording file is downloaded; If recording file is downloaded and completed, then perform step 10;
Step 10, sends to described event handling thread and downloads completed information, terminate.
Here, described event handling thread is used for the information received to send to Web page, and point out and processed by user, such degree of freedom is larger, certainly can also do custom programming and process various situation.
Particularly, step of the present invention comprises:
1, register in systems in which and load ActiveX control, loaded by label <OBJECT>, load successfully, adopt javascript to call ActiveXDownloadRecordPlayFile_AddRemoteDir method at batch download recording interface to realize, the method is self-defining program in ActiveX control;
2, then, in DownloadRecordPlayFile_AddRemoteDir method, start event thread, event to be thrown to foreground Web layer by message mechanism by ActiveX;
3, completed the selection of download file storing path in the method by BROWSEINFO simultaneously, OpenConnection realizes FTP and connects, CloseConnection realizes closing FTP and connects, when encountering problems, such as, when connection failure, can not download etc. judges, call corresponding event such as EventNOConnection () etc. and return to Web layer;
4, after Web layer receives, there is inside javascript following code: <script for=" Phone " event=" OnNOConnection (errorCode) " > carries out the process of event.When calling ActiveX control method, waiting prompting to be triggered to foreground Web layer by case mechanism for some mistakes called, after foreground Web layer receives event, adopting Web prompting to require to point out user.
From user perspective, enforcement of the present invention can respond the needs of user fast, and the use sense improving user is subject to.Download some files in enormous quantities, if too slow, the perception of user is very bad, and wait also may cause user to the query of systematic function for a long time; From enterprise's angle, ActiveX control package file is downloaded, only need to load ActiveX control in Web client, call ActiveX method, transmit information needed as requested, the download of file can be realized, in subsequent project, run into this demand, can directly call this method for packing, save human cost; From system itself, the realization of the method, significantly reduces the pressure of Web server, there is not the phenomenon that system deadlock is lived, improves systematic function.
Certainly, use the inventive method to be not limited to and download recording file use, other file that file server stores also can be downloaded by the inventive method.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.