How to implement automatic asynchronous data exchange in the company
Submitted on June 24, 2002
The Internet Components - Clever Internet Library contains a set of components designed for asynchronous operations with Internet resources.
This functionality can be used not only for checking news or updates on a developer's site but for more complicated, non-trivial tasks. Let us explore the following situation. There is a company that sells goods. All business information of this company is stored in the database serviced by a server application. There are a lot of distant branches and independent agents that use client applications.
It is clear that one of the main tasks is data replication between the main office and its branches. So, the server application produces special script files containing replicated data. The challenge is to automate the process of delivering these script files to all the clients.
The TclNewsChecker can help you to solve this problem. Let us consider that the server application automatically creates replication files on a certain schedule and places them into folder that can be accessed via the Internet. At the same time for each client we'll use the TclNewsChecker component. The client side should remember the last replicates script. We'll put this information into the file name to simplify our task: script1.dat, script2.dat... The last figure in the file name represents the number of the last replicated file. This value can be stored in the Registry, for instance.
Now we should add the event handler of the main form display - OnShow. The initialization of the downloading process (StartCheckNews) should be implemented in it.
You also may add the OnDataItemProceed event handler and implement progress display or the asynchronous operation mode in it.
It is necessary to implement the increment and saving of the next script number (FscriptNo) and response on the downloaded resource in the OnNewsExist event handler:
You also can enhance the functionality and check presence of the next script file in the Internet. It can be necessary if a client hasn't downloaded scripts from the server for a long time:
These few steps allow you to implement automatic asynchronous data exchange in the company.
Clever Components Support Team.