Пример #1
0
 private static void ResetOofHistoryProperty(MapiStream oofHistoryStream, byte[] initialBytes, long hashCode)
 {
     OofHistory.Tracer.TraceDebug(hashCode, "Resetting OOF history to initial values.");
     if (!oofHistoryStream.CanWrite)
     {
         throw new InvalidOperationException("OOF history property stream is not writable.");
     }
     if (!oofHistoryStream.CanSeek)
     {
         throw new InvalidOperationException("OOF history property stream is not seekable.");
     }
     if (0L != oofHistoryStream.Position)
     {
         oofHistoryStream.Seek(0L, SeekOrigin.Begin);
     }
     oofHistoryStream.Write(initialBytes, 0, 6);
     if (oofHistoryStream.Length > 6L)
     {
         oofHistoryStream.SetLength(6L);
     }
 }
Пример #2
0
        internal static void RemoveOofHistoryEntriesWithProperty(MailboxSession itemStore, bool oofEnabled, OofHistory.PropId propId, byte[] propValue)
        {
            MapiFolder mapiFolder  = null;
            MapiFolder mapiFolder2 = null;
            MapiStream mapiStream  = null;
            bool       flag        = false;

            byte[] initialBytes = oofEnabled ? OofHistory.InitialBytesOofStateOn : OofHistory.InitialBytesOofStateOff;
            try
            {
                if (OofHistory.TryOpenFolder(itemStore, out mapiFolder, out mapiFolder2))
                {
                    long hashCode = (long)itemStore.GetHashCode();
                    bool flag2;
                    mapiStream = OofHistory.OpenAndLockStream(mapiFolder2, initialBytes, hashCode, out flag2);
                    flag       = true;
                    if (!flag2)
                    {
                        int num;
                        if (OofHistory.TryGetStreamLengthForEntryRemoval(hashCode, mapiStream, out num))
                        {
                            byte[] buffer;
                            if (OofHistory.TryReadAllFromStream(hashCode, mapiStream, num, out buffer))
                            {
                                int num2 = OofHistory.RemoveEntriesWithProperty(num, buffer, propId, propValue, hashCode);
                                if (num2 < num)
                                {
                                    mapiStream.Seek(0L, SeekOrigin.Begin);
                                    mapiStream.Write(buffer, 0, num2);
                                    mapiStream.SetLength((long)num2);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mapiStream != null)
                {
                    try
                    {
                        if (flag)
                        {
                            mapiStream.UnlockRegion(0L, 1L, 1);
                        }
                    }
                    finally
                    {
                        mapiStream.Dispose();
                    }
                }
                if (mapiFolder != null)
                {
                    mapiFolder.Dispose();
                    mapiFolder = null;
                }
                if (mapiFolder2 != null)
                {
                    mapiFolder2.Dispose();
                    mapiFolder2 = null;
                }
            }
        }