Microsoft.Protocols.TestSuites.MS_OXCTABL.MS_OXCTABLAdapter.GetTableHandle C# (CSharp) Method

GetTableHandle() private method

This method is used to get the table handle
private GetTableHandle ( TableType tableType ) : void
tableType TableType Identify the table type
return void
        private void GetTableHandle(TableType tableType)
        {
            RopCreateFolderRequest createFolderRequest;
            RopCreateFolderResponse createFolderResponse;
            RopQueryRowsRequest queryRowsRequest;
            RopQueryRowsResponse queryRowsResponse;
            RopSetColumnsRequest setColumnsRequest;
            string server = string.Empty;
            string domain = string.Empty;
            string user1 = string.Empty;
            string user2 = string.Empty;
            PropertyTag[] tempPropertyTags = null;
            switch (tableType)
            {
                case TableType.CONTENT_TABLE:
                    server = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
                    domain = Common.GetConfigurationPropertyValue("Domain", this.Site);
                    user1 = Common.GetConfigurationPropertyValue("Sender1Name", this.Site);
                    user2 = Common.GetConfigurationPropertyValue("Sender2Name", this.Site);
                    for (int i = 0; i < 2; i++)
                    {
                        this.CreateMessageForPrepareTable(user1);
                        this.CreateMessageForPrepareTable(user2);
                    }

                    this.VerifyMailCount(4);
                    RopGetContentsTableRequest getContentsTableRequest;
                    RopGetContentsTableResponse getContentsTableResponse;

                    getContentsTableRequest.RopId = 0x05;
                    getContentsTableRequest.LogonId = 0x00;
                    getContentsTableRequest.InputHandleIndex = 0x00;
                    getContentsTableRequest.OutputHandleIndex = 0x01;
                    getContentsTableRequest.TableFlags = 0x00; // Depth.

                    this.responseSOHs = this.DoSingleCallROP(getContentsTableRequest, this.folderHandle, ref this.response, ref this.rawData);
                    getContentsTableResponse = (RopGetContentsTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getContentsTableResponse.OutputHandleIndex];
                    this.rowCount = getContentsTableResponse.RowCount;

                    break;
                case TableType.ATTACHMENTS_TABLE:
                    server = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
                    domain = Common.GetConfigurationPropertyValue("Domain", this.Site);
                    user1 = Common.GetConfigurationPropertyValue("Sender1Name", this.Site);
                    user2 = Common.GetConfigurationPropertyValue("Sender2Name", this.Site);
                    for (int i = 0; i < 2; i++)
                    {
                        this.CreateMessageForPrepareTable(user1);
                        this.CreateMessageForPrepareTable(user2);
                    }

                    this.VerifyMailCount(4);
                    RopGetContentsTableRequest getContentsTableRequest1;
                    RopGetContentsTableResponse getContentsTableResponse1;

                    getContentsTableRequest1.RopId = 0x05;
                    getContentsTableRequest1.LogonId = 0x00;
                    getContentsTableRequest1.InputHandleIndex = 0x00;
                    getContentsTableRequest1.OutputHandleIndex = 0x01;
                    getContentsTableRequest1.TableFlags = 0x00; // Depth.

                    this.responseSOHs = this.DoSingleCallROP(getContentsTableRequest1, this.folderHandle, ref this.response, ref this.rawData);
                    getContentsTableResponse1 = (RopGetContentsTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getContentsTableResponse1.OutputHandleIndex];

                    tempPropertyTags = this.CreateSampleContentsTablePropertyTags();
                    setColumnsRequest.RopId = 0x12;
                    setColumnsRequest.LogonId = 0x00;
                    setColumnsRequest.InputHandleIndex = 0x00;
                    setColumnsRequest.SetColumnsFlags = 0x00;
                    setColumnsRequest.PropertyTagCount = (ushort)tempPropertyTags.Length;
                    setColumnsRequest.PropertyTags = tempPropertyTags;

                    this.responseSOHs = this.DoSingleCallROP(setColumnsRequest, this.tableHandle, ref this.response, ref this.rawData);

                    queryRowsRequest.RopId = 0x15;
                    queryRowsRequest.LogonId = 0x00;
                    queryRowsRequest.InputHandleIndex = 0x00;
                    queryRowsRequest.QueryRowsFlags = 0x00;
                    queryRowsRequest.ForwardRead = 0x01;
                    queryRowsRequest.RowCount = 0x0032;
                    this.rowCountInQueryRowsRequest = 0x0032;
                    this.responseSOHs = this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
                    queryRowsResponse = (RopQueryRowsResponse)this.response;

                    if (queryRowsResponse.RowData.PropertyRows == null)
                    {
                        Site.Assert.Fail("Current user should have received email messages before running this test case.");
                    }

                    ulong messageId = BitConverter.ToUInt64(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[0].Value, 0);

                    RopOpenMessageRequest openMessageRequest;
                    RopOpenMessageResponse openMessageResponse;
                    openMessageRequest.RopId = 0x03;
                    openMessageRequest.LogonId = 0x0;
                    openMessageRequest.InputHandleIndex = 0x0;
                    openMessageRequest.OutputHandleIndex = 0x01;
                    openMessageRequest.CodePageId = 0x0FFF;
                    openMessageRequest.FolderId = this.folderID;
                    openMessageRequest.OpenModeFlags = 0x03; // Standard: Open for read/write if the user has write permissions for the folder, read-only if not.
                    openMessageRequest.MessageId = messageId;

                    this.responseSOHs = this.DoSingleCallROP(openMessageRequest, this.inputObjHandle, ref this.response, ref this.rawData);
                    openMessageResponse = (RopOpenMessageResponse)this.response;
                    uint messageObjHandle = this.responseSOHs[0][openMessageResponse.OutputHandleIndex];

                    RopGetAttachmentTableRequest getAttachmentTableRequest;
                    RopGetAttachmentTableResponse getAttachmentTableResponse;
                    getAttachmentTableRequest.RopId = 0x21;
                    getAttachmentTableRequest.LogonId = 0x00;
                    getAttachmentTableRequest.InputHandleIndex = 0x00;
                    getAttachmentTableRequest.OutputHandleIndex = 0x01;
                    getAttachmentTableRequest.TableFlags = 0x00; // Standard: Open the table.
                    this.responseSOHs = this.DoSingleCallROP(getAttachmentTableRequest, messageObjHandle, ref this.response, ref this.rawData);
                    getAttachmentTableResponse = (RopGetAttachmentTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getAttachmentTableResponse.OutputHandleIndex];
                    break;

                case TableType.HIERARCHY_TABLE:
                    #region Create [TestGetHierarchyTableFolder1] folder under Inbox
                    createFolderRequest.RopId = 0x1C;
                    createFolderRequest.LogonId = 0x00;
                    createFolderRequest.InputHandleIndex = 0x00;
                    createFolderRequest.OutputHandleIndex = 0x01;
                    createFolderRequest.FolderType = 0x01; // Generic folder
                    createFolderRequest.UseUnicodeStrings = 0x0; // FALSE
                    createFolderRequest.OpenExisting = 0x0; // FALSE
                    createFolderRequest.Reserved = 0x0; // FALSE
                    createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.TestGetHierarchyTableFolderName1 + "\0");
                    createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.TestGetHierarchyTableFolderName1 + "\0");

                    this.responseSOHs = this.DoSingleCallROP(createFolderRequest, this.folderHandle, ref this.response, ref this.rawData);
                    createFolderResponse = (RopCreateFolderResponse)this.response;
                    uint testGetHierarchyTableFolder1 = this.responseSOHs[0][createFolderResponse.OutputHandleIndex];
                    #endregion

                    #region Create [TestGetHierarchyTableFolder2] folder under [TestGetHierarchyTableFolder1]
                    createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.TestGetHierarchyTableFolderName2 + "\0");
                    createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.TestGetHierarchyTableFolderName2 + "\0");
                    this.responseSOHs = this.DoSingleCallROP(createFolderRequest, testGetHierarchyTableFolder1, ref this.response, ref this.rawData);
                    createFolderResponse = (RopCreateFolderResponse)this.response;
                    #endregion

                    RopGetHierarchyTableRequest getHierarchyTableRequest;
                    RopGetHierarchyTableResponse getHierarchyTableResponse;

                    getHierarchyTableRequest.RopId = 0x04;
                    getHierarchyTableRequest.LogonId = 0x00;
                    getHierarchyTableRequest.InputHandleIndex = 0x00;
                    getHierarchyTableRequest.OutputHandleIndex = 0x01;
                    getHierarchyTableRequest.TableFlags = 0x04; // Standard: The hierarchy table lists folders from all levels under the folder.

                    this.responseSOHs = this.DoSingleCallROP(getHierarchyTableRequest, this.folderHandle, ref this.response, ref this.rawData);
                    getHierarchyTableResponse = (RopGetHierarchyTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getHierarchyTableResponse.OutputHandleIndex];
                    this.rowCount = getHierarchyTableResponse.RowCount;
                    Site.Assert.AreEqual<uint>(0x02, this.rowCount, "The folder count in the inbox folder should be correct.");

                    break;
                case TableType.PERMISSIONS_TABLE:
                    RopGetPermissionsTableRequest getPermissionsTableRequest;
                    RopGetPermissionsTableResponse getPermissionsTableResponse;

                    getPermissionsTableRequest.RopId = 0x3E;
                    getPermissionsTableRequest.LogonId = 0x00;
                    getPermissionsTableRequest.InputHandleIndex = 0x00;
                    getPermissionsTableRequest.OutputHandleIndex = 0x01;
                    getPermissionsTableRequest.TableFlags = 0x00;

                    this.responseSOHs = this.DoSingleCallROP(getPermissionsTableRequest, this.folderHandle, ref this.response, ref this.rawData);
                    getPermissionsTableResponse = (RopGetPermissionsTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getPermissionsTableResponse.OutputHandleIndex];

                    break;
                case TableType.RULES_TABLE:
                    #region Create [testRuleTableFolder] folder under Inbox
                    createFolderRequest.RopId = 0x1C;
                    createFolderRequest.LogonId = 0x00;
                    createFolderRequest.InputHandleIndex = 0x00;
                    createFolderRequest.OutputHandleIndex = 0x01;
                    createFolderRequest.FolderType = 0x01; // Generic folder
                    createFolderRequest.UseUnicodeStrings = 0x0; // FALSE
                    createFolderRequest.OpenExisting = 0x0; // non-zero(TRUE)
                    createFolderRequest.Reserved = 0x0; // FALSE
                    createFolderRequest.DisplayName = Encoding.ASCII.GetBytes("TestRuleTableFolder" + "\0");
                    createFolderRequest.Comment = Encoding.ASCII.GetBytes("TestRuleTableFolder" + "\0");

                    this.responseSOHs = this.DoSingleCallROP(createFolderRequest, this.folderHandle, ref this.response, ref this.rawData);
                    createFolderResponse = (RopCreateFolderResponse)this.response;
                    this.folderHandle = this.responseSOHs[0][createFolderResponse.OutputHandleIndex];
                    this.folderID = createFolderResponse.FolderId;
                    #endregion

                    #region Add two rules to the created [testRuleTableFolder]
                    RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(Constants.RuleNameMarkAsRead);
                    RuleData ruleForMarkRead = AdapterHelper.GenerateValidRuleData(ActionTypes.OP_MARK_AS_READ, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, null, ruleProperties);
                    RuleData ruleWithXRuleStateFlag = AdapterHelper.GenerateValidRuleData(ActionTypes.OP_MARK_AS_READ, TestRuleDataType.ForAdd, 1, RuleState.X, null, ruleProperties);
                    RuleData[] ruleDatas = { ruleForMarkRead, ruleWithXRuleStateFlag };

                    RopModifyRulesRequest modifyRulesRequest;

                    modifyRulesRequest.RopId = 0x41;
                    modifyRulesRequest.LogonId = 0x0;
                    modifyRulesRequest.InputHandleIndex = 0x00;
                    modifyRulesRequest.ModifyRulesFlags = (byte)ModifyRuleFlag.Modify_ReplaceAll;
                    modifyRulesRequest.RulesCount = 0;
                    if (ruleDatas != null)
                    {
                        modifyRulesRequest.RulesCount = (ushort)ruleDatas.Length;
                    }

                    modifyRulesRequest.RulesData = ruleDatas;

                    this.responseSOHs = this.DoSingleCallROP(modifyRulesRequest, this.folderHandle, ref this.response, ref this.rawData);
                    #endregion

                    RopGetRulesTableRequest getRulesTableRequest;
                    RopGetRulesTableResponse getRulesTableResponse;

                    getRulesTableRequest.RopId = 0x3F;
                    getRulesTableRequest.LogonId = 0x00;
                    getRulesTableRequest.InputHandleIndex = 0x00;
                    getRulesTableRequest.OutputHandleIndex = 0x01;
                    getRulesTableRequest.TableFlags = 0x00; // String values in the table are NOT in Unicode.

                    this.responseSOHs = this.DoSingleCallROP(getRulesTableRequest, this.folderHandle, ref this.response, ref this.rawData);
                    getRulesTableResponse = (RopGetRulesTableResponse)this.response;
                    this.tableHandle = this.responseSOHs[0][getRulesTableResponse.OutputHandleIndex];
                    tempPropertyTags = this.CreateSampleContentsTablePropertyTags();
                    setColumnsRequest.RopId = 0x12;
                    setColumnsRequest.LogonId = 0x00;
                    setColumnsRequest.InputHandleIndex = 0x00;
                    setColumnsRequest.SetColumnsFlags = 0x00;
                    setColumnsRequest.PropertyTagCount = (ushort)tempPropertyTags.Length;
                    setColumnsRequest.PropertyTags = tempPropertyTags;

                    this.responseSOHs = this.DoSingleCallROP(setColumnsRequest, this.tableHandle, ref this.response, ref this.rawData);
                    queryRowsRequest.RopId = 0x15;
                    queryRowsRequest.LogonId = 0x00;
                    queryRowsRequest.InputHandleIndex = 0x00;
                    queryRowsRequest.QueryRowsFlags = 0x01;
                    queryRowsRequest.ForwardRead = 0x01;
                    queryRowsRequest.RowCount = 0x0032;
                    this.rowCountInQueryRowsRequest = 0x0032;
                    this.responseSOHs = this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
                    queryRowsResponse = (RopQueryRowsResponse)this.response;
                    this.rowCount = queryRowsResponse.RowCount;
                    Site.Assert.AreEqual<uint>(0x02, this.rowCount, "The rule count should be correct.");
                    break;
                case TableType.INVALID_TABLE:
                    this.tableHandle = this.folderHandle;

                    break;
            }
        }