예제 #1
0
        public Task <IDistListItemWrapper> Map2To1(vCard source, IDistListItemWrapper target, IEntityMappingLogger logger, DistributionListSychronizationContext context)
        {
            if (string.IsNullOrEmpty(source.FormattedName))
            {
                var name = new StringBuilder();
                name.Append(source.FamilyName);
                if (!string.IsNullOrEmpty(source.GivenName))
                {
                    if (name.Length > 0)
                    {
                        name.Append(",");
                    }
                    name.Append(source.GivenName);
                }
                if (!string.IsNullOrEmpty(source.AdditionalNames))
                {
                    if (name.Length > 0)
                    {
                        name.Append(",");
                    }
                    name.Append(source.AdditionalNames);
                }
                if (name.Length > 0)
                {
                    target.Inner.DLName = name.ToString();
                }
            }
            else
            {
                target.Inner.DLName = source.FormattedName;
            }

            target.Inner.Sensitivity = CommonEntityMapper.MapPrivacy2To1(source.AccessClassification);

            if (source.Categories.Count > 0)
            {
                string[] categories = new string[source.Categories.Count];
                source.Categories.CopyTo(categories, 0);
                target.Inner.Categories = string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, categories);
            }
            else
            {
                target.Inner.Categories = string.Empty;
            }

            if (source.Notes.Count > 0)
            {
                target.Inner.Body = source.Notes[0].Text;
            }
            else
            {
                target.Inner.Body = string.Empty;
            }

            CommonEntityMapper.MapDistListMembers2To1(GetMembers(source, context, logger, s_logger), target, logger, context);

            return(Task.FromResult(target));
        }
예제 #2
0
        public Task <IDistListItemWrapper> Map2To1(DistributionList source, IDistListItemWrapper target, IEntityMappingLogger logger, DistributionListSychronizationContext context)
        {
            target.Inner.DLName = source.Name;
            if (!string.IsNullOrEmpty(source.Description))
            {
                target.Inner.Body = source.Description;
            }

            try
            {
                using (var userPropertiesWrapper = GenericComObjectWrapper.Create(target.Inner.UserProperties))
                {
                    using (var userProperty = GenericComObjectWrapper.Create(userPropertiesWrapper.Inner.Find("NICKNAME")))
                    {
                        if (userProperty.Inner != null)
                        {
                            userProperty.Inner.Value = source.Nickname;
                        }
                        else if (!string.IsNullOrEmpty(source.Nickname))
                        {
                            using (var newUserProperty = GenericComObjectWrapper.Create(userPropertiesWrapper.Inner.Add("NICKNAME", OlUserPropertyType.olText, true)))
                            {
                                newUserProperty.Inner.Value = source.Nickname;
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                s_logger.Warn("Can't access UserProperty of Distribution List!", ex);
                logger.LogMappingWarning("Can't access UserProperty of Distribution List!", ex);
            }

            CommonEntityMapper.MapDistListMembers2To1(source.Members.Concat(source.NonAddressBookMembers), target, logger, context);
            return(Task.FromResult(target));
        }