Exemplo n.º 1
0
 public void Flush()
 {
     lock (this.syncObject)
     {
         if (this.memoryCache.Count > 0)
         {
             this.CreateWorkingFolderIfNotExist();
             int             num      = 0;
             FolderIdType    folderId = this.workingSubFolder.FolderId;
             List <ItemType> list     = new List <ItemType>(Math.Min(this.memoryCache.Count, Constants.ReadWriteBatchSize));
             foreach (ItemId itemId in this.memoryCache)
             {
                 list.Add(new ItemType
                 {
                     ExtendedProperty = this.CreateItemExtendedPropertyValuesFromItemId(itemId)
                 });
                 num++;
                 if (list.Count == Constants.ReadWriteBatchSize || num == this.memoryCache.Count)
                 {
                     List <ItemType> list2 = this.ewsClient.CreateItems(this.targetPrimarySmtpAddress, folderId, list.ToArray());
                     if (list2 == null || list2.Count != list.Count)
                     {
                         throw new ExportException(ExportErrorType.NumberOfItemsMismatched, string.Format("Expected number of items ({0}) supposed to write to the list is not matched with actual ({1})", list.Count, list2.Count));
                     }
                     list.Clear();
                 }
             }
         }
         this.memoryCache.Clear();
     }
 }
Exemplo n.º 2
0
        public bool UploadItems(FolderIdType parentFolderId, IEnumerable <ItemInformation> items, bool alwaysCreateNew)
        {
            UploadItemsType  itemsType        = new UploadItemsType();
            CreateActionType createActionType = alwaysCreateNew ? CreateActionType.CreateNew : CreateActionType.UpdateOrCreate;

            itemsType.Items = (from item in items
                               select new UploadItemType
            {
                CreateAction = createActionType,
                ItemId = new ItemIdType
                {
                    Id = item.Id
                },
                Data = item.Data,
                ParentFolderId = parentFolderId
            }).ToArray <UploadItemType>();
            int successCount = 0;

            this.CallEwsWithRetries((LID)0U, () => this.binding.UploadItems(itemsType), delegate(ResponseMessageType responseMessage, int messageIndex)
            {
                UploadItemsResponseMessageType uploadItemsResponseMessageType = responseMessage as UploadItemsResponseMessageType;
                if (uploadItemsResponseMessageType != null && uploadItemsResponseMessageType.ResponseClass == ResponseClassType.Success)
                {
                    successCount++;
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug(0L, "Items uploaded successfully");
                    }
                }
                return(false);
            }, null);
            return(successCount == itemsType.Items.Length);
        }
Exemplo n.º 3
0
        protected override void InitializeTargetFolderHierarchy()
        {
            string resultFolderName;

            if (this.exportContext.ExportMetadata.IncludeDuplicates)
            {
                string arg = base.DataContext.IsPublicFolder ? "Public Folders" : base.DataContext.SourceName;
                resultFolderName = string.Format("{0}-{1}", arg, this.targetMailbox.ExportSettings.ExportTime);
            }
            else
            {
                resultFolderName = string.Format("{0}-{1}", "Results", this.targetMailbox.ExportSettings.ExportTime);
            }
            string text = this.targetMailbox.CreateResultFolder(resultFolderName);

            if (base.DataContext.IsUnsearchable)
            {
                FolderIdType parentFolderId = new FolderIdType
                {
                    Id = text
                };
                BaseFolderType baseFolderType = this.targetMailbox.GetFolderByName(parentFolderId, Strings.Unsearchable);
                if (baseFolderType == null)
                {
                    baseFolderType = this.targetMailbox.CreateFolder(parentFolderId, Strings.Unsearchable, false);
                }
                text = baseFolderType.FolderId.Id;
            }
            base.FolderMapping.Add("", text);
        }
Exemplo n.º 4
0
 public IEnumerable <ItemId> ReadItemIds()
 {
     if (this.Exists)
     {
         int          offset   = 0;
         FolderIdType folderId = this.workingSubFolder.FolderId;
         for (;;)
         {
             List <ItemType> items = this.ewsClient.RetrieveItems(this.targetPrimarySmtpAddress, folderId, MailboxItemIdList.AdditionalProperties, null, false, new int?(Constants.ReadWriteBatchSize), offset);
             int             totalItemsReturned = (items != null) ? items.Count : 0;
             if (totalItemsReturned == 0)
             {
                 break;
             }
             offset += totalItemsReturned;
             foreach (ItemType item in items)
             {
                 ItemId retItemId = this.PopulateItemIdFromItemExtendedPropertyValues(item.ExtendedProperty);
                 if (retItemId != null)
                 {
                     yield return(retItemId);
                 }
             }
         }
     }
     yield break;
 }
Exemplo n.º 5
0
 public EwsAuditLog(EwsAuditClient ewsClient, FolderIdType auditFolderId, DateTime logRangeStart, DateTime logRangeEnd)
 {
     this.ewsClient             = ewsClient;
     this.auditFolderId         = auditFolderId;
     this.EstimatedLogStartTime = logRangeStart;
     this.EstimatedLogEndTime   = logRangeEnd;
 }
Exemplo n.º 6
0
        public bool FindLog(DateTime timestamp, bool createIfNotExists, out IAuditLog auditLog)
        {
            auditLog = null;
            DateTime     dateTime;
            DateTime     dateTime2;
            string       logFolderNameAndRange = AuditLogCollection.GetLogFolderNameAndRange(timestamp, out dateTime, out dateTime2);
            FolderIdType folderIdType          = null;

            if (!this.ewsClient.FindFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType))
            {
                if (!createIfNotExists)
                {
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug <DateTime>((long)this.GetHashCode(), "No matching log subfolder found. Lookup time={0}", timestamp);
                    }
                    return(false);
                }
                bool flag = this.ewsClient.CreateFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType);
                if (!flag)
                {
                    flag = this.ewsClient.FindFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType);
                }
                if (!flag && this.IsTraceEnabled(TraceType.DebugTrace))
                {
                    this.Tracer.TraceDebug <DateTime, DateTime>((long)this.GetHashCode(), "Failed to create audit log folder for log range [{0}, {1})", dateTime, dateTime2);
                }
            }
            if (folderIdType != null)
            {
                auditLog = new EwsAuditLog(this.ewsClient, folderIdType, dateTime, dateTime2);
            }
            return(folderIdType != null);
        }
