Beispiel #1
0
        /// <summary>
        /// Create learner yeargroup Data entity
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="learnerId"></param>
        /// <param name="startDate"></param>
        /// <param name="yeargroup"></param>
        /// <param name="collectionCount"></param>
        /// <param name="referenceID"></param>
        /// <param name="extensionData"></param>
        /// <returns></returns>
        public DataEntityDTO CreateLearnerYearGroup(Guid ID, Guid learnerId, string startDate, Guid yeargroup, int referenceID, int collectionCount, ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid {
                Value = ID
            };
            DataEntityDTO.SimplePropertyDTODate StartDateProperty = new DataEntityDTO.SimplePropertyDTODate {
                Value = new Date {
                    internalDateTime = DateTime.Parse(startDate)
                }
            };
            DataEntityDTO.ReferencePropertyDTO yearGroupProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = yeargroup
            };

            DataEntityDTO.ReferencePropertyDTO LearnerProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerId,
                InternalReferenceID = (short?)collectionCount
            };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "LearnerYearGroupMembership",
                Values     = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>
                {
                    { "ID", IDProperty },
                    { "StartDate", StartDateProperty },
                    { "Learner", LearnerProperty },
                    { "YearGroup", yearGroupProperty }
                }
            };

            return(DataExchangeDetail.EntitySettings(entity, ID, referenceID, extensionData));
        }
Beispiel #2
0
        /// <summary>
        /// Create SEN Status entity
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="SENStatusID"></param>
        /// <param name="startDate"></param>
        /// <param name="learnerID"></param>
        /// <param name="collectionCount"></param>
        /// <param name="referenceID"></param>
        /// <param name="extensionData"></param>
        /// <returns></returns>
        public DataEntityDTO CreateSENStatus(Guid ID, Guid SENStatusID, string startDate, Guid learnerID, int referenceID, int collectionCount, ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid {
                Value = ID
            };
            DataEntityDTO.SimplePropertyDTODate StartDateProperty = new DataEntityDTO.SimplePropertyDTODate {
                Value = new Date {
                    internalDateTime = DateTime.Parse(startDate)
                }
            };
            DataEntityDTO.ReferencePropertyDTO senStatusProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = SENStatusID
            };

            DataEntityDTO.ReferencePropertyDTO LearnerProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerID,
                InternalReferenceID = (short?)collectionCount
            };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "LearnerSENStatus",
                Values     = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>
                {
                    { "ID", IDProperty },
                    { "StartDate", StartDateProperty },
                    { "Learner", LearnerProperty },
                    { "SENStatus", senStatusProperty }
                }
            };


            return(DataExchangeDetail.EntitySettings(entity, ID, referenceID, extensionData));
        }
Beispiel #3
0
        public DataEntityDTO CreatePupil(
            Guid ID, 
            string legalForename, 
            string legalSurname, 
            Date dateOfBirth,
            Guid genderID,
            Guid schoolID, 
            int referenceID, 
            ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid { Value = ID };
            DataEntityDTO.SimplePropertyDTOString legalForenameProperty = new DataEntityDTO.SimplePropertyDTOString { Value = legalForename };
            DataEntityDTO.SimplePropertyDTOString legalSurnameProperty = new DataEntityDTO.SimplePropertyDTOString { Value = legalSurname };
            DataEntityDTO.SimplePropertyDTODate dateOfBirthProperty = new DataEntityDTO.SimplePropertyDTODate { Value = dateOfBirth };
            DataEntityDTO.ReferencePropertyDTO schoolProperty = new DataEntityDTO.ReferencePropertyDTO { EntityPrimaryKey = schoolID };
            DataEntityDTO.ReferencePropertyDTO genderProperty = new DataEntityDTO.ReferencePropertyDTO { EntityPrimaryKey = genderID };
            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "Learner",
                Values = new Dictionary<string, DataEntityDTO.SimplePropertyDTO>
                {
                    {"ID", IDProperty},
                    {"LegalForename", legalForenameProperty},
                    {"LegalSurname", legalSurnameProperty},
                    {"DateOfBirth", dateOfBirthProperty},
                    {"Gender", genderProperty},
                    {"School", schoolProperty}
                }
            };

            return PupilDetails.EntitySettings(entity, ID, referenceID, extensionData);
        }
