Пример #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 int GetQueueLength()
        {
            MrsTracer.Common.Function("RequestJobProvider.GetQueueLength", new object[0]);
            RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox);
            Restriction restriction  = Restriction.EQ(requestJobNamedPropertySet.PropTags[4], true);
            Restriction restriction2 = Restriction.BitMaskNonZero(requestJobNamedPropertySet.PropTags[10], 256);
            Restriction restriction3 = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.Completed);
            Restriction restriction4 = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.CompletedWithWarning);
            Restriction restriction5 = Restriction.Or(new Restriction[]
            {
                restriction,
                restriction2,
                restriction3,
                restriction4
            });
            Restriction restriction6 = Restriction.Not(restriction5);
            int         result;

            using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(this.SystemMailbox))
            {
                using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                {
                    contentsTable.Restrict(restriction6);
                    int rowCount = contentsTable.GetRowCount();
                    MrsTracer.Common.Debug("Queue length is {0}", new object[]
                    {
                        rowCount
                    });
                    result = rowCount;
                }
            }
            return(result);
        }
Пример #3
0
 public static Restriction CreateKnownExternalSendersGroupCondition(string[] knownExternalSenders)
 {
     Restriction[] array = new Restriction[knownExternalSenders.Length];
     for (int i = 0; i < knownExternalSenders.Length; i++)
     {
         array[i] = Restriction.EQ(PropTag.SenderEmailAddress, knownExternalSenders[i]);
     }
     return(Restriction.Or(array));
 }
        protected override void ProcessJobs(MapiStore systemMbx, MapiTable contentsTable, RequestJobNamedPropertySet nps)
        {
            SortOrder sortOrder = new SortOrder(nps.PropTags[17], SortFlags.Descend);

            sortOrder.Add(nps.PropTags[7], SortFlags.Ascend);
            MrsTracer.Service.Debug("Searching for MRs to Rehome...", new object[0]);
            Restriction restriction = Restriction.And(new Restriction[]
            {
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[20], true)
            });

            MrsTracer.Service.Debug("Searching for MRs to Suspend...", new object[0]);
            base.ProcessJobsInBatches(restriction, false, sortOrder, contentsTable, systemMbx, null);
            Restriction restriction2 = Restriction.And(new Restriction[]
            {
                Restriction.BitMaskNonZero(nps.PropTags[10], 256),
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[20], false),
                Restriction.NE(nps.PropTags[0], RequestStatus.Failed),
                Restriction.NE(nps.PropTags[0], RequestStatus.Suspended),
                Restriction.NE(nps.PropTags[0], RequestStatus.AutoSuspended),
                Restriction.NE(nps.PropTags[0], RequestStatus.Completed),
                Restriction.NE(nps.PropTags[0], RequestStatus.CompletedWithWarning)
            });

            base.ProcessJobsInBatches(restriction2, false, sortOrder, contentsTable, systemMbx, null);
            MrsTracer.Service.Debug("Searching for MRs to Resume...", new object[0]);
            Restriction restriction3 = Restriction.And(new Restriction[]
            {
                Restriction.BitMaskZero(nps.PropTags[10], 256),
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[20], false),
                Restriction.Or(new Restriction[]
                {
                    Restriction.EQ(nps.PropTags[0], RequestStatus.Failed),
                    Restriction.EQ(nps.PropTags[0], RequestStatus.Suspended),
                    Restriction.EQ(nps.PropTags[0], RequestStatus.AutoSuspended)
                })
            });

            base.ProcessJobsInBatches(restriction3, false, sortOrder, contentsTable, systemMbx, null);
            SortOrder sort   = new SortOrder(nps.PropTags[13], SortFlags.Ascend);
            DateTime  utcNow = DateTime.UtcNow;

            MrsTracer.Service.Debug("Searching for Completed MRs to clean up...", new object[0]);
            Restriction restriction4 = Restriction.And(new Restriction[]
            {
                Restriction.EQ(nps.PropTags[20], false),
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[0], RequestStatus.Completed),
                Restriction.NE(nps.PropTags[13], SystemMailboxLightJobs.defaultDoNotPickUntil)
            });

            base.ProcessJobsInBatches(restriction4, false, sort, contentsTable, systemMbx, (MoveJob moveJob) => moveJob.DoNotPickUntilTimestamp > utcNow);
        }
