Пример #1
0
 private void EnumSingleFolder(FolderRecWrapper folderRec, FolderMap.EnumFolderContext ctx, FolderMap.EnumFolderCallback callback, EnumHierarchyFlags flags)
 {
     ctx.Result = EnumHierarchyResult.Continue;
     if (folderRec.IsSpoolerQueue)
     {
         return;
     }
     if (FolderMap.IsValidFolderType(flags, folderRec))
     {
         callback(folderRec, ctx);
     }
     if (ctx.Result == EnumHierarchyResult.Cancel || ctx.Result == EnumHierarchyResult.SkipSubtree)
     {
         return;
     }
     if (folderRec.Children != null)
     {
         foreach (FolderRecWrapper folderRec2 in folderRec.Children)
         {
             ctx.Result = EnumHierarchyResult.Continue;
             this.EnumSingleFolder(folderRec2, ctx, callback, flags);
             if (ctx.Result == EnumHierarchyResult.Cancel)
             {
                 break;
             }
         }
     }
 }
Пример #2
0
        public override bool ShouldCreateFolder(FolderMap.EnumFolderContext context, FolderRecWrapper sourceFolderRecWrapper)
        {
            FolderMapping folderMapping      = sourceFolderRecWrapper as FolderMapping;
            Guid          contentMailboxGuid = this.GetContentMailboxGuid(sourceFolderRecWrapper);
            bool          isRoot             = base.IsRoot;
            bool          flag = contentMailboxGuid == base.TargetMailboxGuid;

            if (!isRoot && !flag && (!this.ShouldCreateUnderParentInSecondary() || !this.DoesAnySubFolderResideInTargetMailbox(sourceFolderRecWrapper)))
            {
                MrsTracer.Service.Debug("Not creating folder \"{0}\" in mailbox {1}. This is neither the primary hierarchy mailbox nor the content mailbox of this folder or any of its subfolders.", new object[]
                {
                    sourceFolderRecWrapper.FullFolderName,
                    base.TargetMailboxGuid
                });
                return(false);
            }
            switch (folderMapping.WKFType)
            {
            case WellKnownFolderType.Root:
            case WellKnownFolderType.NonIpmSubtree:
            case WellKnownFolderType.IpmSubtree:
            case WellKnownFolderType.EFormsRegistry:
                return(false);

            default:
                if (folderMapping.IsLegacyPublicFolder)
                {
                    context.Result = EnumHierarchyResult.SkipSubtree;
                    return(false);
                }
                return(true);
            }
        }
Пример #3
0
 public override void EnumerateSubtree(EnumHierarchyFlags flags, FolderRecWrapper root, FolderMap.EnumFolderCallback callback)
 {
     FolderMap.EnumFolderContext enumFolderContext = new FolderMap.EnumFolderContext();
     enumFolderContext.Result = EnumHierarchyResult.Continue;
     foreach (KeyValuePair <byte[], FolderRecWrapper> keyValuePair in this.folders)
     {
         callback(keyValuePair.Value, enumFolderContext);
     }
 }
Пример #4
0
        public override void CreateFolder(FolderMap.EnumFolderContext context, FolderRecWrapper sourceFolderRecWrapper, CreateFolderFlags createFolderFlags, out byte[] newFolderEntryId)
        {
            if (sourceFolderRecWrapper.IsInternalAccess)
            {
                throw new InternalAccessFolderCreationIsNotSupportedException();
            }
            newFolderEntryId = null;
            FolderMapping   folderMapping   = sourceFolderRecWrapper as FolderMapping;
            FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy;

            byte[]        sessionSpecificEntryId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.EntryId);
            FolderMapping folderMapping2         = folderMapping.Parent as FolderMapping;
            bool          isRoot = base.IsRoot;

            byte[] parentId;
            switch (folderMapping2.WKFType)
            {
            case WellKnownFolderType.Root:
            case WellKnownFolderType.NonIpmSubtree:
            case WellKnownFolderType.IpmSubtree:
            case WellKnownFolderType.EFormsRegistry:
                parentId = folderHierarchy.GetWellKnownFolder(folderMapping2.WKFType).EntryId;
                break;

            default:
                if (isRoot || this.ShouldCreateUnderParentInSecondary())
                {
                    parentId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.ParentId);
                }
                else
                {
                    parentId = folderHierarchy.GetWellKnownFolder(WellKnownFolderType.IpmSubtree).EntryId;
                }
                break;
            }
            byte[] entryId   = folderMapping.FolderRec.EntryId;
            byte[] parentId2 = folderMapping.FolderRec.ParentId;
            folderMapping.FolderRec.EntryId  = sessionSpecificEntryId;
            folderMapping.FolderRec.ParentId = parentId;
            base.DestMailbox.CreateFolder(folderMapping.FolderRec, createFolderFlags, out newFolderEntryId);
            folderMapping.FolderRec.EntryId  = entryId;
            folderMapping.FolderRec.ParentId = parentId2;
            List <PropValueData> list           = new List <PropValueData>(2);
            Guid contentMailboxGuid             = this.GetContentMailboxGuid(sourceFolderRecWrapper);
            StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;

            byte[] bytesFromStringArray = ReplicaListProperty.GetBytesFromStringArray(new string[]
            {
                contentMailboxGuid.ToString()
            });
            list.Add(new PropValueData(PropTag.ReplicaList, bytesFromStringArray));
            using (IDestinationFolder folder = base.DestMailbox.GetFolder(sessionSpecificEntryId))
            {
                if (folder == null)
                {
                    MrsTracer.Service.Error("Something deleted destination folder from under us", new object[0]);
                    throw new UnexpectedErrorPermanentException(-2147221238);
                }
                if (isRoot && !this.AssociatedDumpsterExists(folder))
                {
                    byte[] value = this.CreateAssociatedDumpsterFolder(folderMapping.FolderName, bytesFromStringArray, sessionSpecificEntryId);
                    list.Add(new PropValueData(PropTag.IpmWasteBasketEntryId, value));
                }
                folder.SetProps(list.ToArray());
            }
        }
Пример #5
0
 public virtual void EnumerateSubtree(EnumHierarchyFlags flags, FolderRecWrapper root, FolderMap.EnumFolderCallback callback)
 {
     FolderMap.EnumFolderContext ctx = new FolderMap.EnumFolderContext();
     this.EnumSingleFolder(root, ctx, callback, flags);
 }