© 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 - Sample Code - Example of SEN Provision using reporting

Overview of Example

Example of using reports in the middle of code where appropriate to seamlessly get data from SIMS.

Example Call


            List<SEN_Provision> sen = SIMSInterface.SENProvisionHistory.GetSENProvisions(Server, Database, User, Password);
            json = Newtonsoft.Json.JsonConvert.SerializeObject(sen, Formatting.Indented);
            System.IO.File.WriteAllText(Path.Combine(OutputFolder, "sen_provision.json"), json);
        

Output Class

    public class SEN_Provision
    {
        #region example
        #endregion
        public int id { get; set; }

        public string LegalSurname { get; set; }
        public string LegalForename { get; set; }


        public string ProvisionType { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string Cost { get; set; }
        public string Frequency { get; set; }
        public string Comments { get; set; }
    }

Code Sample

// The DLLs and code for running reports are in the appropriate sample code downloads.


//public static string reportName = "DEMO - Historical SEN Provisions";
//public static string reportFileName = "DEMO - Historical SEN Provisions.RptDef";


public static List<SEN_Provision>   
GetSENProvisions(string Server,string Database,string User,string Password) 
{
    FileInfo F = new FileInfo(Assembly.GetEntryAssembly().Location);
    string filename = Path.Combine(F.Directory.FullName, "ReportSet\\" + reportFileName);
     // Import the report 
    List<SIMSInterface.SEN_Provision> SENProv = new List<SEN_Provision>(); 
    if (SIMSReportingEngine.ReportingEngine.Load(filename, Server, Database, User, Password))
    {
        // Run the report in code.
        XmlDocument d = SIMSReportingEngine.ReportingEngine.Run(reportName, Server, Database, User, Password);
        // Convert the XML Document in to the format required.
        foreach (XmlNode node in d.SelectNodes("SuperStarReport/Record"))
        {
            SEN_Provision s = new SEN_Provision();
            s.id = int.Parse(node["ID"].InnerXml);
            if (node["LegalSurname"] != null)
                s.LegalSurname = node["LegalSurname"].InnerXml;
            if (node["LegalForename"] != null)
                s.LegalForename = node["LegalForename"].InnerXml;
            if (node["ProvisionType"] != null)
                s.ProvisionType = node["ProvisionType"].InnerXml;
            if (node["Cost"] != null)
                s.Cost = node["Cost"].InnerXml;
            if (node["Frequency"] != null)
                s.Frequency = node["Frequency"].InnerXml;
            if (node["Comments"] != null)
                s.Comments = node["Comments"].InnerXml;
            if (node["StartDate"] != null)
                s.StartDate = DateTime.Parse(node["StartDate"].InnerXml);
            if (node["EndDate"] != null)
                s.EndDate = DateTime.Parse( node["EndDate"].InnerXml);
            }
                  
            SENProv.Add(s);
        }

    }
    return SENProv;
}

Example Output

{
    "id": 14373,
    "LegalSurname": "Abdelkoder",
    "LegalForename": "Mohamed",
    "ProvisionType": "Time in SEN Unit",
    "StartDate": "2024-02-26T00:00:00+00:00",
    "EndDate": "0001-01-01T00:00:00",
    "Cost": null,
    "Frequency": null,
    "Comments": "Test"
  },
  {
    "id": 14373,
    "LegalSurname": "Abdelkoder",
    "LegalForename": "Mohamed",
    "ProvisionType": "Resourced Provision",
    "StartDate": "2024-02-26T00:00:00+00:00",
    "EndDate": "0001-01-01T00:00:00",
    "Cost": null,
    "Frequency": null,
    "Comments": "Example of resourced provision"
  },
  {
    "id": 12108,
    "LegalSurname": "Ackton",
    "LegalForename": "Stephen",
    "ProvisionType": "Physiotherapy",
    "StartDate": "2017-09-07T00:00:00+01:00",
    "EndDate": "0001-01-01T00:00:00",
    "Cost": null,
    "Frequency": "Daily",
    "Comments": "Physio"
  },