Пример #1
0
        /// <summary>
        /// Uploads the items into a specified folder.
        /// </summary>
        /// <param name="uploadItemsRequest">Specify the request for UploadItems operation.</param>
        /// <returns>The response to this operation request.</returns>
        public UploadItemsResponseType UploadItems(UploadItemsType uploadItemsRequest)
        {
            if (uploadItemsRequest == null)
            {
                throw new ArgumentException("The uploadItems should not be null.");
            }

            // Send the request and get the response.
            UploadItemsResponseType response = this.exchangeServiceBinding.UploadItems(uploadItemsRequest);

            this.VerifyTransportType();
            this.VerifySoapVersion();
            this.VerifyUploadItemsResponseType(response, this.exchangeServiceBinding.IsSchemaValidated);

            return(response);
        }
        public void MSOXWSBTRF_S01_TC05_ExportAndUploadItems_Update_Fail()
        {
            #region Get the exported items.
            // Get the exported items which are prepared for uploading.
            ExportItemsResponseMessageType[] exportedItem = this.ExportItems(false);
            #endregion

            #region Create a new folder to place the upload item.
            // Create another sub folder.
            string[] subFolderIds = new string[this.ParentFolderType.Count];
            for (int i = 0; i < subFolderIds.Length; i++)
            {
                // Generate the folder name.
                string folderName = Common.GenerateResourceName(this.Site, this.ParentFolderType[i] + "NewFolder");

                // Create sub folder in the specified parent folder
                subFolderIds[i] = this.CreateSubFolder(this.ParentFolderType[i], folderName);
                Site.Assert.IsNotNull(
                    subFolderIds[i],
                    string.Format(
                        "The sub folder named '{0}' under '{1}' should be created successfully.",
                        folderName,
                        this.ParentFolderType[i].ToString()));
            }
            #endregion

            #region Call UploadItems operation with CreateAction set to Update and the ParentFolderId set to the new created sub folder.
            // Initialize the uploaded items using the previous exported items, set the item's CreateAction to Update and the ParentFolderId to the sub folder.
            UploadItemsType uploadItemsWithChangedParentFolderId = new UploadItemsType();
            uploadItemsWithChangedParentFolderId.Items = new UploadItemType[this.ItemCount];
            for (int i = 0; i < uploadItemsWithChangedParentFolderId.Items.Length; i++)
            {
                uploadItemsWithChangedParentFolderId.Items[i] = TestSuiteHelper.GenerateUploadItem(
                    exportedItem[i].ItemId.Id,
                    exportedItem[i].ItemId.ChangeKey,
                    exportedItem[i].Data,
                    subFolderIds[i],
                    CreateActionType.Update);
            }

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsWithChangedParentFolderIdResponse = this.BTRFAdapter.UploadItems(uploadItemsWithChangedParentFolderId);

            // Check whether the ExportItems operation is executed successfully.
            foreach (UploadItemsResponseMessageType responseMessage in uploadItemsWithChangedParentFolderIdResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Error,
                    responseMessage.ResponseClass,
                    string.Format(
                        @"The ExportItems operation should be unsuccessful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        responseMessage.ResponseClass));
            }
            #endregion

            #region Verify UploadItems related requirements.
            // Verify UploadItems related requirements.
            this.VerifyUploadItemsErrorResponse(uploadItemsWithChangedParentFolderIdResponse);

            // If the ResponseClass property equals Error, then MS-OXWSBTRF_R231 can be captured
            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R231.");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R231
            Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorItemNotFound,
                uploadItemsWithChangedParentFolderIdResponse.ResponseMessages.Items[0].ResponseCode,
                231,
                @"[In CreateActionType Simple Type][Update] 
                if the target item is not in the original folder specified by the <ParentFolderId> element in the UploadItemType complex type, 
                an ErrorItemNotFound error code MUST be returned in the UploadItemsResponseMessageType complex type.");
            #endregion

            #region Call UploadItems operation with CreateAction set to Update and the ItemId set to invalid value.
            // Call UploadItemsFail method to upload three kinds of items and set the CreateAction to Update:
            // 1.The ID attribute of ItemId is empty;
            // 2.The ID attribute of ItemId is valid and the ChangeKey is invalid;
            // 3.The ID attribute of ItemId is invalid and the ChangeKey is null.
            this.UploadInvalidItems(this.OriginalFolderId, CreateActionType.Update);
            #endregion
        }
Пример #3
0
        private void MigrateItens(ref DataGridViewRow row, ExchangeServiceBinding srcService, ExchangeServiceBinding tgtService, DistinguishedFolderIdNameType folder, string srcUserMail, string tgtUserMail)
        {
            ResponseMessageType[] itemsResponse = this.GetFolderItems(srcService, folder);

            ExportItemsType exExportItems = new ExportItemsType();

            foreach (ResponseMessageType responseMessage in itemsResponse)
            {
                FindItemResponseMessageType firmt = responseMessage as FindItemResponseMessageType;
                FindItemParentType          fipt  = firmt.RootFolder;
                object obj   = fipt.Item;
                int    count = 0;

                // FindItem contains an array of items.
                if (obj is ArrayOfRealItemsType)
                {
                    ArrayOfRealItemsType items = (obj as ArrayOfRealItemsType);

                    exExportItems.ItemIds = new ItemIdType[(items.Items.Count() + 1)];

                    foreach (ItemType it in items.Items)
                    {
                        exExportItems.ItemIds[count]    = new ItemIdType();
                        exExportItems.ItemIds[count].Id = it.ItemId.Id;
                        count++;
                    }
                }
            }

            ExportItemsResponseType exResponse = srcService.ExportItems(exExportItems);

            ResponseMessageType[] rmResponses   = exResponse.ResponseMessages.Items;
            UploadItemsType       upUploadItems = new UploadItemsType();

            upUploadItems.Items = new UploadItemType[(rmResponses.Length + 1)];
            Int32 icItemCount = 0;

            foreach (ResponseMessageType rmReponse in rmResponses)
            {
                if (rmReponse.ResponseClass == ResponseClassType.Success)
                {
                    ExportItemsResponseMessageType exExportedItem = (ExportItemsResponseMessageType)rmReponse;
                    Byte[]         messageBytes = exExportedItem.Data;
                    UploadItemType upUploadItem = new UploadItemType();
                    upUploadItem.CreateAction          = CreateActionType.UpdateOrCreate;
                    upUploadItem.Data                  = messageBytes;
                    upUploadItem.IsAssociatedSpecified = true;
                    upUploadItem.IsAssociated          = false;
                    upUploadItems.Items[icItemCount]   = upUploadItem;

                    FolderIdManager folderIdMgr = new FolderIdManager();
                    FolderIdType    folderId    = new FolderIdType();
                    folderId.Id = folderIdMgr.GetFolderId(tgtUserMail, Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Contacts, Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2010_SP2);


                    upUploadItem.ParentFolderId = folderId;
                    icItemCount += 1;
                }
            }
            //Erro de Internal Server Error nessa etapa
            UploadItemsResponseType upLoadResponse = tgtService.UploadItems(upUploadItems);
            Int32 Success = 0;
            Int32 Failure = 0;

            foreach (ResponseMessageType upResponse in upLoadResponse.ResponseMessages.Items)
            {
                if (upResponse.ResponseClass == ResponseClassType.Success)
                {
                    Success++;
                }
                if (upResponse.ResponseClass == ResponseClassType.Error)
                {
                    Failure++;
                }
            }


            string resTask = string.Format("Items Copied Sucessfull : {0} - Failure: {1}", Success, Failure);

            Tools.SetRowValue(ref row, EColumns.results, resTask);

            //iv.Offset += fiItems.Items.Count;
        }
Пример #4
0
        /// <summary>
        /// Get the UploadItemsResponseMessageType response of UploadItems operation when this operation executes unsuccessfully.
        /// </summary>
        /// <param name="parentFolderId">Specifies the target folder in which to place the upload item.</param>
        /// <param name="createAction">Specifies the action for uploading items to the folder.</param>
        /// <returns>The array of UploadItemsResponseMessageType response.</returns>
        protected UploadItemsResponseMessageType[] UploadInvalidItems(Collection <string> parentFolderId, CreateActionType createAction)
        {
            #region Get the exported items and parent folder ID.
            // Get the exported items which is prepared for uploading.
            ExportItemsResponseMessageType[] exportedItem = this.ExportItems(false);
            #endregion

            #region Call UploadItems operation to upload the items that exported in last step to the server.
            // Initialize the upload items using the data of previous export items, and set that item CreateAction to a value of CreateActionType.
            UploadItemsType uploadInvalidItems = new UploadItemsType();
            uploadInvalidItems.Items = new UploadItemType[4];

            // The ID attribute of ItemId is empty.
            uploadInvalidItems.Items[0] = TestSuiteHelper.GenerateUploadItem(
                string.Empty,
                null,
                exportedItem[0].Data,
                parentFolderId[0],
                createAction);

            // The ID attribute of ItemId is valid and the ChangeKey is invalid.
            uploadInvalidItems.Items[1] = TestSuiteHelper.GenerateUploadItem(
                exportedItem[1].ItemId.Id,
                InvalidChangeKey,
                exportedItem[1].Data,
                parentFolderId[1],
                createAction);

            // The ID attribute of ItemId is invalid and the ChangeKey is null.
            uploadInvalidItems.Items[2] = TestSuiteHelper.GenerateUploadItem(
                InvalidItemId,
                null,
                exportedItem[2].Data,
                parentFolderId[2],
                createAction);

            // The ID attribute of ItemId is invalid and the ChangeKey is null.
            uploadInvalidItems.Items[3] = TestSuiteHelper.GenerateUploadItem(
                InvalidItemId,
                null,
                exportedItem[3].Data,
                parentFolderId[3],
                createAction);

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsResponse = this.BTRFAdapter.UploadItems(uploadInvalidItems);

            // Check whether the ExportItems operation is executed successfully.
            foreach (UploadItemsResponseMessageType responseMessage in uploadItemsResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Error,
                    responseMessage.ResponseClass,
                    string.Format(
                        @"The UploadItems operation should be unsuccessful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        responseMessage.ResponseClass));
            }
            #endregion

            #region Verify the UploadItemsResponseType related requirements
            // Verify the UploadItemsResponseType related requirements.
            this.VerifyUploadItemsErrorResponse(uploadItemsResponse);
            #endregion

            #region Call GetResponseMessages to get the UploadItemsResponseMessageType items.
            // Get the UploadItemsResponseMessageType items.
            UploadItemsResponseMessageType[] uploadItemsResponseMessages = TestSuiteHelper.GetResponseMessages <UploadItemsResponseMessageType>(uploadItemsResponse);

            return(uploadItemsResponseMessages);

            #endregion
        }
Пример #5
0
        /// <summary>
        /// Get the UploadItemsResponseMessageType response of UploadItems operation when this operation executes successfully.
        /// </summary>
        /// <param name="exportedItems">The items exported from server.</param>
        /// <param name="parentFolderId">Specifies the target folder in which to place the upload item.</param>
        /// <param name="createAction">Specifies the action for uploading items to the folder.</param>
        /// <param name="isAssociatedSpecified">A Boolean value specifies whether IsAssociated attribute is specified.</param>
        /// <param name="isAssociated">Specifies the value of the IsAssociated attribute.</param>
        /// <param name="configureSOAPHeader">A Boolean value specifies whether configuring the SOAP header before calling operations.</param>
        /// <returns>The array of UploadItemsResponseMessageType response.</returns>
        protected UploadItemsResponseMessageType[] UploadItems(
            ExportItemsResponseMessageType[] exportedItems,
            Collection <string> parentFolderId,
            CreateActionType createAction,
            bool isAssociatedSpecified,
            bool isAssociated,
            bool configureSOAPHeader)
        {
            #region Call UploadItems operation to upload the items that exported in last step to the server.
            // Initialize the upload items using the data of previous exported items, and set that item CreateAction to a value of CreateActionType.
            UploadItemsType uploadItems = new UploadItemsType();
            uploadItems.Items = new UploadItemType[this.ItemCount];
            for (int i = 0; i < uploadItems.Items.Length; i++)
            {
                uploadItems.Items[i] = TestSuiteHelper.GenerateUploadItem(
                    exportedItems[i].ItemId.Id,
                    exportedItems[i].ItemId.ChangeKey,
                    exportedItems[i].Data,
                    parentFolderId[i],
                    createAction);
                uploadItems.Items[i].IsAssociatedSpecified = isAssociatedSpecified;
                if (uploadItems.Items[i].IsAssociatedSpecified)
                {
                    uploadItems.Items[i].IsAssociated = isAssociated;
                }
            }

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsResponse = this.BTRFAdapter.UploadItems(uploadItems);

            // Check whether the operation is executed successfully.
            foreach (UploadItemsResponseMessageType uploadResponse in uploadItemsResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Success,
                    uploadResponse.ResponseClass,
                    string.Format(
                        @"The UploadItems operation should be successful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        uploadResponse.ResponseClass));
            }

            // If the operation executes successfully, the items in UploadItems response should be equal to the value of ItemCount
            Site.Assert.AreEqual <int>(
                uploadItemsResponse.ResponseMessages.Items.Length,
                this.ItemCount,
                string.Format(
                    "The uploadItems response should contain {0} items, actually, it contains {1}",
                    this.ItemCount,
                    uploadItemsResponse.ResponseMessages.Items.Length));
            #endregion

            #region Verify the UploadItemsResponseType related requirements
            // Verify the UploadItemsResponseType related requirements.
            this.VerifyUploadItemsSuccessResponse(uploadItemsResponse);
            #endregion

            #region Call GetResponseMessages to get the UploadItemsResponseMessageType items.
            // Get the UploadItemsResponseMessageType items.
            UploadItemsResponseMessageType[] uploadItemsResponseMessages = TestSuiteHelper.GetResponseMessages <UploadItemsResponseMessageType>(uploadItemsResponse);

            return(uploadItemsResponseMessages);

            #endregion
        }
        /// <summary>
        /// This method is used to verify the UploadItems operation response related requirements.
        /// </summary>
        /// <param name="uploadItems"> Specified UploadItemsResponseType instance</param>
        /// <param name="isSchemaValidated">Whether the schema is validated.</param>
        private void VerifyUploadItemsResponseType(UploadItemsResponseType uploadItems, bool isSchemaValidated)
        {
            // Response after Upload Items operation must not be null.
            Site.Assert.IsNotNull(uploadItems, "The response of UploadItems operation should not be null.");

            // If the proxy can communicate with server successfully, then all the WSDL related requirements can be directly captured.
            // Therefore MS-OXWSBTRF_R87, MS-OXWSBTRF_R86 and MS-OXWSBTRF_R101 are captured.
            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R87");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R87
            Site.CaptureRequirement(
                87,
                @"[In UploadItems]The following is the WSDL binding specification of the operation.
                <wsdl:operation name=""UploadItems"">
                    <soap:operation soapAction=""http://schemas.microsoft.com/exchange/services/2006/messages/UploadItems"" />
                    <wsdl:input>
                    <soap:header message=""tns:UploadItemsSoapIn"" part=""Impersonation"" use=""literal""/>
                    <soap:header message=""tns:UploadItemsSoapIn"" part=""MailboxCulture"" use=""literal""/>
                    <soap:header message=""tns:UploadItemsSoapIn"" part=""RequestVersion"" use=""literal""/>
                    <soap:body parts=""request"" use=""literal"" />
                    </wsdl:input>
                    <wsdl:output>
                    <soap:body parts=""UploadItemsResult"" use=""literal"" />
                    <soap:header message=""tns:UploadItemsSoapOut"" part=""ServerVersion"" use=""literal""/>
                    </wsdl:output>
                </wsdl:operation>");

            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R86");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R86
            Site.CaptureRequirement(
                86,
                @"[In UploadItems]The following is the WSDL port type definition of the operation.<wsdl:operation name=""UploadItems""><wsdl:input message=""tns:UploadItemsSoapIn""/><wsdl:output message=""tns:UploadItemsSoapOut""/></wsdl:operation>");

            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R101");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R101
            Site.CaptureRequirement(
                101,
                @"[In tns:UploadItemsSoapOut Message]The UploadItemsSoapOut WSDL message specifies the SOAP message that represents a response that contains the results of an attempt to upload items into a mailbox.
                [In tns:UploadItemsSoapOut Message]<wsdl:message name=""UploadItemsSoapOut"">
                  <wsdl:part name=""UploadItemsResult"" element=""tns:UploadItemsResponse""/>
                  <wsdl:part name=""ServerVersion"" element=""t:ServerVersionInfo""/>
                </wsdl:message>");

            // If the schema validation is successful, then MS-OXWSBTRF_R247, MS-OXWSBTRF_R248 ,MS-OXWSBTRF_R249 and MS-OXWSBTRF_R250 can be captured.
            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R247");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R247
            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                247,
                @"[In tns:UploadItemsSoapOut Message]The Element/type of UploadItemsResult is
                UploadItemsResponse (section 3.1.4.2.2.2).");

            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R248");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R248
            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                248,
                @"[In tns:UploadItemsSoapOut Message]The UploadItemsResult part specifies the SOAP body of the response to an UploadItems operation request.");
            if (this.exchangeServiceBinding.ServerVersionInfoValue != null)
            {
                // Add debug information.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R249");

                // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R249
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    249,
                    @"[In tns:UploadItemsSoapOut Message]The Element/type of ServerVersion is ServerVersion ([MS-OXWSCDATA] section 2.2.3.12).");

                // Add debug information.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R250");

                // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R250
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    250,
                    @"[In tns:UploadItemsSoapOut Message]The ServerVersion part specifies the SOAP header that identifies the server version for the response.");
            }

            // Verify BaseResponseMessageType related requirements in the protocol document MS-OXWSCDATA.
            this.VerifyBaseResponseMessageType(isSchemaValidated);

            // Verify UploadItemsResponseMessageType related requirements.
            foreach (UploadItemsResponseMessageType uploadItem in uploadItems.ResponseMessages.Items)
            {
                this.VerifyUploadItemsResponseMessageType(uploadItem, isSchemaValidated);
            }

            // If the schema validation is successful and the above BaseResponseMessageType validation is fine, then MS-OXWSBTRF_R131 will be captured.
            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R131");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R131
            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                131,
                @"[In m:UploadItemsResponseType Complex Type][The schema of UploadItemsResponseType is:]<xs:complexType name=""UploadItemsResponseType"">
                  <xs:complexContent>
                    <xs:extension base=""m:BaseResponseMessageType""/>
                  </xs:complexContent>
                </xs:complexType>");

            // If the schema validation is successful, then the UpdateItemsResponse element's type is UpdateItemsResponseType, requirement MS-OXWSBTRF_R114 can be captured.
            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R114");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R114
            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                114,
                @"[In UploadItemsResponse Element] [The schema of UploadItemsResponse is:]
                <xs:element name=""UploadItemsResponse""
                type=""m:UploadItemsResponseType""/>");

            // If the response from the UploadItems is not null, then MS-OXWSBTRF_R246 MS-OXWSBTRF_R11301 and  will be captured.
            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R246");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R246
            Site.CaptureRequirementIfIsNotNull(
                uploadItems,
                246,
                @"[In Elements]This element [UploadItemsResponse] MUST be present.");

            // Add debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R11301");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R11301
            Site.CaptureRequirementIfIsNotNull(
                uploadItems,
                11301,
                @"[In UploadItemsResponse Element] This element [UploadItemsResponse Element] MUST be present.");

            // If the schema validation successful, the server version related requirements can be verified.
            this.VerifyServerVersion(isSchemaValidated);
        }