예제 #1
0
        protected QueryFilter ConstructQueryFilterWithCustomFilter(QueryFilter customFilter)
        {
            List <QueryFilter> list = new List <QueryFilter>();

            RecipientType[]             recipientTypes = this.RecipientTypes;
            List <RecipientTypeDetails> list2          = new List <RecipientTypeDetails>();

            if (this.InternalRecipientTypeDetails != null && this.InternalRecipientTypeDetails.Length > 0)
            {
                foreach (RecipientTypeDetails recipientTypeDetails in this.InternalRecipientTypeDetails)
                {
                    RecipientType recipientType = RecipientTaskHelper.RecipientTypeDetailsToRecipientType(recipientTypeDetails);
                    if (recipientType != RecipientType.Invalid && Array.IndexOf <RecipientType>(this.RecipientTypes, recipientType) != -1)
                    {
                        list2.Add(recipientTypeDetails);
                    }
                    else if (base.IsVerboseOn)
                    {
                        base.WriteVerbose(Strings.VerboseRecipientTypeDetailsIgnored(recipientTypeDetails.ToString()));
                    }
                }
                if (list2.Count == 0)
                {
                    base.WriteError(new ArgumentException(Strings.ErrorRecipientTypeDetailsConflictWithRecipientType), ErrorCategory.InvalidArgument, null);
                }
            }
            QueryFilter internalFilter = base.InternalFilter;

            if (internalFilter != null)
            {
                list.Add(internalFilter);
            }
            QueryFilter recipientTypeDetailsFilter = RecipientIdParameter.GetRecipientTypeDetailsFilter(list2.ToArray());

            if (recipientTypeDetailsFilter != null)
            {
                list.Add(recipientTypeDetailsFilter);
            }
            else
            {
                list.Add(RecipientIdParameter.GetRecipientTypeFilter(recipientTypes));
            }
            if (this.Organization != null)
            {
                QueryFilter item = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, base.CurrentOrganizationId.OrganizationalUnit);
                list.Add(item);
            }
            if (customFilter != null)
            {
                list.Add(customFilter);
            }
            if (list.Count != 1)
            {
                return(new AndFilter(list.ToArray()));
            }
            return(list[0]);
        }