Exemple #1
0
        public object[][] GetRows(int rowCount, QueryRowsFlags flags, out bool mightBeMoreRows)
        {
            this.CheckDisposed(null);
            EnumValidator.ThrowIfInvalid <QueryRowsFlags>(flags, "flags");
            int num = rowCount * 3;

            if (!this.moreRowsAvailableToFetch || num <= this.unusedRows.Count)
            {
                mightBeMoreRows = this.moreRowsAvailableToFetch;
            }
            else
            {
                num -= this.unusedRows.Count;
                object[][] rows = this.rawQueryResult.GetRows(num, flags, out mightBeMoreRows);
                foreach (object[] item in rows)
                {
                    this.unusedRows.Enqueue(item);
                }
                this.moreRowsAvailableToFetch = mightBeMoreRows;
            }
            object[][] array2 = this.FilterUnusedRows(rowCount);
            if (this.unusedRows.Count > 0)
            {
                mightBeMoreRows = true;
            }
            if (array2.Length > 0)
            {
                this.currentRow += array2.Length;
            }
            return(array2);
        }
Exemple #2
0
 public override object[][] GetRows(int rowCount, QueryRowsFlags flags, out bool mightBeMoreRows)
 {
     base.CheckDisposed("GetRows");
     object[][] items = this.GetItems <object[]>(rowCount, flags, (PropertyBag item) => item.GetProperties <PropertyDefinition>(this.originalProperties));
     mightBeMoreRows = (items.Length > 0);
     return(items);
 }