Пример #5
0
        protected static Restriction CreatePropertyRestriction <T>(PropTag propertyTag, T value)
        {
            Restriction result;

            if ((PropTag)4096U == ((PropTag)4096U & propertyTag))
            {
                PropTag tag = propertyTag & (PropTag)4294963199U;
                result = new Restriction.PropertyRestriction(Restriction.RelOp.Equal, tag, true, value);
            }
            else
            {
                result = Restriction.EQ(propertyTag, value);
            }
            return(result);
        }
Пример #6
0
 private Restriction BuildRestriction()
 {
     if (this.IsFieldSet("MailboxGuid") && this.IsFieldSet("EventNames"))
     {
         return(Restriction.And(new Restriction[]
         {
             Restriction.EQ(PropTag.EventMailboxGuid, this.MailboxGuid.ToByteArray()),
             Restriction.BitMaskNonZero(PropTag.EventMask, (int)this.EventNames)
         }));
     }
     if (this.IsFieldSet("MailboxGuid"))
     {
         return(Restriction.EQ(PropTag.EventMailboxGuid, this.MailboxGuid.ToByteArray()));
     }
     if (this.IsFieldSet("EventNames"))
     {
         return(Restriction.BitMaskNonZero(PropTag.EventMask, (int)this.EventNames));
     }
     return(null);
 }
        protected override void ProcessJobs(MapiStore systemMbx, MapiTable contentsTable, RequestJobNamedPropertySet nps)
        {
            MrsTracer.Service.Debug("Initializing searches...", new object[0]);
            SortOrder sortOrder = new SortOrder(nps.PropTags[17], SortFlags.Descend);

            sortOrder.Add(nps.PropTags[7], SortFlags.Ascend);
            Restriction restriction = Restriction.And(new Restriction[]
            {
                Restriction.EQ(nps.PropTags[4], true),
                Restriction.EQ(nps.PropTags[20], false)
            });
            Restriction restriction2 = Restriction.And(new Restriction[]
            {
                Restriction.BitMaskZero(nps.PropTags[10], 256),
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[20], false),
                Restriction.Or(new Restriction[]
                {
                    Restriction.EQ(nps.PropTags[0], RequestStatus.Queued),
                    Restriction.EQ(nps.PropTags[0], RequestStatus.InProgress),
                    Restriction.EQ(nps.PropTags[0], RequestStatus.CompletionInProgress)
                })
            });

            base.ProcessJobsInBatches(Restriction.Or(new Restriction[]
            {
                restriction2,
                restriction
            }), true, sortOrder, contentsTable, systemMbx, null);
            Restriction restriction3 = Restriction.And(new Restriction[]
            {
                Restriction.BitMaskZero(nps.PropTags[10], 256),
                Restriction.EQ(nps.PropTags[4], false),
                Restriction.EQ(nps.PropTags[20], false),
                Restriction.EQ(nps.PropTags[0], RequestStatus.Synced)
            });
            SortOrder sort   = new SortOrder(nps.PropTags[13], SortFlags.Ascend);
            DateTime  utcNow = DateTime.UtcNow;

            base.ProcessJobsInBatches(restriction3, false, sort, contentsTable, systemMbx, (MoveJob moveJob) => moveJob.DoNotPickUntilTimestamp > utcNow);
        }
        // Token: 0x06000272 RID: 626 RVA: 0x0000DCFC File Offset: 0x0000BEFC
        private MapiEvent FindNextEventForMailbox(EventAccess eventAccess, long beginCounter)
        {
            Restriction restriction = Restriction.EQ(PropTag.EventMailboxGuid, this.MailboxGuid.ToByteArray());
            Restriction filter      = (base.Controller.Filter == null) ? restriction : Restriction.And(new Restriction[]
            {
                restriction,
                base.Controller.Filter
            });

            ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long>((long)this.GetHashCode(), "{0}: Finding next for this mailbox from {1}...", this, beginCounter);
            long num;

            MapiEvent[] array = eventAccess.ReadEvents(beginCounter, 1, int.MaxValue, filter, out num);
            if (array.Length > 0)
            {
                ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long, MapiEvent>((long)this.GetHashCode(), "{0}: Found next event for this mailbox from {1}: {2}", this, beginCounter, array[0]);
                return(array[0]);
            }
            ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long>((long)this.GetHashCode(), "{0}: Found no events for mailbox after {1}", this, beginCounter);
            return(null);
        }
        internal static Restriction BuildIsFlaggedRestriction(SinglePropertyFilter filter, IFilterBuilderHelper mapper)
        {
            ContentFilterSchema.ContentFilterPropertyDefinition contentFilterPropertyDefinition = (ContentFilterSchema.ContentFilterPropertyDefinition)filter.Property;
            PropTag propTagToSearch = contentFilterPropertyDefinition.PropTagToSearch;
            bool    flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            bool flag2 = (bool)ContentFilterBuilder.GetPropertyValue(filter);

            if (flag)
            {
                flag2 = !flag2;
            }
            Restriction restriction = Restriction.EQ(propTagToSearch, 2);

            if (!flag2)
            {
                return(Restriction.Not(restriction));
            }
            return(restriction);
        }