Beispiel #4
0
        /// <summary>
        /// Display the data in the passed DataEntityCollectionDTO in the console window. This gives an example of how the content
        /// of a loosly typed entity property bag works.
        /// </summary>
        /// <param name="entities"></param>
        internal void DisplayDataInConsoleWindow(DataEntityCollectionDTO entities)
        {
            // The data structure returned may have many entities, (in our case a mixture of Address, LearnerAddress and Learner). The TopLevelDtoIDs collection
            // gives the list of unique IDs that represent the Learner entitities we requested.
            foreach (int referenceId in entities.TopLevelDtoIDs)
            {
                // In our case there is only one expected TopLevel entity - the Learner 8BCF76BF-C067-98AB-5DFC-88D62DE77450
                DataEntityDTO entity = entities.DataEntityDtos[referenceId];
                Console.WriteLine("Entity " + entity.EntityName + " " + entity.ID.ToString());

                // Extract the fields from the DataEntityDTO.Values dictionary
                // Dangerous assumption that these Values can be cast to a String - if they are Null they will be of type SimplePropertyDTONull, not SimplePropertyDTOString
                // programmers should construct a conversion function to prevent having to check this every time, returning a Nullable<Type> when passed an instance of a
                // SimplePropertyDTO
                Console.WriteLine("      Surname " + ((DataEntityDTO.SimplePropertyDTOString)entity.Values["LegalSurname"]).Value);
                Console.WriteLine("     Forename " + ((DataEntityDTO.SimplePropertyDTOString)entity.Values["LegalForename"]).Value);
                Console.WriteLine("     PreferredForename " + ((DataEntityDTO.SimplePropertyDTOString)entity.Values["PreferredForename"]).Value);
                // In theory any value might be returned as Null rather than the expected Type. Third party developers should assume that, due to security redaction or
                // naturally occuring blanks in the data, that any Value property of an DataEntityDTO could be of Type SimplePropertyDTONull.
                if (entity.Values.ContainsKey("UPN"))
                {
                    if (entity.Values["UPN"] is DataEntityDTO.SimplePropertyDTONull)
                    {
                        Console.WriteLine("          UPN NULL");
                    }
                    else
                    {
                        Console.WriteLine("          UPN " + ((DataEntityDTO.SimplePropertyDTOString)entity.Values["UPN"]).Value);
                    }
                }

                if (entity.Values.ContainsKey("LearnerAddresses"))
                {
                    // Spin round each of the possible addresses attached to this learner.
                    foreach (DataEntityDTO.ReferencePropertyDTO learerReference in ((DataEntityDTO.ReferencePropertyDTOArray)entity.Values["LearnerAddresses"]).ReferenceProperties)
                    {
                        if (learerReference.InternalReferenceID.HasValue)
                        {
                            // Get the learnerAddress entity
                            DataEntityDTO learnerAddressEntity = entities.DataEntityDtos[learerReference.InternalReferenceID.Value];
                            Date          dateValue            = ((DataEntityDTO.SimplePropertyDTODate)learnerAddressEntity.Values["StartDate"]).Value;
                            Console.WriteLine("      Address Start Date " + dateValue.internalDateTime.Date);

                            // Get the address unique ID
                            DataEntityDTO.ReferencePropertyDTO addressReference = ((DataEntityDTO.ReferencePropertyDTO)learnerAddressEntity.Values["Address"]);
                            // Get the address entity.
                            // ReSharper disable once AssignNullToNotNullAttribute
                            // ReSharper disable once PossibleInvalidOperationException
                            DataEntityDTO addressEntity = entities.DataEntityDtos[addressReference.InternalReferenceID.Value];
                            Console.WriteLine("      Address PostCode    " + ((DataEntityDTO.SimplePropertyDTOString)addressEntity.Values["PostCode"]).Value);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public DataEntityCollectionDTO UpdateEntity(DataEntityCollectionDTO entitys, string fieldName, string referencevalue)
        {
            foreach (int referenceId in entitys.TopLevelDtoIDs)
            {
                DataEntityDTO entity = entitys.DataEntityDtos[referenceId];
                ((DataEntityDTO.SimplePropertyDTOString)entity.Values[fieldName]).Value = referencevalue;
                _changedFields.Add(fieldName);
            }

            return(entitys);
        }
Beispiel #6
0
        /// <summary>
        /// Create pupil data
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="legalForename"></param>
        /// <param name="legalSurname"></param>
        /// <param name="dateOfBirth"></param>
        /// <param name="genderID"></param>
        /// <param name="UPN"></param>
        /// <param name="admissionNo"></param>
        /// <param name="schoolID"></param>
        /// <param name="referenceID"></param>
        /// <param name="extensionData"></param>
        /// <returns></returns>
        public DataEntityDTO CreatePupil(Guid ID, string legalForename, string legalSurname, string dateOfBirth, Guid genderID, Guid yeargroupID, string UPN, string admissionNo, Guid schoolID, int referenceID, ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid {
                Value = ID
            };
            DataEntityDTO.SimplePropertyDTOString legalForenameProperty = new DataEntityDTO.SimplePropertyDTOString {
                Value = legalForename
            };
            DataEntityDTO.SimplePropertyDTOString legalSurnameProperty = new DataEntityDTO.SimplePropertyDTOString {
                Value = legalSurname
            };
            DataEntityDTO.SimplePropertyDTODate dateOfBirthProperty = new DataEntityDTO.SimplePropertyDTODate {
                Value = new Date {
                    internalDateTime = DateTime.Parse(dateOfBirth)
                }
            };
            DataEntityDTO.ReferencePropertyDTO schoolProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = schoolID
            };
            DataEntityDTO.ReferencePropertyDTO genderProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = genderID
            };
            DataEntityDTO.ReferencePropertyDTO yeargroupProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = yeargroupID
            };
            DataEntityDTO.SimplePropertyDTOString admissionNoProperty = new DataEntityDTO.SimplePropertyDTOString {
                Value = admissionNo
            };
            DataEntityDTO.SimplePropertyDTOString UPNProperty = new DataEntityDTO.SimplePropertyDTOString {
                Value = UPN
            };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "Learner",
                Values     = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>
                {
                    { "ID", IDProperty },
                    { "LegalForename", legalForenameProperty },
                    { "LegalSurname", legalSurnameProperty },
                    { "DateOfBirth", dateOfBirthProperty },
                    { "AdmissionNumber", admissionNoProperty },
                    { "UPN", UPNProperty },
                    { "Gender", genderProperty },
                    { "School", schoolProperty },
                    { "YearGroup", yeargroupProperty }
                }
            };

            return(DataExchangeDetail.EntitySettings(entity, ID, referenceID, extensionData));
        }
Beispiel #7
0
        /// <summary>
        /// Make some modifications to the Learner entity fetched by RetrieveSingleLearnerByID
        /// </summary>
        internal DataEntityCollectionDTO MakeModificatons(DataEntityCollectionDTO entitys, string editedvalue)
        {
            // The data structure returned may have many entities, (in our case a mixture of Address, LearnerAddress and Learner). The TopLevelDtoIDs collection
            // gives the list of unique IDs that represent the Learner entitities we requested.
            foreach (int referenceId in entitys.TopLevelDtoIDs)
            {
                // In our case there is only one expected TopLevel entity
                DataEntityDTO entity = entitys.DataEntityDtos[referenceId];
                // SimplePropertyDTO
                ((DataEntityDTO.SimplePropertyDTOString)entity.Values["PreferredForename"]).Value = editedvalue;
            }

            return(entitys);
        }
Beispiel #8
0
        public static DataEntityDTO EntitySettings(DataEntityDTO entity, Guid ID, int reference, ExtensionDataObject extensionData)
        {
            entity.ReferenceID        = reference;
            entity.ID                 = ID;
            entity.DataModelContextID = "sims8_team1";
            entity.DataModelType      = new DataEntityDTO.DataModelTypeDTO
            {
                SchemaName       = "dbo",
                DataModelPurpose = "BusinessDataModel",
                ExtensionData    = extensionData
            };
            entity.ExtensionData = extensionData;

            return(entity);
        }
Beispiel #9
0
        /// <summary>
        /// Create enrolment details for pupil
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="learnerId"></param>
        /// <param name="startDate"></param>
        /// <param name="leavingDate"></param>
        /// <param name="schoolId"></param>
        /// <param name="referenceID"></param>
        /// <param name="collectionCount"></param>
        /// <param name="extensionData"></param>
        /// <returns></returns>
        public DataEntityDTO CreateLearnerEnrolment(Guid ID, Guid learnerId, string startDate, string leavingDate, Guid schoolId, int referenceID, int collectionCount, ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid {
                Value = ID
            };
            DataEntityDTO.SimplePropertyDTODate StartDateProperty = new DataEntityDTO.SimplePropertyDTODate {
                Value = new Date {
                    internalDateTime = DateTime.Parse(startDate)
                }
            };
            DataEntityDTO.ReferencePropertyDTO schoolProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = schoolId
            };


            DataEntityDTO.ReferencePropertyDTO LearnerProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = learnerId
            };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "LearnerEnrolment",
                Values     = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>
                {
                    { "ID", IDProperty },
                    { "DOA", StartDateProperty },
                    { "Learner", LearnerProperty },
                    { "School", schoolProperty }
                }
            };

            if (string.IsNullOrEmpty(leavingDate))
            {
                return(DataExchangeDetail.EntitySettings(entity, ID, referenceID, extensionData));
            }
            DataEntityDTO.SimplePropertyDTODate DOLProperty = new DataEntityDTO.SimplePropertyDTODate
            {
                Value = new Date {
                    internalDateTime = DateTime.Parse(leavingDate)
                }
            };
            entity.Values.Add("DOL", DOLProperty);

            return(DataExchangeDetail.EntitySettings(entity, ID, referenceID, extensionData));
        }