Exemplo n.º 7
0
        private IAuditLog GetAuditLog(string organizationIdEncoded, AuditRecord auditRecord)
        {
            CacheEntry <IAuditLog> cacheEntry;
            IAuditLog         auditLog          = this.auditLogs.TryGetValue(organizationIdEncoded, DateTime.UtcNow, out cacheEntry) ? cacheEntry.Value : null;
            ExchangePrincipal exchangePrincipal = this.GetExchangePrincipal(organizationIdEncoded);
            EwsAuditClient    ewsClient         = null;
            FolderIdType      folderIdType      = null;

            if (AuditFeatureManager.IsPartitionedAdminLogEnabled(exchangePrincipal) && (auditLog == null || auditLog.EstimatedLogEndTime < auditRecord.CreationTime))
            {
                this.GetClientAndRootFolderId(exchangePrincipal, ref ewsClient, ref folderIdType);
                EwsAuditLogCollection ewsAuditLogCollection = new EwsAuditLogCollection(ewsClient, folderIdType);
                if (ewsAuditLogCollection.FindLog(auditRecord.CreationTime, true, out auditLog))
                {
                    this.auditLogs.Set(organizationIdEncoded, DateTime.UtcNow, new CacheEntry <IAuditLog>(auditLog));
                }
                else
                {
                    auditLog = null;
                }
            }
            if (auditLog == null)
            {
                this.GetClientAndRootFolderId(exchangePrincipal, ref ewsClient, ref folderIdType);
                auditLog = new EwsAuditLog(ewsClient, folderIdType, DateTime.MinValue, DateTime.MaxValue);
                this.auditLogs.Set(organizationIdEncoded, DateTime.UtcNow, new CacheEntry <IAuditLog>(auditLog));
            }
            return(auditLog);
        }
Exemplo n.º 8
0
        public void MSOXWSFOLD_S02_TC02_CopyMultipleFolders()
        {
            #region Copy the "drafts" and "deleteditems" folder to inbox

            // Set "drafts" and "deleteditems" folders' Id.
            DistinguishedFolderIdType copiedFolderId1 = new DistinguishedFolderIdType();
            copiedFolderId1.Id = DistinguishedFolderIdNameType.drafts;
            DistinguishedFolderIdType copiedFolderId2 = new DistinguishedFolderIdType();
            copiedFolderId2.Id = DistinguishedFolderIdNameType.deleteditems;

            // CopyFolder request.
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), copiedFolderId1, copiedFolderId2);

            // Copy the "drafts" and "deleteditems" folder.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyFolderResponse, 2, this.Site);

            // Save copied folders' id.
            FolderIdType folderId1 = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            FolderIdType folderId2 = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[1]).Folders[0].FolderId;

            // Save the copied folders' id.
            this.NewCreatedFolderIds.Add(folderId1);
            this.NewCreatedFolderIds.Add(folderId2);

            #endregion
        }
Exemplo n.º 9
0
 private FolderId(FolderIdType folderIdType, string id = null)
 {
     FolderIdType = folderIdType;
     if (!string.IsNullOrEmpty(id))
     {
         Id = id;
     }
 }
Exemplo n.º 10
0
 private FolderId(FolderIdType folderIdType, string id = null)
 {
     FolderIdType = folderIdType;
     if (!string.IsNullOrEmpty(id))
     {
         Id = id;
     }
 }
Exemplo n.º 11
0
        public void MSOXWSFOLD_S03_TC03_MoveFolderFailed()
        {
            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Delete the created folder

            // DeleteFolder request.
            DeleteFolderType deleteFolderRequest = this.GetDeleteFolderRequest(DisposalType.HardDelete, newFolderId);

            // Delete the specified folder.
            DeleteFolderResponseType deleteFolderResponse = this.FOLDAdapter.DeleteFolder(deleteFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(deleteFolderResponse, 1, this.Site);

            // The folder has been deleted, so its folder id has disappeared.
            this.NewCreatedFolderIds.Remove(newFolderId);

            #endregion

            #region Move the deleted folder
            MoveFolderType moveFolderRequest = new MoveFolderType();
            moveFolderRequest.FolderIds    = new BaseFolderIdType[1];
            moveFolderRequest.FolderIds[0] = newFolderId;
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.inbox;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folder.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

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

            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Error,
                moveFolderResponse.ResponseMessages.Items[0].ResponseClass,
                4315,
                @"[In MoveFolder Operation]An unsuccessful MoveFolder operation request returns a MoveFolderResponse element with the ResponseClass attribute of the MoveFolderResponseMessage element set to ""Error"".");
            #endregion
        }
Exemplo n.º 12
0
        public BaseFolderType GetFolder(string folderId)
        {
            FolderIdType folderId2 = new FolderIdType
            {
                Id = folderId
            };

            return(this.ewsClient.GetFolderById(this.PrimarySmtpAddress, folderId2));
        }
Exemplo n.º 13
0
        public List <ItemInformation> CopyItems(string parentFolderId, IList <ItemInformation> items)
        {
            FolderIdType parentFolderId2 = new FolderIdType
            {
                Id = parentFolderId
            };

            return(this.ewsClient.UploadItems(this.PrimarySmtpAddress, parentFolderId2, items, true));
        }
Exemplo n.º 14
0
        public void MSOXWSFOLD_S05_TC04_EmptyPublicFolderFailed()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Delete the created folder

            // DeleteFolder request.
            DeleteFolderType deleteFolderRequest = this.GetDeleteFolderRequest(DisposalType.HardDelete, newFolderId);

            // Delete the specified folder.
            DeleteFolderResponseType deleteFolderResponse = this.FOLDAdapter.DeleteFolder(deleteFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(deleteFolderResponse, 1, this.Site);

            // The folder has been deleted, so its folder id has disappeared.
            this.NewCreatedFolderIds.Remove(newFolderId);

            #endregion

            #region Empty the deleted folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(newFolderId, DisposalType.HardDelete, true);

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

            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Error,
                emptyFolderResponse.ResponseMessages.Items[0].ResponseClass,
                34745,
                @"[In EmptyFolder Operation]An unsuccessful EmptyFolder operation request returns an EmptyFolderResponse element with the ResponseClass attribute of the EmptyFolderResponseMessage element set to ""Error"".");
            #endregion
        }
