© 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 - Summer 24 - Attendance Codes

This work is subject to confirmation.

 

The call to get attendance codes is very similar to the previous call, but will offer potentially misleading answers without the guidance below.

SIMS.Processes.TPAttendanceRead TPAR = new SIMS.Processes.TPAttendanceRead();
            SIMS.Processes.TPAttendanceWrite TPAW = new SIMS.Processes.TPAttendanceWrite();
            // We get back a list of all possible codes codes 
            SIMSInterfaceS24.AttendanceCodes aCodes = SIMSInterfaceS24.AttendanceV3.GetAttendanceCodesV3();
            // We need a list of current codes.
            SIMSInterfaceS24.AttendanceCodes currentCodes = new SIMSInterfaceS24.AttendanceCodes();
            // We need a list of codes that need statutory explanation
            SIMSInterfaceS24.AttendanceCodes currentCodesThatRequireExplanation = new SIMSInterfaceS24.AttendanceCodes();
            foreach (SIMSInterfaceS24.AttendanceCode code in aCodes.Codes)
            {
                if (code.Start_Date <= DateTime.Now && (code.End_Date == null || code.End_Date >= DateTime.Now))
                {
                    currentCodes.Codes.Add(code);
                    if ( code.statutory_comment_required && code.Statutory_Start_Date != null && code.Statutory_Start_Date <= DateTime.Now && (code.Statutory_End_Date == null || code.Statutory_End_Date >= DateTime.Now))
                    {
                        currentCodesThatRequireExplanation.Codes.Add(code);
                    }
                    else
                    {
                        // No statutory explanation needed.
                    }
                }
                else
                {
                    // it is isn't current
                }
            }

            return;

It is essential that the 'statutory comment required' is checked because all codes will have a statutory explanation start date which will be before today!

Class for attendance codes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace SIMSInterfaceS24
{
    // using System.Xml.Serialization;
    // XmlSerializer serializer = new XmlSerializer(typeof(AttendanceCodes));
    // using (StringReader reader = new StringReader(xml))
    // {
    //    var test = (AttendanceCodes)serializer.Deserialize(reader);
    // }

    [XmlRoot(ElementName = "AttendanceCode")]
    public class AttendanceCode
    {

        [XmlElement(ElementName = "AttendanceCodeID")]
        public int? AttendanceCodeID { get; set; }

        [XmlElement(ElementName = "Code")]
        public string Code { get; set; }

        [XmlElement(ElementName = "ExternalDescription")]
        public string ExternalDescription { get; set; }

        [XmlElement(ElementName = "InternalCode")]
        public string InternalCode { get; set; }

        [XmlElement(ElementName = "Description")]
        public string Description { get; set; }

        [XmlElement(ElementName = "PhysicalMappingID")]
        public int? PhysicalMappingID { get; set; }

        [XmlElement(ElementName = "PhysicalMappingDescription")]
        public string PhysicalMappingDescription { get; set; }

        [XmlElement(ElementName = "StatisticalMappingID")]
        public int? StatisticalMappingID { get; set; }

        [XmlElement(ElementName = "StatisticalMappingDescription")]
        public string StatisticalMappingDescription { get; set; }

        [XmlElement(ElementName = "PhysicalMappingEditable")]
        public string PhysicalMappingEditable { get; set; }

        [XmlElement(ElementName = "StatisticalMappingEditable")]
        public string StatisticalMappingEditable { get; set; }

        [XmlElement(ElementName = "DescriptionEditable")]
        public string DescriptionEditable { get; set; }

        [XmlElement(ElementName = "NonSimsUse")]
        public string NonSimsUse { get; set; }

        [XmlElement(ElementName = "IsRestricted")]
        public string IsRestricted { get; set; }

        [XmlElement(ElementName = "Active")]
        public string Active { get; set; }

        [XmlElement(ElementName = "AttendanceCodeCategory")]
        public string AttendanceCodeCategory { get; set; }

        
        [XmlElement(ElementName = "StartDate")]
        public string StartDate { get; set; }
        
        public DateTime? Start_Date
        {
            get
            {
                DateTime r = DateTime.MinValue;
                if (DateTime.TryParse(StartDate, out r))
                {
                    return r;
                }
                return null;
            }
        }

        [XmlElement(ElementName = "EndDate")]
        public string EndDate { get; set; }

        public DateTime? End_Date
        {
            get
            {
                DateTime r = DateTime.MinValue;
                if (DateTime.TryParse(EndDate, out r))
                {
                    return r;
                }
                return null;
            }
        }
        [XmlElement(ElementName = "IsStatutoryCommentRequired")]
        public string IsStatutoryCommentRequired { get; set; }
        public bool statutory_comment_required 
        { 
            get
            {
                return IsStatutoryCommentRequired.Length > 0 ? IsStatutoryCommentRequired[0] == 'T' : false;
            }
                 
        }


        [XmlElement(ElementName = "StatutoryStartDate")]
        public string StatutoryStartDate { get; set; }
        public DateTime? Statutory_Start_Date 
        {
            get
            {
                DateTime r = DateTime.MinValue;
                if (DateTime.TryParse(StatutoryStartDate, out r))
                {
                    return r;
                }
                return null;
            }
        }

        [XmlElement(ElementName = "StatutoryEndDate")]
        public string StatutoryEndDate { get; set; }

        public DateTime? Statutory_End_Date
        {
            get
            {
                DateTime r = DateTime.MinValue;
                if (DateTime.TryParse(StatutoryEndDate, out r))
                {
                    return r;
                }
                return null;
            }
        }
        [XmlElement(ElementName = "RegionCode")]
        public string RegionCode { get; set; }
    }
    [XmlRoot(ElementName = "AttendanceCodes")]
    public class AttendanceCodes
    {

        [XmlElement(ElementName = "AttendanceCode")]
        public List<AttendanceCode> Codes = new List<AttendanceCode>(); 
    }

}

Whilst the use of string types above for most fields is perhaps a little ugly, it is simpler to grab the data on input and make it sensible when read.

Loading call


        public static AttendanceCodes GetAttendanceCodesV3()
        {
            AttendanceCodes List = null;
            try
            {
                SIMS.Processes.TPAttendanceRead ATR = new SIMS.Processes.TPAttendanceRead();
                // XML Document needed to get the codes
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                // This is the actual call to get the codes
                doc.InnerXml = ATR.GetXmlAttendanceCodesV3();
                XmlSerializer serializer = new XmlSerializer(typeof(AttendanceCodes));
                using (StringReader reader = new StringReader(doc.InnerXml))
                {
                    List = (AttendanceCodes)serializer.Deserialize(reader);
                }
            }
            catch (Exception ex)   // Should look for a not implemented exception
            {
            	// This was a regualr spot when I tried to more closely type the response.
            }
            return List;
        }