Exemplo n.º 1
0
        public string GetPupilUsername(int personid, string udf)
        {
            try
            {
                var studentsedt          = new EditStudentInformationReadOnly();
                StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);

                foreach (UDFValue udfVal in studentsedt.Student.UDFValues)
                {
                    if (udfVal.FieldTypeCode == UDFFieldType.STRING1_CODE)
                    {
                        if (udfVal.TypedValueAttribute.Description == udf)
                        {
                            return(((StringAttribute)udfVal.TypedValueAttribute).Value);
                        }
                    }
                }
                studentsedt.Dispose();
            }
            catch (Exception GetStudentUdfException)
            {
                logger.Log(LogLevel.Error, GetStudentUdfException);
            }
            return(null);
        }
Exemplo n.º 2
0
 public string GetPupilAdmissionDate(Int32 personid)
 {
     try
     {
         var studentsedt          = new EditStudentInformationReadOnly();
         StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);
         return(studentsedt.Student.DateOfAdmission.ToString());
     }
     catch (Exception GetPupilAdmis_Exception)
     {
         logger.Log(LogLevel.Error, GetPupilAdmis_Exception);
     }
     return(null);
 }
Exemplo n.º 3
0
 public string GetPupilRegistration(Int32 personid)
 {
     try
     {
         var studentsedt          = new EditStudentInformationReadOnly();
         StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);
         return(studentsedt.Student.RegGroup.Description);
     }
     catch (Exception GetPupilReg_Exception)
     {
         logger.Log(LogLevel.Error, GetPupilReg_Exception);
     }
     return(null);
 }
Exemplo n.º 4
0
        public string GetPupilEmail(Int32 personid)
        {
            string result = "";

            try
            {
                var studentsedt          = new EditStudentInformationReadOnly();
                StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);
                if (studentsedt.Student.Communication.Emails.Value.Count > 0)
                {
                    logger.Log(LogLevel.Debug, " - eMail: " + studentsedt.Student.Communication.Emails.Value.Count);

                    int    workcount      = 1;
                    string emailaddresses = null;

                    foreach (EMail item in studentsedt.Student.Communication.Emails.Value)
                    {
                        //int location = item.Location.ID;
                        //if (location == emailLocationId)

                        if (workcount == 1)
                        {
                            emailaddresses = item.Address.ToLower();
                        }
                        else
                        {
                            emailaddresses = emailaddresses + "," + item.Address.ToLower();
                        }
                        workcount = workcount + 1;
                    }
                    if (string.IsNullOrEmpty(emailaddresses))
                    {
                        return("<NO TYPE EMAILS>");
                    }
                    return(emailaddresses);
                }
                return("<BLANK>");
            }
            catch (Exception GetPupilEmail_Exception)
            {
                logger.Log(LogLevel.Info, GetPupilEmail_Exception);
            }
            return(result);
        }
