Ejemplo n.º 1
0
 public static FolderRec Create(MapiFolder folder, PropTag[] additionalPtagsToLoad)
 {
     PropTag[] array;
     if (additionalPtagsToLoad == null)
     {
         array = FolderRec.PtagsToLoad;
     }
     else
     {
         List <PropTag> list = new List <PropTag>();
         list.AddRange(FolderRec.PtagsToLoad);
         list.AddRange(additionalPtagsToLoad);
         array = list.ToArray();
     }
     PropValue[] props  = folder.GetProps(array);
     byte[]      array2 = null;
     for (int i = 0; i < array.Length; i++)
     {
         PropTag propTag  = array[i];
         PropTag propTag2 = propTag;
         if (propTag2 != PropTag.EntryId)
         {
             if (propTag2 == PropTag.LTID)
             {
                 props[i] = new PropValue(PropTag.LTID, folder.MapiStore.GlobalIdFromId(folder.MapiStore.GetFidFromEntryId(array2)));
             }
         }
         else
         {
             array2 = (byte[])props[i].Value;
         }
     }
     return(FolderRec.Create(props));
 }
Ejemplo n.º 2
0
 private void GetHierarchy(IFolder iFolder, List <FolderRec> hierarchy, PropertyTag[] momtPtagsToLoad)
 {
     using (PstFxFolder pstFxFolder = new PstFxFolder(this, iFolder))
     {
         hierarchy.Add(FolderRec.Create(PstMailbox.PvaFromMoMTPva(pstFxFolder.GetProps(momtPtagsToLoad))));
         foreach (uint num in iFolder.SubFolderIds)
         {
             IFolder folder;
             try
             {
                 folder = this.iPst.ReadFolder(num);
             }
             catch (PSTIOException innerException)
             {
                 throw new UnableToReadPSTFolderTransientException(num, innerException);
             }
             catch (PSTExceptionBase innerException2)
             {
                 throw new UnableToReadPSTFolderPermanentException(num, innerException2);
             }
             if (folder == null)
             {
                 MrsTracer.Provider.Error("Pst folder 0x{0:x} does not exist", new object[]
                 {
                     num
                 });
             }
             else
             {
                 this.GetHierarchy(folder, hierarchy, momtPtagsToLoad);
             }
         }
     }
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 private void LoadFolderHierarchy(StoreObjectId rootFolderId, NativeStorePropertyDefinition[] propertiesToLoad, List <FolderRec> result)
 {
     using (CoreFolder coreFolder = CoreFolder.Bind(this.StoreSession, rootFolderId))
     {
         FolderRec folderRec = this.GetFolderRec(coreFolder, propertiesToLoad);
         if (base.Flags.HasFlag(LocalMailboxFlags.ParallelPublicFolderMigration))
         {
             folderRec.FolderName = "Public Root";
         }
         result.Add(folderRec);
         using (QueryResult queryResult = coreFolder.QueryExecutor.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, propertiesToLoad))
         {
             object[][] rows;
             do
             {
                 using (base.RHTracker.Start())
                 {
                     rows = queryResult.GetRows(1000);
                 }
                 foreach (object[] values in rows)
                 {
                     FolderRec folderRec2 = FolderRec.Create(this.StoreSession, propertiesToLoad, values);
                     if (folderRec2 != null)
                     {
                         result.Add(folderRec2);
                     }
                 }
             }while (rows.Length != 0);
         }
     }
 }
Ejemplo n.º 5
0
 private FolderRec GetFolderRec(CoreFolder folder, NativeStorePropertyDefinition[] propertiesToLoad)
 {
     folder.PropertyBag.Load(propertiesToLoad);
     object[] array = new object[propertiesToLoad.Length];
     for (int i = 0; i < propertiesToLoad.Length; i++)
     {
         array[i] = folder.PropertyBag.TryGetProperty(propertiesToLoad[i]);
     }
     return(FolderRec.Create(this.StoreSession, propertiesToLoad, array));
 }
