SIMS 7 - Change Tracking API - Guidance for all API Calls
The document lists the .NET interfaces developed for getting changed entities from SIMS. These interfaces are available via ThirdPartyProcesses.dll.
The sections ‘Introduction’ and ‘Architectural constraints’ have been obtained the from ‘Project Architecture – 3rd Party Data Change’
The section Interface Description explains all the ‘changedXml’ interfaces along with sample code and output.
Introduction
Many third party systems extract data from the SIMS System, into their own Data Storage Systems. This is currently achieved by doing a full extract of Logical Data Entities from the SIMS system. Keeping the extract data synchronised with the SIMS database can currently be achieved by periodic full extracts of those same logical entities. The new ChangedXml interfaces are based around a solution which delivers the capability of requesting Logical Entities which have changed since a given reference date. Changed Entities also include Instances of Entities which have been deleted.
It is anticipated and encouraged that as with full synchronisation, data change synchronisation will be run at a low frequency (expected daily) at system off peak times.
The data that is finally presented is subject to the same security constraints as the entity when accessed for any other purpose. If a changed entity is identified but is subject to row level security it will not be present in the output, even if the data has changed. If a changed entity is identified and is subject only to field level security then non-permitted fields will be removed from the entity.
Entities which are generated accurately reflect the current state of that entity. There is no need to represent the entity state at any other point than the current system date.
The accuracy of the data itself is absolute. The accuracy implied by this data as being changed in relation to the reference date is not absolute. The principle followed is to over-report data change (with accurate information) rather than potentially under-report (miss a change). The nature of the data change is not important or considered. If a string has been reformatted eg: case, punctuation whitespace etc... It will be reported. Any physical change to data contained within a monitored table which underpins a supported entity, will result in that entity being reported.
Change tracking is turned on in SIMS.
Does change tracking always work well for applications?
/// <summary>
/// WARNING - THIS CLASS IS NOT RECOMMENDED for live implementation
/// </summary>
public class PenPicture
{
string StudentSurname;
string StudentForename;
string StudentEmail;
string StudentParent1Forename;
string StudentParent2Forename;
string StudentParent1Email;
string StudentParent2Email;
string StudentParent1Phone;
string StudentParent2Phone;
string StudentParent1Surname;
string StudentParent2Surname2;
}
No, not always! The value of change tracking is typically greatest when the data needed by the application matches the entity structure in SIMS. Composite entities such as 'PenPicture' above may be inefficient to track change using the GetChanged APIs, this is because to find out what's changed, we need to check what:
- student's have changed/been deleted.
- email links have changed/been deleted.
- emails have changed/been deleted.
- telephones have changed/been deleted.
- telephone links have changed/been deleted.
- contacts have changed/been deleted.
- relationships have changed/been deleted
And then workout how any change that is reported links back to the pen picture. For example if email address 45 changes from a@a.com to b@b.com which PenPictures are impacted (if any).
Alternative techniques such as building potential export entities, storing hash values and exporting based on changed hash values might be a more effective.
Sample Code
The following example for interface changed students has been explained in detail below.
using System;
using System.Xml;
using System.IO;
namespace SIMSInterface
{
// NB: Code is written to show principle and has never been compiled! .
public class DemoChange
{
public string ConfigFileName = @"c:\temp\demochange.xml";
public const string FileFormat = "<Root><LastCalled>{0}</LastCalled></Root>";
public void SampleUsage()
{
// Want to get all changes since we last made the call.
DateTime LastCall = GetLastTimeTheCallWasMade();
// We store the new last updated time before we do anything.
// this ensures that we won't miss any activity that occurs
// during the calls.
DateTime ThisCall = DateTime.Now;
try
{
// Look for changed students
SIMS.Processes.TPPersonStudent ttps = new SIMS.Processes.TPPersonStudent();
XmlDocument changedStudentXML = new XmlDocument();
changedStudentXML.InnerXml = ttps.GetXmlChangedStudents(LastCall);
// Warning the document might be empty of no students have changed.
// Your application would then do something with the data that it had asked for..
// Your app should only return here if it was successful - otherwise throw an exception
// If all was good.
SetLastTimeTheCallWasMade(ThisCall);
}
catch
{
// Don't save the new last updated because it didn't work
}
}
/// <summary>
/// The calling programme has a simple task which is to record the start of the request
/// for change tracked data and store it for future use, assuming that the following calls are successful.
/// </summary>
/// <returns></returns>
public DateTime GetLastTimeTheCallWasMade()
{
DateTime LastCalled = DateTime.Parse("1980-01-01");
if (File.Exists(ConfigFileName))
{
XmlDocument d = new XmlDocument();
d.Load(ConfigFileName);
LastCalled = DateTime.Parse(d.SelectSingleNode("Root/LastCalled").InnerXml);
}
return LastCalled;
}
public void SetLastTimeTheCallWasMade(DateTime TimeToSave)
{
XmlDocument d = new XmlDocument();
d.InnerXml = string.Format(FileFormat, TimeToSave.ToUniversalTime());
d.Save(ConfigFileName);
}
}
}