Beispiel #10
0
        /// <summary>
        /// Create enrolment details for pupil
        /// </summary>
        /// <param name="id"></param>
        /// <param name="learnerEnrolmentId"></param>
        /// <param name="enrolmentStatusID"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="referenceID"></param>
        /// <param name="collectionCount"></param>
        /// <param name="extensionData"></param>
        /// <returns></returns>

        public DataEntityDTO CreateLearnerEnrolmentStatus(Guid id, Guid learnerEnrolmentId, Guid enrolmentStatusID, string startDate, string endDate, int referenceID, int collectionCount, ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid {
                Value = id
            };
            DataEntityDTO.SimplePropertyDTODate StartDateProperty = new DataEntityDTO.SimplePropertyDTODate {
                Value = new Date {
                    internalDateTime = DateTime.Parse(startDate)
                }
            };
            DataEntityDTO.ReferencePropertyDTO learnerEnrolmentProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = learnerEnrolmentId
            };


            DataEntityDTO.ReferencePropertyDTO enrolmentStatusProperty = new DataEntityDTO.ReferencePropertyDTO {
                EntityPrimaryKey = enrolmentStatusID
            };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "LearnerEnrolmentStatus",
                Values     = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>
                {
                    { "ID", IDProperty },
                    { "StartDate", StartDateProperty },
                    { "LearnerEnrolment", learnerEnrolmentProperty },
                    { "EnrolmentStatus", enrolmentStatusProperty }
                }
            };

            if (string.IsNullOrEmpty(endDate))
            {
                return(DataExchangeDetail.EntitySettings(entity, id, referenceID, extensionData));
            }
            DataEntityDTO.SimplePropertyDTODate endDateProperty = new DataEntityDTO.SimplePropertyDTODate
            {
                Value = new Date {
                    internalDateTime = DateTime.Parse(endDate)
                }
            };
            entity.Values.Add("EndDate", endDateProperty);

            return(DataExchangeDetail.EntitySettings(entity, id, referenceID, extensionData));
        }
