Beispiel #1
0
        public PropertyBag[] QueryAttachmentTable(NativeStorePropertyDefinition[] properties)
        {
            this.CheckDisposed(null);
            if (this.savedAttachmentList.Count == 0)
            {
                return(null);
            }
            Dictionary <StorePropertyDefinition, int> propertyPositionsDictionary = QueryResultPropertyBag.CreatePropertyPositionsDictionary(properties);

            PropertyBag[] array = new PropertyBag[this.savedAttachmentList.Count];
            int           num   = 0;

            foreach (KeyValuePair <int, PersistablePropertyBag> keyValuePair in this.savedAttachmentList)
            {
                keyValuePair.Value[AttachmentSchema.AttachNum] = keyValuePair.Key;
                object[] array2 = new object[properties.Length];
                for (int num2 = 0; num2 != properties.Length; num2++)
                {
                    NativeStorePropertyDefinition propertyDefinition = properties[num2];
                    array2[num2] = ((IDirectPropertyBag)keyValuePair.Value).GetValue(propertyDefinition);
                }
                QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(null, propertyPositionsDictionary);
                queryResultPropertyBag.ExTimeZone = this.ExTimeZone;
                queryResultPropertyBag.ReturnErrorsOnTruncatedProperties = true;
                queryResultPropertyBag.SetQueryResultRow(array2);
                array[num++] = queryResultPropertyBag;
            }
            return(array);
        }
Beispiel #2
0
        private static void QueryItemsUsingView(Folder folder, SortBy[] sortBy, QueryFilter condition, ICollection <PropertyDefinition> propertySet, Func <PropertyBag, bool> readRow)
        {
            long num = 0L;

            using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, sortBy, propertySet))
            {
                if (condition != null)
                {
                    queryResult.SeekToCondition(SeekReference.OriginBeginning, condition, (condition is ComparisonFilter) ? SeekToConditionFlags.None : SeekToConditionFlags.AllowExtendedFilters);
                }
                bool flag = false;
                while (!flag)
                {
                    object[][] rows = queryResult.GetRows(50);
                    flag = (rows.Length == 0);
                    foreach (object[] queryResultRow in rows)
                    {
                        QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(folder.Session, propertySet);
                        queryResultPropertyBag.SetQueryResultRow(queryResultRow);
                        if (!readRow(queryResultPropertyBag) || (num += 1L) >= 1000L)
                        {
                            flag = true;
                            break;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private T[] GetItems <T>(int rowCount, QueryRowsFlags flags, Func <PropertyBag, T> converResultItem)
        {
            if (rowCount < 0)
            {
                throw new ArgumentOutOfRangeException("rowCount", ServerStrings.ExInvalidRowCount);
            }
            List <T> list = new List <T>(rowCount);

            rowCount = Math.Min(200, rowCount);
            PropValue[][] array = base.Fetch(rowCount, flags);
            if (array != null)
            {
                byte[] array2 = null;
                List <IStorePropertyBag> list2 = null;
                foreach (PropValue[] queryResultRow in array)
                {
                    QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(base.HeaderPropBag);
                    queryResultPropertyBag.SetQueryResultRow(queryResultRow);
                    IStorePropertyBag storePropertyBag = queryResultPropertyBag.AsIStorePropertyBag();
                    byte[]            valueOrDefault   = storePropertyBag.GetValueOrDefault <byte[]>(InternalSchema.MapiConversationId, null);
                    if (array2 != null && !ArrayComparer <byte> .Comparer.Equals(valueOrDefault, array2))
                    {
                        list.Add(this.PrepareItem <T>(list2, converResultItem));
                        list2  = null;
                        array2 = null;
                    }
                    if (array2 == null)
                    {
                        array2 = valueOrDefault;
                    }
                    if (list2 == null)
                    {
                        list2 = new List <IStorePropertyBag>(1);
                    }
                    list2.Add(storePropertyBag);
                }
                if (list2 != null)
                {
                    list.Add(this.PrepareItem <T>(list2, converResultItem));
                }
            }
            return(list.ToArray());
        }
Beispiel #4
0
        private static Notification CreateQueryNotification(MapiNotification notification, ColumnPropertyDefinitions columns)
        {
            MapiTableNotification mapiTableNotification = notification as MapiTableNotification;
            QueryNotificationType eventType;

            switch (mapiTableNotification.TableEvent)
            {
            case TableEvent.TableChanged:
                eventType = QueryNotificationType.QueryResultChanged;
                break;

            case TableEvent.TableError:
                eventType = QueryNotificationType.Error;
                break;

            case TableEvent.TableRowAdded:
                eventType = QueryNotificationType.RowAdded;
                break;

            case TableEvent.TableRowDeleted:
            case TableEvent.TableRowDeletedExtended:
                eventType = QueryNotificationType.RowDeleted;
                break;

            case TableEvent.TableRowModified:
                eventType = QueryNotificationType.RowModified;
                break;

            case TableEvent.TableSortDone:
                eventType = QueryNotificationType.SortDone;
                break;

            case TableEvent.TableRestrictDone:
                eventType = QueryNotificationType.RestrictDone;
                break;

            case TableEvent.TableSetColDone:
                eventType = QueryNotificationType.SetColumnDone;
                break;

            case TableEvent.TableReload:
                eventType = QueryNotificationType.Reload;
                break;

            default:
                return(null);
            }
            int hresult = mapiTableNotification.HResult;

            byte[] index = mapiTableNotification.Index.GetBytes() ?? Array <byte> .Empty;
            byte[] prior = mapiTableNotification.Prior.GetBytes() ?? Array <byte> .Empty;
            ICollection <PropertyDefinition> propertyDefinitions;

            object[] row;
            if (mapiTableNotification.Row != null && mapiTableNotification.Row.Length > 0)
            {
                if (mapiTableNotification.TableEvent == TableEvent.TableRowDeletedExtended)
                {
                    PropTag[] array = new PropTag[mapiTableNotification.Row.Length];
                    for (int i = 0; i < array.Length; i++)
                    {
                        array[i] = mapiTableNotification.Row[i].PropTag;
                    }
                    propertyDefinitions = Subscription.PropertiesForRowDeletedExtended;
                    ICollection <PropertyDefinition> columns2 = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType, null, null, array);
                    QueryResultPropertyBag           queryResultPropertyBag = new QueryResultPropertyBag(null, columns2);
                    queryResultPropertyBag.SetQueryResultRow(mapiTableNotification.Row);
                    row = queryResultPropertyBag.GetProperties(propertyDefinitions);
                }
                else
                {
                    if (!QueryResult.DoPropertyValuesMatchColumns(columns, mapiTableNotification.Row))
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug(0L, "Subcription::CreateQueryNotification. The notification data does not match the columns the client knows about. Dropping notification.");
                        return(null);
                    }
                    QueryResultPropertyBag queryResultPropertyBag2 = new QueryResultPropertyBag(null, columns.SimplePropertyDefinitions);
                    queryResultPropertyBag2.SetQueryResultRow(mapiTableNotification.Row);
                    propertyDefinitions = columns.PropertyDefinitions;
                    row = queryResultPropertyBag2.GetProperties(columns.PropertyDefinitions);
                }
            }
            else
            {
                propertyDefinitions = Array <UnresolvedPropertyDefinition> .Empty;
                row = Array <object> .Empty;
            }
            return(new QueryNotification(eventType, hresult, index, prior, propertyDefinitions, row));
        }
Beispiel #5
0
        public PropertyBag[] QueryAttachmentTable(NativeStorePropertyDefinition[] properties)
        {
            PropValue[][] array     = null;
            MapiTable     mapiTable = null;
            StoreSession  session   = this.AttachmentCollection.ContainerItem.Session;
            bool          flag      = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                mapiTable = this.AttachmentCollection.ContainerItem.MapiMessage.GetAttachmentTable();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetAttachmentTable, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiAttachmentProvider::QueryAttachmentTable", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetAttachmentTable, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiAttachmentProvider::QueryAttachmentTable", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            using (mapiTable)
            {
                ICollection <PropTag> propTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(this.AttachmentCollection.ContainerItem.MapiMessage, this.AttachmentCollection.ContainerItem.Session, properties);
                StoreSession          session2 = this.AttachmentCollection.ContainerItem.Session;
                bool flag2 = false;
                try
                {
                    if (session2 != null)
                    {
                        session2.BeginMapiCall();
                        session2.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    array = mapiTable.QueryAllRows(null, propTags);
                }
                catch (MapiPermanentException ex3)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetAttachmentTable, ex3, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::QueryAttachmentTable", new object[0]),
                        ex3
                    });
                }
                catch (MapiRetryableException ex4)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetAttachmentTable, ex4, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::QueryAttachmentTable", new object[0]),
                        ex4
                    });
                }
                finally
                {
                    try
                    {
                        if (session2 != null)
                        {
                            session2.EndMapiCall();
                            if (flag2)
                            {
                                session2.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
            PropertyBag[] array2 = null;
            if (array != null && array.Length > 0)
            {
                Dictionary <StorePropertyDefinition, int> propertyPositionsDictionary = QueryResultPropertyBag.CreatePropertyPositionsDictionary(properties);
                array2 = new PropertyBag[array.Length];
                for (int num = 0; num != array.Length; num++)
                {
                    QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(this.AttachmentCollection.ContainerItem.Session, propertyPositionsDictionary);
                    queryResultPropertyBag.ExTimeZone = this.ExTimeZone;
                    queryResultPropertyBag.ReturnErrorsOnTruncatedProperties = true;
                    queryResultPropertyBag.SetQueryResultRow(array[num]);
                    array2[num] = queryResultPropertyBag;
                }
            }
            return(array2);
        }