Inheritance: BaseRequestType
コード例 #1
0
 /// <remarks/>
 public void FindItemAsync(FindItemType FindItem1)
 {
     this.FindItemAsync(FindItem1, null);
 }
コード例 #2
0
 /// <remarks/>
 public void FindItemAsync(FindItemType FindItem1, object userState)
 {
     if ((this.FindItemOperationCompleted == null))
     {
         this.FindItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFindItemOperationCompleted);
     }
     this.InvokeAsync("FindItem", new object[] {
             FindItem1}, this.FindItemOperationCompleted, userState);
 }
コード例 #3
0
 /// <summary>
 /// Find item on the server.
 /// </summary>
 /// <param name="findItemRequest">Find item operation request type.</param>
 /// <returns>Find item operation response type.</returns>
 public FindItemResponseType FindItem(FindItemType findItemRequest)
 {
     FindItemResponseType findItemResponse = this.exchangeServiceBinding.FindItem(findItemRequest);
     return findItemResponse;
 }
コード例 #4
0
 /// <remarks/>
 public System.IAsyncResult BeginFindItem(FindItemType FindItem1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("FindItem", new object[] {
             FindItem1}, callback, asyncState);
 }
コード例 #5
0
        /// <summary>
        /// The method searches the mailbox and returns the items that meet a specified search restriction.
        /// </summary>
        /// <param name="folder">A string that specifies the folder to search.</param>
        /// <param name="value">A string that specifies the value for a search restriction.</param>
        /// <returns>If the method succeeds, return an array of item; otherwise, return null.</returns>
        private ItemIdType[] GetItemIds(string folder, string value)
        {
            #region Construct FindItem request
            FindItemType findRequest = new FindItemType();

            if (string.IsNullOrEmpty(folder) || string.IsNullOrEmpty(value))
            {
                Site.Assert.Fail("Invalid argument: one or more invalid arguments passed to GetItemIds method.");
            }

            findRequest.ItemShape = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType folderIdName;
            if (Enum.TryParse<DistinguishedFolderIdNameType>(folder, out folderIdName))
            {
                folderId.Id = folderIdName;
            }
            else
            {
                Site.Assert.Fail("The value of the first argument (foldIdNameType) of FindItem operation is invalid.");
            }

            findRequest.ParentFolderIds = new BaseFolderIdType[1];
            findRequest.ParentFolderIds[0] = folderId;

            PathToUnindexedFieldType itemClass = new PathToUnindexedFieldType();
            itemClass.FieldURI = UnindexedFieldURIType.itemSubject;
            ContainsExpressionType expressionType = new ContainsExpressionType();
            expressionType.Item = itemClass;
            expressionType.ContainmentMode = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified = true;
            expressionType.ContainmentComparison = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant = new ConstantValueType();
            expressionType.Constant.Value = value;

            RestrictionType restriction = new RestrictionType();
            restriction.Item = expressionType;

            findRequest.Restriction = restriction;
            #endregion

            #region Get the ids of all ItemId instances
            int counter = 0;
            int upperBound = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            FindItemResponseType findResponse = new FindItemResponseType();

            while (counter < upperBound)
            {
                Thread.Sleep(waitTime);

                findResponse = this.exchangeServiceBinding.FindItem(findRequest);
                if (findResponse != null
                    && findResponse.ResponseMessages != null
                    && findResponse.ResponseMessages.Items != null
                    && findResponse.ResponseMessages.Items.Length > 0)
                {
                    ArrayOfRealItemsType items = ((FindItemResponseMessageType)findResponse.ResponseMessages.Items[0]).RootFolder.Item as ArrayOfRealItemsType;

                    if (items.Items != null && items.Items.Length > 0)
                    {
                        List<ItemIdType> itemIds = new List<ItemIdType>();
                        foreach (ItemType item in items.Items)
                        {
                            if (item.ItemId != null)
                            {
                                itemIds.Add(item.ItemId);
                            }
                        }

                        if (itemIds.Count > 0)
                        {
                            return itemIds.ToArray();
                        }
                    }
                }

                counter++;
            }

            Site.Log.Add(LogEntryKind.Debug, "When there is not any message found by FindItem operation, the retry count is {0}", counter);
            return null;
            #endregion
        }
コード例 #6
0
        /// <summary>
        /// Find if item within a specific folder is deleted.
        /// </summary>
        /// <param name="folderName">The name of the folder to search item.</param>
        /// <param name="itemSubject">The subject of the item to be searched.</param>
        /// <returns>If item has been deleted.</returns>
        protected bool IfItemDeleted(string folderName, string itemSubject)
        {
            // Create the request and specify the parent folder ID.
            FindItemType findItemRequest = new FindItemType();
            findItemRequest.ParentFolderIds = new BaseFolderIdType[1];

            DistinguishedFolderIdType parentFolder = new DistinguishedFolderIdType();
            parentFolder.Id = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true);

            findItemRequest.ParentFolderIds[0] = parentFolder;

            // Get properties that are defined as the default for the items.
            findItemRequest.ItemShape = new ItemResponseShapeType();
            findItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            // Await the item created properly.
            int sleepTime = Convert.ToInt32(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = Convert.ToInt32(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int timesOfSleep = 0;
            bool itemDeleted = true;
            do
            {
                itemDeleted = true;
                Thread.Sleep(sleepTime);

                // Invoke the FindItem operation.
                FindItemResponseType findItemResponse = this.SRCHAdapter.FindItem(findItemRequest);

                if (findItemResponse != null)
                {
                    // Get the found items from the response.
                    FindItemResponseMessageType findItemMessage = findItemResponse.ResponseMessages.Items[0] as FindItemResponseMessageType;
                    ArrayOfRealItemsType itemArray = findItemMessage.RootFolder.Item as ArrayOfRealItemsType;
                    ItemType[] items = itemArray.Items;
                    if (items != null)
                    {
                        foreach (ItemType item in items)
                        {
                            if (item.Subject == itemSubject)
                            {
                                itemDeleted = false;
                                break;
                            }
                        }
                    }

                    timesOfSleep++;
                }
            }
            while (!itemDeleted && timesOfSleep <= retryCount);

            return itemDeleted;
        }
コード例 #7
0
        /// <summary>
        /// The operation construct a request for FindItem operation.
        /// </summary>
        /// <param name="folderName">A string that specifies the folder to search.</param>
        /// <param name="value">A string that specifies the value for a search restriction.</param>
        /// <param name="field">A string that specifies the type of referenced field URI.</param>
        /// <returns>The request of FindItem operation which constructed with special folder name, search restriction and referenced field URI</returns>
        protected FindItemType ConstructFindItemRequest(string folderName, string value, string field)
        {
            FindItemType findRequest = new FindItemType();
            findRequest.ItemShape = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType folderIdName;
            if (Enum.TryParse<DistinguishedFolderIdNameType>(folderName, out folderIdName))
            {
                folderId.Id = folderIdName;
            }
            else
            {
                Site.Assert.Fail("The value of the first argument (foldIdNameType) of FindItem operation is invalid.");
            }

            findRequest.ParentFolderIds = new BaseFolderIdType[1];
            findRequest.ParentFolderIds[0] = folderId;

            PathToUnindexedFieldType itemClass = new PathToUnindexedFieldType();
            UnindexedFieldURIType fieldURI;
            if (Enum.TryParse<UnindexedFieldURIType>(field, out fieldURI))
            {
                // set search field.
                itemClass.FieldURI = fieldURI;
            }
            else
            {
                Site.Assert.Fail("The value of the second argument (fieldURIType) of FindItem operation is invalid.");
            }

            ContainsExpressionType expressionType = new ContainsExpressionType();
            expressionType.Item = itemClass;
            expressionType.ContainmentMode = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified = true;
            expressionType.ContainmentComparison = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant = new ConstantValueType();
            expressionType.Constant.Value = value;

            RestrictionType restriction = new RestrictionType();
            restriction.Item = expressionType;

            if (!string.IsNullOrEmpty(value))
            {
                findRequest.Restriction = restriction;
            }

            return findRequest;
        }
コード例 #8
0
        /// <summary>
        /// Find all the items in the specified folder.
        /// </summary>
        /// <param name="folderName">Name of the specified folder.</param>
        /// <returns>An array of found items.</returns>
        private ItemType[] FindAllItems(DistinguishedFolderIdNameType folderName)
        {
            // Create an array of ItemType.
            ItemType[] items = null;

            // Create an instance of FindItemType.
            FindItemType findItemRequest = new FindItemType();
            findItemRequest.ParentFolderIds = new BaseFolderIdType[1];

            DistinguishedFolderIdType parentFolder = new DistinguishedFolderIdType();
            parentFolder.Id = folderName;
            findItemRequest.ParentFolderIds[0] = parentFolder;

            // Get properties that are defined as the default for the items.
            findItemRequest.ItemShape = new ItemResponseShapeType();
            findItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.Default;

            // Invoke the FindItem operation.
            FindItemResponseType findItemResponse = this.exchangeServiceBinding.FindItem(findItemRequest);

            if (findItemResponse != null && findItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                // Get the found items from the response.
                FindItemResponseMessageType findItemMessage = findItemResponse.ResponseMessages.Items[0] as FindItemResponseMessageType;
                ArrayOfRealItemsType findItems = findItemMessage.RootFolder.Item as ArrayOfRealItemsType;
                items = findItems.Items;
            }

            return items;
        }
コード例 #9
0
        public void MSOXWSCORE_S01_TC24_CreateItemAssociatedWithFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2285, this.Site), "Exchange 2007 does not support the IsAssociated element.");

            #region Create an user configuration object.
            // User configuration objects are items that are associated with folders in a mailbox.
            string userConfiguratioName = Common.GenerateResourceName(this.Site, "UserConfigurationSampleName").Replace("_", string.Empty);
            bool isSuccess = this.USRCFGSUTControlAdapter.CreateUserConfiguration(
                Common.GetConfigurationPropertyValue("User1Name", this.Site),
                Common.GetConfigurationPropertyValue("User1Password", this.Site),
                Common.GetConfigurationPropertyValue("Domain", this.Site),
                userConfiguratioName);
            Site.Assert.IsTrue(isSuccess, "The user configuration object should be created successfully.");
            #endregion

            #region Find the created user configuration object
            FindItemType findRequest = new FindItemType();
            findRequest.ItemShape = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
            findRequest.ParentFolderIds = new BaseFolderIdType[1]
            {
                new DistinguishedFolderIdType() { Id = DistinguishedFolderIdNameType.inbox }
            };
            PathToUnindexedFieldType itemSubject = new PathToUnindexedFieldType();
            itemSubject.FieldURI = UnindexedFieldURIType.itemItemClass;
            ContainsExpressionType expressionType = new ContainsExpressionType();
            expressionType.Item = itemSubject;
            expressionType.ContainmentMode = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified = true;
            expressionType.ContainmentComparison = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant = new ConstantValueType();
            expressionType.Constant.Value = "IPM.Configuration";

            RestrictionType restriction = new RestrictionType();
            restriction.Item = expressionType;
            findRequest.Restriction = restriction;
            findRequest.Traversal = ItemQueryTraversalType.Associated;

            FindItemResponseType findResponse = this.SRCHAdapter.FindItem(findRequest);
            ItemType[] foundItems = (((FindItemResponseMessageType)findResponse.ResponseMessages.Items[0]).RootFolder.Item as ArrayOfRealItemsType).Items;
            ItemType item = null;
            foreach (ItemType foundItem in foundItems)
            {
                if (foundItem.ItemClass.Contains(userConfiguratioName))
                {
                    item = foundItem;
                    break;
                }
            }

            Site.Assert.IsNotNull(item, "The created user configuration object should be found!");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1618
            this.Site.CaptureRequirementIfIsTrue(
                item.IsAssociatedSpecified && item.IsAssociated,
                1618,
                @"[In t:ItemType Complex Type] [IsAssociated is] True, indicates the item is associated with a folder.");
            #endregion
        }