Beispiel #11
0
        public static DataEntityDTO NewEntitySettings(Guid ID, int reference, ExtensionDataObject extensionData, string entityName)
        {
            DataEntityDTO entity = new DataEntityDTO
            {
                ReferenceID        = reference,
                ID                 = ID,
                EntityName         = entityName,
                DataModelContextID = "sims8_team1",
                DataModelType      = new DataEntityDTO.DataModelTypeDTO
                {
                    SchemaName       = "dbo",
                    DataModelPurpose = "BusinessDataModel",
                    ExtensionData    = extensionData
                },
                ExtensionData = extensionData,
                Values        = new Dictionary <string, DataEntityDTO.SimplePropertyDTO>()
            };

            return(entity);
        }
Beispiel #12
0
        public DataEntityDTO CreateStandardPupilLogNote(
            Guid ID, 
            string title, 
            string noteText, 
            Guid learnerID, 
            Guid categoryID, 
            Guid userID,
            bool pinned, 
            int collectionCount, 
            int referenceID, 
            ExtensionDataObject extensionData)
        {
            DataEntityDTO.SimplePropertyDTOGuid IDProperty = new DataEntityDTO.SimplePropertyDTOGuid { Value = ID };
            DataEntityDTO.SimplePropertyDTOString titleProperty = new DataEntityDTO.SimplePropertyDTOString { Value = title };
            DataEntityDTO.SimplePropertyDTOString noteTextProperty = new DataEntityDTO.SimplePropertyDTOString { Value = noteText };
            DataEntityDTO.SimplePropertyDTOBool pinnedProperty = new DataEntityDTO.SimplePropertyDTOBool { Value = pinned };
            DataEntityDTO.SimplePropertyDTODateTime createdOnProperty = new DataEntityDTO.SimplePropertyDTODateTime { Value = DateTime.Now };
            DataEntityDTO.SimplePropertyDTOGuid createdByProperty = new DataEntityDTO.SimplePropertyDTOGuid { Value = userID };
            DataEntityDTO.ReferencePropertyDTO learnerProperty = new DataEntityDTO.ReferencePropertyDTO { EntityPrimaryKey = learnerID };
            DataEntityDTO.ReferencePropertyDTO categoryProperty = new DataEntityDTO.ReferencePropertyDTO { EntityPrimaryKey = categoryID };

            DataEntityDTO entity = new DataEntityDTO
            {
                EntityName = "PupilLogNoteStandard",
                Values = new Dictionary<string, DataEntityDTO.SimplePropertyDTO>
                {
                    {"ID", IDProperty},
                    {"Title", titleProperty},
                    {"NoteText", noteTextProperty},
                    {"Pinned", pinnedProperty},
                    {"CreatedOn", createdOnProperty},
                    {"CreatedByUserId", createdByProperty},
                    {"Learner", learnerProperty},
                    {"PupilLogNoteCategory", categoryProperty}
                }
            };

            return PupilDetails.EntitySettings(entity, ID, referenceID, extensionData);
        }
