© 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 - Staff Iteration using staff edit

Overview of Example

This demonstrates how to obtain an example set of staff data using the employee browse and detail form.

Example Call

            List<SIMSInterface.StaffDetails> sd =  SIMSInterface.Staff.GetStaff();
            string _sd = JsonConvert.SerializeObject(sd,Formatting.Indented);
            File.WriteAllText(Path.Combine(OutputFolder,"staff.json"), _sd);

Output Class

    public class StaffDetails
    {
        public int id;
        public string name;

        public List<string> FormerFamilyNames = new List<string>();
        /// <summary>
        /// Disability
        /// </summary>
        public List<string> Impairments = new List<string>();
        /// <summary>
        /// QTLS
        /// </summary>
        public string QTLS { get; set; }
        /// <summary>
        /// EYTS
        /// </summary>
        public string EYTS { get; set; }
        /// <summary>
        /// NewlyQualifiedTeacher
        /// </summary>
        public string NQT { get; set; }
        //Post
        //DestinationCode
        //Origin
        public List<dContracts> Contracts = new List<dContracts>();
        //YearGroup

    }

Code Sample

public static List<StaffDetails> GetStaff()
{
    List<StaffDetails> staffdatas = new List<StaffDetails>(); 
    BrowseEmployee employees = new BrowseEmployee();
    employees.Load(EmployeeFilter.All,"%","%","%","%","%",false, DateTime.Now);
    foreach (SIMS.Entities.EmployeeSummary empSum in employees.Employees)
    {
        StaffDetails s = new StaffDetails();
        SIMS.Processes.EditEmployee editEmployee = new EditEmployee();
        s.id = empSum.PersonID;
        s.name = empSum.Forename + " " + empSum.Surname; // Just to make it readable
        editEmployee.Load(empSum.PersonID, System.DateTime.Now);
        foreach (SIMS.Entities.EmployeePreviousName name in editEmployee.Employee.PreviousNames)
        {
            s.FormerFamilyNames.Add(name.Surname);
        }
        s.QTLS = editEmployee.Employee.QTLSStatusAttribute.Value.ToString();
        s.EYTS = editEmployee.Employee.EYTStatusAttribute.Value.ToString();
        s.NQT = "Null";
        if (editEmployee.Employee.NQTStatusAttribute.Value != null)
            s.NQT = editEmployee.Employee.NQTStatusAttribute.Value.ToString();
        foreach (SIMS.Entities.Impairment imp in  editEmployee.Employee.ImpairmentsAttribute.Value)
        {  // Need to decide what data is needed.
            s.Impairments.Add(imp.Description);
        }
        foreach( SIMS.Entities.Contract c in editEmployee.Employee.Contracts.Value)
        {
            dContracts x = new dContracts();
            x.DestinationCode = "Null";
            x.Origin = "Null";
            x.Post = "Null";
            if (c.Destination != null)
                x.DestinationCode = c.Destination.Code;
            if (c.Origin != null)
                x.Origin = c.Origin.Code;
            if (c.PostDescription != null)
                x.Post = c.PostDescription;
            foreach (SIMS.Entities.ContractScale sc in c.Scales.Value)
            {
                if (sc.RangeType)  // Just consider pay range type records.
                {
                    PayRange pr = new PayRange();   
                    pr.Start = sc.StartDate;
                    pr.End  = sc.EndDate;    
                    pr.Amount = sc.SalaryAmount;
                    x.PayRange.Add(pr);
                }
            }
            s.Contracts.Add(x);

        }
        staffdatas.Add(s);
    }
    return staffdatas;  
}

Example Output

  {
    "id": 12268,
    "name": "Mildred Abdullah",
    "FormerFamilyNames": [
      "Jane",
      "Abdullah"
    ],
    "Impairments": [
      "Wooden Leg"
    ],
    "Contracts": [
      {
        "PayRange": [],
        "Post": "TCHR-Teacher",
        "DestinationCode": "Null",
        "Origin": "TCHLEA"
      }
    ],
    "QTLS": "True",
    "EYTS": "True",
    "NQT": "Not in year 1 or 2 of QT Status Induction"
  },