© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

SIMS 7 - Attendance Change Tracking Simplified Example (Reg Gp)

Switching to session attendance change tracking is important because it drastically reduces call volumes for TIs and makes it viable to get more frequent refreshes than might be reasonable via other methods.

Session Attendance Change Tracking does not need Data Change Tracking turned on in SIMS to work.

This variant uses Reg Groups to create the cache.  The alternative Year Group version will likely suffice for most schools but this is a belt and braces alternative.

For a Year Group example, click here.

Sample code, click here.

Starting point for the example is a c# console application on Framework 4.7.2.

The main application is:

using System;
using System.IO;
using System.Xml;

namespace Change_Tracked_Attendance
{
    internal class Program
    {
        // Based on standard training data
        public static string Database = "WelshGA";
        public static string Server = ".";
        public static string User = "Blacka";
        public static string Password = "Pa$$w0rd";
        public static DateTime Start  = DateTime.Now.AddYears(-1);
        public static DateTime End = DateTime.Now;
        public static string OutputPath = @"c:\temp";
        static void Main(string[] args)
        {
            SIMSInterface.SIMSDllResolution.AddSIMSDllResolution();
            Remainder();
        }
        public static void Remainder()
        { 
            if (SIMSInterface.LoginHelper.SIMSlogin(Server,Database,User,Password))
            {
                foreach (string r in SIMSInterface.Attendance.AttendanceRegGroups.Keys)
                {
                    string fileName = Path.Combine(OutputPath, r + ".xml");
                    XmlDocument YearlyAttendance = SIMSInterface.Attendance.GetAttendanceForYearGroup(r, Start, End);
                    YearlyAttendance.Save(fileName);
                }
                XmlDocument Changes = SIMSInterface.Attendance.GetChangeAttendance(End.AddDays(-1));
                Changes.Save(Path.Combine(OutputPath,  "changes.xml"));

            }
        }
    }
}

The use of SIMS Dll resolution as shown is always recommended.

It requires a SIMS Login.

The application then gets the set of reg groups as follows:

        private static Dictionary<string, int> _AttendanceRegGroups = new Dictionary<string, int>();
        public static Dictionary<string, int> AttendanceRegGroups
        {
            get
            {
                if (_AttendanceRegGroups.Count == 0)
                {
                    SIMS.Processes.GroupCache.Populate();
                    foreach (RegistrationGroup r in SIMS.Entities.GroupCache.RegistrationGroups)
                    {
                        _AttendanceRegGroups.Add(r.Code, r.ID);
                    }
                }
                return _AttendanceRegGroups;
            }
        }

using the group cache.

Exemplar below:

We can then simply iterate through the groups and get the base line attendance marks making the call below, both Year and Reg group coding is shown.

        public static XmlDocument GetAttendanceForRegGroup(string RegGroup, DateTime Start, DateTime End)
        {
            XmlDocument doc = null;
            int SampleGroup = -1;
            if (AttendanceRegGroups.TryGetValue(RegGroup, out SampleGroup))
            {
                doc = GetAttendanceForGroup(SampleGroup, Start, End);
            }
            return doc;
        }
        public static XmlDocument GetAttendanceForGroup(int GroupId, DateTime Start, DateTime End)
        {
            SIMS.Processes.TPAttendanceRead ATR = new SIMS.Processes.TPAttendanceRead();
            // XML Document needed to get the codes
            XmlDocument doc = new System.Xml.XmlDocument();
            // This is the actual call to get the codes
            doc.InnerXml = ATR.GetXmlSessionAttendancesExtended(0, GroupId, Start.Date, End);
            return doc;
        }

Finally, it is very simple to get what's changed from a given point in time

        public static XmlDocument GetChangeAttendance(DateTime Start)
        {
            DateTime End = DateTime.Now;
            XmlDocument d = new XmlDocument();
            TPAttendanceRead tpar = new TPAttendanceRead();
            d.InnerXml = tpar.GetXmlChangedSessionAttendancesInRange(Start, End);
            return d;
        }