Beispiel #13
0
        public static List <Guid> AddPupil(string legalForename, string legalSurname, Date dateOfBirth, string genderCode)
        {
            //New Instance of PupilQuery
            PupilQuery pupilQuery = new PupilQuery();

            //Security Token
            SecurityToken sessionToken = pupilQuery.Login(TestDefaults.Default.SchoolAdministrator,
                                                          TestDefaults.Default.SchoolAdministratorPassword,
                                                          TestDefaults.Default.SchoolID,
                                                          TestDefaults.Default.TenantId.ToString(CultureInfo.InvariantCulture),
                                                          Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath,
                                                          Configuration.GetSutUrl() + TestDefaults.Default.SecurityServerPath);

            //Retrieved collection of Pupil Records
            DataEntityCollectionDTO pupilCollection = pupilQuery.RetrieveEntityByNameQuery("SIMS8PupilSearchQuery", new Dictionary <string, object>(), sessionToken);

            int pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            Guid pupilID = Guid.NewGuid();

            //Retrieve collection of Genders
            DataQuery genderQuery = CreateStandardQuery("Gender", "dbo");

            genderQuery.SelectedElements = new Dictionary <string, QuerySelectionElementBase>
            {
                { "Gender.Code", new QuerySelectionField {
                      SymbolName = "Gender.Code"
                  } }
            };
            genderQuery.Filter = new AndExpression
            {
                Expressions = new List <object> {
                    new EqualsExpression
                    {
                        CurrentValue = new ParameterValue
                        {
                            SymbolName     = "Gender.Code",
                            SymbolTypeName = "iSIMS.Common.DataTypes.String"
                        },
                        TestValue = new InputParameterValue
                        {
                            SymbolName     = "GenderCode",
                            SymbolTypeName = typeof(string).FullName
                        }
                    }
                }
            };

            var parameters = new Dictionary <string, object>()
            {
                { "GenderCode", genderCode }
            };

            DataEntityCollectionDTO genderCollection = pupilQuery.RetrieveEntityByQuery(genderQuery, parameters, sessionToken);
            DataEntityDTO           gender           = genderCollection.DataEntityDtos.FirstOrDefault().Value;

            //Create the Pupil Record
            DataEntityDTO pupil = pupilQuery.CreatePupil(pupilID,
                                                         legalForename,
                                                         legalSurname,
                                                         dateOfBirth,
                                                         gender.ID,
                                                         Guid.Parse(TestDefaults.Default.SchoolID),
                                                         pupilCollectionCount,
                                                         pupilCollection.ExtensionData);

            //Add the Pupil Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, pupil);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            //Save Scope for Pupil
            List <string> pupilSaveScope = new List <string>
            {
                "Learner.ID",
                "Learner.LegalForename",
                "Learner.LegalSurname",
                "Learner.DateOfBirth",
                "Learner.Gender",
                "Learner.School"
            };

            //Save the modified collection
            pupilQuery.Save(pupilCollection, sessionToken, Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath, pupilSaveScope);

            return(new List <Guid> {
                pupilID
            });
        }
