protected static Restriction CreateOneOrTwoTimesRestrictions(ExDateTime?before, ExDateTime?after) { Restriction[] array = null; if (before != null && after != null) { array = new Restriction[2]; } if (before != null) { Restriction restriction = Condition.CreateDateTimePropertyRestriction(PropTag.MessageDeliveryTime, before.Value, Restriction.RelOp.LessThan); if (after == null) { return(restriction); } array[0] = restriction; } if (after != null) { Restriction restriction2 = Condition.CreateDateTimePropertyRestriction(PropTag.MessageDeliveryTime, after.Value, Restriction.RelOp.GreaterThan); if (before == null) { return(restriction2); } array[1] = restriction2; } return(Restriction.And(array)); }
protected static Restriction CreateSizeRestriction(int?atLeast, int?atMost) { Restriction[] array = null; if (atLeast != null && atMost != null) { array = new Restriction[2]; } if (atLeast != null) { Restriction restriction = Condition.CreateIntPropertyRestriction(PropTag.MessageSize, (atLeast * 1024).Value, Restriction.RelOp.GreaterThan); if (atMost == null) { return(restriction); } array[0] = restriction; } if (atMost != null) { Restriction restriction2 = Condition.CreateIntPropertyRestriction(PropTag.MessageSize, (atMost * 1024).Value, Restriction.RelOp.LessThan); if (atLeast == null) { return(restriction2); } array[1] = restriction2; } return(Restriction.And(array)); }
protected static Restriction CreateCcToMeRestriction() { return(Restriction.And(new Restriction[] { Condition.CreateBooleanPropertyRestriction(PropTag.MessageCcMe, true, Restriction.RelOp.Equal), Condition.CreateBooleanPropertyRestriction(PropTag.MessageRecipMe, true, Restriction.RelOp.Equal), Condition.CreateBooleanPropertyRestriction(PropTag.MessageToMe, false, Restriction.RelOp.Equal) })); }
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); }
protected static Restriction CreateOnlyToMeRestriction() { Restriction[] array = new Restriction[3]; array[0] = Condition.CreateBooleanPropertyRestriction(PropTag.MessageToMe, true, Restriction.RelOp.Equal); Restriction restriction = Condition.CreateStringContentRestriction(PropTag.DisplayTo, ";", ContentFlags.SubString); array[1] = Restriction.Not(restriction); array[2] = Condition.CreatePropertyRestriction <string>(PropTag.DisplayCc, string.Empty); return(Restriction.And(array)); }
private static Restriction BuildRestriction(QueryFilter filter, IFilterBuilderHelper helper) { CompositeFilter compositeFilter = filter as CompositeFilter; if (compositeFilter != null) { Restriction[] array = new Restriction[compositeFilter.FilterCount]; int num = 0; foreach (QueryFilter filter2 in compositeFilter.Filters) { array[num++] = ContentFilterBuilder.BuildRestriction(filter2, helper); } if (compositeFilter is AndFilter) { return(Restriction.And(array)); } if (compositeFilter is OrFilter) { return(Restriction.Or(array)); } throw ContentFilterBuilder.UnexpectedFilterType(filter); } else { NotFilter notFilter = filter as NotFilter; if (notFilter != null) { return(Restriction.Not(ContentFilterBuilder.BuildRestriction(notFilter.Filter, helper))); } SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter; if (singlePropertyFilter == null) { throw ContentFilterBuilder.UnexpectedFilterType(filter); } ContentFilterSchema.ContentFilterPropertyDefinition contentFilterPropertyDefinition = singlePropertyFilter.Property as ContentFilterSchema.ContentFilterPropertyDefinition; if (contentFilterPropertyDefinition == null) { throw ContentFilterBuilder.UnexpectedFilterType(filter); } return(contentFilterPropertyDefinition.ConvertToRestriction(singlePropertyFilter, helper)); } }
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); }
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); }
internal static Restriction ConvertToMapiRestriction(Restriction restriction) { if (restriction == null) { return(null); } switch (restriction.RestrictionType) { case RestrictionType.And: return(Restriction.And(ConvertHelper.ConvertToMapiRestrictions(((CompositeRestriction)restriction).ChildRestrictions))); case RestrictionType.Or: return(Restriction.Or(ConvertHelper.ConvertToMapiRestrictions(((CompositeRestriction)restriction).ChildRestrictions))); case RestrictionType.Not: return(Restriction.Not(ConvertHelper.ConvertToMapiRestriction(((NotRestriction)restriction).ChildRestriction))); case RestrictionType.Content: { ContentRestriction contentRestriction = restriction as ContentRestriction; if (contentRestriction.PropertyValue == null) { throw new NspiException(NspiStatus.InvalidParameter, "Null PropertyValue is not valid for ContentRestriction."); } return(Restriction.Content(ConvertHelper.ConvertToMapiPropTag(contentRestriction.PropertyTag), contentRestriction.PropertyTag.IsMultiValuedProperty, ConvertHelper.ConvertToMapiPropValue(contentRestriction.PropertyValue.Value), (ContentFlags)contentRestriction.FuzzyLevel)); } case RestrictionType.Property: { PropertyRestriction propertyRestriction = restriction as PropertyRestriction; if (propertyRestriction.PropertyValue == null) { throw new NspiException(NspiStatus.InvalidParameter, "Null PropertyValue is not valid for PropertyRestriction."); } return(Restriction.Property(ConvertHelper.ConvertToMapiRelOp(propertyRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(propertyRestriction.PropertyTag), propertyRestriction.PropertyTag.IsMultiValuedProperty, ConvertHelper.ConvertToMapiPropValue(propertyRestriction.PropertyValue.Value))); } case RestrictionType.CompareProps: { ComparePropsRestriction comparePropsRestriction = restriction as ComparePropsRestriction; return(Restriction.CompareProps(ConvertHelper.ConvertToMapiRelOp(comparePropsRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(comparePropsRestriction.Property1), ConvertHelper.ConvertToMapiPropTag(comparePropsRestriction.Property2))); } case RestrictionType.BitMask: { BitMaskRestriction bitMaskRestriction = restriction as BitMaskRestriction; return(Restriction.BitMask(ConvertHelper.ConvertToMapiRelBmr(bitMaskRestriction.BitMaskOperator), ConvertHelper.ConvertToMapiPropTag(bitMaskRestriction.PropertyTag), (int)bitMaskRestriction.BitMask)); } case RestrictionType.Size: { SizeRestriction sizeRestriction = restriction as SizeRestriction; return(Restriction.PropertySize(ConvertHelper.ConvertToMapiRelOp(sizeRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(sizeRestriction.PropertyTag), (int)sizeRestriction.Size)); } case RestrictionType.Exists: { ExistsRestriction existsRestriction = restriction as ExistsRestriction; return(Restriction.Exist(ConvertHelper.ConvertToMapiPropTag(existsRestriction.PropertyTag))); } case RestrictionType.SubRestriction: { SubRestriction subRestriction = restriction as SubRestriction; return(Restriction.Sub(ConvertHelper.ConvertToMapiPropTag(subRestriction.SubRestrictionType), ConvertHelper.ConvertToMapiRestriction(subRestriction.ChildRestriction))); } default: throw new NspiException(NspiStatus.InvalidParameter, string.Format("Invalid restriction type: {0}", restriction)); } }
internal Restriction ReadRestriction() { OutlookBlobWriter.RestrictionType restrictionType = (OutlookBlobWriter.RestrictionType) this.ReadInt(); switch (restrictionType) { case OutlookBlobWriter.RestrictionType.And: case OutlookBlobWriter.RestrictionType.Or: { int num = this.ReadInt(); Restriction[] array = new Restriction[num]; for (int i = 0; i < num; i++) { array[i] = this.ReadRestriction(); } if (restrictionType == OutlookBlobWriter.RestrictionType.And) { return(Restriction.And(array)); } return(Restriction.Or(array)); } case OutlookBlobWriter.RestrictionType.Not: return(Restriction.Not(this.ReadRestriction())); case OutlookBlobWriter.RestrictionType.Content: { ContentFlags flags = (ContentFlags)this.ReadInt(); PropTag tag = (PropTag)this.ReadInt(); return(Restriction.Content(tag, this.ReadPropValue().Value, flags)); } case OutlookBlobWriter.RestrictionType.Property: { Restriction.RelOp relOp = (Restriction.RelOp) this.ReadInt(); PropTag tag2 = (PropTag)this.ReadInt(); return(new Restriction.PropertyRestriction(relOp, tag2, this.ReadPropValue().Value)); } case OutlookBlobWriter.RestrictionType.PropertyComparison: { Restriction.RelOp relOp2 = (Restriction.RelOp) this.ReadInt(); PropTag tagLeft = (PropTag)this.ReadInt(); PropTag tagRight = (PropTag)this.ReadInt(); return(new Restriction.ComparePropertyRestriction(relOp2, tagLeft, tagRight)); } case OutlookBlobWriter.RestrictionType.Bitmask: if (this.ReadInt() == 0) { return(Restriction.BitMaskZero((PropTag)this.ReadInt(), this.ReadInt())); } return(Restriction.BitMaskNonZero((PropTag)this.ReadInt(), this.ReadInt())); case OutlookBlobWriter.RestrictionType.Size: { Restriction.RelOp relop = (Restriction.RelOp) this.ReadInt(); PropTag tag3 = (PropTag)this.ReadInt(); int size = this.ReadInt(); return(new Restriction.SizeRestriction(relop, tag3, size)); } case OutlookBlobWriter.RestrictionType.Exist: { PropTag tag4 = (PropTag)this.ReadInt(); return(Restriction.Exist(tag4)); } case OutlookBlobWriter.RestrictionType.Subfilter: { PropTag propTag = (PropTag)this.ReadInt(); if (propTag == PropTag.MessageAttachments || propTag == PropTag.MessageRecipients) { return(Restriction.Sub(propTag, this.ReadRestriction())); } throw new CorruptDataException(ServerStrings.ExUnknownRestrictionType); } default: throw new CorruptDataException(ServerStrings.ExUnknownRestrictionType); } }
protected static Restriction CreateAndRestriction(Restriction[] subRestrictions) { return(Restriction.And(subRestrictions)); }
internal override Restriction GetRestriction() { return(Restriction.And(base.GetRestrictions())); }