Exemplo n.º 15
0
        public void MSOXWSFOLD_S06_TC02_UpdateFolderWithAppendToFolderFieldType()
        {
            #region Create a new folder in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);
            FolderIdType             folderId             = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(folderId);

            #endregion

            #region Update Folder Operation with AppendToFolderFieldType Complex Type set.

            // Specified folder to be updated.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest("Folder", "AppendToFolderField", folderId);

            // Update the specific folder's properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

            // Check the length.
            Site.Assert.AreEqual <int>(
                1,
                updateFolderResponse.ResponseMessages.Items.GetLength(0),
                "Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                updateFolderResponse.ResponseMessages.Items.GetLength(0));

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R507.
            Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Error,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                507,
                @"[In t:AppendToFolderFieldType Complex Type]Any request that uses this complex type will always return an error response.");

            #endregion
        }
Exemplo n.º 16
0
        public void MSOXWSFOLD_S03_TC02_MoveMultipleFolders()
        {
            #region Create multiple folders in the "drafts" folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), new string[] { "ForMoveFolder1", "ForMoveFolder2" }, new string[] { "IPF.MyCustomFolderClass", "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);
            FolderIdType             newFolderId1         = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            FolderIdType             newFolderId2         = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[1]).Folders[0].FolderId;

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 2, this.Site);

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(newFolderId1);
            this.NewCreatedFolderIds.Add(newFolderId2);

            #endregion

            #region Move the new created folder to the inbox folder

            // MoveFolder request.
            MoveFolderType moveFolderRequest = new MoveFolderType();

            // Set the request's folderId field.
            moveFolderRequest.FolderIds    = new BaseFolderIdType[2];
            moveFolderRequest.FolderIds[0] = newFolderId1;
            moveFolderRequest.FolderIds[1] = newFolderId2;

            // Set the request's destFolderId field.
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.inbox;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folder.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(moveFolderResponse, 2, this.Site);

            #endregion
        }
Exemplo n.º 17
0
        private string CreateSearchLogEmail(FolderIdType folderId, MailboxDiscoverySearch searchObject, List <string> successfulMailboxes, List <string> unsuccessfulMailboxes)
        {
            ItemType itemType = new ItemType
            {
                Subject = string.Format("{0}-{1}", searchObject.Name, searchObject.LastStartTime.ToString()),
                Body    = new BodyType
                {
                    BodyType1 = BodyTypeType.HTML,
                    Value     = Util.CreateLogMailBody(searchObject, this.StatusMailRecipients, successfulMailboxes, unsuccessfulMailboxes, this.ExportContext.Sources)
                }
            };
            List <ItemType> list = this.ewsClient.CreateItems(this.PrimarySmtpAddress, folderId, new ItemType[]
            {
                itemType
            });

            return(list[0].ItemId.Id);
        }
Exemplo n.º 18
0
        public bool CreateFolder(string folderName, FolderIdType parentFolderId, out FolderIdType folderId)
        {
            DiagnosticContext.TraceLocation((LID)39100U);
            folderId = null;
            CreateFolderType cft = new CreateFolderType
            {
                ParentFolderId = new TargetFolderIdType
                {
                    Item = parentFolderId
                },
                Folders = new BaseFolderType[]
                {
                    new FolderType
                    {
                        DisplayName = folderName
                    }
                }
            };

            return(this.InternalCreateFolder(cft, null, out folderId));
        }
        /// <summary>
        /// Find the specified sub folder.
        /// </summary>
        /// <param name="parentFolderName">Name of the specified parent folder.</param>
        /// <param name="subFolderName">Name of the specified sub folder.</param>
        /// <returns>Id of the folder.</returns>
        private FolderIdType FindSubFolder(DistinguishedFolderIdNameType parentFolderName, string subFolderName)
        {
            FolderIdType folderId = new FolderIdType();

            // Find all sub folders in the specified parent folder.
            BaseFolderType[] folders = this.FindAllSubFolders(parentFolderName);
            Site.Assert.IsNotNull(folders, "There should be at least one folder in the '{0}' folder.", parentFolderName);

            // Find the item with the specified subject.
            foreach (BaseFolderType currentFolder in folders)
            {
                if (currentFolder.DisplayName == subFolderName)
                {
                    folderId = currentFolder.FolderId;
                    break;
                }
            }

            Site.Assert.IsNotNull(folderId.Id, "There should be at least one folder with the specified subject '{0}'.", subFolderName);
            return(folderId);
        }