Beispiel #14
0
        public static Guid AddStandardPupilLogNote(Guid learnerID, string title, string noteText, string categoryCode, bool pinned, string userName = "******")
        {
            //New Instance of PupilQuery
            PupilQuery pupilQuery = new PupilQuery();

            //Security Token
            SecurityToken sessionToken = pupilQuery.Login(TestDefaults.Default.SchoolAdministrator,
                                                          TestDefaults.Default.SchoolAdministratorPassword,
                                                          TestDefaults.Default.SchoolID,
                                                          TestDefaults.Default.TenantId.ToString(CultureInfo.InvariantCulture),
                                                          Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath,
                                                          Configuration.GetSutUrl() + TestDefaults.Default.SecurityServerPath);

            //Retrieve collection of Pupil Log Notes
            DataQuery noteQuery = CreateStandardQuery("PupilLogNoteStandard", "dbo");

            noteQuery.SelectedElements = new Dictionary <string, QuerySelectionElementBase>
            {
                { "PupilLogNoteStandard.Title", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Title"
                  } },
                { "PupilLogNoteStandard.NoteText", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.NoteText"
                  } },
                { "PupilLogNoteStandard.Pinned", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Pinned"
                  } },
                { "PupilLogNoteStandard.CreatedOn", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.CreatedOn"
                  } },
                { "PupilLogNoteStandard.CreatedByUserId", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.CreatedByUserId"
                  } },
                { "PupilLogNoteStandard.Learner", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Learner"
                  } },
                { "PupilLogNoteStandard.PupilLogNoteCategory", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.PupilLogNoteCategory"
                  } }
            };
            noteQuery.Filter = new AndExpression {
                Expressions = new List <object>()
            };
            var parameters = new Dictionary <string, object>();
            DataEntityCollectionDTO noteCollection = pupilQuery.RetrieveEntityByQuery(noteQuery, parameters, sessionToken);

            var category      = GetNoteCategory(pupilQuery, sessionToken, categoryCode);
            var createdByUser = GetUser(pupilQuery, sessionToken, userName);
            int pupilLogNoteCollectionCount = noteCollection.DataEntityDtos.Count;

            Guid pupilLogNoteID = Guid.NewGuid();

            //Create the PupilLog Note
            DataEntityDTO pupilLogNote = pupilQuery.CreateStandardPupilLogNote(pupilLogNoteID,
                                                                               title,
                                                                               noteText,
                                                                               learnerID,
                                                                               category.ID,
                                                                               createdByUser.ID,
                                                                               pinned,
                                                                               category.ReferenceID,
                                                                               pupilLogNoteCollectionCount,
                                                                               noteCollection.ExtensionData);

            noteCollection.DataEntityDtos.Add(pupilLogNoteCollectionCount, pupilLogNote);
            noteCollection.TopLevelDtoIDs.Add(pupilLogNoteCollectionCount);

            //Save Scope for Pupil Log Note
            List <string> pupilLogNoteSaveScope = new List <string>
            {
                "PupilLogNoteStandard.ID",
                "PupilLogNoteStandard.Title",
                "PupilLogNoteStandard.NoteText",
                "PupilLogNoteStandard.Pinned",
                "PupilLogNoteStandard.CreatedOn",
                "PupilLogNoteStandard.CreatedByUserId",
                "PupilLogNoteStandard.Learner",
                "PupilLogNoteStandard.PupilLogNoteCategory"
            };

            //Save the modified collection
            pupilQuery.Save(noteCollection, sessionToken, Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath, pupilLogNoteSaveScope);

            return(pupilLogNoteID);
        }
