Example #1
0
 protected void GetExtendedProps(FolderRec folderRec, GetFolderRecFlags flags)
 {
     MrsTracer.Provider.Function("MapiFolder.GetExtendedProps", new object[0]);
     if ((flags & GetFolderRecFlags.PromotedProperties) != GetFolderRecFlags.None)
     {
         PropValue prop;
         using (this.Mailbox.RHTracker.Start())
         {
             prop = this.Folder.GetProp(PropTag.PromotedProperties);
         }
         if (!prop.IsNull() && !prop.IsError())
         {
             PropTag[] array = PropTagHelper.PropTagArray(prop.GetBytes());
             folderRec.SetPromotedProperties(array);
             MrsTracer.Provider.Debug("Found {0} promoted properties.", new object[]
             {
                 array.Length
             });
         }
         else
         {
             folderRec.SetPromotedProperties(null);
             MrsTracer.Provider.Debug("Source server does not support promoted property retrieval.", new object[0]);
         }
     }
     if ((flags & (GetFolderRecFlags.Views | GetFolderRecFlags.Restrictions)) != GetFolderRecFlags.None)
     {
         this.Mailbox.GetFolderViewsOrRestrictions(folderRec, flags, this.FolderId);
     }
 }
Example #2
0
 FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
 {
     if (this.folderRec != null)
     {
         return(this.folderRec);
     }
     PropTag[] pta;
     if (additionalPtagsToLoad != null)
     {
         List <PropTag> list = new List <PropTag>();
         list.AddRange(FolderRec.PtagsToLoad);
         list.AddRange(additionalPtagsToLoad);
         pta = list.ToArray();
     }
     else
     {
         pta = FolderRec.PtagsToLoad;
     }
     PropertyValue[] momtPva = null;
     try
     {
         momtPva = this.folder.GetProps(PstMailbox.MoMTPtaFromPta(pta));
     }
     catch (PSTIOException innerException)
     {
         throw new UnableToGetPSTFolderPropsTransientException(BitConverter.ToUInt32(this.folderId, 0), innerException);
     }
     catch (PSTExceptionBase innerException2)
     {
         uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(this.folder.PstMailbox.IPst.MessageStore.Guid, this.folderId);
         throw new UnableToGetPSTFolderPropsPermanentException(nodeIdFromEntryId, innerException2);
     }
     this.folderRec = FolderRec.Create(PstMailbox.PvaFromMoMTPva(momtPva));
     return(this.folderRec);
 }
Example #3
0
        FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
        {
            FolderRec result = null;

            base.CreateContext("IFolder.GetFolderRec", new DataContext[]
            {
                new PropTagsDataContext(additionalPtagsToLoad),
                new SimpleValueDataContext("Flags", flags)
            }).Execute(delegate
            {
                result = this.WrappedObject.GetFolderRec(additionalPtagsToLoad, flags);
            }, true);
            return(result);
        }
Example #4
0
        FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
        {
            if (!base.ServerVersion[15])
            {
                return(base.MrsProxy.IFolder_GetFolderRec2(base.Handle, DataConverter <PropTagConverter, PropTag, int> .GetData(additionalPtagsToLoad)));
            }
            FolderRec folderRec = base.MrsProxy.IFolder_GetFolderRec3(base.Handle, DataConverter <PropTagConverter, PropTag, int> .GetData(additionalPtagsToLoad), (int)flags);

            this.FolderName = folderRec.FolderName;
            MrsTracer.ProxyClient.Function("IFolder.GetFolderRec(): {0}", new object[]
            {
                this.FolderName
            });
            return(folderRec);
        }
Example #5
0
        FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
        {
            FolderRec folderRec;

            if (flags.HasFlag(GetFolderRecFlags.NoProperties))
            {
                folderRec = new FolderRec();
            }
            else
            {
                folderRec = FolderRec.Create(this.Folder, additionalPtagsToLoad);
                this.GetExtendedProps(folderRec, flags);
                this.TranslateParentFolderId(folderRec);
            }
            folderRec.IsGhosted = (this.Folder.MapiStore != this.Mailbox.MapiStore);
            return(folderRec);
        }