Exemplo n.º 20
0
        private bool InternalCreateFolder(CreateFolderType cft, Func <ResponseMessageType, int, bool> responseErrorProcessor, out FolderIdType targetFolderId)
        {
            targetFolderId = null;
            FolderIdType localTargetFolderId = null;

            this.CallEwsWithRetries((LID)37052U, () => this.binding.CreateFolder(cft), delegate(ResponseMessageType responseMessage, int messageIndex)
            {
                FolderInfoResponseMessageType folderInfoResponseMessageType = responseMessage as FolderInfoResponseMessageType;
                if (folderInfoResponseMessageType != null && folderInfoResponseMessageType.ResponseClass == ResponseClassType.Success && folderInfoResponseMessageType.Folders != null && folderInfoResponseMessageType.Folders.Length == 1)
                {
                    localTargetFolderId = folderInfoResponseMessageType.Folders[0].FolderId;
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug(0L, "Folder created successfully");
                    }
                    return(true);
                }
                return(false);
            }, responseErrorProcessor);
            targetFolderId = localTargetFolderId;
            return(localTargetFolderId != null);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Log on to a mailbox with a specified user account and delete all the subfolders from the specified folder.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="folderName">Name of the folder which should be cleaned up.</param>
        /// <param name="destFolderName">The name of the destination folder which will be deleted.</param>
        /// <returns>If the folder is cleaned up successfully, return true; otherwise, return false.</returns>
        public bool CleanupFolder(string userName, string userPassword, string userDomain, string folderName, string destFolderName)
        {
            // Log on mailbox with specified user mailbox.
            this.exchangeServiceBinding.Credentials = new NetworkCredential(userName, userPassword, userDomain);
            #region Delete all sub folders and the items in these sub folders in the specified parent folder.
            // Parse the parent folder name.
            DistinguishedFolderIdNameType parentFolderName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true);

            // Create an array of BaseFolderType.
            BaseFolderType[] folders = null;

            // Create the request and specify the traversal type.
            FindFolderType findFolderRequest = new FindFolderType();
            findFolderRequest.Traversal = FolderQueryTraversalType.Deep;

            // Define the properties to be returned in the response.
            FolderResponseShapeType responseShape = new FolderResponseShapeType();
            responseShape.BaseShape       = DefaultShapeNamesType.Default;
            findFolderRequest.FolderShape = responseShape;

            // Identify which folders to search.
            DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
            folderIDArray[0]    = new DistinguishedFolderIdType();
            folderIDArray[0].Id = parentFolderName;

            // Add the folders to search to the request.
            findFolderRequest.ParentFolderIds = folderIDArray;

            // Invoke FindFolder operation and get the response.
            FindFolderResponseType findFolderResponse = this.exchangeServiceBinding.FindFolder(findFolderRequest);

            // If there are folders found under the specified folder, delete all of them.
            if (findFolderResponse != null && findFolderResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                // Get the folders from the response.
                FindFolderResponseMessageType findFolderResponseMessageType = findFolderResponse.ResponseMessages.Items[0] as FindFolderResponseMessageType;
                Site.Assert.IsNotNull(findFolderResponseMessageType, "The items in FindFolder response should not be null.");

                folders = findFolderResponseMessageType.RootFolder.Folders;
                if (folders.Length != 0)
                {
                    ////Indicates whether the destination folder was found and removed.
                    bool found = false;

                    // Loop to delete all the found folders.
                    foreach (BaseFolderType currentFolder in folders)
                    {
                        if (string.Compare(currentFolder.DisplayName, destFolderName, StringComparison.InvariantCultureIgnoreCase) != 0)
                        {
                            continue;
                        }

                        FolderIdType responseFolderId = currentFolder.FolderId;

                        FolderIdType folderId = new FolderIdType();
                        folderId.Id = responseFolderId.Id;

                        DeleteFolderType deleteFolderRequest = new DeleteFolderType();
                        deleteFolderRequest.DeleteType   = DisposalType.HardDelete;
                        deleteFolderRequest.FolderIds    = new BaseFolderIdType[1];
                        deleteFolderRequest.FolderIds[0] = folderId;

                        // Invoke DeleteFolder operation and get the response.
                        DeleteFolderResponseType deleteFolderResponse = this.exchangeServiceBinding.DeleteFolder(deleteFolderRequest);

                        Site.Assert.AreEqual <ResponseClassType>(
                            ResponseClassType.Success,
                            deleteFolderResponse.ResponseMessages.Items[0].ResponseClass,
                            "The delete folder operation should be successful.");

                        found = true;
                        break;
                    }

                    Site.Assert.IsTrue(
                        found,
                        "The destination folder can not be found in the assigned parent folder.");
                }
            }
            #endregion

            #region Check whether sub folders are deleted successfully.
            // Invoke the FindFolder operation again.
            findFolderResponse = this.exchangeServiceBinding.FindFolder(findFolderRequest);

            Site.Assert.AreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                findFolderResponse.ResponseMessages.Items[0].ResponseCode,
                string.Format(
                    "The delete folder operation should be successful. Expected response code: {0}, actual response code: {1}",
                    ResponseCodeType.NoError,
                    findFolderResponse.ResponseMessages.Items[0].ResponseCode));

            // Get the found folders from the response.
            FindFolderResponseMessageType findFolderResponseMessage = findFolderResponse.ResponseMessages.Items[0] as FindFolderResponseMessageType;
            folders = findFolderResponseMessage.RootFolder.Folders;

            // If no sub folders that created by case could be found, the folder has been cleaned up successfully.
            foreach (BaseFolderType folder in folders)
            {
                if (string.Compare(folder.DisplayName, destFolderName, StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    continue;
                }
                else
                {
                    return(false);
                }
            }

            return(true);

            #endregion
        }