Пример #10
0
        private static Restriction BuildComparisonRestriction(ComparisonFilter filter, PropTag ptagToSearch, object propValue)
        {
            Restriction.PropertyRestriction propertyRestriction;
            switch (filter.ComparisonOperator)
            {
            case ComparisonOperator.Equal:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.EQ(ptagToSearch, propValue);
                break;

            case ComparisonOperator.NotEqual:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.NE(ptagToSearch, propValue);
                break;

            case ComparisonOperator.LessThan:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.LT(ptagToSearch, propValue);
                break;

            case ComparisonOperator.LessThanOrEqual:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.LE(ptagToSearch, propValue);
                break;

            case ComparisonOperator.GreaterThan:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.GT(ptagToSearch, propValue);
                break;

            case ComparisonOperator.GreaterThanOrEqual:
                propertyRestriction = (Restriction.PropertyRestriction)Restriction.GE(ptagToSearch, propValue);
                break;

            default:
                throw ContentFilterBuilder.UnexpectedFilterType(filter);
            }
            if (ptagToSearch.IsMultiValued())
            {
                propertyRestriction.MultiValued = true;
            }
            return(propertyRestriction);
        }
Пример #11
0
        private static Restriction BuildPolicyTagRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            bool flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            List <Restriction> list = new List <Restriction>();
            string             text = (string)ContentFilterBuilder.GetPropertyValue(filter);

            if (ContentFilterBuilder.guidRegex.Match(text).Success)
            {
                try
                {
                    Guid guid = new Guid(text);
                    list.Add(Restriction.EQ(ptagToSearch, guid.ToByteArray()));
                }
                catch (FormatException)
                {
                }
            }
            if (list.Count == 0)
            {
                Guid[] array = mapper.MapPolicyTag(text);
                if (array != null)
                {
                    foreach (Guid guid2 in array)
                    {
                        list.Add(Restriction.EQ(ptagToSearch, guid2.ToByteArray()));
                    }
                }
            }
            Restriction restriction = (list.Count == 1) ? list[0] : Restriction.Or(list.ToArray());

            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }
Пример #12
0
        public static List <T> LoadAll(byte[] searchKey, Restriction additionalRestriction, Guid mdbGuid, MapiStore store, string folderName, MoveObjectInfo <T> .IsSupportedObjectTypeDelegate isSupportedObjectType, MoveObjectInfo <T> .EmptyTDelegate emptyT)
        {
            List <T> list = new List <T>();

            using (MapiFolder mapiFolder = MapiUtils.OpenFolderUnderRoot(store, folderName, false))
            {
                if (mapiFolder == null)
                {
                    return(list);
                }
                using (MapiTable contentsTable = mapiFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                {
                    PropTag propTag = PropTag.ReplyTemplateID;
                    contentsTable.SortTable(new SortOrder(propTag, SortFlags.Ascend), SortTableFlags.None);
                    List <PropTag> list2 = new List <PropTag>();
                    list2.Add(PropTag.EntryId);
                    list2.Add(propTag);
                    Restriction restriction = null;
                    if (searchKey != null)
                    {
                        restriction = Restriction.EQ(propTag, searchKey);
                    }
                    if (additionalRestriction != null)
                    {
                        if (restriction == null)
                        {
                            restriction = additionalRestriction;
                        }
                        else
                        {
                            restriction = Restriction.And(new Restriction[]
                            {
                                restriction,
                                additionalRestriction
                            });
                        }
                    }
                    foreach (PropValue[] array2 in MapiUtils.QueryAllRows(contentsTable, restriction, list2))
                    {
                        byte[]         bytes  = array2[0].GetBytes();
                        byte[]         bytes2 = array2[1].GetBytes();
                        OpenEntryFlags flags  = OpenEntryFlags.Modify | OpenEntryFlags.DontThrowIfEntryIsMissing;
                        using (MapiMessage mapiMessage = (MapiMessage)store.OpenEntry(bytes, flags))
                        {
                            if (mapiMessage != null)
                            {
                                T t = default(T);
                                if (isSupportedObjectType != null)
                                {
                                    if (isSupportedObjectType(mapiMessage, store))
                                    {
                                        t = MoveObjectInfo <T> .ReadObjectFromMessage(mapiMessage, false);
                                    }
                                    if (t == null && emptyT != null)
                                    {
                                        t = emptyT(bytes2);
                                    }
                                }
                                else
                                {
                                    t = MoveObjectInfo <T> .ReadObjectFromMessage(mapiMessage, false);
                                }
                                if (t != null)
                                {
                                    list.Add(t);
                                }
                                else
                                {
                                    MrsTracer.Common.Error("Unable to deserialize message '{0}'.", new object[]
                                    {
                                        bytes
                                    });
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Пример #13
0
        public LocalizedString ComputePositionInQueue(Guid requestGuid)
        {
            int crows = 1000;
            int num   = 0;
            int num2  = 0;

            if (requestGuid.Equals(Guid.Empty))
            {
                return(MrsStrings.ErrorEmptyMailboxGuid);
            }
            using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(this.SystemMailbox))
            {
                using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                {
                    RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox);
                    contentsTable.SetColumns(requestJobNamedPropertySet.PropTags);
                    SortOrder sortOrder = new SortOrder(requestJobNamedPropertySet.PropTags[7], SortFlags.Ascend);
                    contentsTable.SortTable(sortOrder, SortTableFlags.None);
                    Restriction restriction = Restriction.EQ(requestJobNamedPropertySet.PropTags[0], RequestStatus.Queued);
                    contentsTable.Restrict(restriction);
                    contentsTable.SeekRow(BookMark.Beginning, 0);
                    PropValue[][] array = contentsTable.QueryRows(crows);
                    bool          flag  = false;
                    while (array != null && array.Length > 0)
                    {
                        int num3 = 0;
                        if (!flag)
                        {
                            foreach (PropValue[] array3 in array)
                            {
                                num3++;
                                if (num2 + num3 >= 10000)
                                {
                                    break;
                                }
                                Guid value = MapiUtils.GetValue <Guid>(array3[26], Guid.Empty);
                                if (requestGuid.Equals(value))
                                {
                                    flag = true;
                                    num  = num2 + num3;
                                    break;
                                }
                            }
                        }
                        num2 += array.Length;
                        if (num2 >= 10000)
                        {
                            break;
                        }
                        array = contentsTable.QueryRows(crows);
                    }
                }
            }
            LocalizedString value2 = LocalizedString.Empty;
            LocalizedString value3 = LocalizedString.Empty;

            if (num == 0)
            {
                if (num2 < 10000)
                {
                    value2 = MrsStrings.MoveRequestNotFoundInQueue;
                    value3 = MrsStrings.PositionInteger(num2);
                }
                else
                {
                    value2 = MrsStrings.PositionIntegerPlus(10000);
                    value3 = MrsStrings.PositionIntegerPlus(10000);
                }
            }
            else
            {
                value2 = MrsStrings.PositionInteger(num);
                if (num2 < 10000)
                {
                    value3 = MrsStrings.PositionInteger(num2);
                }
                else
                {
                    value3 = MrsStrings.PositionIntegerPlus(num2);
                }
            }
            return(MrsStrings.PositionOfMoveRequestInSystemMailboxQueue(value2, value3));
        }
Пример #14
0
        internal void ExecuteRecovery(EventSink eventSink)
        {
            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Starting Recovery. EventSink = {1}.", this, eventSink);
            try
            {
                IRecoveryEventSink recoveryEventSink = null;
                EventWatermark     eventWatermark    = null;
                long num = 0L;
                Guid mailboxGuid;
                try
                {
                    mailboxGuid       = eventSink.MailboxGuid;
                    recoveryEventSink = eventSink.StartRecovery();
                    eventWatermark    = recoveryEventSink.FirstMissedEventWatermark;
                    num = recoveryEventSink.LastMissedEventWatermark;
                }
                catch (ObjectDisposedException)
                {
                    ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                    return;
                }
                Restriction restriction = null;
                if (!eventSink.IsPublicFolderDatabase)
                {
                    restriction = Restriction.EQ(PropTag.EventMailboxGuid, mailboxGuid.ToByteArray());
                }
                long num2 = eventWatermark.WasEventProcessed ? (eventWatermark.MapiWatermark + 1L) : eventWatermark.MapiWatermark;
                long num3 = num2;
                bool flag = true;
                while (flag)
                {
                    int eventCountToCheck = EventPump.GetEventCountToCheck(num3, eventWatermark, num2, num);
                    if (eventCountToCheck > 0)
                    {
                        MapiEvent[] array = null;
                        long        num4  = 0L;
                        try
                        {
                            this.disposeLock.EnterReadLock();
                            if (this.IsDisposed)
                            {
                                return;
                            }
                            array = EventPump.ReadEvents(this.mapiEventManager, this.mapiEventManagerLock, num3, eventCountToCheck, eventCountToCheck, restriction, out num4);
                        }
                        finally
                        {
                            try
                            {
                                this.disposeLock.ExitReadLock();
                            }
                            catch (SynchronizationLockException)
                            {
                            }
                        }
                        int num5 = 0;
                        while (num5 < array.Length && flag)
                        {
                            MapiEvent mapiEvent = array[num5];
                            if (EventPump.IsEventBetweenCounters(num3, num, mapiEvent.Watermark.EventCounter))
                            {
                                try
                                {
                                    flag = recoveryEventSink.RecoveryConsume(mapiEvent);
                                    goto IL_179;
                                }
                                catch (ObjectDisposedException)
                                {
                                    ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                                    return;
                                }
                                goto Block_9;
                            }
                            goto IL_150;
IL_179:
                            num5++;
                            continue;
Block_9:
                            try
                            {
IL_150:
                                recoveryEventSink.EndRecovery();
                            }
                            catch (ObjectDisposedException)
                            {
                                ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                                return;
                            }
                            flag = false;
                            goto IL_179;
                        }
                        num3 = num4 + 1L;
                    }
                    else
                    {
                        try
                        {
                            recoveryEventSink.EndRecovery();
                        }
                        catch (ObjectDisposedException)
                        {
                            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Executing recovery in a disposed sink. Aborting recovery. EventSink = {1}.", this, eventSink);
                            return;
                        }
                        flag = false;
                    }
                }
            }
            catch (StoragePermanentException ex)
            {
                eventSink.HandleException(ex);
            }
            catch (StorageTransientException ex2)
            {
                eventSink.HandleException(ex2);
            }
            ExTraceGlobals.EventTracer.TraceDebug <EventPump, EventSink>((long)this.GetHashCode(), "EventPump::ExecuteRecovery. {0}. Exiting Recovery. EventSink = {1}.", this, eventSink);
        }
Пример #15
0
        List <MessageRec> IFolder.LookupMessages(PropTag ptagToLookup, List <byte[]> keysToLookup, PropTag[] additionalPtagsToLoad)
        {
            EntryIdMap <MessageRec> result = new EntryIdMap <MessageRec>();

            ContentsTableFlags[] array = new ContentsTableFlags[]
            {
                ContentsTableFlags.None,
                ContentsTableFlags.Associated
            };
            List <PropTag> pta        = new List <PropTag>(5);
            int            idxEntryId = pta.Count;

            pta.Add(PropTag.EntryId);
            int idxMessageSize = pta.Count;

            pta.Add(PropTag.MessageSize);
            int idxCreationTime = pta.Count;

            pta.Add(PropTag.CreationTime);
            int idxExtraPtags = pta.Count;

            if (additionalPtagsToLoad != null)
            {
                pta.AddRange(additionalPtagsToLoad);
            }
            for (int i = 0; i < array.Length; i++)
            {
                if (result.Count >= keysToLookup.Count)
                {
                    break;
                }
                ContentsTableFlags flags = ContentsTableFlags.DeferredErrors | array[i];
                bool doingFAI            = (flags & ContentsTableFlags.Associated) != ContentsTableFlags.None;
                ExecutionContext.Create(new DataContext[]
                {
                    new OperationDataContext("MapiFolder.GetContentsTable", OperationType.None),
                    new SimpleValueDataContext("Flags", flags)
                }).Execute(delegate
                {
                    MapiTable msgTable;
                    using (this.Mailbox.RHTracker.Start())
                    {
                        msgTable = this.Folder.GetContentsTable(flags);
                    }
                    using (msgTable)
                    {
                        if (ptagToLookup != PropTag.EntryId)
                        {
                            using (this.Mailbox.RHTracker.Start())
                            {
                                msgTable.SortTable(new SortOrder(ptagToLookup, SortFlags.Ascend), SortTableFlags.None);
                            }
                        }
                        msgTable.SetColumns(pta);
                        using (List <byte[]> .Enumerator enumerator = keysToLookup.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                byte[] key = enumerator.Current;
                                if (!result.ContainsKey(key))
                                {
                                    ExecutionContext.Create(new DataContext[]
                                    {
                                        new EntryIDsDataContext(key)
                                    }).Execute(delegate
                                    {
                                        try
                                        {
                                            using (this.Mailbox.RHTracker.Start())
                                            {
                                                if (!msgTable.FindRow(Restriction.EQ(ptagToLookup, key), BookMark.Beginning, FindRowFlag.None))
                                                {
                                                    return;
                                                }
                                            }
                                        }
                                        catch (MapiExceptionNotFound)
                                        {
                                            return;
                                        }
                                        PropValue[][] array2;
                                        using (this.Mailbox.RHTracker.Start())
                                        {
                                            array2 = msgTable.QueryRows(1);
                                        }
                                        if (array2.Length == 1)
                                        {
                                            PropValue[] array3 = array2[0];
                                            if (array3.Length != pta.Count)
                                            {
                                                return;
                                            }
                                            PropValueData[] array4 = null;
                                            if (additionalPtagsToLoad != null && additionalPtagsToLoad.Length > 0)
                                            {
                                                array4 = new PropValueData[additionalPtagsToLoad.Length];
                                                for (int j = idxExtraPtags; j < array3.Length; j++)
                                                {
                                                    array4[j - idxExtraPtags] = DataConverter <PropValueConverter, PropValue, PropValueData> .GetData(array3[j]);
                                                }
                                            }
                                            MessageRec value = new MessageRec(array3[idxEntryId].GetBytes(), this.FolderId, MapiUtils.GetDateTimeOrDefault(array3[idxCreationTime]), array3[idxMessageSize].GetInt(1000), doingFAI ? MsgRecFlags.Associated : MsgRecFlags.None, array4);
                                            result.Add(key, value);
                                            return;
                                        }
                                    });
                                }
                            }
                        }
                    }
                });
            }
            MrsTracer.Provider.Debug("MapiFolder.LookupMessages returns {0} items.", new object[]
            {
                result.Count
            });
            return(new List <MessageRec>(result.Values));
        }
Пример #16
0
        private List <T> InternalFind <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) where T : IConfigurable, new()
        {
            if (!RequestJobProvider.IsRequestStatistics(typeof(T), false))
            {
                throw new ArgumentException("RequestJobProvider can only find *RequestStatistics objects.");
            }
            List <T> list = new List <T>();
            RequestJobQueryFilter requestJobQueryFilter = filter as RequestJobQueryFilter;

            if (requestJobQueryFilter != null)
            {
                MRSRequestType?requestType = requestJobQueryFilter.RequestType;
                Guid           mdbGuid     = requestJobQueryFilter.MdbGuid;
                Guid           requestGuid = requestJobQueryFilter.RequestGuid;
                this.EnsureStoreConnectionExists(mdbGuid);
                Restriction restriction = null;
                if (requestType != null)
                {
                    RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox);
                    restriction = Restriction.EQ(requestJobNamedPropertySet.PropTags[14], requestType.Value);
                    if (requestType.Value == MRSRequestType.Move)
                    {
                        restriction = Restriction.Or(new Restriction[]
                        {
                            Restriction.Not(Restriction.Exist(requestJobNamedPropertySet.PropTags[14])),
                            restriction
                        });
                    }
                }
                byte[] searchKey = null;
                if (requestGuid != Guid.Empty)
                {
                    searchKey = RequestJobXML.CreateMessageSearchKey(requestGuid);
                }
                List <RequestJobXML> list2 = MoveObjectInfo <RequestJobXML> .LoadAll(searchKey, restriction, mdbGuid, this.store, RequestJobXML.RequestJobsFolderName, new MoveObjectInfo <RequestJobXML> .IsSupportedObjectTypeDelegate(RequestJobXML.IsMessageTypeSupported), new MoveObjectInfo <RequestJobXML> .EmptyTDelegate(this.CreateDummyFromSearchKey));

                if (list2 == null || list2.Count == 0)
                {
                    MrsTracer.Common.Debug("No RequestJob messages found.", new object[0]);
                }
                else
                {
                    foreach (RequestJobXML requestJobXML in list2)
                    {
                        RequestJobProvider.FixTenantInfo(requestJobXML);
                        RequestStatisticsBase requestStatisticsBase = RequestJobProvider.CreateRequestStatistics(typeof(T), requestJobXML, true);
                        requestStatisticsBase.OriginatingMDBGuid = mdbGuid;
                        if (requestStatisticsBase.Identity == null)
                        {
                            requestStatisticsBase.Identity = new RequestJobObjectId(requestStatisticsBase.IdentifyingGuid, mdbGuid, null);
                        }
                        if (!requestStatisticsBase.IsFake)
                        {
                            using (this.IndexProvider.RescopeTo(requestStatisticsBase.DomainControllerToUpdate, requestStatisticsBase.OrganizationId))
                            {
                                if (requestStatisticsBase.UserId != null)
                                {
                                    requestStatisticsBase.User = this.IndexProvider.ReadADUser(requestStatisticsBase.UserId, requestStatisticsBase.ExchangeGuid);
                                }
                                if (requestStatisticsBase.SourceUserId != null)
                                {
                                    requestStatisticsBase.SourceUser = this.IndexProvider.ReadADUser(requestStatisticsBase.SourceUserId, requestStatisticsBase.SourceExchangeGuid);
                                }
                                if (requestStatisticsBase.TargetUserId != null)
                                {
                                    requestStatisticsBase.TargetUser = this.IndexProvider.ReadADUser(requestStatisticsBase.TargetUserId, requestStatisticsBase.TargetExchangeGuid);
                                }
                                if (!typeof(T).Equals(typeof(MoveRequestStatistics)) && requestStatisticsBase.RequestType != MRSRequestType.Move)
                                {
                                    List <IRequestIndexEntry> list3 = new List <IRequestIndexEntry>();
                                    if (requestStatisticsBase.IndexIds != null && requestStatisticsBase.IndexIds.Count > 0)
                                    {
                                        foreach (RequestIndexId indexId in requestStatisticsBase.IndexIds)
                                        {
                                            IRequestIndexEntry requestIndexEntry;
                                            try
                                            {
                                                requestIndexEntry = this.IndexProvider.Read(new RequestIndexEntryObjectId(requestStatisticsBase.RequestGuid, requestStatisticsBase.TargetExchangeGuid, requestStatisticsBase.RequestType, requestStatisticsBase.OrganizationId, indexId, null));
                                            }
                                            catch (TenantOrgContainerNotFoundException)
                                            {
                                                requestIndexEntry = null;
                                            }
                                            if (requestIndexEntry != null)
                                            {
                                                list3.Add(requestIndexEntry);
                                            }
                                        }
                                    }
                                    requestStatisticsBase.IndexEntries = list3;
                                }
                                if (this.IndexProvider.DomainController == null && !string.IsNullOrEmpty(requestStatisticsBase.DomainControllerToUpdate))
                                {
                                    requestStatisticsBase.DomainControllerToUpdate = null;
                                }
                            }
                        }
                        requestStatisticsBase.ValidateRequestJob();
                        if (this.LoadReport)
                        {
                            ReportData reportData = new ReportData(requestStatisticsBase.IdentifyingGuid, requestStatisticsBase.ReportVersion);
                            reportData.Load(this.SystemMailbox);
                            requestStatisticsBase.Report = reportData.ToReport();
                        }
                        if (requestStatisticsBase != null && requestStatisticsBase.GetType().Equals(typeof(T)))
                        {
                            list.Add((T)((object)requestStatisticsBase));
                        }
                    }
                }
            }
            return(list);
        }
Пример #17
0
 internal PropertyError[] SetPropertiesWithChangeKeyCheck(byte[] changeKey, PropertyDefinition[] propertyDefinitions, object[] propertyValues)
 {
     if (changeKey != null)
     {
         return(this.InternalSetProperties(propertyDefinitions, propertyValues, (PropValue[] propValues) => ((MapiFolder)this.MapiProp).SetPropsConditional(Restriction.EQ(PropTag.ChangeKey, changeKey), propValues)));
     }
     return(this.SetProperties(propertyDefinitions, propertyValues));
 }
Пример #18
0
        private static Restriction BuildMessageKindRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            List <string> list = new List <string>();
            bool          flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            switch ((MessageKindEnum)ContentFilterBuilder.GetPropertyValue(filter))
            {
            case MessageKindEnum.Email:
                list.Add("IPM.Note");
                break;

            case MessageKindEnum.Calendar:
                list.Add("IPM.Schedule");
                list.Add("IPM.Appointment");
                break;

            case MessageKindEnum.Task:
                list.Add("IPM.Task");
                break;

            case MessageKindEnum.Note:
                list.Add("IPM.StickyNote");
                break;

            case MessageKindEnum.Doc:
                list.Add("IPM.Document");
                break;

            case MessageKindEnum.Journal:
                list.Add("IPM.Activity");
                break;

            case MessageKindEnum.Contact:
                list.Add("IPM.Contact");
                break;

            case MessageKindEnum.InstantMessage:
                list.Add("IPM.Note.Microsoft.Conversation");
                list.Add("IPM.Note.Microsoft.Missed");
                list.Add("IPM.Note.Microsoft.Conversation.Voice");
                list.Add("IPM.Note.Microsoft.Missed.Voice");
                break;

            case MessageKindEnum.Voicemail:
                list.Add("IPM.Note.Microsoft.Voicemail");
                break;

            case MessageKindEnum.Fax:
                list.Add("IPM.Note.Microsoft.Fax");
                break;

            case MessageKindEnum.Post:
                list.Add("IPM.Post");
                break;

            case MessageKindEnum.RSSFeed:
                list.Add("IPM.Post.RSS");
                break;

            default:
                throw ContentFilterBuilder.UnexpectedFilterType(filter);
            }
            Restriction[] array = new Restriction[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                array[i] = Restriction.EQ(ptagToSearch, list[i]);
            }
            Restriction restriction = (array.Length == 1) ? array[0] : Restriction.Or(array);

            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }