public static void ProcessContentFilter(string contentFilter, int contentFilterLCID, PSCmdlet cmdlet, IFilterBuilderHelper mapper, out RestrictionData restriction, out string normalizedFilter)
        {
            Exception ex = null;

            try
            {
                QueryParser queryParser  = new QueryParser(contentFilter, ObjectSchema.GetInstance <ContentFilterSchema>(), QueryParser.Capabilities.All, (cmdlet != null) ? new QueryParser.EvaluateVariableDelegate(cmdlet.GetVariableValue) : null, new QueryParser.ConvertValueFromStringDelegate(ContentFilterBuilder.ConvertValueFromString));
                QueryFilter parseTree    = queryParser.ParseTree;
                Restriction restriction2 = ContentFilterBuilder.BuildRestriction(parseTree, mapper);
                restriction      = RestrictionData.GetRestrictionData(restriction2);
                restriction.LCID = contentFilterLCID;
                normalizedFilter = parseTree.GenerateInfixString(FilterLanguage.Monad);
                return;
            }
            catch (InvalidCastException ex2)
            {
                ex = ex2;
            }
            catch (ParsingException ex3)
            {
                ex = ex3;
            }
            catch (ArgumentOutOfRangeException ex4)
            {
                ex = ex4;
            }
            throw new InvalidContentFilterPermanentException(ex.Message, ex);
        }
Beispiel #2
0
 void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
 {
     MrsTracer.Provider.Function("PstFolder.GetSearchCriteria", new object[0]);
     restriction = null;
     entryIds    = null;
     state       = SearchState.None;
 }
Beispiel #3
0
 internal void ParseQueryFilter(StoreSession storeSession, QueryFilter queryFilter)
 {
     this.Restrictions = new RestrictionData[]
     {
         RestrictionData.GetRestrictionData(storeSession, queryFilter)
     };
 }
Beispiel #4
0
 public void TranslateRestriction(RestrictionData r)
 {
     if (r != null)
     {
         r.EnumeratePropValues(new CommonUtils.EnumPropValueDelegate(this.TranslatePropValue));
     }
 }
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
     MrsTracer.Provider.Function("StorageFolder.SetContentsRestriction: {0}", new object[]
     {
         this.DisplayNameForTracing
     });
     this.contentsRestriction = restriction;
 }
Beispiel #6
0
 internal void ParseQueryFilters(StoreSession storeSession, ReadOnlyCollection <QueryFilter> queryFilters)
 {
     this.Restrictions = new RestrictionData[queryFilters.Count];
     for (int i = 0; i < queryFilters.Count; i++)
     {
         this.Restrictions[i] = RestrictionData.GetRestrictionData(storeSession, queryFilters[i]);
     }
 }
Beispiel #7
0
 internal void ParseRestrictions(params Restriction[] rest)
 {
     this.Restrictions = new RestrictionData[rest.Length];
     for (int i = 0; i < rest.Length; i++)
     {
         this.Restrictions[i] = RestrictionData.GetRestrictionData(rest[i]);
     }
 }
 public void TranslateRestriction(RestrictionData rest)
 {
     if (rest != null)
     {
         this.ResolveMappingsIfNeeded();
         rest.EnumeratePropTags(new CommonUtils.EnumPropTagDelegate(this.TranslatePtag));
     }
 }
        bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
        {
            Restriction native = DataConverter <RestrictionConverter, Restriction, RestrictionData> .GetNative(restriction);

            using (base.Mailbox.RHTracker.Start())
            {
                base.Folder.SetSearchCriteria(native, entryIds, flags);
            }
            return(true);
        }
Beispiel #10
0
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
     base.CreateContext("IFolder.SetContentsRestriction", new DataContext[]
     {
         new RestrictionDataContext(restriction)
     }).Execute(delegate
     {
         this.WrappedObject.SetContentsRestriction(restriction);
     }, true);
 }
Beispiel #11
0
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
     MrsTracer.ProxyClient.Function("IFolder.SetContentsRestriction(): {0}", new object[]
     {
         this.FolderName
     });
     if (!base.ServerVersion[8])
     {
         throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IFolder_SetContentsRestriction");
     }
     base.MrsProxy.IFolder_SetContentsRestriction(base.Handle, restriction);
 }
Beispiel #12
0
        bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
        {
            bool result = false;

            base.CreateContext("IDestinationFolder.SetSearchCriteria", new DataContext[]
            {
                new RestrictionDataContext(restriction),
                new EntryIDsDataContext(entryIds),
                new SimpleValueDataContext("Flags", flags)
            }).Execute(delegate
            {
                result = ((IDestinationFolder)this.WrappedObject).SetSearchCriteria(restriction, entryIds, flags);
            }, true);
            return(result);
        }
