Ejemplo n.º 1
0
        internal QueryResultPropertyBag(IStorePropertyBag storePropertyBag, ICollection <PropertyDefinition> propertyDefinitions, IList <object> propertyValues)
        {
            QueryResultPropertyBag queryResultPropertyBag = (QueryResultPropertyBag)((PropertyBag.StorePropertyBagAdaptor)storePropertyBag).PropertyBag;

            this.Context.Session = queryResultPropertyBag.Context.Session;
            this.timeZone        = queryResultPropertyBag.timeZone;
            List <object> list = new List <object>(queryResultPropertyBag.currentRowValues);

            this.propertyPositions = new Dictionary <StorePropertyDefinition, int>(queryResultPropertyBag.propertyPositions);
            int num = 0;

            foreach (PropertyDefinition propertyDefinition in propertyDefinitions)
            {
                StorePropertyDefinition key = propertyDefinition as StorePropertyDefinition;
                int index;
                if (!this.propertyPositions.TryGetValue(key, out index))
                {
                    this.propertyPositions.Add(key, list.Count);
                    list.Add(propertyValues[num]);
                }
                else
                {
                    list[index] = propertyValues[num];
                }
                num++;
            }
            this.currentRowValues = list.ToArray();
        }
Ejemplo n.º 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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public QueryResultPropertyBag(StoreSession session, ICollection <PropertyDefinition> columns)
 {
     this.Context.Session = session;
     if (session != null)
     {
         this.ExTimeZone = session.ExTimeZone;
     }
     this.currentRowValues = null;
     this.returnErrorsOnTruncatedProperties = false;
     this.propertyPositions = QueryResultPropertyBag.CreatePropertyPositionsDictionary(columns);
 }
Ejemplo n.º 5
0
        protected override object TryGetStoreProperty(StorePropertyDefinition propertyDefinition)
        {
            int num = 0;

            if (this.propertyPositions.TryGetValue(propertyDefinition, out num))
            {
                object obj = this.currentRowValues[num];
                if (this.returnErrorsOnTruncatedProperties && QueryResultPropertyBag.CanValueBeTruncated(obj))
                {
                    obj = new PropertyError(propertyDefinition, PropertyErrorCode.PropertyValueTruncated);
                }
                return(obj);
            }
            throw new NotInBagPropertyErrorException(propertyDefinition);
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyStore)
        {
            StoreObjectId storeObjectId = null;
            ICoreObject   coreObject    = propertyStore.Context.CoreObject;

            if (coreObject != null)
            {
                storeObjectId = coreObject.InternalStoreObjectId;
            }
            if (storeObjectId == null)
            {
                byte[] array = propertyStore.GetValue(InternalSchema.EntryId) as byte[];
                if (array != null)
                {
                    storeObjectId = StoreObjectId.FromProviderSpecificId(array, this.GetStoreObjectType(propertyStore));
                }
                else
                {
                    QueryResultPropertyBag queryResultPropertyBag = ((PropertyBag)propertyStore) as QueryResultPropertyBag;
                    if (queryResultPropertyBag != null && (!((IDirectPropertyBag)queryResultPropertyBag).IsLoaded(InternalSchema.RowType) || object.Equals(queryResultPropertyBag.TryGetProperty(InternalSchema.RowType), 1)))
                    {
                        ExDiagnostics.FailFast(string.Format("EntryId: \"{0}\" in view", queryResultPropertyBag.TryGetProperty(InternalSchema.EntryId)), false);
                    }
                }
            }
            if (storeObjectId == null)
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            VersionedId versionedId = new VersionedId(storeObjectId, this.GetChangeKey(propertyStore));

            if (!this.IsCompatibleId(versionedId, coreObject))
            {
                return(new PropertyError(this, PropertyErrorCode.NotSupported));
            }
            return(versionedId);
        }
Ejemplo n.º 8
0
 internal QueryResultPropertyBag(QueryResultPropertyBag queryPropertyBagHeaderInfo) : base(queryPropertyBagHeaderInfo)
 {
     this.timeZone          = queryPropertyBagHeaderInfo.timeZone;
     this.currentRowValues  = queryPropertyBagHeaderInfo.currentRowValues;
     this.propertyPositions = queryPropertyBagHeaderInfo.propertyPositions;
 }
Ejemplo n.º 9
0
 internal static bool CanValueBeTruncated(object value)
 {
     return(QueryResultPropertyBag.CanBinaryValueBeTruncated(value as byte[]) || QueryResultPropertyBag.CanStringValueBeTruncated(value as string));
 }
Ejemplo n.º 10
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));
        }
Ejemplo n.º 11
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);
        }