Exemplo n.º 22
0
        public void MSOXWSFOLD_S02_TC01_CopyFolder()
        {
            #region Copy the "drafts" folder to the inbox folder

            // Identify the folders to be copied.
            DistinguishedFolderIdType copiedFolderId = new DistinguishedFolderIdType();
            copiedFolderId.Id = DistinguishedFolderIdNameType.drafts;

            // CopyFolder request.
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), copiedFolderId);

            // Copy the "drafts" folder.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyFolderResponse, 1, this.Site);

            // Variable to save the folder.
            FolderIdType folderId = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the copied folder's folder id.
            this.NewCreatedFolderIds.Add(folderId);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1852
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                copyFolderResponse.ResponseMessages.Items[0].ResponseClass,
                1852,
                @"[In CopyFolder Operation]A successful CopyFolder operation request returns a CopyFolderResponse element with the ResponseClass attribute of the CopyFolderResponseMessage element set to ""Success"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R185222
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                copyFolderResponse.ResponseMessages.Items[0].ResponseCode,
                185222,
                @"[In CopyFolder Operation]A successful CopyFolder operation request returns a CopyFolderResponse element with the ResponseCode element of the CopyFolderResponse element set to ""NoError"".");

            #region Get the new copied folder

            // GetFolder request.
            GetFolderType getSubFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderId);

            // Get the specified folder.
            GetFolderResponseType getSubFolderResponse = this.FOLDAdapter.GetFolder(getSubFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getSubFolderResponse, 1, this.Site);

            #endregion

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

            // The copied folder can be gotten successfully through returned folder id, so the draft folder was copied.
            this.Site.CaptureRequirement(
                211,
                @"[In m:CopyFolderType Complex Type]The CopyFolderType complex type specifies a request message to copy folders in a server database.");
        }
        /// <summary>
        /// Log on to a mailbox with a specified user account and create two different-level subfolders in the specified parent folder.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="parentFolderName">Name of the parent folder.</param>
        /// <param name="firstLevelSubFolderName">Name of the first level sub folder which will be created under the parent folder.</param>
        /// <param name="secondLevelSubFolderName">Name of the second level sub folder which will be created under the first level sub folder.</param>
        /// <returns>If the two level sub folders are created successfully, return true; otherwise, return false.</returns>
        public bool CreateSubFolders(string userName, string userPassword, string userDomain, string parentFolderName, string firstLevelSubFolderName, string secondLevelSubFolderName)
        {
            // Log on mailbox with specified user account(userName, userPassword, userDomain).
            bool isLoged = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);

            Site.Assert.IsTrue(
                isLoged,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Initialize variables
            FolderIdType     folderId                        = null;
            CreateFolderType createFolderRequest             = new CreateFolderType();
            string           folderClassName                 = null;
            DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), parentFolderName, true);

            // Define different folder class name according to different parent folder.
            switch (parentFolderIdName)
            {
            case DistinguishedFolderIdNameType.inbox:
                folderClassName = "IPF.Note";
                break;

            case DistinguishedFolderIdNameType.contacts:
                folderClassName = "IPF.Contact";
                break;

            case DistinguishedFolderIdNameType.calendar:
                folderClassName = "IPF.Appointment";
                break;

            case DistinguishedFolderIdNameType.tasks:
                folderClassName = "IPF.Task";
                break;

            default:
                Site.Assume.Fail(string.Format("The parent folder name '{0}' is invalid. Valid values are: inbox, contacts, calendar or tasks.", parentFolderName));
                break;
            }

            // Set parent folder ID.
            createFolderRequest.ParentFolderId = new TargetFolderIdType();
            DistinguishedFolderIdType parentFolder = new DistinguishedFolderIdType();

            parentFolder.Id = parentFolderIdName;
            createFolderRequest.ParentFolderId.Item = parentFolder;

            // Set Display Name and Folder Class for the folder to be created.
            FolderType folderProperties = new FolderType();

            folderProperties.DisplayName = firstLevelSubFolderName;
            folderProperties.FolderClass = folderClassName;

            createFolderRequest.Folders    = new BaseFolderType[1];
            createFolderRequest.Folders[0] = folderProperties;

            bool isSubFolderCreated = false;

            // Invoke CreateFolder operation and get the response.
            CreateFolderResponseType createFolderResponse = this.exchangeServiceBinding.CreateFolder(createFolderRequest);

            if (createFolderResponse != null && ResponseClassType.Success == createFolderResponse.ResponseMessages.Items[0].ResponseClass)
            {
                // If the first level sub folder is created successfully, save the folder ID of it.
                folderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
                FolderType created = new FolderType()
                {
                    DisplayName = folderProperties.DisplayName, FolderClass = folderClassName, FolderId = folderId
                };
                AdapterHelper.CreatedFolders.Add(created);
            }

            // Create another sub folder under the created folder above.
            if (folderId != null)
            {
                createFolderRequest.ParentFolderId.Item = folderId;
                folderProperties.DisplayName            = secondLevelSubFolderName;

                createFolderResponse = this.exchangeServiceBinding.CreateFolder(createFolderRequest);

                if (createFolderResponse != null && ResponseClassType.Success == createFolderResponse.ResponseMessages.Items[0].ResponseClass)
                {
                    // If the two level sub folders are created successfully, return true; otherwise, return false.
                    isSubFolderCreated = true;
                    folderId           = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
                    FolderType created = new FolderType()
                    {
                        DisplayName = folderProperties.DisplayName, FolderClass = folderClassName, FolderId = folderId
                    };
                    AdapterHelper.CreatedFolders.Add(created);
                }
            }

            return(isSubFolderCreated);
        }
Exemplo n.º 24
0
    static void CreateFolder(ExchangeServiceBinding esb, FolderIdType fiFolderID, String fnFldName)
    {
        // Create the request
        FolderType folder = new FolderType();
        folder.DisplayName = fnFldName;

        TargetFolderIdType targetID = new TargetFolderIdType();
        targetID.Item = fiFolderID;

        CreateFolderType createFolder = new CreateFolderType();
        createFolder.Folders = new FolderType[] { folder };
        createFolder.ParentFolderId = targetID;

        try
        {
            // Send the request and get the response
            CreateFolderResponseType response = esb.CreateFolder(createFolder);

            // Get the response messages
            ResponseMessageType[] rmta = response.ResponseMessages.Items;

        }
        catch (Exception e)
        {
            string problem = e.Message;
        }
    }
Exemplo n.º 25
0
        public void MSOXWSFOLD_S02_TC03_CopyPublicFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(55501, this.Site), "Exchange 2007 and Exchange 2010 support the CopyFolder operation if either the source folder or the destination folder is a public folder");

            #region Create a new public folder in the public folder root

            // CreateFolder request.
            CreateFolderType createPublicFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.publicfoldersroot.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new public folder.
            CreateFolderResponseType createPublicFolderResponse = this.FOLDAdapter.CreateFolder(createPublicFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createPublicFolderResponse, 1, this.Site);

            // Save the new created public folder's folder id.
            FolderIdType newPublicFolderId = ((FolderInfoResponseMessageType)createPublicFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newPublicFolderId);

            #endregion

            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Copy the public folder to the folder created in inbox

            // CopyFolder request.
            CopyFolderType copyPublicFolderRequest = this.GetCopyFolderRequest(newFolderId.Id, newPublicFolderId);

            // Copy the public folder.
            CopyFolderResponseType copyPublicFolderResponse = this.FOLDAdapter.CopyFolder(copyPublicFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyPublicFolderResponse, 1, this.Site);

            // Variable to save the folder.
            FolderIdType copiedPublicFolderId = ((FolderInfoResponseMessageType)copyPublicFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the copied folder's folder id.
            this.NewCreatedFolderIds.Add(copiedPublicFolderId);

            #endregion

            #region Get the new copied public folder that in inbox

            // GetFolder request.
            GetFolderType getNewCopiedPulicFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, copiedPublicFolderId);

            // Get the new copied public folder.
            GetFolderResponseType getNewCopiedPublicFolderResponse = this.FOLDAdapter.GetFolder(getNewCopiedPulicFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getNewCopiedPublicFolderResponse, 1, this.Site);

            #endregion

            #region Copy the folder in inbox to the public folder created

            // CopyFolder request.
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(newPublicFolderId.Id, newFolderId);

            // Copy the public folder.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyFolderResponse, 1, this.Site);

            // Variable to save the folder.
            FolderIdType copiedFolderId = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the copied folder's folder id.
            this.NewCreatedFolderIds.Add(copiedFolderId);

            #endregion

            #region Get the new copied folder that in root public folder

            // GetFolder request.
            GetFolderType getNewCopiedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, copiedFolderId);

            // Get the new copied folder.
            GetFolderResponseType getNewCopiedFolderResponse = this.FOLDAdapter.GetFolder(getNewCopiedFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getNewCopiedFolderResponse, 1, this.Site);

            #endregion

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

            // Folder can be copied successfully either when the source folder or destination folder is public folder ,so this requirement can be captured.
            this.Site.CaptureRequirement(
                55501,
                @"[In Appendix C: Product Behavior] Implementation does support the CopyFolder operation if either the source folder or the destination folder is a public folder.(Exchange Server 2007 and Exchange Server 2010 follow this behavior.)");
        }
