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); } } } }
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); }
public T GetFolder <T>(byte[] folderId) where T : PstFolder, new() { MrsTracer.Provider.Function("PstMailbox.GetFolder({0})", new object[] { TraceUtils.DumpEntryId(folderId) }); uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(this.iPst.MessageStore.Guid, folderId); IFolder folder; try { folder = this.iPst.ReadFolder(nodeIdFromEntryId); } catch (PSTIOException innerException) { throw new UnableToReadPSTFolderTransientException(nodeIdFromEntryId, innerException); } catch (PSTExceptionBase innerException2) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId, innerException2); } if (folder == null) { MrsTracer.Provider.Debug("Folder does not exist", new object[0]); return(default(T)); } PstFxFolder pstFxFolder = new PstFxFolder(this, folder); if (MrsTracer.Provider.IsEnabled(TraceType.DebugTrace)) { MrsTracer.Provider.Debug("Opened folder '{0}'", new object[] { (string)pstFxFolder.GetProp(PropertyTag.DisplayName).Value }); } T result = Activator.CreateInstance <T>(); result.Config(folderId, pstFxFolder); return(result); }
void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.Provider.Function("PstDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); newFolderId = null; uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.ParentId); if (sourceFolder.EntryId != null) { uint nodeIdFromEntryId2 = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.EntryId); IFolder folder = base.IPst.ReadFolder(nodeIdFromEntryId2); if (folder != null) { if (createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists)) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId2); } if (nodeIdFromEntryId == folder.ParentId) { return; } } } IFolder folder2 = base.IPst.ReadFolder(nodeIdFromEntryId); if (folder2 == null) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId); } using (PstFxFolder pstFxFolder = new PstFxFolder(this, folder2.AddFolder())) { pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.DisplayName, sourceFolder.FolderName)); pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.FolderType, (int)sourceFolder.FolderType)); newFolderId = PstMailbox.CreateEntryIdFromNodeId(base.IPst.MessageStore.Guid, pstFxFolder.IPstFolder.Id); } }
internal virtual void Config(byte[] folderId, PstFxFolder folder) { this.folderId = folderId; this.folder = folder; this.folderRec = null; }
private FolderEntry(PstFxFolder folder) : base(folder) { this.folder = folder; }