A simple, real-world Windows service: Implement local data upload to server

Source: Internet
Author: User

Function: Implement local data upload to remote server


Operation implementation:

1, send the local ID to the remote server for authentication, verify success can get to the local need to send the ID of the data, for example:

Local send Identity id:key123, the authentication succeeds, the remote server matches to the data entry that the ID contains, for example returns 7 Exdid.

2, after receiving 7 Exdid, the local need to transfer data from many data in the database of the 7 Exdid to the remote server, the remote server will receive the data saved, updated to the remote database.


Note the problem:

1, in order to ensure the bandwidth load easily, you can not frequently transfer data to the remote server.

2, considering the network condition, the data between the network can not be lost, need a complete and a non-leaking transmission to the remote server.

3. Do not transfer locally-updated data to a remote server with an update Time field in the local data.

4, can only query the database records, no other action.


Workaround:

1, set the timer, for example, every 5s to make a connection.

2, the first data sent to a TXT file, containing the content has exdid, update time.

3, each time from the database to obtain data, and the TXT file to compare the data, if the same Exdid data update time is the same, then this data is deleted, the remaining data is updated to TXT file and transferred to the remote server.

4, after the network, save all the records in the database to a local file, the first time out of the data to create an additional TXT file. Each time you take out the data in the save should be a tree, in the format of the first year to build folders, the year folder to establish the month folder, the month folder to establish the daily file for the month as a file for storage from the database is removed but not sent to the remote server data, and in order to reduce the size of the file saved data, Before each save with the data in the TXT file comparison, if the same Exdid data update time is the same, then this data is deleted, the remaining data is updated to TXT file and saved to the Japanese file. When the network is reconnected, the data from the local file is sent to the remote server.

A simple, real-world Windows service: Implement local data upload to server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.