internal static PropertyError UpdateElcRootFolderName(DefaultFolderContext context, string newName)
        {
            PropertyError result        = null;
            StoreObjectId storeObjectId = context[DefaultFolderType.ElcRoot];

            if (storeObjectId != null)
            {
                using (MapiPropertyBag mapiPropertyBag = MapiPropertyBag.CreateMapiPropertyBag(context.Session, storeObjectId))
                {
                    PropertyDefinition[] propertyDefinitions = new PropertyDefinition[]
                    {
                        FolderSchema.DisplayName
                    };
                    PropertyError[] array = mapiPropertyBag.SetProperties(propertyDefinitions, new object[]
                    {
                        newName
                    });
                    if (array.Length > 0)
                    {
                        result = array[0];
                    }
                    mapiPropertyBag.SaveChanges(false);
                    return(result);
                }
            }
            throw new ObjectNotFoundException(ServerStrings.ExDefaultFolderNotFound(DefaultFolderType.ElcRoot));
        }
Exemplo n.º 2
0
        private bool InternalLocalize(DefaultFolderData data, out PropertyError error)
        {
            error = null;
            if (data.FolderId == null)
            {
                return(false);
            }
            ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InternalLocalize. We are trying to localize the default folder. defaultFolder = {0}.", this);
            string text = this.defaultFolderInfo.LocalizableDisplayName.ToString(this.cultureInfo);

            try
            {
                using (MapiPropertyBag mapiPropertyBag = MapiPropertyBag.CreateMapiPropertyBag(this.context.Session, data.FolderId))
                {
                    object[] properties = mapiPropertyBag.GetProperties(DefaultFolder.displayNameNativePropertyDefinition);
                    if (properties.Length <= 0)
                    {
                        return(false);
                    }
                    string text2 = properties[0] as string;
                    if (text2 == null || string.Compare(text, text2, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        PropertyDefinition[] propertyDefinitions;
                        if (this.defaultFolderInfo.DefaultFolderType == DefaultFolderType.ElcRoot)
                        {
                            propertyDefinitions = DefaultFolder.elcFolderLocalizedNamePropertyDefinition;
                        }
                        else
                        {
                            propertyDefinitions = DefaultFolder.displayNamePropertyDefinition;
                        }
                        PropertyError[] array = mapiPropertyBag.SetProperties(propertyDefinitions, new object[]
                        {
                            text
                        });
                        if (array != null && array.Length > 0)
                        {
                            if (array[0].PropertyErrorCode == PropertyErrorCode.FolderNameConflict)
                            {
                                ExTraceGlobals.DefaultFoldersTracer.TraceError <string, DefaultFolderType>((long)this.GetHashCode(), "DefaultFolder::InternalLocalize. Failed to localize default folder. Folder = {0}, defaultFolderType = {1}.", this.defaultFolderInfo.LocalizableDisplayName.ToString(this.cultureInfo), this.defaultFolderInfo.DefaultFolderType);
                                throw new DefaultFolderLocalizationException(new DefaultFolderNameClashException(this.defaultFolderInfo.LocalizableDisplayName));
                            }
                            error = array[0];
                            ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder, PropertyError>((long)this.GetHashCode(), "DefaultFolder::InternalLocalize. We failed to localize default folder due to error. defaultFolder = {0}, error = {1}.", this, error);
                        }
                        mapiPropertyBag.SaveChanges(false);
                        return(true);
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InternalLocalize. The default folder was missing. Localization aborted. defaultFolder = {0}.", this);
            }
            return(false);
        }