Ejemplo n.º 6
0
        List <FolderRec> IMailbox.EnumerateFolderHierarchy(EnumerateFolderHierarchyFlags flags, PropTag[] additionalPtagsToLoad)
        {
            MrsTracer.Provider.Function("PstMailbox.IMailbox.EnumerateFolderHierarchy({0})", new object[]
            {
                flags
            });
            List <FolderRec> list  = new List <FolderRec>(50);
            List <PropTag>   list2 = new List <PropTag>(FolderRec.PtagsToLoad);

            if (additionalPtagsToLoad != null)
            {
                list2.AddRange(additionalPtagsToLoad);
            }
            PropertyTag[] array = PstMailbox.MoMTPtaFromPta(list2.ToArray());
            try
            {
                IFolder folder = this.iPst.ReadFolder(290U);
                if (folder == null)
                {
                    throw new UnableToGetPSTHierarchyPermanentException(this.filePath);
                }
                using (PstFxFolder pstFxFolder = new PstFxFolder(this, folder))
                {
                    list.Add(FolderRec.Create(PstMailbox.PvaFromMoMTPva(pstFxFolder.GetProps(array))));
                    PropertyValue property = this.MessageStorePropertyBag.GetProperty(PropertyTag.IPMSubtreeFolder);
                    if (property.IsError || ((byte[])property.Value).Length != 24)
                    {
                        throw new UnableToGetPSTHierarchyPermanentException(this.filePath);
                    }
                    uint    nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(this.iPst.MessageStore.Guid, (byte[])property.Value, true);
                    IFolder folder2           = this.iPst.ReadFolder(nodeIdFromEntryId);
                    if (folder2 == null)
                    {
                        throw new UnableToGetPSTHierarchyPermanentException(this.filePath);
                    }
                    this.GetHierarchy(folder2, list, array);
                }
            }
            catch (PSTIOException innerException)
            {
                throw new UnableToGetPSTHierarchyTransientException(this.filePath, innerException);
            }
            catch (PSTExceptionBase innerException2)
            {
                throw new UnableToGetPSTHierarchyPermanentException(this.filePath, innerException2);
            }
            MrsTracer.Provider.Debug("PST hierarchy contains {0} folders including root", new object[]
            {
                list.Count
            });
            return(list);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public static FolderRec Create(StoreSession storageSession, NativeStorePropertyDefinition[] definitions, object[] values)
        {
            PropValue[]        array      = new PropValue[definitions.Length];
            ICollection <uint> collection = PropertyTagCache.Cache.PropertyTagsFromPropertyDefinitions(storageSession, definitions);

            byte[] array2 = null;
            int    num    = 0;

            foreach (uint num2 in collection)
            {
                if (num2 == 268370178U)
                {
                    array2 = storageSession.IdConverter.GetLongTermIdFromId(storageSession.IdConverter.GetFidFromId(StoreObjectId.FromProviderSpecificId((byte[])values[num])));
                }
                num++;
            }
            num = 0;
            foreach (uint num3 in collection)
            {
                object  obj     = values[num];
                PropTag propTag = (PropTag)num3;
                if (propTag == PropTag.LTID)
                {
                    obj = array2;
                }
                if (obj == null)
                {
                    propTag = propTag.ChangePropType(PropType.Null);
                }
                else if (obj is PropertyError)
                {
                    propTag = propTag.ChangePropType(PropType.Error);
                    obj     = (int)((PropertyError)obj).PropertyErrorCode;
                }
                else if (obj is ExDateTime)
                {
                    obj = (DateTime)((ExDateTime)obj);
                }
                array[num] = new PropValue(propTag, obj);
                num++;
            }
            return(FolderRec.Create(storageSession, array));
        }
Ejemplo n.º 9
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);
        }
        void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId)
        {
            MrsTracer.Provider.Function("MapiDestinationMailbox.CreateFolder(\"{0}\")", new object[]
            {
                sourceFolder.FolderName
            });
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            if (createFolderFlags.HasFlag(CreateFolderFlags.InternalAccess))
            {
                throw new InternalAccessFolderCreationIsNotSupportedException();
            }
            FolderRec folderRec = null;

            newFolderId = null;
            using (base.RHTracker.Start())
            {
                if (!createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists) && sourceFolder.EntryId != null)
                {
                    OpenEntryFlags flags = OpenEntryFlags.DontThrowIfEntryIsMissing;
                    using (MapiFolder mapiFolder = (MapiFolder)base.MapiStore.OpenEntry(sourceFolder.EntryId, flags))
                    {
                        if (mapiFolder != null)
                        {
                            folderRec   = FolderRec.Create(mapiFolder, null);
                            newFolderId = folderRec.EntryId;
                        }
                    }
                }
                if (newFolderId == null)
                {
                    OpenEntryFlags flags2 = OpenEntryFlags.DeferredErrors | OpenEntryFlags.Modify;
                    using (MapiFolder mapiFolder2 = (MapiFolder)base.MapiStore.OpenEntry(sourceFolder.ParentId, flags2))
                    {
                        using (MapiFolder mapiFolder3 = mapiFolder2.CreateFolder(sourceFolder.FolderName, null, false, sourceFolder.FolderType == FolderType.Search, sourceFolder.EntryId))
                        {
                            newFolderId = mapiFolder3.GetProp(PropTag.EntryId).GetBytes();
                        }
                        goto IL_160;
                    }
                }
                if (!CommonUtils.IsSameEntryId(folderRec.ParentId, sourceFolder.ParentId))
                {
                    MrsTracer.Provider.Debug("Existing folder is under the wrong parent. Moving it.", new object[0]);
                    ((IDestinationMailbox)this).MoveFolder(folderRec.EntryId, folderRec.ParentId, sourceFolder.ParentId);
                }
IL_160:
                PropTag[] promotedProperties = sourceFolder.GetPromotedProperties();
                if ((promotedProperties != null && promotedProperties.Length > 0) || (sourceFolder.Restrictions != null && sourceFolder.Restrictions.Length > 0) || (sourceFolder.Views != null && sourceFolder.Views.Length > 0) || (sourceFolder.ICSViews != null && sourceFolder.ICSViews.Length > 0))
                {
                    using (MapiDestinationFolder folder = base.GetFolder <MapiDestinationFolder>(newFolderId))
                    {
                        ICSViewData[] icsViews = null;
                        if (this.ServerVersion >= Server.E15MinVersion)
                        {
                            icsViews = sourceFolder.ICSViews;
                        }
                        folder.SetExtendedProps(promotedProperties, sourceFolder.Restrictions, sourceFolder.Views, icsViews);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public static FolderRec Create(PropValue[] pva)
 {
     return(FolderRec.Create(null, pva));
 }