Exemplo n.º 26
0
    static FolderIdType FindFolder(ExchangeServiceBinding esb, DistinguishedFolderIdType fiFolderID, String fnFldName)
    {
        FolderIdType rvFolderID = new FolderIdType();

        // Create the request and specify the travesal type
        FindFolderType findFolderRequest = new FindFolderType();
        findFolderRequest.Traversal = FolderQueryTraversalType.Deep;

        // Define the properties returned in the response
        FolderResponseShapeType responseShape = new FolderResponseShapeType();
        responseShape.BaseShape = DefaultShapeNamesType.Default;
        findFolderRequest.FolderShape = responseShape;

        // Identify which folders to search
        DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
        folderIDArray[0] = new DistinguishedFolderIdType();
        folderIDArray[0].Id = fiFolderID.Id;

        //Add Restriction for DisplayName
        RestrictionType ffRestriction = new RestrictionType();
        IsEqualToType ieToType = new IsEqualToType();
        PathToUnindexedFieldType diDisplayName = new PathToUnindexedFieldType();
        diDisplayName.FieldURI = UnindexedFieldURIType.folderDisplayName;
        FieldURIOrConstantType ciConstantType = new FieldURIOrConstantType();
        ConstantValueType cvConstantValueType = new ConstantValueType();
        cvConstantValueType.Value = fnFldName;
        ciConstantType.Item = cvConstantValueType;
        ieToType.Item = diDisplayName;
        ieToType.FieldURIOrConstant = ciConstantType;
        ffRestriction.Item = ieToType;
        findFolderRequest.Restriction = ffRestriction;

        // Add the folders to search to the request
        findFolderRequest.ParentFolderIds = folderIDArray;

        try
        {
            // Send the request and get the response
            FindFolderResponseType findFolderResponse = esb.FindFolder(findFolderRequest);

            // Get the response messages
            ResponseMessageType[] rmta = findFolderResponse.ResponseMessages.Items;

            foreach (ResponseMessageType rmt in rmta)
            {
                // Cast to the correct response message type
                FindFolderResponseMessageType ffResponse = (FindFolderResponseMessageType)rmt;

                foreach (FolderType fFoundFolder in ffResponse.RootFolder.Folders)
                {
                    rvFolderID = fFoundFolder.FolderId;
                }
            }
        }
        catch (Exception e)
        {
            string problem = e.Message;
        }

        return rvFolderID;
    }
Exemplo n.º 27
0
        public void MSOXWSFOLD_S04_TC08_GetExtendedProperty()
        {
            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Set folder class to null.
            createFolderRequest.Folders[0].FolderClass = null;

            // Set folder extended property and its value.
            PathToExtendedFieldType publishInAddressBook = new PathToExtendedFieldType();

            // Set extended property Id and type.
            publishInAddressBook.PropertyTag  = "0x671E";
            publishInAddressBook.PropertyType = MapiPropertyTypeType.Boolean;

            ExtendedPropertyType pubAddressbook = new ExtendedPropertyType();
            pubAddressbook.ExtendedFieldURI = publishInAddressBook;

            // Set extended property value.
            pubAddressbook.Item = "1";

            ExtendedPropertyType[] extendedProperties = new ExtendedPropertyType[1];
            extendedProperties[0] = pubAddressbook;

            createFolderRequest.Folders[0].ExtendedProperty = extendedProperties;

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7801
            // Folder created successfully with extended property this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                7801,
                @"[In t:BaseFolderType Complex Type]This element [ExtendedProperty] is present, server responses NO_ERROR.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R980302
            //  Folder created successfully without permission set so this requirement can be covered.
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                980302,
                @"[In t:FolderType Complex Type]This element [PermissionSet] is not present, server responses NO_ERROR.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R589202
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                589202,
                @"[In t:BaseFolderType Complex Type]This element [FolderClass] is not present, server responses NO_ERROR.");

            #region Get the new created folder

            // GetFolder request.
            GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);
            getNewFolderRequest.FolderShape.AdditionalProperties    = new BasePathToElementType[1];
            getNewFolderRequest.FolderShape.AdditionalProperties[0] = publishInAddressBook;

            // Get the new created folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderResponse, 1, this.Site);

            FolderInfoResponseMessageType allFolders = (FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0];
            FolderType folderInfo = (FolderType)allFolders.Folders[0];

            #endregion

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

            // Folder ids is set in request and response is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                423,
                @"[In m:GetFolderType Complex Type]FolderIds is an array of one or more folder identifiers.");

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

            // Folder id that contains id and change key value is set in request and response is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                426,
                @"[In t:NonEmptyArrayOfBaseFolderIdsType Complex Type]FolderId specifies the folder identifier and change key. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R77
            // Extended property value is returned from server, and schema is verified in adapter so this requirement can be covered.
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ExtendedProperty,
                77,
                @"[In t:BaseFolderType Complex Type]The type of element ExtendedProperty is t:ExtendedPropertyType ([MS-OXWSXPROP] section 2.1.5).");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7701
            // In create operation this property value is set to 1 and type to Boolean this means the value is "true" in string type.
            this.Site.CaptureRequirementIfAreEqual <string>(
                "true",
                ((ExtendedPropertyType)folderInfo.ExtendedProperty.GetValue(0)).Item.ToString(),
                7701,
                @"[In t:BaseFolderType Complex Type]ExtendedProperty specifies the set of extended properties on a folder.");
        }
Exemplo n.º 28
0
        public void MSOXWSFOLD_S05_TC02_EmptyFolderWithoutDeletingSubFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(newFolderId);

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");
            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder.

            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.HardDelete, false);

            // Check the response.
            Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site);

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderResponse, 1, this.Site);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R381.
            Site.CaptureRequirementIfAreNotEqual <ResponseCodeType>(
                ResponseCodeType.ErrorItemNotFound,
                getFolderResponse.ResponseMessages.Items[0].ResponseCode,
                381,
                @"[In m:EmptyFolderType Complex Type][if the subfolders are not to be deleted], it is set to ""false"". ");
        }
