コード例 #1
0
 private void DeleteOldTestFolders()
 {
     using (MapiTable hierarchyTable = this.parentFolder.GetHierarchyTable())
     {
         PropValue[][] array = hierarchyTable.QueryAllRows(Restriction.Content(PropTag.DisplayName, "test-exchangesearch-folder-", ContentFlags.Prefix), new PropTag[]
         {
             PropTag.EntryId
         });
         foreach (PropValue[] array3 in array)
         {
             this.threadExit.CheckStop();
             this.parentFolder.DeleteFolder(array3[0].GetBytes(), DeleteFolderFlags.DeleteMessages | DeleteFolderFlags.DelSubFolders | DeleteFolderFlags.ForceHardDelete);
         }
     }
 }
コード例 #2
0
        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();
                }
            }
        }
コード例 #3
0
        private static Restriction BuildTextRestriction(TextFilter filter, PropTag ptagToSearch, object propValue)
        {
            ContentFlags contentFlags;

            switch (filter.MatchOptions)
            {
            case MatchOptions.FullString:
                contentFlags = ContentFlags.FullString;
                break;

            case MatchOptions.SubString:
            case MatchOptions.Suffix:
            case MatchOptions.WildcardString:
                contentFlags = ContentFlags.SubString;
                break;

            case MatchOptions.Prefix:
                contentFlags = ContentFlags.Prefix;
                break;

            case MatchOptions.PrefixOnWords:
                contentFlags = ContentFlags.PrefixOnWords;
                break;

            case MatchOptions.ExactPhrase:
                contentFlags = ContentFlags.ExactPhrase;
                break;

            default:
                contentFlags = ContentFlags.FullString;
                break;
            }
            if ((filter.MatchFlags & MatchFlags.IgnoreCase) != MatchFlags.Default)
            {
                contentFlags |= ContentFlags.IgnoreCase;
            }
            if ((filter.MatchFlags & MatchFlags.IgnoreNonSpace) != MatchFlags.Default)
            {
                contentFlags |= ContentFlags.IgnoreNonSpace;
            }
            if ((filter.MatchFlags & MatchFlags.Loose) != MatchFlags.Default)
            {
                contentFlags |= ContentFlags.Loose;
            }
            return(Restriction.Content(ptagToSearch, propValue, contentFlags));
        }
コード例 #4
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);
 }
コード例 #5
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));
        }
コード例 #6
0
 internal static Restriction BuildSenderCondition(SmtpAddress smtpAddress)
 {
     return(Restriction.Content(PropTag.SenderSmtpAddress, smtpAddress.ToString(), ContentFlags.IgnoreCase));
 }
コード例 #7
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));
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
0
 internal bool DoSearch()
 {
     return(this.SearchSucceeded(Restriction.Content(PropTag.Subject, this.searchString, ContentFlags.Prefix)));
 }
コード例 #10
0
 protected static Restriction CreateStringContentRestriction(PropTag propertyTag, string value, ContentFlags flags)
 {
     return(Restriction.Content(propertyTag, value, flags));
 }
コード例 #11
0
 protected static Restriction CreateSearchKeyContentRestriction(PropTag propertyTag, byte[] value, ContentFlags flags)
 {
     return(Restriction.Content(propertyTag, value, flags));
 }