/// <summary> /// SetStaffTelephone /// </summary> /// <param name="personid"></param> /// <param name="telephone"></param> /// <param name="main"></param> /// <param name="primary"></param> /// <param name="notes"></param> /// <param name="location"></param> /// <param name="device"></param> /// <returns></returns> public bool SetStaffTelephone(Int32 personid, string telephone, string main, string primary, string notes, string location, string device) { try { logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.SetStaffTelephone(personid=" + personid + ", telephone=" + telephone + ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location + ", device=" + device); var empprocess = new EditEmployee(); // Load employee\staff record empprocess.Load(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": logger.Log(LogLevel.Debug, "SetStaffTelephone Main: Yes"); phone.MainAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0) ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity; break; case "Yes (Overwrite)": logger.Log(LogLevel.Debug, "SetStaffTelephone Main: Yes (Overwrite)"); phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(1); break; case "No": logger.Log(LogLevel.Debug, "SetStaffTelephone Main: No"); phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(0); break; default: logger.Log(LogLevel.Debug, "SetStaffTelephone Main: default"); phone.MainAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0) ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity; break; } // Set Primary switch (primary) { case "Yes": logger.Log(LogLevel.Debug, "SetStaffTelephone primary: Yes"); phone.PrimaryAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0) ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity; break; case "Yes (Overwrite)": logger.Log(LogLevel.Debug, "SetStaffTelephone primary: Yes (Overwrite)"); phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(1); break; case "No": logger.Log(LogLevel.Debug, "SetStaffTelephone primary: No"); phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(0); break; default: logger.Log(LogLevel.Debug, "SetStaffTelephone primary: default"); phone.PrimaryAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0) ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity; break; } // Set the notes if (!string.IsNullOrWhiteSpace(notes)) { logger.Log(LogLevel.Debug, "SetStaffTelephone notes: " + 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 empprocess.Employee.Telephones.Add(phone); bool result = empprocess.Save(DateTime.Now); logger.Log(LogLevel.Debug, "SetStaffTelephone result: " + result); return(true); } catch (Exception SetStaffTelephone_Exception) { logger.Log(LogLevel.Error, "SetStaffTelephone " + SetStaffTelephone_Exception); return(false); } }
/// <summary> /// SetContactTelephone /// </summary> /// <param name="personid"></param> /// <param name="telephone"></param> /// <param name="main"></param> /// <param name="primary"></param> /// <param name="notes"></param> /// <param name="location"></param> /// <param name="device"></param> /// <returns></returns> public bool SetContactTelephone(Int32 personid, string telephone, string main, string primary, string notes, string location, string device) { try { logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Contacts.SetContactTelephone(personid=" + personid + ", telephone=" + telephone + ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location + ", device=" + device); var contactprocess = new EditContact(); // Load Contact record contactprocess.Populate(new PersonID(personid)); IContactRelation relation = null; relation = new StudentContact(); contactprocess.Contact.ContactRelation = relation; // Create a new Email record var phone = new Telephone(); // Set the email address phone.NumberAttribute.Value = telephone; // Set Main switch (main) { case "Yes": phone.MainAttribute.Value = (contactprocess.Contact.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 = (contactprocess.Contact.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 = (contactprocess.Contact.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 = (contactprocess.Contact.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 contactprocess.Contact.Phones.Add(phone); return(contactprocess.Save()); } catch (Exception SetContactsTelephone_Exception) { logger.Log(LogLevel.Error, "SetContactsTelephone " + SetContactsTelephone_Exception); return(false); } }
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); } }