Exemplo n.º 29
0
    static void MoveFolder(ExchangeServiceBinding esb, FolderIdType sourceFolderID, FolderIdType destinationFolderID)
    {
        MoveFolderType moveFolder = new MoveFolderType();
        moveFolder.FolderIds = new FolderIdType[] { sourceFolderID };
        TargetFolderIdType targetID = new TargetFolderIdType();
        targetID.Item = destinationFolderID;
        moveFolder.ToFolderId = targetID;

        try
        {
            // Send the request and get the response
            MoveFolderResponseType response = esb.MoveFolder(moveFolder);

            // Get the response messages
            ResponseMessageType[] rmta = response.ResponseMessages.Items;

        }
        catch (Exception e)
        {
            string problem = e.Message;
        }
    }
Exemplo n.º 30
0
        public void MSOXWSFOLD_S05_TC03_EmptyFolderMoveToDeletedItems()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            this.NewCreatedFolderIds.Add(newFolderId);

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");

            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder

            // Specify which folder will be emptied.
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.MoveToDeletedItems, true);

            // Check the response.
            Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site);

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderResponse, 1, this.Site);

            #endregion

            #region Find the item to see whether it has been deleted

            // Verify if item under inbox exists.
            ItemIdType itemIdAfterEmpty     = this.FindItem(DistinguishedFolderIdNameType.deleteditems.ToString(), itemName2);
            bool       isItemInDeletedItems = itemIdAfterEmpty != null;
            this.NewCreatedItemIds.Add(itemIdAfterEmpty);

            #endregion

            #region Get new created folder's parent folder

            GetFolderType getParentFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId);

            // Get the new created folder.
            GetFolderResponseType getParentFolderResponse = this.FOLDAdapter.GetFolder(getParentFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getParentFolderResponse, 1, this.Site);

            string folderDisplayName = ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].DisplayName;

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R37802
            bool isVerifiedR37802 = folderDisplayName.Equals("Deleted Items") && isItemInDeletedItems;

            Site.Assert.IsTrue(
                isVerifiedR37802,
                "Parent folder name after deleted expected to be \"Deleted Items\" and actual is {0};\n" +
                "Item in deleted items expected to be \"true\" and actual is {1};\n ",
                folderDisplayName,
                isItemInDeletedItems);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR37802,
                37802,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is MoveToDeletedItems specifies that an item or folder is moved to the Deleted Items folder.");
        }
Exemplo n.º 31
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;
        }
Exemplo n.º 32
0
        public void MSOXWSFOLD_S03_TC01_FolderPropertiesAfterMoved()
        {
            #region Create two nested folders with an item in the high-level one into the "drafts" folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), new string[] { "ForMoveFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Create a message into this folder
            string     itemName = Common.GenerateResourceName(this.Site, "Test Mail");
            ItemIdType itemId   = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName);
            this.NewCreatedItemIds.Add(itemId);

            // Create sub folder request.
            CreateFolderType createSubFolderRequest = this.GetCreateFolderRequest(newFolderId.Id, new string[] { "SubFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createNewFolderResponse = this.FOLDAdapter.CreateFolder(createSubFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createNewFolderResponse, 1, this.Site);

            FolderIdType subFolderId = ((FolderInfoResponseMessageType)createNewFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(subFolderId);

            #endregion

            #region Move the new created folder to the inbox folder

            // MoveFolder request.
            MoveFolderType moveFolderRequest = new MoveFolderType();

            // Set the request's folderId field.
            moveFolderRequest.FolderIds    = new BaseFolderIdType[1];
            moveFolderRequest.FolderIds[0] = newFolderId;

            // Set the request's destFolderId field.
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.inbox;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folder.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(moveFolderResponse, 1, this.Site);

            FolderIdType movedFolderId = ((FolderInfoResponseMessageType)moveFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(movedFolderId);
            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R4314
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                moveFolderResponse.ResponseMessages.Items[0].ResponseCode,
                4314,
                @"[In MoveFolder Operation]A successful MoveFolder operation request returns a MoveFolderResponse element with the ResponseCode element of the MoveFolderResponse element set to ""NoError"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R43144
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                moveFolderResponse.ResponseMessages.Items[0].ResponseClass,
                43144,
                @"[In MoveFolder Operation]A successful MoveFolder operation request returns a MoveFolderResponse element with the ResponseClass attribute of the MoveFolderResponseMessage element set to ""Success"".");

            #region Get the inbox folder's folder id

            DistinguishedFolderIdType folder = new DistinguishedFolderIdType();
            folder.Id = DistinguishedFolderIdNameType.inbox;

            // GetFolder request.
            GetFolderType getInboxFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folder);

            // Get the Inbox folder.
            GetFolderResponseType getInboxFolderResponse = this.FOLDAdapter.GetFolder(getInboxFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getInboxFolderResponse, 1, this.Site);

            // Variable to save folder.
            FolderInfoResponseMessageType inboxFolder = (FolderInfoResponseMessageType)getInboxFolderResponse.ResponseMessages.Items[0];
            BaseFolderType inboxFolderInfo            = (BaseFolderType)inboxFolder.Folders[0];

            // Save the inbox's folder id.
            FolderIdType inboxFolderId = inboxFolderInfo.FolderId;

            #endregion

            #region Get the new created folder after moved to inbox folder

            // GetFolder request.
            GetFolderType getSubFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, movedFolderId);

            // Get the specified folder.
            GetFolderResponseType getSubFolderResponse = this.FOLDAdapter.GetFolder(getSubFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getSubFolderResponse, 1, this.Site);

            FolderInfoResponseMessageType allFolders = (FolderInfoResponseMessageType)getSubFolderResponse.ResponseMessages.Items[0];
            BaseFolderType folderInfo = (BaseFolderType)allFolders.Folders[0];

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R595
            // Since one message in the folder before move, if TotalCount for the folder is 1 after move, this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                folderInfo.TotalCount,
                595,
                @"[In MoveFolder Operation]The contents of the folder move with the folder.");

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

            // The moved folder can be gotten successfully, so the specified folder was moved.
            this.Site.CaptureRequirement(
                461,
                @"[In m:MoveFolderType Complex Type]The MoveFolderType complex type specifies a request message to move folders in a mailbox.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R429
            this.Site.CaptureRequirementIfAreEqual <string>(
                inboxFolderId.Id,
                folderInfo.ParentFolderId.Id,
                429,
                @"[In MoveFolder Operation]The MoveFolder operation moves folders from a specified parent folder and puts them in another parent folder.");

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

            // Verify MS-OXWSFOLD_R594.
            // Verify if the values of FolderClass and DisplayName property are changed after the folder being moved.
            bool isVerifyR594 = folderInfo.FolderClass == "IPF.MyCustomFolderClass" &&
                                folderInfo.DisplayName == createFolderRequest.Folders[0].DisplayName;

            Site.Log.Add(
                LogEntryKind.Debug,
                "FolderClass expected to be \"IPF.MyCustomFolderClass\" and actual is {0};\n" +
                "DisplayName expected to be {1} and actual is {2};\n ",
                folderInfo.FolderClass,
                createFolderRequest.Folders[0].DisplayName,
                folderInfo.DisplayName);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR594,
                594,
                @"[In MoveFolder Operation]The properties FolderClass and DisplayName of the folder move with the folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7501
            // Only one child folder was created in the folder.
            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                folderInfo.ChildFolderCount,
                7501,
                @"[In t:BaseFolderType Complex Type]ChildFolderCount specifies the total number of child folders in a folder.");

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

            // Child folder count is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                5912,
                @"[In t:BaseFolderType Complex Type]This property[ChildFolderCount] is returned in a response.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R75
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ChildFolderCount,
                75,
                @"[In t:BaseFolderType Complex Type]The type of element ChildFolderCount is xs:int.");

            #region Get subfolder in the moved folder

            // GetFolder request.
            GetFolderType getSubFolderAfterMovedRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, subFolderId);

            // Get the specified folder.
            GetFolderResponseType getFolderAfterMovedResponse = this.FOLDAdapter.GetFolder(getSubFolderAfterMovedRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderAfterMovedResponse, 1, this.Site);

            allFolders = (FolderInfoResponseMessageType)getFolderAfterMovedResponse.ResponseMessages.Items[0];
            folderInfo = (BaseFolderType)allFolders.Folders[0];

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R596
            this.Site.CaptureRequirementIfAreEqual <string>(
                movedFolderId.ToString(),
                folderInfo.ParentFolderId.ToString(),
                596,
                @"[In MoveFolder Operation]The subfolders of the folder move with the folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R68
            // Parent folder id is returned from server, and schema is verified in adapter so this requirement can be covered.
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ParentFolderId,
                68,
                @"[In t:BaseFolderType Complex Type]The type of element ParentFolderId is t:FolderIdType.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R6801
            this.Site.CaptureRequirementIfAreEqual <string>(
                NewCreatedFolderIds[0].ToString(),
                folderInfo.ParentFolderId.ToString(),
                6801,
                @"[In t:BaseFolderType Complex Type]ParentFolderId specifies the folder identifier and change key for the parent folder.");
        }
