This module was created in order to support data transfer between the MFC document and a SQL Server database in the SchedulePro desktop application. The provided functionality is used by several clients in order to publish the production schedule for interested parties to access. The module supports automatic database setup and migrations, data exporting and data importing to/from the database. Specifically, the module allows for exporting/importing almost the entire document consisting of approximately 80 classes. The implementation involves all three technologies VC++ (where the MFC document information is stored), C++/CLI (database management, importing, exporting), C#/Windows Forms (user interfaces).
Functionality at a glance:
- Multiple database connection methods such as: shared memory, network connection with static or dynamic port, windows or SQL Server authentication.
- Full management of the database and the database data through a number of relevant interfaces.
- Two methods for database schema updating:
- Fully automatic: Tables and columns are declared in C++/CLI arrays. The application reads the array values and creates or updates the tables accordingly (e.g. adding a column name/type to the designated array will automatically add the column to the corresponding database table).
- Migration-based: XML-based migrations for database schema (tables and triggers) and database objects (functions, procedures, views, roles and indexes). Database schema units (i.e. tables) are altered to accommodate evolving needs, whereas database objects are deleted and recreated whenever a change is made.
- Snapshot-based data exporting. Every export creates a new snapshot, containing the document data at exporting time. Document entities are identified by their user-defined name. Thus, a full history of each entity is available from all the snapshots it belongs to.
- The data of an entity in different snapshots can be used to track the entity status over time and to report on various comparative scenarios (e.g. planned vs. actual schedules).
- Various reports may be produced on the server data in one of two ways:
- As .rdlc reports hosted in an MS ReportViewer control.
- As MFC control fed data from the database.
- Classes were mapped to database tables according to “Table Per Type” or “Single Table Inheritance”, depending on the individual scenario.
- C++/CLI classes in the core MFC dll (mixed mode)
are responsible for:
- Managing the database schema.
- Reading, marshalling and writing to the database data from the VC++ MFC document.
- Reading from the database, marshalling the data and then updating the MFC document.
- Reading the document, marshalling the data and feed it to Windows Forms reports.
- C#/Windows Forms windows allow for accessing and managing the database data.
- A C++/CLI-enabled wrapper class is used so that managed code can be called from purely native classes.