Beispiel #15
0
        /// <summary>
        /// Add pupil data with SEN details
        /// </summary>
        /// <param name="legalForename"></param>
        /// <param name="legalSurname"></param>
        /// <param name="dateOfBirth"></param>
        /// <param name="genderCode"></param>
        /// <param name="UPN"></param>
        /// <param name="admissionno"></param>
        /// <param name="startDate"></param>
        /// <param name="senStatusCode"></param>
        /// <param name="senNeedTypeCode"></param>
        /// <param name="rank"></param>
        /// <param name="leavingDate"></param>
        /// <returns></returns>
        public static Guid AddPupilWithSEN(string legalForename, string legalSurname, string dateOfBirth, string genderCode, string shortNameYearGroup, string UPN, string admissionno, string startDate, string senStatusCode, string senNeedTypeCode, int rank, string shortNameNCYear, string enrolmentStatusCode, string leavingDate = null)
        {
            //New Instance of DataExchangeQuery
            DataExchangeQuery dataExchangeQuery = new DataExchangeQuery();

            string sql      = "SELECT id FROM school WHERE Name ='" + TestDefaults.Default.SchoolName.Replace("'", "''") + "'";
            Guid   schoolid = DataAccessHelpers.GetValue <Guid>(sql);


            //Security Token
            SecurityToken sessionToken = dataExchangeQuery.Login(TestDefaults.Default.TestUser,
                                                                 TestDefaults.Default.TestUserPassword,
                                                                 schoolid.ToString(),
                                                                 TestDefaults.Default.TenantId.ToString(CultureInfo.InvariantCulture),
                                                                 Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath,
                                                                 Configuration.GetSutUrl() + TestDefaults.Default.SecurityServerPath);

            //create collection of Pupil Records
            DataEntityCollectionDTO pupilCollection = new DataEntityCollectionDTO();

            pupilCollection.DataEntityDtos = new Dictionary <int, DataEntityDTO>();
            pupilCollection.TopLevelDtoIDs = new List <int>();

            int pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            Guid pupilID                  = Guid.NewGuid();
            Guid learnerSENStatusID       = Guid.NewGuid();
            Guid learnerSENneedTypeID     = Guid.NewGuid();
            Guid learnerEnrolmentID       = Guid.NewGuid();
            Guid learnerNCyearID          = Guid.NewGuid();
            Guid learneryearID            = Guid.NewGuid();
            Guid learnerenrolmentStatusID = Guid.NewGuid();

            //get basic details to save pupil
            DataEntityDTO gender       = getGenderDetails(genderCode, sessionToken);
            DataEntityDTO schoolncyear = getSchoolNCyearDetails(shortNameNCYear, sessionToken);

            DataEntityDTO yeargroup = getyearGroupDetails(shortNameYearGroup, sessionToken);
            Guid          yeargroupguid;

            if (yeargroup == null)
            {
                string yeargroupQuery = "SELECT TOP 1 ID FROM dbo.yeargroup WHERE school = '" + schoolid + "'";
                yeargroupguid = DataAccessHelpers.GetValue <Guid>(yeargroupQuery);
            }
            else
            {
                yeargroupguid = yeargroup.ID;
            }
            DataEntityDTO SENStatus = getSENStatusDetails(senStatusCode, sessionToken);
            DataEntityDTO needType  = getNeedTypeDetails(senNeedTypeCode, sessionToken);
            DataEntityDTO learnerEnrolmentStatus = getEnrolmentStatus(enrolmentStatusCode, sessionToken);

            //Create the Pupil Record
            DataEntityDTO pupil = dataExchangeQuery.CreatePupil(pupilID,
                                                                legalForename,
                                                                legalSurname,
                                                                dateOfBirth,
                                                                gender.ID,
                                                                yeargroupguid,
                                                                UPN,
                                                                admissionno,
                                                                schoolid,
                                                                pupilCollectionCount,
                                                                pupilCollection.ExtensionData);

            //Add the Pupil Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, pupil);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            DataEntityDTO enrolment = dataExchangeQuery.CreateLearnerEnrolment(learnerEnrolmentID,
                                                                               pupilID,
                                                                               startDate,
                                                                               leavingDate,
                                                                               schoolid,
                                                                               pupil.ReferenceID,
                                                                               pupilCollectionCount,
                                                                               pupilCollection.ExtensionData);

            //Add the enrolment Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, enrolment);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            //Add sen status and needtype as a reference property
            DataEntityDTO.ReferencePropertyDTO learnerEnrolmentProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerEnrolmentID,
                InternalReferenceID = (short?)pupilCollectionCount
            };


            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;


            DataEntityDTO learnerEnrolmentStatusEntity = dataExchangeQuery.CreateLearnerEnrolmentStatus(learnerenrolmentStatusID,
                                                                                                        learnerEnrolmentID,
                                                                                                        learnerEnrolmentStatus.ID,
                                                                                                        startDate,
                                                                                                        leavingDate,
                                                                                                        pupil.ReferenceID,
                                                                                                        pupilCollectionCount,
                                                                                                        pupilCollection.ExtensionData);

            //Add the enrolment Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, learnerEnrolmentStatusEntity);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            //Add sen status and needtype as a reference property
            DataEntityDTO.ReferencePropertyDTO learnerEnrolmentStatusProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerenrolmentStatusID,
                InternalReferenceID = (short?)pupilCollectionCount
            };


            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;


            //Create the learner year Record
            DataEntityDTO learnerYeargroup = dataExchangeQuery.CreateLearnerYearGroup(learneryearID,
                                                                                      pupilID,
                                                                                      startDate,
                                                                                      yeargroupguid,
                                                                                      pupil.ReferenceID,
                                                                                      pupilCollectionCount,
                                                                                      pupilCollection.ExtensionData);

            //Add the yeargroup Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, learnerYeargroup);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);


            DataEntityDTO.ReferencePropertyDTO learnerYearGroupProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learneryearID,
                InternalReferenceID = (short?)pupilCollectionCount
            };

            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            //Create the pupil ncyear Record
            DataEntityDTO learnerncyear = dataExchangeQuery.CreateLearnerNCYear(learnerNCyearID,
                                                                                pupilID,
                                                                                startDate,
                                                                                schoolncyear.ID,
                                                                                pupil.ReferenceID,
                                                                                pupilCollectionCount,
                                                                                pupilCollection.ExtensionData);

            //Add the nc year Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, learnerncyear);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            //Add sen status and needtype as a reference property
            DataEntityDTO.ReferencePropertyDTO learnerNCYearProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerNCyearID,
                InternalReferenceID = (short?)pupilCollectionCount
            };


            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            //Create the SENnStatus Record
            DataEntityDTO learnerSenStatus = dataExchangeQuery.CreateSENStatus(learnerSENStatusID,
                                                                               SENStatus.ID,
                                                                               startDate,
                                                                               pupilID,
                                                                               pupil.ReferenceID,
                                                                               pupilCollectionCount,
                                                                               pupilCollection.ExtensionData);

            //Add sen status and needtype as a reference property
            DataEntityDTO.ReferencePropertyDTO learnerSENStatusProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerSENStatusID,
                InternalReferenceID = (short?)pupilCollectionCount
            };

            //Add the SEN details to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, learnerSenStatus);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            //Create the SEN need type
            DataEntityDTO learnerSenNeedType = dataExchangeQuery.CreateSENSNeed(learnerSENneedTypeID,
                                                                                needType.ID,
                                                                                rank,
                                                                                startDate,
                                                                                pupilID,
                                                                                pupil.ReferenceID,
                                                                                pupilCollectionCount,
                                                                                pupilCollection.ExtensionData);

            //Add the Service Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, learnerSenNeedType);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            DataEntityDTO.ReferencePropertyDTO learnerSENSNeedProperty = new DataEntityDTO.ReferencePropertyDTO
            {
                EntityPrimaryKey    = learnerSENneedTypeID,
                InternalReferenceID = (short?)pupilCollectionCount
            };

            DataEntityDTO.ReferencePropertyDTOArray learnerSENStatus = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerSENStatusProperty
                }
            };


            DataEntityDTO.ReferencePropertyDTOArray learnerNeedType = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerSENSNeedProperty
                }
            };

            DataEntityDTO.ReferencePropertyDTOArray enrolmentReference = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerEnrolmentProperty
                }
            };

            DataEntityDTO.ReferencePropertyDTOArray enrolmentStatusReference = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerEnrolmentStatusProperty
                }
            };


            DataEntityDTO.ReferencePropertyDTOArray ncyearReference = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerNCYearProperty
                }
            };

            DataEntityDTO.ReferencePropertyDTOArray yearReference = new DataEntityDTO.ReferencePropertyDTOArray
            {
                ReferenceProperties = new List <DataEntityDTO.ReferencePropertyDTO> {
                    learnerYearGroupProperty
                }
            };

            enrolment.Values.Add("MulitpleLearnerEnrolmentStatus", enrolmentStatusReference);

            //Add references in pupil entity
            pupil.Values.Add("LearnerEnrolments", enrolmentReference);
            //pupil.Values.Add("LearnerEnrolments.MulitpleLearnerEnrolmentStatus", enrolmentStatusReference);
            pupil.Values.Add("LearnerYearGroupMemberships", yearReference);
            pupil.Values.Add("LearnerNCYearMemberships", ncyearReference);
            pupil.Values.Add("LearnerSENStatuses", learnerSENStatus);
            pupil.Values.Add("LearnerSENNeedTypes", learnerNeedType);


            //Save Scope for Pupil
            List <string> pupilSaveScope = new List <string>
            {
                "Learner.ID",
                "Learner.LegalForename",
                "Learner.LegalSurname",
                "Learner.DateOfBirth",
                "Learner.Gender",
                "Learner.School",
                "Learner.AdmissionNumber",
                "Learner.UPN",
                "Learner.YearGroup",
                "Learner.LearnerEnrolments.DOA",
                "Learner.LearnerEnrolments.DOL",
                "Learner.LearnerEnrolments.School",
                "Learner.LearnerEnrolments.Learner",
                "Learner.LearnerEnrolments.MulitpleLearnerEnrolmentStatus.EnrolmentStatus",
                "Learner.LearnerEnrolments.MulitpleLearnerEnrolmentStatus.LearnerEnrolment",
                "Learner.LearnerEnrolments.MulitpleLearnerEnrolmentStatus.StartDate",
                "Learner.LearnerEnrolments.MulitpleLearnerEnrolmentStatus.EndDate",
                "Learner.LearnerYearGroupMemberships.StartDate",
                "Learner.LearnerYearGroupMemberships.Learner",
                "Learner.LearnerYearGroupMemberships.YearGroup",
                "Learner.LearnerNCYearMemberships.StartDate",
                "Learner.LearnerNCYearMemberships.Learner",
                "Learner.LearnerNCYearMemberships.SchoolNCYear",
                "Learner.LearnerSENStatuses.StartDate",
                "Learner.LearnerSENStatuses.Learner",
                "Learner.LearnerSENStatuses.SENStatus",
                "Learner.LearnerSENNeedTypes.NeedType",
                "Learner.LearnerSENNeedTypes.StartDate",
                "Learner.LearnerSENNeedTypes.Rank",
                "Learner.LearnerSENNeedTypes.Learner"
            };

            //Save the modified collection
            dataExchangeQuery.Save(pupilCollection, sessionToken, Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath, pupilSaveScope);

            return(pupilID);
        }