Exemplo n.º 33
0
        public void MSOXWSFOLD_S05_TC01_EmptyFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");

            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder

            // Specify which folder will be emptied.
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.HardDelete, true);

            // Check the response.
            Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R3474
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                emptyFolderResponse.ResponseMessages.Items[0].ResponseClass,
                3474,
                @"[In EmptyFolder Operation]A successful EmptyFolder operation request returns an EmptyFolderResponse element with the ResponseClass attribute of the EmptyFolderResponseMessage element set to ""Success"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R34744
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                emptyFolderResponse.ResponseMessages.Items[0].ResponseCode,
                34744,
                @"[In EmptyFolder Operation]A successful EmptyFolder operation request returns an EmptyFolderResponse element with the ResponseCode element of the EmptyFolderResponse element set to ""NoError"".");

            #region Find the item in inbox to see whether it has been deleted

            // Verify if item under inbox exists.
            bool isInboxItemDeleted = this.IfItemDeleted(DistinguishedFolderIdNameType.inbox.ToString(), itemName2);

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);
            Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Error, getFolderResponse.ResponseMessages.Items[0].ResponseClass, "Folder information should not be returned! ");

            // Variable to indicate whether the folder in inbox folder is deleted.
            bool isFolderDeleted = getFolderResponse.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.ErrorItemNotFound;
            bool isItemDeleted   = isInboxItemDeleted && this.IfItemDeleted(DistinguishedFolderIdNameType.inbox.ToString(), itemName1);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R367.
            bool isVerifyR367 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifyR367,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR367,
                367,
                @"[In Elements]EmptyFolder specifies a request to empty folders in a mailbox in the server store.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R571.
            bool isVerifyR571 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifyR571,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR571,
                571,
                @"[In m:EmptyFolderType Complex Type]The EmptyFolderType complex type specifies a request message to empty a folder in a mailbox.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R380.
            // DeleteSubFolders has been set as true, if the subfolder is deleted, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isFolderDeleted,
                380,
                @"[In m:EmptyFolderType Complex Type]The DeleteSubFolders attribute is set to ""true"" if the subfolders are to be deleted.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R5664
            bool isVerifiedR5664 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifiedR5664,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR5664,
                5664,
                @"[In Appendix C: Product Behavior] Implementation does include the EmptyFolder operation.(Exchange Server 2010 SP2 and above follow this behavior.)");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R37801
            bool isVerifiedR37801 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifiedR37801,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR37801,
                37801,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is HardDelete specifies that an item or folder is permanently removed from the store.");
        }
Exemplo n.º 34
0
        public void MSOXWSFOLD_S05_TC05_SoftEmptyFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");
            Site.Assume.IsTrue(Common.IsRequirementEnabled(4000, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not include enumeration value recoverableitemsdeletions");

            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 1, this.Site);

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Create an item

            string itemName = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            #endregion

            #region Get the new created folder

            // GetFolder request.
            GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the new created folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderResponse, 1, this.Site);

            #endregion

            #region Empty the created folder

            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(newFolderId, DisposalType.SoftDelete, true);
            Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site);

            #endregion

            #region Find the item
            ItemIdType findItemID = this.FindItem(DistinguishedFolderIdNameType.recoverableitemsdeletions.ToString(), itemName);

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

            this.Site.CaptureRequirementIfIsNotNull(
                findItemID,
                37803,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is SoftDelete specifies that an item or folder is moved to the dumpster if the dumpster is enabled.");

            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = new BaseItemIdType[] { findItemID };
            DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            #endregion
        }