Beispiel #13
0
        void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
        {
            RestrictionData restrictionInt = null;

            byte[][]    entryIdsInt = null;
            SearchState stateInt    = SearchState.None;

            base.CreateContext("IFolder.GetSearchCriteria", new DataContext[0]).Execute(delegate
            {
                this.WrappedObject.GetSearchCriteria(out restrictionInt, out entryIdsInt, out stateInt);
            }, true);
            restriction = restrictionInt;
            entryIds    = entryIdsInt;
            state       = stateInt;
        }
Beispiel #14
0
 void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
 {
     MrsTracer.ProxyClient.Function("IFolder.GetSearchCriteria(): {0}", new object[]
     {
         this.FolderName
     });
     if (base.ServerVersion[8])
     {
         int num;
         base.MrsProxy.IFolder_GetSearchCriteria(base.Handle, out restriction, out entryIds, out num);
         state = (SearchState)num;
         return;
     }
     if (this is RemoteSourceFolder)
     {
         int num;
         base.MrsProxy.ISourceFolder_GetSearchCriteria(base.Handle, out restriction, out entryIds, out num);
         state = (SearchState)num;
         return;
     }
     throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IFolder_GetProps");
 }
Beispiel #15
0
        void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
        {
            MrsTracer.Provider.Function("StorageFolder.GetSearchCriteria: {0}", new object[]
            {
                this.DisplayNameForTracing
            });
            restriction = null;
            entryIds    = null;
            state       = SearchState.None;
            SearchFolderCriteria searchFolderCriteria = null;

            try
            {
                using (this.Mailbox.RHTracker.Start())
                {
                    searchFolderCriteria = this.CoreFolder.GetSearchCriteria(false);
                }
            }
            catch (ObjectNotInitializedException ex)
            {
                MrsTracer.Provider.Warning("GetSearchCriteria failed with ObjectNotInitializedException, ignoring.\n{0}", new object[]
                {
                    CommonUtils.FullExceptionMessage(ex)
                });
            }
            if (searchFolderCriteria != null)
            {
                state = (SearchState)searchFolderCriteria.SearchState;
                if (searchFolderCriteria.FolderScope != null)
                {
                    entryIds = new byte[searchFolderCriteria.FolderScope.Length][];
                    for (int i = 0; i < searchFolderCriteria.FolderScope.Length; i++)
                    {
                        entryIds[i] = StoreId.GetStoreObjectId(searchFolderCriteria.FolderScope[i]).ProviderLevelItemId;
                    }
                }
                restriction = RestrictionData.GetRestrictionData(this.Mailbox.StoreSession, searchFolderCriteria.SearchQuery);
            }
        }
Beispiel #16
0
 void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
 {
     MrsTracer.Provider.Function("MapiFolder.GetSearchCriteria", new object[0]);
     try
     {
         Restriction native;
         using (this.Mailbox.RHTracker.Start())
         {
             this.Folder.GetSearchCriteria(out native, out entryIds, out state);
         }
         restriction = DataConverter <RestrictionConverter, Restriction, RestrictionData> .GetData(native);
     }
     catch (MapiExceptionNotInitialized ex)
     {
         MrsTracer.Provider.Warning("GetSearchCriteria failed with ecNotInitialized, ignoring.\n{0}", new object[]
         {
             CommonUtils.FullExceptionMessage(ex)
         });
         restriction = null;
         entryIds    = null;
         state       = SearchState.None;
     }
 }
        bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
        {
            MrsTracer.Provider.Function("StorageDestinationFolder.SetSearchCriteria: {0}", new object[]
            {
                base.DisplayNameForTracing
            });
            QueryFilter queryFilter = restriction.GetQueryFilter(base.Mailbox.StoreSession);

            StoreId[] array = null;
            if (entryIds != null && entryIds.Length > 0)
            {
                array = new StoreId[entryIds.Length];
                for (int i = 0; i < entryIds.Length; i++)
                {
                    array[i] = StoreObjectId.FromProviderSpecificId(entryIds[i]);
                }
            }
            using (base.Mailbox.RHTracker.Start())
            {
                SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(queryFilter, array);
                base.CoreFolder.SetSearchCriteria(searchFolderCriteria, this.ConvertSearchCriteriaFlags(flags));
            }
            return(true);
        }