Exemplo n.º 5
0
        public string GetPupilTelephone(Int32 personid)
        {
            string result = "";

            try
            {
                var studentsedt          = new EditStudentInformationReadOnly();
                StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);
                if (studentsedt.Student.Communication.Phones.Value.Count > 0)
                {
                    logger.Log(LogLevel.Debug, " - telephone: " + studentsedt.Student.Communication.Phones.Value.Count);

                    int    workcount = 1;
                    string telephone = null;

                    foreach (Telephone item in studentsedt.Student.Communication.Phones.Value)
                    {
                        //int location = item.Location.ID;
                        //if (location == telephoneLocationId)
                        if (workcount == 1)
                        {
                            telephone = item.Number.ToLower();
                        }
                        else
                        {
                            telephone = telephone + "," + item.Number.ToLower();
                        }
                        workcount = workcount + 1;
                    }
                    if (string.IsNullOrEmpty(telephone))
                    {
                        return("<NO TYPE TELEPHONE>");
                    }
                    return(telephone);
                }
                return("<NO TELEPHONE>");
            }
            catch (Exception GetPupilEmail_Exception)
            {
                logger.Log(LogLevel.Info, GetPupilEmail_Exception);
            }
            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Writes the Pupil UDF to SIMS .net (string)
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="udfvalue"></param>
        /// <returns></returns>
        public bool SetPupilUDF(int personid, string udfvalue)
        {
            logger.Log(LogLevel.Debug, "SIMSAPI-SetPupilUDF - personid: " + personid + " - udfvalue: " + udfvalue);
            bool result = false;

            try
            {
                //logger.Log(NLog.LogLevel.Info, "PersonId: " + personid + " - UDF: " + udfvalue);
                using (EditStudentInformation studentsedt = new EditStudentInformation())
                {
                    StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);
                    foreach (UDFValue udfVal in studentsedt.Student.UDFValues)
                    {
                        //logger.Log(NLog.LogLevel.Debug, "Checkpoint1");
                        if (simsudf == udfVal.TypedValueAttribute.Description)
                        {
                            if (Core.SetUdf(udfVal, udfvalue))
                            {
                                studentsedt.Save();
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                logger.Error("UDF {0} not found.", simsudf);
                return(false);
            }
            catch (Exception SetPupilUDF_Exception)
            {
                logger.Log(LogLevel.Error, SetPupilUDF_Exception);
                result = false;
            }

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Writes a new Pupil email address into the SIMS database
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="emailValue"></param>
        /// <param name="main"></param>
        /// <param name="primary"></param>
        /// <param name="notes"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public bool SetPupilEmail(Int32 personid, string emailValue, string main, string primary, string notes, string location)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Pupils.SetPupilEmail(personid=" + personid + ", emailValue=" + emailValue +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location);
                var studentsedt = new EditStudentInformation();

                // Load Pupil\Student record
                StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);

                // Create a new email record
                var email = new EMail();

                // Set the email address
                email.AddressAttribute.Value = emailValue;

                // Set Main
                switch (main)
                {
                case "Yes":
                    email.MainAttribute.Value = (studentsedt.Student.Communication.Emails.Value.Count > 0)
                            ? EMailMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    email.MainAttribute.Value = EMailMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    email.MainAttribute.Value = EMailMainCollection.GetValues().Item(0);
                    break;

                default:
                    email.MainAttribute.Value = (studentsedt.Student.Communication.Emails.Value.Count > 0)
                            ? EMailMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set Primary
                switch (primary)
                {
                case "Yes":
                    email.PrimaryAttribute.Value = (studentsedt.Student.Communication.Emails.Value.Count > 0)
                            ? EMailPrimaryCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailPrimaryCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    email.PrimaryAttribute.Value = EMailPrimaryCollection.GetValues().Item(1);
                    break;

                case "No":
                    email.PrimaryAttribute.Value = EMailPrimaryCollection.GetValues().Item(0);
                    break;

                default:
                    email.PrimaryAttribute.Value = (studentsedt.Student.Communication.Emails.Value.Count > 0)
                            ? EMailPrimaryCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailPrimaryCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set the notes
                if (!string.IsNullOrWhiteSpace(notes))
                {
                    email.NotesAttribute.Value = notes;
                }

                // Set the location
                email.LocationAttribute.Value = PersonCache.EmailLocations.ItemByDescription(location);

                // Run Validation against the new record
                email.Validate();
                logger.Log(LogLevel.Debug, "Email Valid: " + email.Valid());

                // Save the new record to the database
                studentsedt.Student.Communication.Emails.Add(email);
                StudentEditResult result = studentsedt.Save();
                switch (result)
                {
                case StudentEditResult.Success:
                    return(true);

                case StudentEditResult.DuplicateFound:
                    logger.Log(LogLevel.Error, "DuplicateFound");
                    return(false);

                case StudentEditResult.Failure:
                    logger.Log(LogLevel.Error, "Failure");
                    return(false);

                case StudentEditResult.Unknown:
                    logger.Log(LogLevel.Error, "Unknown");
                    return(false);

                default:
                    logger.Log(LogLevel.Error, "default");
                    return(false);
                }
            }
            catch (Exception SetStudentEmailException)
            {
                logger.Log(LogLevel.Error, SetStudentEmailException);
                return(false);
            }
        }
Exemplo n.º 8
0
        public bool SetPupilTelephone(Int32 personid, string telephone, string main, string primary, string notes, string location, string device)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Pupils.SetPupilTelephone(personid=" + personid + ", telephone=" + telephone +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location + ", device=" + device);
                var studentsedt = new EditStudentInformation();

                // Load Pupil\Student record
                StudentEditResult status = studentsedt.Load(new Person(personid), DateTime.Now);

                // Create a new telephone number
                var phone = new Telephone();

                // Set the telephone number
                phone.NumberAttribute.Value = telephone;

                // Set Main
                switch (main)
                {
                case "Yes":
                    phone.MainAttribute.Value = (studentsedt.Student.Communication.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    phone.MainAttribute.Value = (studentsedt.Student.Communication.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set primary
                switch (primary)
                {
                case "Yes":
                    phone.PrimaryAttribute.Value = (studentsedt.Student.Communication.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    phone.PrimaryAttribute.Value = (studentsedt.Student.Communication.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set the notes
                if (!string.IsNullOrWhiteSpace(notes))
                {
                    phone.NotesAttribute.Value = notes;
                }

                // Set the location
                phone.LocationAttribute.Value = PersonCache.TelephoneLocations.ItemByDescription(location);

                // Set the device (telephone\fax)
                phone.DeviceAttribute.Value = PersonCache.TelephoneDevices.ItemByDescription(device);

                // Run Validation against the new record
                phone.Validate();
                logger.Log(LogLevel.Debug, "Telephone Valid: " + phone.Valid());

                // Writes the new record to the database
                studentsedt.Student.Communication.Phones.Add(phone);
                StudentEditResult result = studentsedt.Save();
                switch (result)
                {
                case StudentEditResult.Success:
                    return(true);

                case StudentEditResult.DuplicateFound:
                    logger.Log(LogLevel.Error, "DuplicateFound");
                    return(false);

                case StudentEditResult.Failure:
                    logger.Log(LogLevel.Error, "Failure");
                    return(false);

                case StudentEditResult.Unknown:
                    logger.Log(LogLevel.Error, "Unknown");
                    return(false);

                default:
                    logger.Log(LogLevel.Error, "default");
                    return(false);
                }
            }
            catch (Exception SetPupilTelephone_Exception)
            {
                logger.Log(LogLevel.Error, "SetPupilTelephone " + SetPupilTelephone_Exception);
                return(false);
            }
        }