private static void PopulatePhone(Phone[] phoneList, ITracingService trace, FieldService fieldService) { if (phoneList == null || phoneList.Length <= 0) { return; } if (fieldService == null) { return; } trace.Trace("Contact populate phone - start"); var phone1 = phoneList[0]; var phone2 = phoneList.Length > 1 ? phoneList[1] : null; var phone3 = phoneList.Length > 2 ? phoneList[2] : null; if (phone1 != null) { fieldService.PopulateField(Attributes.Contact.Telephone1Type, CommonXrm.GetPhoneType(phone1.PhoneType)); fieldService.PopulateField(Attributes.Contact.Telephone1, phone1.Number); } if (phone2 != null) { fieldService.PopulateField(Attributes.Contact.Telephone2Type, CommonXrm.GetPhoneType(phone2.PhoneType)); fieldService.PopulateField(Attributes.Contact.Telephone2, phone2.Number); } if (phone3 != null) { fieldService.PopulateField(Attributes.Contact.Telephone3Type, CommonXrm.GetPhoneType(phone3.PhoneType)); fieldService.PopulateField(Attributes.Contact.Telephone3, phone3.Number); } trace.Trace("Contact populate phone - end"); }
private static void PopulatePhone(Entity contact, Phone[] phoneNumbers, ITracingService trace) { if (phoneNumbers == null || phoneNumbers.Length <= 0) { return; } trace.Trace("Contact populate phone - start"); var phone1 = phoneNumbers[0]; var phone2 = phoneNumbers.Length > 1 ? phoneNumbers[1] : null; var phone3 = phoneNumbers.Length > 2 ? phoneNumbers[2] : null; if (phone1 != null) { contact[Attributes.Contact.Telephone1Type] = CommonXrm.GetPhoneType(phone1.PhoneType); contact[Attributes.Contact.Telephone1] = (!string.IsNullOrWhiteSpace(phone1.Number)) ? phone1.Number : string.Empty; } if (phone2 != null) { contact[Attributes.Contact.Telephone2Type] = CommonXrm.GetPhoneType(phone2.PhoneType); contact[Attributes.Contact.Telephone2] = (!string.IsNullOrWhiteSpace(phone2.Number)) ? phone2.Number : string.Empty; } if (phone3 != null) { contact[Attributes.Contact.Telephone3Type] = CommonXrm.GetPhoneType(phone3.PhoneType); contact[Attributes.Contact.Telephone3] = (!string.IsNullOrWhiteSpace(phone3.Number)) ? phone3.Number : string.Empty; } trace.Trace("Contact populate phone - end"); }
public static void PopulatePhone(Entity account, Phone[] phoneList, ITracingService trace) { if (trace == null) { throw new InvalidPluginExecutionException("Tracing service is null;"); } trace.Trace("Account populate phone - start"); if (account == null) { throw new InvalidPluginExecutionException("Account entity is null;"); } if (phoneList == null || phoneList.Length == 0) { ClearPhoneList(account); return; } var phone1 = phoneList[0]; var phone2 = phoneList.Length > 1 ? phoneList[1] : ClearPhone2(account); var phone3 = phoneList.Length > 2 ? phoneList[2] : ClearPhone3(account); trace.Trace("phone 1"); if (phone1 == null) { return; } account[Attributes.Account.Telephone1Type] = CommonXrm.GetPhoneType(phone1.PhoneType); account[Attributes.Account.Telephone1] = (!string.IsNullOrWhiteSpace(phone1.Number)) ? phone1.Number : string.Empty; trace.Trace("phone 2"); if (phone2 == null) { return; } account[Attributes.Account.Telephone2Type] = CommonXrm.GetPhoneType(phone2.PhoneType); account[Attributes.Account.Telephone2] = (!string.IsNullOrWhiteSpace(phone2.Number)) ? phone2.Number : string.Empty; trace.Trace("phone 3"); if (phone3 == null) { return; } account[Attributes.Account.Telephone3Type] = CommonXrm.GetPhoneType(phone2.PhoneType); account[Attributes.Account.Telephone3] = (!string.IsNullOrWhiteSpace(phone3.Number)) ? phone3.Number : string.Empty; trace.Trace("Account populate phone - end"); }
private static void PopulatePhone(Entity contact, Phone[] phoneNumbers, ITracingService trace) { trace.Trace("Contact populate phone - start"); if (trace == null) { throw new InvalidPluginExecutionException("Tracing service is null;"); } if (contact == null) { throw new InvalidPluginExecutionException("Populate Phone: contact entity is null."); } if (phoneNumbers == null || phoneNumbers.Length == 0) { ClearPhoneList(contact); return; } ; var phone1 = phoneNumbers[0]; var phone2 = phoneNumbers.Length > 1 ? phoneNumbers[1] : ClearPhone2(contact); var phone3 = phoneNumbers.Length > 2 ? phoneNumbers[2] : ClearPhone3(contact); trace.Trace("phone 1"); if (phone1 == null) { return; } contact[Attributes.Contact.Telephone1Type] = CommonXrm.GetPhoneType(phone1.PhoneType); contact[Attributes.Contact.Telephone1] = (!string.IsNullOrWhiteSpace(phone1.Number)) ? phone1.Number:string.Empty; trace.Trace("phone 2"); if (phone2 == null) { return; } contact[Attributes.Contact.Telephone2Type] = CommonXrm.GetPhoneType(phone2.PhoneType); contact[Attributes.Contact.Telephone2] = (!string.IsNullOrWhiteSpace(phone2.Number)) ? phone2.Number : string.Empty; trace.Trace("phone 3"); if (phone3 == null) { return; } contact[Attributes.Contact.Telephone3Type] = CommonXrm.GetPhoneType(phone3.PhoneType); contact[Attributes.Contact.Telephone3] = (!string.IsNullOrWhiteSpace(phone3.Number)) ? phone3.Number : string.Empty; trace.Trace("Contact populate phone - end"); }