Beispiel #18
0
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
 }
 public void SetExtendedProps(PropTag[] promotedProperties, RestrictionData[] restrictions, SortOrderData[] views, ICSViewData[] icsViews)
 {
     MrsTracer.Provider.Function("MapiDestinationFolder.SetExtendedProps", new object[0]);
     if (promotedProperties != null && promotedProperties.Length > 0)
     {
         ExecutionContext.Create(new DataContext[]
         {
             new OperationDataContext("MapiDestinationFolder.SetPromotedProps", OperationType.None),
             new PropTagsDataContext(promotedProperties)
         }).Execute(delegate
         {
             using (this.Mailbox.RHTracker.Start())
             {
                 using (MapiTable contentsTable = this.Folder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                 {
                     contentsTable.SetColumns(promotedProperties);
                     contentsTable.QueryRows(1);
                 }
             }
         });
     }
     if (restrictions != null && restrictions.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying restrictions.", new object[0]);
         for (int i = 0; i < restrictions.Length; i++)
         {
             RestrictionData rd = restrictions[i];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplyRestriction", OperationType.None),
                 new RestrictionDataContext(rd)
             }).Execute(delegate
             {
                 Restriction native = DataConverter <RestrictionConverter, Restriction, RestrictionData> .GetNative(rd);
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiTable contentsTable = this.Folder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                     {
                         using (new SortLCIDContext(this.Folder.MapiStore, rd.LCID))
                         {
                             contentsTable.Restrict(native);
                             contentsTable.QueryRows(1);
                         }
                     }
                 }
             });
         }
     }
     if (views != null && views.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying views.", new object[0]);
         for (int j = 0; j < views.Length; j++)
         {
             SortOrderData sod = views[j];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplySortOrder", OperationType.None),
                 new SortOrderDataContext(sod)
             }).Execute(delegate
             {
                 SortOrder native = DataConverter <SortOrderConverter, SortOrder, SortOrderData> .GetNative(sod);
                 ContentsTableFlags contentsTableFlags = ContentsTableFlags.DeferredErrors;
                 if (sod.FAI)
                 {
                     contentsTableFlags |= ContentsTableFlags.Associated;
                 }
                 else if (sod.Conversation)
                 {
                     contentsTableFlags |= ContentsTableFlags.ShowConversations;
                 }
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiTable contentsTable = this.Folder.GetContentsTable(contentsTableFlags))
                     {
                         using (new SortLCIDContext(this.Folder.MapiStore, sod.LCID))
                         {
                             contentsTable.SortTable(native, SortTableFlags.None);
                             contentsTable.QueryRows(1);
                         }
                     }
                 }
             });
         }
     }
     if (icsViews != null && icsViews.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying ICS views.", new object[0]);
         for (int k = 0; k < icsViews.Length; k++)
         {
             ICSViewData icsView = icsViews[k];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplyICSView", OperationType.None),
                 new ICSViewDataContext(icsView)
             }).Execute(delegate
             {
                 ManifestConfigFlags flags = ManifestConfigFlags.Associated | ManifestConfigFlags.Normal;
                 if (icsView.Conversation)
                 {
                     flags = ManifestConfigFlags.Conversations;
                 }
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiManifest mapiManifest = this.Folder.CreateExportManifest())
                     {
                         PropTag[] array = Array <PropTag> .Empty;
                         if (icsView.CoveringPropertyTags != null)
                         {
                             array = new PropTag[icsView.CoveringPropertyTags.Length];
                             for (int l = 0; l < icsView.CoveringPropertyTags.Length; l++)
                             {
                                 array[l] = (PropTag)icsView.CoveringPropertyTags[l];
                             }
                         }
                         mapiManifest.Configure(flags, null, null, MapiDestinationFolder.DummyManifestContentsCallback.Instance, array);
                         while (mapiManifest.Synchronize() != ManifestStatus.Done)
                         {
                         }
                     }
                 }
             });
         }
     }
 }
 bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
 {
     return(base.MrsProxy.IDestinationFolder_SetSearchCriteria(base.Handle, restriction, entryIds, (int)flags));
 }
Beispiel #21
0
 bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
 {
     return(true);
 }
Beispiel #22
0
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
     this.contentsRestriction = restriction;
 }
 bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
 {
     throw new NotImplementedException();
 }
 public void EnumerateRestriction(FolderRec folderRec, BadItemKind badItemKind, RestrictionData rest)
 {
     if (rest != null)
     {
         CommonUtils.ProcessKnownExceptions(delegate
         {
             rest.EnumeratePropTags(new CommonUtils.EnumPropTagDelegate(this.EnumeratePtag));
         }, delegate(Exception ex)
         {
             if (this.reportBadItemsDelegate != null && CommonUtils.ExceptionIsAny(ex, new WellKnownException[]
             {
                 WellKnownException.DataProviderPermanent,
                 WellKnownException.CorruptData
             }))
             {
                 List <BadMessageRec> list = new List <BadMessageRec>(1);
                 list.Add(BadMessageRec.Folder(folderRec, badItemKind, ex));
                 this.reportBadItemsDelegate(list);
                 return(true);
             }
             return(false);
         });
         this.hasUnresolvedMappings = true;
     }
 }