Example #6
0
        FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
        {
            MrsTracer.Provider.Function("StorageFolder.GetFolderRec: {0}", new object[]
            {
                this.DisplayNameForTracing
            });
            FolderRec folderRec;

            if (flags.HasFlag(GetFolderRecFlags.NoProperties))
            {
                folderRec = new FolderRec();
            }
            else
            {
                NativeStorePropertyDefinition[] array;
                if (additionalPtagsToLoad == null || additionalPtagsToLoad.Length == 0)
                {
                    array = this.Mailbox.FolderPropertyDefinitionsToLoad;
                }
                else
                {
                    List <NativeStorePropertyDefinition> list = new List <NativeStorePropertyDefinition>();
                    list.AddRange(this.Mailbox.ConvertPropTagsToDefinitions(additionalPtagsToLoad));
                    list.AddRange(this.Mailbox.FolderPropertyDefinitionsToLoad);
                    array = list.ToArray();
                }
                object[] array2 = new object[array.Length];
                this.CoreFolder.PropertyBag.Load(array);
                for (int i = 0; i < array.Length; i++)
                {
                    array2[i] = this.CoreFolder.PropertyBag.TryGetProperty(array[i]);
                }
                folderRec = FolderRec.Create(this.Mailbox.StoreSession, array, array2);
                this.GetExtendedProps(folderRec, flags);
            }
            folderRec.IsGhosted = !this.CoreFolder.IsContentAvailable();
            return(folderRec);
        }
Example #7
0
 FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
 {
     return(this.InternalGetFolderRec(additionalPtagsToLoad, flags));
 }
Example #8
0
 protected virtual FolderRec InternalGetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
 {
     return(EasFolderBase.CreateGenericFolderRec(this));
 }
