protected void CreateSingleProcessEachLoop(ref RopLogonResponse logonResponse, out uint tableHandle, int count, RopCreateMessageRequest createMessageRequest, RopSaveChangesMessageRequest saveChangesMessageRequest, RopReleaseRequest releaseRequest)
{
RopCreateMessageResponse createMessageResponse = new RopCreateMessageResponse();
RopSaveChangesMessageResponse saveChangesMessageResponse = new RopSaveChangesMessageResponse();
#region Preparing the table: CreateFolder
// Open a folder first
RopOpenFolderRequest openFolderRequest;
RopOpenFolderResponse openFolderResponse;
openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
openFolderRequest.LogonId = TestSuiteBase.LogonId;
openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
openFolderRequest.FolderId = logonResponse.FolderIds[4];
openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the RopOpenFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
openFolderRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
openFolderResponse = (RopOpenFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
openFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
uint openedFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
// Create a new subfolder in the opened folder
// The new subfolder will be used as target folder
RopCreateFolderRequest createFolderRequest;
RopCreateFolderResponse createFolderResponse;
createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
createFolderRequest.LogonId = TestSuiteBase.LogonId;
createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
createFolderRequest.FolderType = (byte)FolderType.Genericfolder;
createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);
createFolderRequest.OpenExisting = TestSuiteBase.NonZero;
createFolderRequest.Reserved = TestSuiteBase.Reserved;
createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
createFolderRequest.Comment = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the RopCreateFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
createFolderRequest,
openedFolderHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
createFolderResponse = (RopCreateFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
createFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
uint targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
tableHandle = this.GetContentsTableHandle(targetFolderHandle);
ulong folderId = createFolderResponse.FolderId;
#endregion
#region Preparing the table: RopCreateAndSaveMessages
int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
int maxRetryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
int retryCount;
uint returnValue = 0;
for (int i = 1; i < count; i++)
{
// If the RPC report error code reported by the following three ROP methods is 1726 (The remote procedure call failed),
// re-do the common steps of this case.
if (returnValue == 1726)
{
#region The common steps
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
this.cropsAdapter.RpcConnect(
Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
ConnectionType.PrivateMailboxServer,
Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
Common.GetConfigurationPropertyValue("PassWord", this.Site));
logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopOpenFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
openFolderRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
openFolderResponse = (RopOpenFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
openFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
openedFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopCreateFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
createFolderRequest,
openedFolderHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
createFolderResponse = (RopCreateFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
createFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
tableHandle = this.GetContentsTableHandle(targetFolderHandle);
folderId = createFolderResponse.FolderId;
#endregion
}
#region Create message
createMessageRequest.FolderId = folderId;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopCreateMessage request:loop counter i={0}", i);
retryCount = maxRetryCount;
do
{
// Send the RopCreateMessage to create message.
this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
createMessageRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse,
out returnValue);
System.Threading.Thread.Sleep(waitTime);
retryCount--;
}
while (this.response is RopBackoffResponse && retryCount >= 0);
Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);
// If the error code is 1726, continue this loop.
if (returnValue == 1726)
{
continue;
}
createMessageResponse = (RopCreateMessageResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
createMessageResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
uint targetMessageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];
#endregion
#region Save message
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopSaveChangesMessage request:loop counter i={0}", i);
retryCount = maxRetryCount;
// Do the loop when response is RopBackoffResponse or saveChangesMessageResponse is 0x80040401 (ecTimeout).
do
{
// Send the RopSaveChangesMessage request to save the created message.
this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
saveChangesMessageRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse,
out returnValue);
if (this.response is RopSaveChangesMessageResponse)
{
saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;
}
System.Threading.Thread.Sleep(waitTime);
retryCount--;
}
while ((this.response is RopBackoffResponse || saveChangesMessageResponse.ReturnValue == 0x80040401) && retryCount >= 0);
Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);
// If the error code is 1726, continue this loop.
if (returnValue == 1726)
{
continue;
}
saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
saveChangesMessageResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
#endregion
#region Release all resources
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopRelease request.");
retryCount = maxRetryCount;
do
{
this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
releaseRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse,
out returnValue);
System.Threading.Thread.Sleep(waitTime);
retryCount--;
}
while (this.response is RopBackoffResponse && retryCount >= 0);
Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);
// If the error code is 1726, continue this loop.
if (returnValue == 1726)
{
continue;
}
#endregion
}
// If the error code 1726 occurs on the last time of the above "for" loop, re-do the common steps.
if (returnValue == 1726)
{
#region The common steps
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
this.cropsAdapter.RpcConnect(
Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
ConnectionType.PrivateMailboxServer,
Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
Common.GetConfigurationPropertyValue("PassWord", this.Site));
logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopOpenFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
openFolderRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
openFolderResponse = (RopOpenFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
openFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
openedFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopCreateFolder request.");
this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
createFolderRequest,
openedFolderHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
createFolderResponse = (RopCreateFolderResponse)this.response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
createFolderResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
tableHandle = this.GetContentsTableHandle(targetFolderHandle);
folderId = createFolderResponse.FolderId;
#endregion
}
#endregion
}