Beispiel #25
0
 void IFolder.SetContentsRestriction(RestrictionData restriction)
 {
     throw new NotImplementedException();
 }
 public void SetExtendedProps(PropTag[] promotedProperties, RestrictionData[] restrictions, SortOrderData[] views, ICSViewData[] icsViews)
 {
     MrsTracer.Provider.Function("StorageDestinationFolder.SetExtendedProps: {0}", new object[]
     {
         base.DisplayNameForTracing
     });
     if (promotedProperties != null && promotedProperties.Length > 0)
     {
         ExecutionContext.Create(new DataContext[]
         {
             new OperationDataContext("StorageDestinationFolder.SetPromotedProps", OperationType.None),
             new PropTagsDataContext(promotedProperties)
         }).Execute(delegate
         {
             PropertyDefinition[] dataColumns = this.Mailbox.ConvertPropTagsToDefinitions(promotedProperties);
             using (this.Mailbox.RHTracker.Start())
             {
                 using (QueryResult queryResult = this.CoreFolder.QueryExecutor.ItemQuery(ItemQueryType.None, null, null, dataColumns))
                 {
                     this.GetRowsIgnoreKnownFailures(queryResult);
                 }
             }
         });
     }
     if (restrictions != null && restrictions.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying restrictions.", new object[0]);
         for (int i = 0; i < restrictions.Length; i++)
         {
             RestrictionData rd = restrictions[i];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("StorageDestinationFolder.ApplyRestriction", OperationType.None),
                 new RestrictionDataContext(rd)
             }).Execute(delegate
             {
                 QueryFilter queryFilter          = rd.GetQueryFilter(this.Mailbox.StoreSession);
                 PropertyDefinition[] dataColumns = new PropertyDefinition[]
                 {
                     CoreObjectSchema.EntryId
                 };
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (new SortLCIDContext(this.Mailbox.StoreSession, rd.LCID))
                     {
                         using (QueryResult queryResult = this.CoreFolder.QueryExecutor.ItemQuery(ItemQueryType.None, queryFilter, null, dataColumns))
                         {
                             this.GetRowsIgnoreKnownFailures(queryResult);
                         }
                     }
                 }
             });
         }
     }
     if (views != null && views.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying views.", new object[0]);
         for (int j = 0; j < views.Length; j++)
         {
             SortOrderData sod = views[j];
             if (sod.Members != null && sod.Members.Length != 0)
             {
                 ExecutionContext.Create(new DataContext[]
                 {
                     new OperationDataContext("StorageDestinationFolder.ApplySortOrder", OperationType.None),
                     new SortOrderDataContext(sod)
                 }).Execute(delegate
                 {
                     List <SortBy> list;
                     List <GroupByAndOrder> list2;
                     int expandCount;
                     this.GetSortBy(sod, out list, out list2, out expandCount);
                     ItemQueryType itemQueryType = ItemQueryType.None;
                     if (sod.FAI)
                     {
                         itemQueryType |= ItemQueryType.Associated;
                     }
                     else if (sod.Conversation)
                     {
                         itemQueryType |= ItemQueryType.ConversationView;
                     }
                     PropertyDefinition[] dataColumns = new PropertyDefinition[]
                     {
                         CoreObjectSchema.EntryId
                     };
                     using (this.Mailbox.RHTracker.Start())
                     {
                         using (new SortLCIDContext(this.Mailbox.StoreSession, sod.LCID))
                         {
                             QueryResult queryResult;
                             if (list2.Count > 0)
                             {
                                 queryResult = this.CoreFolder.QueryExecutor.GroupedItemQuery(null, itemQueryType, list2.ToArray(), expandCount, list.ToArray(), dataColumns);
                             }
                             else
                             {
                                 queryResult = this.CoreFolder.QueryExecutor.ItemQuery(itemQueryType, null, (list.Count == 0) ? null : list.ToArray(), dataColumns);
                             }
                             using (queryResult)
                             {
                                 this.GetRowsIgnoreKnownFailures(queryResult);
                             }
                         }
                     }
                 });
             }
         }
     }
     if (icsViews != null && icsViews.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying ICS views.", new object[0]);
         for (int k = 0; k < icsViews.Length; k++)
         {
             ICSViewData icsView = icsViews[k];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("StorageDestinationFolder.ApplyICSView", OperationType.None),
                 new ICSViewDataContext(icsView)
             }).Execute(delegate
             {
                 using (MailboxSyncProvider mailboxSyncProvider = new MailboxSyncProvider(this.Folder, true, !icsView.Conversation, true, icsView.Conversation, true, false, null))
                 {
                     mailboxSyncProvider.GetMaxItemWatermark(mailboxSyncProvider.CreateNewWatermark());
                 }
             });
         }
     }
 }
Beispiel #27
0
 void IFolder.GetSearchCriteria(out RestrictionData restriction, out byte[][] entryIds, out SearchState state)
 {
     throw new NotImplementedException();
 }
 public RestrictionDataContext(RestrictionData restriction)
 {
     this.restriction = restriction;
 }