Example #9
0
        public virtual void EnsureDataLoaded(IFolder folder, FolderRecDataFlags dataToLoad, MailboxCopierBase mbxCtx)
        {
            FolderRecDataFlags folderRecDataFlags = dataToLoad & FolderRecDataFlags.ExtendedData;

            if (folderRecDataFlags != FolderRecDataFlags.None && !this.FieldIsLoaded(folderRecDataFlags))
            {
                GetFolderRecFlags getFolderRecFlags = GetFolderRecFlags.None;
                if (this.FolderType == FolderType.Generic)
                {
                    if ((dataToLoad & FolderRecDataFlags.PromotedProperties) != FolderRecDataFlags.None && !this.FieldIsLoaded(FolderRecDataFlags.PromotedProperties))
                    {
                        getFolderRecFlags |= GetFolderRecFlags.PromotedProperties;
                    }
                    if ((dataToLoad & FolderRecDataFlags.Restrictions) != FolderRecDataFlags.None && !this.FieldIsLoaded(FolderRecDataFlags.Restrictions))
                    {
                        getFolderRecFlags |= GetFolderRecFlags.Restrictions;
                    }
                }
                if ((this.FolderType == FolderType.Generic || this.FolderType == FolderType.Search) && (dataToLoad & FolderRecDataFlags.Views) != FolderRecDataFlags.None && !this.FieldIsLoaded(FolderRecDataFlags.Views))
                {
                    getFolderRecFlags |= GetFolderRecFlags.Views;
                }
                if (getFolderRecFlags != GetFolderRecFlags.None)
                {
                    FolderRec folderRec = folder.GetFolderRec(null, getFolderRecFlags);
                    this.FolderRec.SetPromotedProperties(folderRec.GetPromotedProperties());
                    this.FolderRec.Views        = folderRec.Views;
                    this.FolderRec.ICSViews     = folderRec.ICSViews;
                    this.FolderRec.Restrictions = folderRec.Restrictions;
                }
                this.LoadedData |= folderRecDataFlags;
            }
            if ((dataToLoad & FolderRecDataFlags.SearchCriteria) != FolderRecDataFlags.None && !this.IsSpoolerQueue && !this.FieldIsLoaded(FolderRecDataFlags.SearchCriteria))
            {
                this.ReadSearchCriteria(folder, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.LoadedData |= FolderRecDataFlags.SearchCriteria;
            }
            if ((dataToLoad & FolderRecDataFlags.Rules) != FolderRecDataFlags.None && !this.FieldIsLoaded(FolderRecDataFlags.Rules))
            {
                this.ReadRules(folder, FolderRecWrapper.extraTags, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.LoadedData |= FolderRecDataFlags.Rules;
                MrsTracer.Service.Debug("Rules loaded: {0}", new object[]
                {
                    new RulesDataContext(this.Rules)
                });
            }
            if ((dataToLoad & FolderRecDataFlags.SecurityDescriptors) != FolderRecDataFlags.None && !this.FieldIsLoaded(FolderRecDataFlags.SecurityDescriptors))
            {
                this.FolderNTSD         = this.ReadSD(folder, SecurityProp.NTSD, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.FolderFreeBusyNTSD = this.ReadSD(folder, SecurityProp.FreeBusyNTSD, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.LoadedData        |= FolderRecDataFlags.SecurityDescriptors;
                MrsTracer.Service.Debug("FolderSDs loaded: NTSD {0}, FreeBusyNTSD {1}", new object[]
                {
                    CommonUtils.GetSDDLString(this.FolderNTSD),
                    CommonUtils.GetSDDLString(this.FolderFreeBusyNTSD)
                });
            }
            if (dataToLoad.HasFlag(FolderRecDataFlags.FolderAcls) && !this.FieldIsLoaded(FolderRecDataFlags.FolderAcls))
            {
                this.FolderACL         = this.ReadACL(folder, SecurityProp.NTSD, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.FolderFreeBusyACL = this.ReadACL(folder, SecurityProp.FreeBusyNTSD, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.LoadedData       |= FolderRecDataFlags.FolderAcls;
                MrsTracer.Service.Debug("FolderAcls are loaded: ACL {0}, FreeBusyACL {1}", new object[]
                {
                    new PropValuesDataContext(this.FolderACL).ToString(),
                    new PropValuesDataContext(this.FolderFreeBusyACL).ToString()
                });
            }
            if (dataToLoad.HasFlag(FolderRecDataFlags.ExtendedAclInformation) && !this.FieldIsLoaded(FolderRecDataFlags.ExtendedAclInformation))
            {
                this.FolderACL         = this.ReadExtendedAcl(folder, AclFlags.FolderAcl, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.FolderFreeBusyACL = this.ReadExtendedAcl(folder, AclFlags.FreeBusyAcl, new Action <List <BadMessageRec> >(mbxCtx.ReportBadItems), new Func <byte[], IFolder>(mbxCtx.SourceMailboxWrapper.GetFolder));
                this.LoadedData       |= FolderRecDataFlags.ExtendedAclInformation;
                MrsTracer.Service.Debug("FolderExtendedAcls are loaded: Acl {0}, FreeBusyAcl {1}", new object[]
                {
                    new PropValuesDataContext(this.FolderACL).ToString(),
                    new PropValuesDataContext(this.FolderFreeBusyACL).ToString()
                });
            }
        }
Example #10
0
 public void FoldersExport(ISourceMailbox mailbox, List <byte[]> folderIds, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
 {
     this.RunExportThread(delegate
     {
         using (BufferedTransmitter bufferedTransmitter = new BufferedTransmitter(this, this.service.ExportBufferSizeFromMrsKB, false, this.service.UseBufferring, this.service.UseCompression))
         {
             using (AsynchronousTransmitter asynchronousTransmitter = new AsynchronousTransmitter(bufferedTransmitter, false))
             {
                 using (FxProxyPoolTransmitter fxProxyPoolTransmitter = new FxProxyPoolTransmitter(asynchronousTransmitter, false, this.service.ClientVersion))
                 {
                     mailbox.ExportFolders(folderIds, fxProxyPoolTransmitter, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps, copyPropertiesFlags, excludeProps, extendedAclFlags);
                 }
             }
         }
     });
 }
 protected override FolderRec InternalGetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
 {
     return(this.FolderRec);
 }
 private void ExportSingleFolder(IFxProxyPool proxyPool, byte[] folderEntryId, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludePropertiesFromCopy, AclFlags extendedAclFlags)
 {
     ExecutionContext.Create(new DataContext[]
     {
         new OperationDataContext("StorageSourceMailbox.ExportSingleFolder", OperationType.None),
         new EntryIDsDataContext(folderEntryId),
         new SimpleValueDataContext("exportFoldersDataToCopyFlags", exportFoldersDataToCopyFlags),
         new SimpleValueDataContext("folderRecFlags", folderRecFlags),
         new PropTagsDataContext(additionalFolderRecProps),
         new SimpleValueDataContext("copyPropertiesFlags", copyPropertiesFlags),
         new PropTagsDataContext(excludePropertiesFromCopy),
         new SimpleValueDataContext("extendedAclFlags", extendedAclFlags)
     }).Execute(delegate
     {
         using (this.RHTracker.Start())
         {
             using (ISourceFolder folder = this.GetFolder <StorageSourceFolder>(folderEntryId))
             {
                 if (folder == null)
                 {
                     MrsTracer.Provider.Debug("Folder {0} is missing in source. Skipping.", new object[]
                     {
                         TraceUtils.DumpEntryId(folderEntryId)
                     });
                 }
                 else
                 {
                     using (IFolderProxy folderProxyForExportFolder = StorageSourceMailbox.GetFolderProxyForExportFolder(proxyPool, folder, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps))
                     {
                         if (extendedAclFlags != AclFlags.None)
                         {
                             this.ExportExtendedAcls(extendedAclFlags, folder, folderProxyForExportFolder);
                         }
                         using (FxProxyBudgetWrapper fxProxyBudgetWrapper = new FxProxyBudgetWrapper(folderProxyForExportFolder, false, new Func <IDisposable>(this.RHTracker.StartExclusive), new Action <uint>(this.RHTracker.Charge)))
                         {
                             if (exportFoldersDataToCopyFlags.HasFlag(ExportFoldersDataToCopyFlags.IncludeCopyToStream))
                             {
                                 folder.CopyTo(fxProxyBudgetWrapper, copyPropertiesFlags, excludePropertiesFromCopy);
                             }
                         }
                     }
                 }
             }
         }
     });
 }
        private static IFolderProxy GetFolderProxyForExportFolder(IFxProxyPool proxyPool, IFolder sourceFolder, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps)
        {
            IFolderProxy result;

            if ((exportFoldersDataToCopyFlags & ExportFoldersDataToCopyFlags.OutputCreateMessages) == ExportFoldersDataToCopyFlags.OutputCreateMessages)
            {
                FolderRec folderRec = sourceFolder.GetFolderRec(additionalFolderRecProps, folderRecFlags);
                result = proxyPool.CreateFolder(folderRec);
            }
            else
            {
                result = proxyPool.GetFolderProxy(sourceFolder.GetFolderId());
            }
            return(result);
        }
        void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
        {
            MrsTracer.ProxyClient.Function("StorageSourceMailbox.ExportFolders", new object[0]);
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            bool exportCompleted = false;

            CommonUtils.ProcessKnownExceptions(delegate
            {
                foreach (byte[] folderEntryId in folderIds)
                {
                    this.ExportSingleFolder(proxyPool, folderEntryId, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps, copyPropertiesFlags, excludeProps, extendedAclFlags);
                }
                exportCompleted = true;
                proxyPool.Flush();
            }, delegate(Exception ex)
            {
                if (!exportCompleted)
                {
                    MrsTracer.Provider.Debug("Flushing target proxy after receiving an exception.", new object[0]);
                    CommonUtils.CatchKnownExceptions(new Action(proxyPool.Flush), null);
                }
                return(false);
            });
        }
 void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
 {
     throw new NotImplementedException();
 }
        void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
        {
            string    text           = "ISourceMailbox.ExportFolders";
            TimeSpan  targetDuration = TimeSpan.Zero;
            Stopwatch stopwatch      = Stopwatch.StartNew();

            base.CreateContext(text, new DataContext[]
            {
                new EntryIDsDataContext(folderIds),
                new SimpleValueDataContext("exportFoldersDataToCopyFlags", exportFoldersDataToCopyFlags),
                new SimpleValueDataContext("folderRecFlags", folderRecFlags),
                new PropTagsDataContext(additionalFolderRecProps),
                new SimpleValueDataContext("copyPropertiesFlags", copyPropertiesFlags),
                new PropTagsDataContext(excludeProps),
                new SimpleValueDataContext("extendedAclFlags", extendedAclFlags)
            }).Execute(delegate
            {
                using (FxProxyPoolFxCallbackWrapper fxProxyPoolFxCallbackWrapper = new FxProxyPoolFxCallbackWrapper(proxyPool, true, delegate(TimeSpan duration)
                {
                    targetDuration += duration;
                }))
                {
                    ((ISourceMailbox)this.WrappedObject).ExportFolders(folderIds, fxProxyPoolFxCallbackWrapper, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps, copyPropertiesFlags, excludeProps, extendedAclFlags);
                }
            }, false);
            base.UpdateDuration(text, stopwatch.Elapsed.Subtract(targetDuration));
        }
Example #17
0
 FolderRec IFolder.GetFolderRec(PropTag[] additionalPtagsToLoad, GetFolderRecFlags flags)
 {
     return(this.Mailbox.CreateFolderRec(this.Folder));
 }
        void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
        {
            MrsTracer.ProxyClient.Function("RemoteSourceMailbox.ExportFolders", new object[0]);
            base.VerifyMailboxConnection();
            if (!base.ServerVersion[54])
            {
                throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "ISourceMailbox_ExportFolders");
            }
            DataExportBatch dataExportBatch = base.MrsProxy.ISourceMailbox_ExportFolders(base.Handle, folderIds, (int)exportFoldersDataToCopyFlags, (int)folderRecFlags, DataConverter <PropTagConverter, PropTag, int> .GetData(additionalFolderRecProps), (int)copyPropertiesFlags, DataConverter <PropTagConverter, PropTag, int> .GetData(excludeProps), (int)extendedAclFlags);

            using (IDataImport dataImport = new FxProxyPoolReceiver(proxyPool, false))
            {
                using (BufferedReceiver bufferedReceiver = new BufferedReceiver(dataImport, false, base.MrsProxyClient.UseBuffering, base.MrsProxyClient.UseCompression))
                {
                    RemoteDataExport.ExportRoutine(base.MrsProxy, dataExportBatch.DataExportHandle, bufferedReceiver, dataExportBatch, base.MrsProxyClient.UseCompression);
                }
            }
        }