예제 #1
0
		/// <remarks/>
		public void FindItemAsync(FindItemType FindItem1, object userState)
		{
			if ((FindItemOperationCompleted == null))
			{
				FindItemOperationCompleted = new SendOrPostCallback(OnFindItemOperationCompleted);
			}
			InvokeAsync("FindItem", new object[]
			                        	{
			                        		FindItem1
			                        	}, FindItemOperationCompleted, userState);
		}
예제 #2
0
		/// <remarks/>
		public IAsyncResult BeginFindItem(FindItemType FindItem1, AsyncCallback callback, object asyncState)
		{
			return BeginInvoke("FindItem", new object[]
			                               	{
			                               		FindItem1
			                               	}, callback, asyncState);
		}
예제 #3
0
		/// <remarks/>
		public void FindItemAsync(FindItemType FindItem1)
		{
			FindItemAsync(FindItem1, null);
		}
        /// <summary>
        /// Finds all Calendar Items for the current User's Mailbox.
        /// </summary>
        /// <returns></returns>
        //protected internal CalendarItemType[] FindCalendarItems()
        //{
        //    // Identify which folders to search.
        //    DistinguishedFolderIdType[] parentFolderIds = new DistinguishedFolderIdType[1];

        //    parentFolderIds[0] = new DistinguishedFolderIdType();
        //    parentFolderIds[0].Id = DistinguishedFolderIdNameType.calendar;

        //    return FindCalendarItems(parentFolderIds);
        //}

		protected internal CalendarItemType[] FindCalendarItems(DistinguishedFolderIdType[] parentFolderIds)
		{
			// Form the FindItem request.
			FindItemType findItemRequest = new FindItemType();

			// Define the item properties that are returned in the response.
			ItemResponseShapeType itemProperties = new ItemResponseShapeType();
			itemProperties.BaseShape = DefaultShapeNamesType.IdOnly;
			
			PathToUnindexedFieldType calendarIsRecurringFieldPath = new PathToUnindexedFieldType();
			calendarIsRecurringFieldPath.FieldURI = UnindexedFieldURIType.calendarIsRecurring;
			
			PathToUnindexedFieldType calendarItemTypeFieldPath = new PathToUnindexedFieldType();
			calendarIsRecurringFieldPath.FieldURI = UnindexedFieldURIType.calendarCalendarItemType;

			PathToUnindexedFieldType calendarStartFieldPath = new PathToUnindexedFieldType();
			calendarStartFieldPath.FieldURI = UnindexedFieldURIType.calendarStart;

			PathToUnindexedFieldType calendarEndFieldPath = new PathToUnindexedFieldType();
			calendarEndFieldPath.FieldURI = UnindexedFieldURIType.calendarEnd;

            //location
            //PathToUnindexedFieldType calendarLocation = new PathToUnindexedFieldType();
            //calendarLocation.FieldURI = UnindexedFieldURIType.calendarLocation;
            //// body
            //PathToUnindexedFieldType itemBody = new PathToUnindexedFieldType();
            //itemBody.FieldURI = UnindexedFieldURIType.itemBody;

			itemProperties.AdditionalProperties = new PathToUnindexedFieldType[]
			                                      	{
			                                      		calendarIsRecurringFieldPath, 
			                                      		calendarItemTypeFieldPath,
			                                      		calendarStartFieldPath,
			                                      		calendarEndFieldPath
			                                      	};
			findItemRequest.ItemShape = itemProperties;

			findItemRequest.ParentFolderIds = parentFolderIds;

			// Define the sort order of items.
			FieldOrderType[] fieldsOrder = new FieldOrderType[1];
			fieldsOrder[0] = new FieldOrderType();
			PathToUnindexedFieldType subjectOrder = new PathToUnindexedFieldType();
			subjectOrder.FieldURI = UnindexedFieldURIType.calendarStart;
			fieldsOrder[0].Item = subjectOrder;
			fieldsOrder[0].Order = SortDirectionType.Ascending;
			findItemRequest.SortOrder = fieldsOrder;

			// Define the traversal type.
			findItemRequest.Traversal = ItemQueryTraversalType.Shallow;

			// Send the FindItem request and get the response.
			FindItemResponseType findItemResponse = Service.FindItem(findItemRequest);

			// Access the response message.
			ArrayOfResponseMessagesType responseMessages = findItemResponse.ResponseMessages;
			ResponseMessageType responseMessage = responseMessages.Items[0];

			if (responseMessage is FindItemResponseMessageType)
			{
				FindItemResponseMessageType firmt = (responseMessage as FindItemResponseMessageType);
				FindItemParentType fipt = firmt.RootFolder;
				object obj = fipt.Item;

				if (obj is ArrayOfRealItemsType)
				{
					ArrayOfRealItemsType items = (obj as ArrayOfRealItemsType);

					if (items.Items != null)
					{
						List<CalendarItemType> calendarItems = new List<CalendarItemType>(items.Items.Length);
						foreach (ItemType item in items.Items)
						{
							CalendarItemType calendarItem = item as CalendarItemType;

							if (calendarItem != null)
							{
								calendarItems.Add(calendarItem);
							}
						}

						return calendarItems.ToArray();
					}

					return new CalendarItemType[0];
				}
			}

			return null;
		}