public virtual void SynchronizeParticipants()
 {
     if (string.IsNullOrEmpty(Entity.Sender) && string.IsNullOrEmpty(Entity.Recepient))
     {
         return;
     }
     if (Entity.GetTypedColumnValue <Guid>("ActivityCategoryId") == ExchangeConsts.ActivityMeetingCategoryId)
     {
         var recepientsEmails = (List <string>)RecepientsEmails;
         Dictionary <Guid, string> contactDictionary = ContactUtilities.GetContactsByEmails(UserConnection, recepientsEmails);
         if (contactDictionary.Count > 0)
         {
             var participantRoles = ActivityUtils.GetParticipantsRoles(UserConnection);
             foreach (var contactId in contactDictionary.Keys)
             {
                 AddActivityParticipantToInsertedValues(
                     contactId,
                     new Dictionary <string, object> {
                     { "RoleId", participantRoles["Participant"] }
                 },
                     false
                     );
             }
             var insertedValues = InsertedValues as Dictionary <Guid, object>;
             if (insertedValues != null)
             {
                 UpdateContactAndAccountByParticipant(insertedValues.Keys.ToList());
             }
         }
         Entity.SetColumnValue("Sender", string.Empty);
         Entity.SetColumnValue("Recepient", string.Empty);
     }
 }
        protected virtual void FillRecepientActivityField(Activity activity, Guid recordId, string schemaName)
        {
            var    contactEsq               = new EntitySchemaQuery(UserConnection.EntitySchemaManager, schemaName);
            string contactIdName            = contactEsq.AddColumn("Contact.Id").Name;
            string emailColumnName          = contactEsq.AddColumn("Contact.Email").Name;
            string emailTitleColumnName     = contactEsq.AddColumn("ParentActivity.Title").Name;
            string emailSenderColumnName    = contactEsq.AddColumn("ParentActivity.Sender").Name;
            string emailRecipientColumnName = contactEsq.AddColumn("ParentActivity.Recepient").Name;
            string emailCcColumnName        = contactEsq.AddColumn("ParentActivity.CopyRecepient").Name;
            string emailBlindCopyColumnName = contactEsq.AddColumn("ParentActivity.BlindCopyRecepient").Name;
            var    contact = contactEsq.GetEntity(UserConnection, recordId);

            if (contact != null)
            {
                Guid contactId = contact.GetTypedColumnValue <Guid>(contactIdName);
                activity.SetColumnValue("ContactId", contactId);
                string contactEmail = contact.GetTypedColumnValue <string>(emailSenderColumnName);
                if (contactEmail.IsNullOrEmpty())
                {
                    contactEmail = contact.GetTypedColumnValue <string>(emailColumnName).IsNullOrEmpty() ?
                                   ContactUtilities.GetLastAddContactEmail(UserConnection,
                                                                           contact.GetTypedColumnValue <Guid>(contactIdName)) :
                                   contact.GetTypedColumnValue <string>(emailColumnName);
                }
                activity.SetColumnValue("Recepient", contactEmail);
                string title = contact.GetTypedColumnValue <string>(emailTitleColumnName);
                activity.SetColumnValue("Title", title);
                string recipient          = contact.GetTypedColumnValue <string>(emailRecipientColumnName);
                string copyRecipient      = contact.GetTypedColumnValue <string>(emailCcColumnName);
                string blindCopyRecipient = contact.GetTypedColumnValue <string>(emailBlindCopyColumnName);
                activity.SetColumnValue("CopyRecepient", copyRecipient);
                string recipients = recipient + ";" + copyRecipient + ";" + blindCopyRecipient;
                EmailSender = EmailSenderObtainerWrapper.GetSupportMailBox(recipients, contactId);
            }
        }
            public void PickUpContactEmail(string contactEmail, UserConnection userConnection)
            {
                ContactEmail = contactEmail;
                if (ContactEmail.IsNullOrEmpty())
                {
                    ContactEmail = ContactUtilities.GetLastAddContactEmail(userConnection, ContactId);
                }
                bool notifyOnlyContact = SystemSettings.GetValue(userConnection, "AutoNotifyOnlyContact", false);

                if (ContactEmail.IsNullOrEmpty() && !notifyOnlyContact)
                {
                    ContactEmail = ParentActivitySender;
                }
            }
 /// <summary>
 /// Retrieves <see cref="SysAdminUnit"/> identifiers list.
 /// </summary>
 /// <param name="mailbox"><see cref="MailboxSyncSettings"/> instance.</param>
 /// <returns><see cref="SysAdminUnit"/> identifiers list.</returns>
 protected virtual IEnumerable <Guid> GetMailboxOwners(Entity mailbox)
 {
     return(ContactUtilities.GetUsersByEmails(UserConnection, new List <string> {
         mailbox.GetTypedColumnValue <string>("SenderEmailAddress")
     }).Select(kvp => kvp.Key));
 }
 /// <summary>
 /// Retrieves contacts list containing list of <paramref name="emails"/>.
 /// </summary>
 /// <param name="userConnection">A instance of the current user connection.</param>
 /// <param name="emails"> A list of email addresses.</param>
 /// <returns>List of contacts.</returns>
 protected virtual Dictionary <Guid, string> GetContactsByEmails(UserConnection userConnection, List <string> emails)
 {
     return(ContactUtilities.GetContactsByEmails(userConnection, emails.Where(e => !e.IsNullOrEmpty()).ToList()));
 }
        public virtual IContactFieldConverter GetContactConverter()
        {
            IContactFieldConverter converter = ContactUtilities.GetContactConverter(UserConnection);

            return(converter);
        }