示例#1
0
 private byte[] FindMessageId()
 {
     using (MapiFolder mapiFolder = MapiUtils.OpenFolderUnderRoot(this.store, this.folderName, false))
     {
         if (mapiFolder == null)
         {
             return(null);
         }
         this.FolderId = mapiFolder.GetProp(PropTag.EntryId).GetBytes();
         using (MapiTable contentsTable = mapiFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
         {
             PropTag propTag = PropTag.ReplyTemplateID;
             contentsTable.SetColumns(new PropTag[]
             {
                 PropTag.EntryId
             });
             contentsTable.SortTable(new SortOrder(propTag, SortFlags.Ascend), SortTableFlags.None);
             if (contentsTable.FindRow(Restriction.EQ(propTag, this.searchKey), BookMark.Beginning, FindRowFlag.None))
             {
                 PropValue[][] array = contentsTable.QueryRows(1);
                 if (array == null || array.Length == 0 || array[0].Length == 0)
                 {
                     return(null);
                 }
                 return(array[0][0].GetBytes());
             }
         }
     }
     return(null);
 }
示例#2
0
 public static byte[] GetSignatureBytes(MapiStore systemMailbox)
 {
     byte[] result = null;
     using (MapiFolder rootFolder = systemMailbox.GetRootFolder())
     {
         result = (rootFolder.GetProp(PropTag.MappingSignature).Value as byte[]);
     }
     return(result);
 }
        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);
                    }
                }
            }
        }
示例#4
0
        public void SaveObjectChunks(List <T> chunks, int maxChunks, MoveObjectInfo <T> .GetAdditionalProperties getAdditionalPropertiesCallback)
        {
            if (chunks.Count > maxChunks)
            {
                MrsTracer.Common.Warning("Too many chunks supplied, truncating", new object[0]);
                chunks.RemoveRange(0, chunks.Count - maxChunks);
            }
            bool flag = false;

            if (this.message == null)
            {
                using (MapiFolder mapiFolder = MapiUtils.OpenFolderUnderRoot(this.store, this.folderName, true))
                {
                    this.FolderId = mapiFolder.GetProp(PropTag.EntryId).GetBytes();
                    this.message  = mapiFolder.CreateMessage();
                }
                this.message.SetProps(new PropValue[]
                {
                    new PropValue(PropTag.MessageClass, this.messageClass),
                    new PropValue(PropTag.Subject, this.subject),
                    new PropValue(PropTag.ReplyTemplateID, this.searchKey)
                });
                flag = true;
            }
            if (chunks.Count > 1)
            {
                using (MapiTable attachmentTable = this.message.GetAttachmentTable())
                {
                    if (attachmentTable != null)
                    {
                        int num = attachmentTable.GetRowCount() - (maxChunks - chunks.Count);
                        if (num > 0)
                        {
                            attachmentTable.SetColumns(MoveObjectInfo <T> .AttachmentTagsToLoad);
                            PropValue[][] array = attachmentTable.QueryRows(num);
                            for (int i = 0; i < num; i++)
                            {
                                this.message.DeleteAttach(array[i][0].GetInt());
                            }
                        }
                    }
                }
                for (int j = 0; j < chunks.Count - 1; j++)
                {
                    int num2;
                    using (MapiAttach mapiAttach = this.message.CreateAttach(out num2))
                    {
                        using (MapiStream mapiStream = mapiAttach.OpenStream(PropTag.AttachDataBin, OpenPropertyFlags.Create))
                        {
                            MoveObjectInfo <T> .SerializeToStream(chunks[j], mapiStream);
                        }
                        mapiAttach.SetProps(new PropValue[]
                        {
                            new PropValue(PropTag.AttachFileName, string.Format("MOI_Chunk_{0:yyyymmdd_HHmmssfff}", DateTime.UtcNow)),
                            new PropValue(PropTag.AttachMethod, AttachMethods.ByValue)
                        });
                        mapiAttach.SaveChanges();
                    }
                }
            }
            T obj = chunks[chunks.Count - 1];

            if (getAdditionalPropertiesCallback != null)
            {
                this.message.SetProps(getAdditionalPropertiesCallback(this.store));
            }
            using (MapiStream mapiStream2 = this.message.OpenStream(PropTag.Body, OpenPropertyFlags.Create))
            {
                MoveObjectInfo <T> .SerializeToStream(obj, mapiStream2);
            }
            this.message.SaveChanges();
            if (flag)
            {
                this.MessageId = this.message.GetProp(PropTag.EntryId).GetBytes();
            }
        }