private static Restriction BuildRestrictionWrapper(SinglePropertyFilter filter, PropTag ptagToSearch, IFilterBuilderHelper mapper, ContentFilterBuilder.BuildRestrictionDelegate restrictionBuilder)
 {
     ContentFilterSchema.ContentFilterPropertyDefinition contentFilterPropertyDefinition = (ContentFilterSchema.ContentFilterPropertyDefinition)filter.Property;
     if (ptagToSearch == PropTag.Null)
     {
         if (contentFilterPropertyDefinition.NamedPropToSearch != null)
         {
             ptagToSearch = mapper.MapNamedProperty(contentFilterPropertyDefinition.NamedPropToSearch, contentFilterPropertyDefinition.NamedPropType);
         }
         else
         {
             ptagToSearch = contentFilterPropertyDefinition.PropTagToSearch;
         }
     }
     if (filter is ExistsFilter)
     {
         return(Restriction.Exist(ptagToSearch));
     }
     return(restrictionBuilder(filter, mapper, ptagToSearch));
 }
Beispiel #2
0
 internal override Restriction GetRestriction()
 {
     return(Restriction.Exist((PropTag)this.PropTag));
 }
        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);
            }
        }
        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));
            }
        }
Beispiel #5
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);
        }