Пример #1
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);
        }
Пример #2
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);
        }
Пример #4
0
        internal override Restriction BuildRestriction()
        {
            Restriction restriction = Condition.CreateORStringContentRestriction(base.Text, PropTag.MessageClass, ContentFlags.IgnoreCase | ContentFlags.Loose);

            if (Restriction.ResType.Content == restriction.Type)
            {
                return(Restriction.Or(new Restriction[]
                {
                    restriction
                }));
            }
            return(restriction);
        }
        private static void CleanUpInbox(MapiFolder folder)
        {
            DateTime  t = DateTime.UtcNow.AddMinutes(-20.0);
            MapiTable contentsTable;
            MapiTable mapiTable = contentsTable = folder.GetContentsTable();

            try
            {
                mapiTable.SetColumns(new PropTag[]
                {
                    PropTag.EntryId,
                    PropTag.MessageDeliveryTime,
                    PropTag.NormalizedSubject,
                    PropTag.OriginalSubject
                });
                Restriction restriction = Restriction.Or(new Restriction[]
                {
                    Restriction.Content(PropTag.NormalizedSubject, "66c7004a-6860-44b2-983a-327aa3c9cfec", ContentFlags.SubString | ContentFlags.IgnoreCase),
                    Restriction.Content(PropTag.OriginalSubject, "66c7004a-6860-44b2-983a-327aa3c9cfec", ContentFlags.SubString | ContentFlags.IgnoreCase)
                });
                mapiTable.Restrict(restriction);
                mapiTable.SortTable(new SortOrder(PropTag.MessageDeliveryTime, SortFlags.Ascend), SortTableFlags.None);
                PropValue[][] array = mapiTable.QueryRows(100, QueryRowsFlags.None);
                List <byte[]> list  = new List <byte[]>(100);
                for (int i = 0; i <= array.GetUpperBound(0); i++)
                {
                    if (TestMailFlowHelper.IsValidPropData(array, i, 2))
                    {
                        if (array[i][1].GetDateTime() > t)
                        {
                            break;
                        }
                        list.Add(array[i][0].GetBytes());
                    }
                }
                if (list.Count > 0)
                {
                    folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list.ToArray());
                }
            }
            finally
            {
                if (contentsTable != null)
                {
                    ((IDisposable)contentsTable).Dispose();
                }
            }
        }
Пример #6
0
 protected static Restriction CreateORStringContentRestriction(string[] values, PropTag propertyTag, ContentFlags flags)
 {
     if (values.Length > 1)
     {
         Restriction[] array = new Restriction.ContentRestriction[values.Length];
         for (int i = 0; i < values.Length; i++)
         {
             array[i] = Restriction.Content(propertyTag, values[i], flags);
         }
         return(Restriction.Or(array));
     }
     if (values.Length == 1)
     {
         return(Condition.CreateStringContentRestriction(propertyTag, values[0], flags));
     }
     return(null);
 }
        internal static Restriction BuildAttachmentRestriction(SinglePropertyFilter filter, IFilterBuilderHelper mapper)
        {
            Restriction restriction  = ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.SearchAttachments, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal));
            Restriction restriction2 = Restriction.Or(new Restriction[]
            {
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachFileName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachLongFileName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachExtension, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.DisplayName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal))
            });

            return(Restriction.Or(new Restriction[]
            {
                restriction,
                Restriction.Sub(PropTag.MessageAttachments, restriction2)
            }));
        }
Пример #8
0
 protected static Restriction CreateORGuidContentRestriction(Guid[] values, PropTag propertyTag)
 {
     if (values.Length > 1)
     {
         Restriction[] array = new Restriction.PropertyRestriction[values.Length];
         for (int i = 0; i < values.Length; i++)
         {
             array[i] = Condition.CreatePropertyRestriction <Guid>(propertyTag, values[i]);
         }
         return(Restriction.Or(array));
     }
     if (values.Length == 1)
     {
         return(Condition.CreatePropertyRestriction <Guid>(propertyTag, values[0]));
     }
     return(null);
 }
Пример #9
0
 protected static Restriction CreateSubjectOrBodyRestriction(string[] values)
 {
     Restriction[] array = new Restriction.ContentRestriction[values.Length * 2];
     if (values.Length > 0)
     {
         int i   = 0;
         int num = 0;
         while (i < values.Length)
         {
             array[num]     = Condition.CreateStringContentRestriction(PropTag.Subject, values[i], ContentFlags.SubString | ContentFlags.IgnoreCase);
             array[num + 1] = Condition.CreateStringContentRestriction(PropTag.Body, values[i], ContentFlags.SubString | ContentFlags.IgnoreCase);
             i++;
             num += 2;
         }
         return(Restriction.Or(array));
     }
     return(null);
 }
Пример #10
0
        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));
            }
        }
        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);
        }
Пример #12
0
        private static Restriction BuildRecipientRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            List <Restriction> list = new List <Restriction>();
            bool flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            object propertyValue = ContentFilterBuilder.GetPropertyValue(filter);

            list.Add(Restriction.Content(ptagToSearch, propertyValue, ContentFlags.Prefix | ContentFlags.IgnoreCase));
            string text = propertyValue as string;

            if (text != null)
            {
                string[] array = mapper.MapRecipient(text);
                if (array != null)
                {
                    foreach (string text2 in array)
                    {
                        if (!StringComparer.OrdinalIgnoreCase.Equals(text2, text))
                        {
                            list.Add(Restriction.Content(ptagToSearch, text2, ContentFlags.Prefix | ContentFlags.IgnoreCase));
                        }
                    }
                }
            }
            Restriction restriction;

            if (list.Count == 1)
            {
                restriction = list[0];
            }
            else
            {
                restriction = Restriction.Or(list.ToArray());
            }
            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }
Пример #13
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));
        }
 internal static Restriction BuildRuleCondition(IEnumerable <SmtpAddress> neverClutterSenders)
 {
     return(Restriction.Or((from address in neverClutterSenders
                            select ClutterOverrideManager.BuildSenderCondition(address)).ToArray <Restriction>()));
 }
Пример #15
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));
        }
Пример #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 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);
            }
        }
Пример #18
0
        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));
            }
        }
Пример #19
0
 internal override Restriction GetRestriction()
 {
     return(Restriction.Or(base.GetRestrictions()));
 }