Exemple #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());
        }
        /// <summary>
        /// Parse the RopQueryRowsRequest structure.
        /// </summary>
        /// <param name="s">An stream containing RopQueryRowsRequest structure.</param>
        public override void Parse(Stream s)
        {
            base.Parse(s);

            this.RopId = (RopIdType)ReadByte();
            this.LogonId = ReadByte();
            this.InputHandleIndex = ReadByte();
            this.QueryRowsFlags = (QueryRowsFlags)ReadByte();
            this.ForwardRead = ReadBoolean();
            this.RowCount = ReadUshort();
        }
        /// <summary>
        /// Query table rows data.
        /// </summary>
        /// <param name="serverID">server id.</param>
        /// <param name="inputHandle">Table object handle.</param>
        /// <param name="queryRowsFlags">Query flags</param>
        /// <param name="forwardRead">Forward read.</param>
        /// <param name="rowCount">The number of rows.</param>
        /// <param name="serverObjectHandleTable">Server object handle table.</param>
        /// <returns>The response of RopQueryRows operation.</returns>
        private RopQueryRowsResponse QueryRows(
            int serverID,
            uint inputHandle,
            QueryRowsFlags queryRowsFlags,
            bool forwardRead,
            ushort rowCount,
            out List<uint> serverObjectHandleTable)
        {
            RopQueryRowsRequest queryRowsRequest;

            // Construct ROP request
            queryRowsRequest.RopId = 0x15;
            queryRowsRequest.LogonId = 0x00;
            queryRowsRequest.InputHandleIndex = 0x00;
            queryRowsRequest.QueryRowsFlags = (byte)queryRowsFlags;
            queryRowsRequest.ForwardRead = (byte)(forwardRead ? 1 : 0);
            queryRowsRequest.RowCount = rowCount;

            // Send request.
            RopQueryRowsResponse rt = (RopQueryRowsResponse)this.Process(
                serverID,
                queryRowsRequest,
                inputHandle);
            serverObjectHandleTable = this.responseSOHs;
            return rt;
        }
        public static void RopQueryRowsResponse(QueryRowsFlags queryRowFlags, bool isForwardRead, bool isZeroRow, TableRopType ropType, bool isCorrectRowCount, bool isCursorPositionChanged, bool isLatestRopData, bool isLastSuccessRopData, BookmarkType queryRowOrigin, bool isRequestCountTooLarger)
        {
            // If the NoAdvance flag (0x01) is set in the QueryRowsFlags field, the server MUST NOT change the position of the cursor.
            if (queryRowFlags == QueryRowsFlags.NoAdvance)
            {
                Condition.IsTrue(!isCursorPositionChanged);
                ModelHelper.CaptureRequirement(470, @"[In Processing RopQueryRows] If the NoAdvance flag (0x01) is set in the QueryRowsFlags field, the server MUST NOT change the position of the cursor.");
                if (queryRowOrigin == BookmarkType.BOOKMARK_BEGINNING)
                {
                    ModelHelper.CaptureRequirement(27, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_BEGINNING with value 0x00 means points to the beginning position of the table, or the first row.");
                }
            }

            // Test RopSetColumns MUST be sent on the table prior to sending RopQueryRows
            bool latestSetColumnFlag = false;
            setColumnsFlags.TryGetValue((uint)setColumnsFlags.Count, out latestSetColumnFlag);
            if (latestSetColumnFlag)
            {
                Condition.IsTrue(isCorrectRowCount);

                // If the ForwardRead field is TRUE, RopQueryRows MUST return the rows beginning at the origin, reading forward.
                if (isForwardRead)
                {
                    // In the Test Suite, the origin is beginning, and if the enough row is true, 
                    // the RowCount rows will be queried from table. Also, here it only verify whether the correct row count 
                    // is returned, because for the details of the table row, it can't be verified.
                    ModelHelper.CaptureRequirement(468, @"[In Processing RopQueryRows] If rows are returned by the RopQueryRows ROP and the ForwardRead field is set to ""TRUE"" (0x01), the RopQueryRows ROP returns the rows beginning at the position pointed to by the Origin field, reading forward.");
                }
                else
                { 
                    Condition.IsTrue((requirementContainer[896] && !requirementContainer[897]) || (!requirementContainer[896] && requirementContainer[897]));

                    // if there are no more rows to return and the ForwardRead field in the ROP request is set to "false",
                    // Exchange 2007 will set the Origin field to "BOOKMARK_BEGINNING".
                    if (requirementContainer[896] && isRequestCountTooLarger)
                    {
                        Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_BEGINNING);
                        ModelHelper.CaptureRequirement(896, @"[In Appendix A: Product Behavior] Implementation does set the Origin field to ""BOOKMARK_BEGINNING"", if there are no more rows to return and the ForwardRead field in the ROP request is set to ""FALSE"". (Exchange Server 2007 follows this behavior.)");
                    }

                    // if there are no more rows to return and the ForwardRead field in the ROP request is set to "false",
                    // Exchange 2010 and above will set the Origin field to "BOOKMARK_END".
                    if (requirementContainer[897] && isRequestCountTooLarger)
                    {
                        Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_END);
                        ModelHelper.CaptureRequirement(897, @"[In Appendix A: Product Behavior] Implementation does set the Origin field to ""BOOKMARK_END"", if there are no more rows to return and the ForwardRead field in the ROP request is set to ""FALSE"". (<25> Section 3.2.5.5: Exchange 2010, Exchange 2013, and Exchange 2016 set the Origin field to ""BOOKMARK_END"".)");
                    }

                    // When ForwardRead in request is false, if the correct row count is returned, this requirement can be verified.
                    ModelHelper.CaptureRequirement(469, @"[In Processing RopQueryRows] If it [ForeardRead] is set to ""FALSE"" (0x00), the server returns the rows starting at the number of rows equal to the value of the RowCount field before the position pointed to by the Origin field, such that the rows returned are those between the value of the Origin field minus the value of the RowCount field and the position pointed to by the Origin field.");
                }

                // If the RopRestrict ROP has not been issued, the RowData field MUST include all rows.
                bool isLastestRestrictFlags = false;
                restrictFlags.TryGetValue((uint)restrictFlags.Count, out isLastestRestrictFlags);
                
                if (!isLastestRestrictFlags)
                {
                    ModelHelper.CaptureRequirement(118, @"[In RopQueryRows ROP Response Buffer] If the RopRestrict ROP has not been issued, the RowData field MUST include all rows.");
                }

                // When correct row count is returned and the returned row count is zero, the R467 is verified. 
                if (isZeroRow)
                {
                    ModelHelper.CaptureRequirement(467, @"[In Processing RopQueryRows] This ROP MUST only send zero rows when there are no more rows in the table.");
                }
            }

            ModelHelper.CaptureRequirement(462, @"[In Processing RopQueryRows] When a RopQueryRows ROP request ([MS-OXCROPS] section 2.2.5.4) is sent, the server MUST send the rows from the table starting at the current cursor position.");

            // If there are no more rows to return, the Origin field will be set to BOOKMARK_END if the ForwardRead field in the ROP request is set to true.
            if (isCursorPositionChanged && isForwardRead && queryRowOrigin == BookmarkType.BOOKMARK_END)
            {
                ModelHelper.CaptureRequirement(29, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_END with value 0x02 means points to the ending position of the table, or the location after the last row.");
                ModelHelper.CaptureRequirement(725, @"[In Processing RopQueryRows] If there are no more rows to return and the ForwardRead field in the ROP request is set to ""TRUE"", then the Origin field is set to ""BOOKMARK_END"".");
            }

            if (!isRequestCountTooLarger && isForwardRead && isCursorPositionChanged)
            {
                Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_CURRENT);
                ModelHelper.CaptureRequirement(28, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_CURRENT with value 0x01 means points to the current position of the table, or the current row.");
                ModelHelper.CaptureRequirement(726, @"[In Processing RopQueryRows] Otherwise,[If there are more rows to return] it [Origin] will be set to ""BOOKMARK_CURRENT"".");
            }

            // Below is to parse the data queried
            switch (ropType)
            {
                // Query rows is called after a SetColumn request
                case TableRopType.SETCOLUMNS:
                    {
                        ParseQueryRowsAfterSetColumns(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // Query rows is called after sort table request
                case TableRopType.SORTTABLE:
                    {
                        ParseQueryRowsAfterSortTable(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // Query rows is called after restrict table request
                case TableRopType.RESTRICT:
                    {
                        ParseQueryRowsAfterRestrict(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // If no above operation, query rows must return all rows, the parameter bIsLatestRopData is used to identify whether all row data is returned
                default:
                    {
                        break;
                    }
            }
        }
        public static TableRopReturnValues RopQueryRows(QueryRowsFlags queryRowFlags, bool isForwardRead)
        {
            // This ROP is only valid on Table objects.
            if (globleTableType == TableType.CONTENT_TABLE)
            {
                // The RopQueryRows ROP MUST be supported for contents tables.
                ModelHelper.CaptureRequirement(837, @"[In Processing RopQueryRows] The RopQueryRows ROP MUST be supported for contents tables.");
            }
            else if (globleTableType == TableType.HIERARCHY_TABLE)
            {
                // The RopQueryRows ROP MUST be supported for hierarchy tables.
                ModelHelper.CaptureRequirement(835, @"[In Processing RopQueryRows] The RopQueryRows ROP MUST be supported for hierarchy tables.");
            }
            else if (globleTableType == TableType.RULES_TABLE)
            {
                // The RopQueryRows ROP MUST be supported for attachments tables.
                ModelHelper.CaptureRequirement(836, @"[In Processing RopQueryRows] The RopQueryRows ROP MUST be supported for rules tables.");
            }
            else
            {
                // If the table type is invalid, ecNotSupported will be returned, in this test suite, invalid table
                // is referred as a folderId, for details, see the table initial method in adapter project
                ModelHelper.CaptureRequirement(477, @"[In Processing RopQueryRows] The error code ecNotSupported will be returned with value 0x80040102,%x02.01.04.80, if the object on which this ROP was sent is not of type table.");
                ModelHelper.CaptureRequirement(614, @"[In RopQueryRows ROP] This ROP is valid only on Table objects.");
                return TableRopReturnValues.ecNotSupported;
            }

            // Test RopSetColumns MUST be sent on the table prior to sending RopQueryRows
            bool latestSetColumnFlag = false;
            setColumnsFlags.TryGetValue((uint)setColumnsFlags.Count, out latestSetColumnFlag);

            // If there is no successful SetColumn response
            if (!latestSetColumnFlag)
            {
                Condition.IsTrue((requirementContainer[768] && requirementContainer[866] && requirementContainer[867]) ||
                    (!requirementContainer[768] && !requirementContainer[866] && !requirementContainer[867]));
                if (requirementContainer[768] && requirementContainer[866] && requirementContainer[867])
                {
                    ModelHelper.CaptureRequirement(768, @"[In Appendix A: Product Behavior] If a RopQueryRows ROP is sent before a successful RopSetColumns ROP, then the implementation fails the ROP with ""ecNullObject"". (Microsoft Exchange Server 2010 and above follow this behavior.)");
                    ModelHelper.CaptureRequirement(866, @"[In Appendix A: Product Behavior] The RopSetColumns ROP ([MS-OXCROPS] section 2.2.5.1) MUST be sent on the table before sending a RopQueryRows ROP request on the implementation. (Microsoft Exchange Server 2010 and above follow this behavior.)");
                    ModelHelper.CaptureRequirement(867, @"[In Appendix A: Product Behavior] The error code ecNullObject will be returned with value 0x000004B9,%xB9.04.00.00, if RopSetColumns has not been sent on this table on the implementation. (Microsoft Exchange Server 2010 and above follow this behavior.)");
                    return TableRopReturnValues.ecNullObject;
                }
                else
                {
                    if ((uint)setColumnsFlags.Count == 0)
                    {
                        return TableRopReturnValues.unexpected;
                    }
                }
            }

            return TableRopReturnValues.success;
        }
        /// <summary>
        /// This method is used to query rows for a table
        /// </summary>
        /// <param name="queryRowFlags">A flag for the query row operation</param>
        /// <param name="forwardRead">Identify whether to read the data forward</param>
        /// <returns>Table ROP return value</returns>
        public TableRopReturnValues RopQueryRows(QueryRowsFlags queryRowFlags, bool forwardRead)
        {
            // The enabled property value for MS-OXCTABL_R768, MS-OXCTABL_R866 and MS-OXCTABL_R867 must the same.
            if (!(Common.IsRequirementEnabled(768, this.Site) == Common.IsRequirementEnabled(866, this.Site) == Common.IsRequirementEnabled(867, this.Site) == true) && !(Common.IsRequirementEnabled(768, this.Site) == Common.IsRequirementEnabled(866, this.Site) == Common.IsRequirementEnabled(867, this.Site) == false))
            {
                Site.Assert.Inconclusive("Requirements implementation conflict, the conflict requirements number are: MS-OXCTABL_R768, MS-OXCTABL_R866 and MS-OXCTABL_R867");
            }

            uint tempRowCount = this.GetRowsCount(forwardRead); // Gets the number of rows from current location to begin row or last row.

            RopQueryRowsRequest queryRowsRequest;
            RopQueryRowsResponse queryRowsResponse;

            queryRowsRequest.RopId = 0x15;
            queryRowsRequest.LogonId = 0x00;
            queryRowsRequest.InputHandleIndex = 0x00;
            queryRowsRequest.QueryRowsFlags = (byte)queryRowFlags; // Whether advance the table cursor. 
            queryRowsRequest.ForwardRead = Convert.ToByte(forwardRead); // It is set to FALSE (0x00) to read the table backwards. It MUST NOT be set to any other value.
            queryRowsRequest.RowCount = 0x0003; // Return a maximum of 3 rows.
            this.rowCountInQueryRowsRequest = queryRowsRequest.RowCount;

            if (Common.IsRequirementEnabled(768, this.Site))
            {
                this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
            }
            else
            {
                // In order to test the case when buffer is smaller.
                try
                {
                    this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
                }
                catch (Exception ex)
                {
                    if (ex.Message == Constants.BufferTooSmall)
                    {
                        return TableRopReturnValues.ecBufferTooSmall;
                    }
                    else
                    {
                        Site.Log.Add(LogEntryKind.Comment, ex.Message);
                        Site.Log.Add(LogEntryKind.Comment, "The behavior when a RopQueryRows ROP is sent before a successful RopSetColumns ROP is undefined for implementation following Exchange 2007.");
                        return TableRopReturnValues.unexpected;
                    }
                }
            }

            queryRowsResponse = (RopQueryRowsResponse)this.response;

            int queryRowCount = 0;
            bool isLatestRopData = false;
            bool isLastSuccessRopData = false;
            bool zeroRow = false;
            bool isCorrectRowCountReturned = false;
            bool cursorPositionChanged = false;
            bool isRequestCountTooLarger = this.rowCountInQueryRowsRequest > tempRowCount;
            if ((TableRopReturnValues)queryRowsResponse.ReturnValue == TableRopReturnValues.success)
            {
                queryRowCount = queryRowsResponse.RowCount;
                this.queryRowOrigin = (BookmarkType)queryRowsResponse.Origin;
                isCorrectRowCountReturned = tempRowCount > this.rowCountInQueryRowsRequest ? queryRowCount == this.rowCountInQueryRowsRequest : queryRowCount == tempRowCount; // It MUST be less than or equal to the RowCount that is specified in the request
                cursorPositionChanged = tempRowCount != this.GetRowsCount(forwardRead);
                if (queryRowCount == 0)
                {
                    zeroRow = true;
                }
                else
                {
                    this.propertyValues = queryRowsResponse.RowData.PropertyRows[0].PropertyValues; // Gets the first row 
                    isLastSuccessRopData = this.latestSuccessPropertyTages.Length == queryRowsResponse.RowData.PropertyRows[0].PropertyValues.Count;
                    isLatestRopData = this.latestPropertyTags.Length == queryRowsResponse.RowData.PropertyRows[0].PropertyValues.Count;

                    if (this.tableType == TableType.CONTENT_TABLE)
                    {
                        bool isCorrectSortOrder = true;

                        // Gets the value of PidTagSenderName.
                        string tempSenderName = Encoding.Unicode.GetString(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[2].Value);
                        if (this.latestSuccessSortOrder == SortOrderFlag.SortOrderASC)
                        {
                            // The PidTagSenderName must be Test1 when sortOrder is ascend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender1Name", this.Site));
                        }
                        else if (this.latestSuccessSortOrder == SortOrderFlag.SortOrderDESC)
                        {
                            // The PidTagSenderName must be Test2 when sortOrder is descend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender2Name", this.Site));
                        }

                        bool isCorrectRestriction = true;
                        if (this.latestSuccessRestrict == RestrictFlag.SenderIsTest1Restrict)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        if (this.latestSuccessRestrict == RestrictFlag.SenderIsTest2Restriction)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        bool isFirstHeaderExpanded = true;
                        bool areAllCategoryExpanded = true;
                        bool isCorrectSortOrderAndCategory = true;
                        if (this.latestSuccessSortOrder != SortOrderFlag.NotSort)
                        {
                            if (this.isExpanded == true)
                            {
                                if (BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[3].Value, 0) != 0x03)
                                {
                                    isFirstHeaderExpanded = false;
                                }
                            }

                            if (this.areAllCategoryExpanded)
                            {
                                foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                                {
                                    if (BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x04)
                                    {
                                        areAllCategoryExpanded = false;
                                        break;
                                    }
                                }
                            }

                            if (!this.areAllSortOrdersUsedAsCategory)
                            {
                                if (this.areMultipleSortOrders)
                                {
                                    foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                                    {
                                        // Since the PidTagSenderName property is used in the first sortOrder structure, it will be used as category.
                                        if (BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x03 || BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x04)
                                        {
                                            if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)) &&
                                                !this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                            {
                                                isCorrectSortOrderAndCategory = false;
                                                break;
                                            }
                                        }
                                    }

                                    if (isCorrectSortOrderAndCategory)
                                    {
                                        for (int i = 0; i < queryRowsResponse.RowData.PropertyRows.Count - 1; i++)
                                        {
                                            // Since the PidTagInstID property is used in the second sortOrder structure, it will be used to sort the rows within the category.
                                            if (BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[3].Value, 0) == 0x01 &&
                                                BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[3].Value, 0) == 0x01)
                                            {
                                                if ((this.latestSuccessSortOrder == SortOrderFlag.SortOrderASC && BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[0].Value, 0) <
                                                    BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[0].Value, 0)) ||
                                                    (this.latestSuccessSortOrder == SortOrderFlag.SortOrderDESC && BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[0].Value, 0) >
                                                    BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[0].Value, 0)))
                                                {
                                                    isCorrectSortOrderAndCategory = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        isLastSuccessRopData = isLastSuccessRopData && isCorrectSortOrder && isCorrectRestriction && isFirstHeaderExpanded && areAllCategoryExpanded && isCorrectSortOrderAndCategory;

                        if (this.latestSortOrder == SortOrderFlag.SortOrderASC)
                        {
                            // The PidTagSenderName must be Test1 when sortOrder is ascend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender1Name", this.Site));
                        }
                        else if (this.latestSortOrder == SortOrderFlag.SortOrderDESC)
                        {
                            // The PidTagSenderName must be Test2 when sortOrder is descend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender2Name", this.Site));
                        }

                        if (this.latestRestrict == RestrictFlag.SenderIsTest1Restrict)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        if (this.latestRestrict == RestrictFlag.SenderIsTest2Restriction)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        isLatestRopData = isLatestRopData && isCorrectSortOrder && isCorrectRestriction;
                    }
                }
            }
            else
            {
                isCorrectRowCountReturned = false;
            }

            if (this.RopQueryRowsResponse != null)
            {
                this.RopQueryRowsResponse(queryRowFlags, forwardRead, zeroRow, this.ropType, isCorrectRowCountReturned, cursorPositionChanged, isLatestRopData, isLastSuccessRopData, this.queryRowOrigin, isRequestCountTooLarger);
            }

            return (TableRopReturnValues)queryRowsResponse.ReturnValue;
        }
Exemple #9
0
        public object[][] GetRows(int rowCount, QueryRowsFlags flags, out bool mightBeMoreRows)
        {
            this.CheckDisposed(null);
            EnumValidator.ThrowIfInvalid <QueryRowsFlags>(flags, "flags");
            List <object[]> list = new List <object[]>();
            int             num  = 0;
            int             num2 = 0;

            while (num2 < rowCount && this.currentRowIndex + num < this.tableEntries.Count)
            {
                object[] array = new object[this.columns.Count];
                for (int i = 0; i < this.columns.Count; i++)
                {
                    if (this.columns[i] == InternalSchema.InstanceKey)
                    {
                        array[i] = BitConverter.GetBytes(this.tableEntries[this.currentRowIndex + num].MemberId);
                    }
                    else if (this.columns[i] == PermissionSchema.MemberId)
                    {
                        array[i] = this.tableEntries[this.currentRowIndex + num].MemberId;
                    }
                    else if (this.columns[i] == PermissionSchema.MemberEntryId)
                    {
                        array[i] = this.tableEntries[this.currentRowIndex + num].MemberEntryId;
                    }
                    else if (this.columns[i] == PermissionSchema.MemberRights)
                    {
                        MemberRights memberRights = this.tableEntries[this.currentRowIndex + num].MemberRights;
                        if (this.removeFreeBusyRights)
                        {
                            array[i] = (int)(memberRights & ~(MemberRights.FreeBusySimple | MemberRights.FreeBusyDetailed));
                        }
                        else
                        {
                            array[i] = (int)memberRights;
                        }
                    }
                    else if (this.columns[i] == PermissionSchema.MemberName)
                    {
                        array[i] = this.tableEntries[this.currentRowIndex + num].MemberName;
                    }
                    else if (this.columns[i] == PermissionSchema.MemberSecurityIdentifier)
                    {
                        if (!this.allowExtendedPermissionInformationQuery)
                        {
                            throw new InvalidOperationException("QueryResult doesn't support MemberSecurityIdentifier property");
                        }
                        SecurityIdentifier securityIdentifier = this.tableEntries[this.currentRowIndex + num].SecurityIdentifier;
                        byte[]             array2             = new byte[securityIdentifier.BinaryLength];
                        securityIdentifier.GetBinaryForm(array2, 0);
                        array[i] = array2;
                    }
                    else if (this.columns[i] == PermissionSchema.MemberIsGroup)
                    {
                        if (!this.allowExtendedPermissionInformationQuery)
                        {
                            throw new InvalidOperationException("QueryResult doesn't support MemberIsGroup property");
                        }
                        array[i] = this.tableEntries[this.currentRowIndex + num].IsGroup;
                    }
                }
                list.Add(array);
                num++;
                num2++;
            }
            if ((flags & QueryRowsFlags.NoAdvance) != QueryRowsFlags.NoAdvance)
            {
                this.currentRowIndex += num;
            }
            mightBeMoreRows = (list.Count > 0);
            return(list.ToArray());
        }