SIMS 7 - Attendance Code Sample
Introduction
This application is designed to show the principles of coding against SIMS Partner Interfaces. The UI is designed to facilitate the demo rather than to suggest good UI practice. The interfaces, particularly with regard to XML are simply sufficient to show principle rather than elegance.
This document adds a commentary to the downloadable sample code.
Legal Bit
The download and use of the sample code is subject to terms and conditions of use and would require the distributor to register as a SIMS Partner and be subject to any charges which result from that partnership. Sample code may not be redistributed as code; however permission is given to share the URL of this document and for the subsequent reader to download the code themselves subject to the same terms and conditions. This enables ESS to update the code samples and reduces the likelihood of bug propagation.
Other Requirements
In order to compile binaries, a copy of Visual Studio 2017 or later is required with the appropriate components installed for C# and Windows Command Line Applications.
A copy of SIMS 7 (all components) is required to be installed on the machine at the latest available version.
A copy of training data is required in order to ensure DPA / GDPR compliance. If you do not have this available, please contact us. (Charges apply).
The Applications
- Solution ‘Sample Partner Application’ (4 Projects)
- Partner World
- Read Attendance
- Write Attendance
Recommended architecture
Our example has 2 console applications:
- ReadAttendance
- WriteAttendance
Which essentially read or write one student’s attendance marks for a given day. Whilst typically the read application works on any day, the write application is likely to fail if users try to write marks back in a holiday or other inappropriate scenarios.
The applications join up 2 services:
- Partner World which will contain all the partner IP and functionality.
- Get a student
- Get a mark to save in SIMS
- SIMS Interface
- Get Students for the partner Application
- Write marks from the partner system back in to SIMS.
In an ideal world, the data moving between the 2 services is via a portable format such as XML.
Read
if (SIMSInterface.LoginHelper.SIMSlogin(Server, Database, User, Password))
{ // Get Students
XmlDocument Students = SIMSInterface.Students.GetCurrentStudents();
// Save Students to Partner System
PartnerWorld.AttendanceInterface.SaveStudentData(Students);
// Get Attendance codes
XmlDocument AttendanceCodes = SIMSInterface.Attendance.GetAttendanceCodes();
// Save Attendance Codes to partner system
PartnerWorld.AttendanceInterface.SaveAttendanceMarks(AttendanceCodes);
// Get some Marks
Console.WriteLine(SIMSInterface.Attendance.GetAttendanceRead(
PartnerWorld.AttendanceInterface.AttendanceDate,
PartnerWorld.AttendanceInterface.StudentID).InnerXml);
}
Commentary
- First there is a need to log in to SIMS.
- The get students is used to find a valid student ID for the read / write.
- Save Students to the Partner World sets a student id for later use.
- Get Attendance Codes loads the codes from SIMS – see module 6 for an example.
- Save attendance codes to Partner World makes sense on the assumption that marks will need to be interpreted.
- GetAttendanceRead pulls back the day of attendance marks for the specified student.
Write
As above but adds
// Add some Marks
SIMSInterface.Attendance.ClearMarks();
// AM
SIMSInterface.Attendance.AddAMMark(PartnerWorld.AttendanceInterface.StudentID, PartnerWorld.AttendanceInterface.AttendanceDate, PartnerWorld.AttendanceInterface.AttendanceCode, 1, "Good Morning");
// PM
SIMSInterface.Attendance.AddPMMark(PartnerWorld.AttendanceInterface.StudentID, PartnerWorld.AttendanceInterface.AttendanceDate, PartnerWorld.AttendanceInterface.AttendanceCode, 1, "Good Afternoon");
// Save
string Errors = SIMSInterface.Attendance.SaveSessionMarks();
Commentary
- The class keeps a list of session marks formatted as XML to save.
- Clear marks clears the list
- Add – adds a new mark AM or PM
- The Partner Attendance Code Save sets the default mark to save.
- Save Session Marks will try to save the marks
Strong Names.
SIMS 7 is strong named and hence when SIMS is update a partner application is likely to fail strong name checks.
SIMSInterface.SIMSDllResolution.AddSIMSDllResolution();
Adding the line above in to the main application is generally all that is needed to resolve dll changes however this takes effect once the current function is exited. Hence the guidance to call SIMS functionality from any other function but not ‘main’…
This code would need to be modified for web applications.
Partners are not licensed to re-distribute SIMS Binaries but this is actually a benefit to partners. Where partners have accidentally shipped binaries with their application, SIMS upgrades usually break their application. Use Copy Local = False in the IDE for best results.
Single Threaded Code Model
SIMS APIs are not typically stateless unless advised to the contrary on a per API basis. Odd errors occur if SIMS APIs are used in a multi-threaded environment and data corruption via thread bleed may occur when used in anger. Typically, developers do not see this issue during coding.
An understanding of SIMS Logins is assumed from the SIMS Write Back Core Module.