Basic functionality of the FTPGateway class:
A. Maintain open connection to FTP host server
B. Poll frequently to build snapshot of host server's directory tree
C. Detect when folders or their contents have changed since last snapshot.
D. Update data model objects to reflect lastest changes
- HostAddress and Port of FTP host server must be-user configurable. Suggest using Applications Settings file or other .NET standard for configuration.
- Connect to designated FTP host and port. If connection fails, sleep 15 seconds and try again. Loop indefinitely when not connected.
- While connected, perform "snapshot processing" loop (see below) until connection is lost. If connection is lost, return to step A until connection is re-established.
B. Data Snapshots
- A snapshot captures the exact state of a directory tree on the remote FTP host at a moment in time, including it's folders and files, and all of their nested folders and files. Each item is associated with a name and a timestamp when it was last modified.
- After each snapshot is processed, the class will sleep for 5 seconds then request a new snapshot again. (It is expected that most server processing time will be spent constantly fetching and comparing unchanged snapshots. The goal is to respond ASAP when a change does occur. The cost of frequent polling is offset by the benefits of early change detection and response.)
C. Snapshot Processing
- Each data snapshot will be compared to the one that preceded it to determine if anything has changed. This includes:
addition of any sub-folder,
removal of any sub-folder,
addition of any file,
removal of any file, OR
change in modification timestamp for any folder or file.
If none of these data have changed, the snapshot is saved for next comparison and the class loops to sleep 5 seconds then take the next snapshot.
D. Updating the data model
- If any folder or file has been added, deleted, or re-ordered, or if any folder timestamp has changed, find and update the matching Rundown object in the data model
- If any file timestamp has changed, fetch the changed file via FTP, then find and update the matching Story object in the data model.
- The programming will conform to .NET Design Guidelines for Developing Class LIbraries, including naming conventions and error handling.
- Runs in NET 3.5 when built w/ MSVS 2008
- Runs in NET 4.0 when built w/ MSVS 2010
We will provide the two data model objects to be updated, and mapping from the FTP directory items to the data model objects.
Deliverable: C# source code of standalone tested class (to be migrated into our Namespace)