private static void PopulateEmail(Email[] emails, ITracingService trace, FieldService fieldService) { if (emails == null || emails.Length <= 0) { return; } if (fieldService == null) { return; } trace.Trace("Contact populate email - start"); var email1 = emails[0]; var email2 = emails.Length > 1 ? emails[1] : null; var email3 = emails.Length > 2 ? emails[2] : null; if (email1 != null) { fieldService.PopulateField(Attributes.Contact.EmailAddress1Type, CommonXrm.GetEmailType(email1.EmailType)); fieldService.PopulateField(Attributes.Contact.EmailAddress1, email1.Address); } if (email2 != null) { fieldService.PopulateField(Attributes.Contact.EmailAddress2Type, CommonXrm.GetEmailType(email2.EmailType)); fieldService.PopulateField(Attributes.Contact.EmailAddress2, email2.Address); } if (email3 != null) { fieldService.PopulateField(Attributes.Contact.EmailAddress3Type, CommonXrm.GetEmailType(email3.EmailType)); fieldService.PopulateField(Attributes.Contact.EmailAddress3, email3.Address); } trace.Trace("Contact populate email - end"); }
private static void PopulateEmail(Entity contact, Email[] emails, ITracingService trace) { if (emails == null || emails.Length <= 0) { return; } trace.Trace("Contact populate email - start"); var email1 = emails[0]; var email2 = emails.Length > 1 ? emails[1] : null; var email3 = emails.Length > 2 ? emails[2] : null; if (email1 != null) { contact[Attributes.Contact.EmailAddress1Type] = CommonXrm.GetEmailType(email1.EmailType); contact[Attributes.Contact.EmailAddress1] = (!string.IsNullOrWhiteSpace(email1.Address)) ? email1.Address : string.Empty; } if (email2 != null) { contact[Attributes.Contact.EmailAddress2Type] = CommonXrm.GetEmailType(email2.EmailType); contact[Attributes.Contact.EmailAddress2] = (!string.IsNullOrWhiteSpace(email2.Address)) ? email2.Address : string.Empty; } if (email3 != null) { contact[Attributes.Contact.EmailAddress3Type] = CommonXrm.GetEmailType(email3.EmailType); contact[Attributes.Contact.EmailAddress3] = (!string.IsNullOrWhiteSpace(email3.Address)) ? email3.Address : string.Empty; } trace.Trace("Contact populate email - end"); }
private static void PopulateEmail(Email[] emailList, ITracingService trace, FieldService fieldService) { if (fieldService == null) { return; } trace.Trace("Account populate email - start"); var email1 = emailList[0]; var email2 = emailList.Length > 1 ? emailList[1] : null; var email3 = emailList.Length > 2 ? emailList[2] : null; if (email1 != null) { trace.Trace(email1.EmailType.ToString()); trace.Trace(CommonXrm.GetEmailType(email1.EmailType).Value.ToString()); fieldService.PopulateField(Attributes.Account.EmailAddress1Type, CommonXrm.GetEmailType(email1.EmailType)); fieldService.PopulateField(Attributes.Account.EmailAddress1, email1.Address); } if (email2 != null) { trace.Trace(email2.EmailType.ToString()); trace.Trace(CommonXrm.GetEmailType(email2.EmailType).Value.ToString()); fieldService.PopulateField(Attributes.Account.EmailAddress2Type, CommonXrm.GetEmailType(email2.EmailType)); fieldService.PopulateField(Attributes.Account.EmailAddress2, email2.Address); } if (email3 != null) { trace.Trace(email3.EmailType.ToString()); trace.Trace(CommonXrm.GetEmailType(email3.EmailType).Value.ToString()); fieldService.PopulateField(Attributes.Account.EmailAddress3Type, CommonXrm.GetEmailType(email3.EmailType)); fieldService.PopulateField(Attributes.Account.EmailAddress3, email3.Address); } trace.Trace("Account populate email - end"); }
public static void PopulateEmail(Entity account, Email[] emailList, ITracingService trace) { if (trace == null) { throw new InvalidPluginExecutionException("Tracing service is null;"); } trace.Trace("Account populate email - start"); if (account == null) { throw new InvalidPluginExecutionException("Account entity is null;"); } if (emailList == null || emailList.Length == 0) { ClearEmailList(account); return; } var email1 = emailList[0]; var email2 = emailList.Length > 1 ? emailList[1] : ClearEmail2(account); var email3 = emailList.Length > 2 ? emailList[2] : ClearEmail3(account); trace.Trace("email 1"); if (email1 == null) { return; } account[Attributes.Account.EmailAddress1] = (!string.IsNullOrWhiteSpace(email1.Address)) ? email1.Address : string.Empty; account[Attributes.Account.EmailAddress1Type] = CommonXrm.GetEmailType(email1.EmailType); trace.Trace("email 2"); if (email2 == null) { return; } account[Attributes.Account.EmailAddress2] = (!string.IsNullOrWhiteSpace(email2.Address)) ? email2.Address : string.Empty; account[Attributes.Account.EmailAddress2Type] = CommonXrm.GetEmailType(email2.EmailType); trace.Trace("email 3"); if (email3 == null) { return; } account[Attributes.Account.EmailAddress3] = (!string.IsNullOrWhiteSpace(email3.Address)) ? email3.Address : string.Empty; account[Attributes.Account.EmailAddress3Type] = CommonXrm.GetEmailType(email3.EmailType); trace.Trace("Account populate email - end"); }
private static void PopulateEmail(Entity contact, Email[] emails, ITracingService trace) { trace.Trace("Contact populate email - start"); if (trace == null) { throw new InvalidPluginExecutionException("Tracing service is null;"); } if (emails == null || emails.Length == 0) { ClearEmailList(contact); return; } var email1 = emails[0]; var email2 = emails.Length > 1 ? emails[1] : ClearEmail2(contact); var email3 = emails.Length > 2 ? emails[2] : ClearEmail3(contact); if (email1 == null) { return; } trace.Trace("email 1"); contact[Attributes.Contact.EmailAddress1] = (!string.IsNullOrWhiteSpace(email1.Address)) ? email1.Address : string.Empty; contact[Attributes.Contact.EmailAddress1Type] = CommonXrm.GetEmailType(email1.EmailType); if (email2 == null) { return; } trace.Trace("email 2"); contact[Attributes.Contact.EmailAddress2] = (!string.IsNullOrWhiteSpace(email2.Address)) ? email2.Address:string.Empty; contact[Attributes.Contact.EmailAddress2Type] = CommonXrm.GetEmailType(email2.EmailType); trace.Trace("email 3"); if (email3 == null) { return; } contact[Attributes.Contact.EmailAddress3] = (!string.IsNullOrWhiteSpace(email3.Address)) ? email3.Address:string.Empty; contact[Attributes.Contact.EmailAddress3Type] = CommonXrm.GetEmailType(email3.EmailType); trace.Trace("Contact populate email - end"); }