// Token: 0x0600057D RID: 1405 RVA: 0x0002A0C0 File Offset: 0x000282C0 public BaseFolderType CreateFolder(BaseFolderIdType parentFolderId, BaseFolderType newFolder) { CreateFolderType createFolder = new CreateFolderType(); createFolder.Folders = new BaseFolderType[] { newFolder }; createFolder.ParentFolderId = new TargetFolderIdType { Item = parentFolderId }; List <BaseFolderType> newFolders = new List <BaseFolderType>(1); this.CallService(() => this.ServiceBinding.CreateFolder(createFolder), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass != ResponseClassType.Error) { FolderInfoResponseMessageType folderInfoResponseMessageType = (FolderInfoResponseMessageType)responseMessage; newFolders.AddRange(folderInfoResponseMessageType.Folders); return(true); } if (responseMessage.ResponseCode == ResponseCodeType.ErrorFolderExists) { throw new ElcEwsException(ElcEwsErrorType.FailedToCreateExistingFolder, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText); } throw new ElcEwsException(ElcEwsErrorType.FailedToCreateFolder, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToCreateFolder, exception)); if (newFolders.Count <= 0) { return(null); } return(newFolders[0]); }
public BaseFolderType CreateFolder(BaseFolderIdType parentFolderId, string newFolderName, bool isHidden) { FolderType folderType = new FolderType { DisplayName = newFolderName }; if (isHidden) { folderType.ExtendedProperty = new ExtendedPropertyType[] { MailboxItemIdList.IsHiddenExtendedProperty }; } List <BaseFolderType> list = this.ewsClient.CreateFolder(this.PrimarySmtpAddress, parentFolderId, new BaseFolderType[] { folderType }); if (list == null || list.Count <= 0) { return(null); } return(list[0]); }
public PXSyncDirectFolder(string mailbox, BaseFolderIdType folder, PXEmailSyncDirection.Directions direction, bool categorized, PXSyncMovingCondition[] moveTo) : base(mailbox, folder) { Direction = direction; Categorized = categorized; MoveToFolder = moveTo; }
// Token: 0x0600057E RID: 1406 RVA: 0x0002A21C File Offset: 0x0002841C public BaseFolderType GetFolderByName(BaseFolderIdType parentFolderId, string folderDisplayName, BasePathToElementType[] additionalProperties) { FindFolderType findFolder = new FindFolderType(); FolderResponseShapeType folderResponseShapeType = new FolderResponseShapeType(); folderResponseShapeType.BaseShape = DefaultShapeNamesType.IdOnly; folderResponseShapeType.AdditionalProperties = additionalProperties; findFolder.FolderShape = folderResponseShapeType; findFolder.Restriction = new RestrictionType { Item = new IsEqualToType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.folderDisplayName }, FieldURIOrConstant = new FieldURIOrConstantType { Item = new ConstantValueType { Value = folderDisplayName } } } }; findFolder.ParentFolderIds = new BaseFolderIdType[] { parentFolderId }; List <BaseFolderType> folders = new List <BaseFolderType>(1); this.CallService(() => this.ServiceBinding.FindFolder(findFolder), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Error) { if (responseMessage.ResponseCode != ResponseCodeType.ErrorItemNotFound) { folders.Clear(); throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToGetFolderByName, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText), false); } } else { FindFolderResponseMessageType findFolderResponseMessageType = (FindFolderResponseMessageType)responseMessage; folders.AddRange(findFolderResponseMessageType.RootFolder.Folders); } return(true); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToGetFolderByName, exception)); if (folders.Count <= 0) { return(null); } return(folders[0]); }
private static CreateItemType GetCreateItemType(IAuditLogRecord auditRecord, BaseFolderIdType targetFolderId, out int recordSize) { string asString = AuditLogParseSerialize.GetAsString(auditRecord); string text = string.Format("{0} : {1}", auditRecord.UserId, auditRecord.Operation); string text2 = string.Format("{0}{1}", auditRecord.UserId, "audit"); string text3 = string.Format("{0}{1}", auditRecord.ObjectId, "audit"); recordSize = Encoding.Unicode.GetByteCount(text) + Encoding.Unicode.GetByteCount(asString) + Encoding.Unicode.GetByteCount(text2) + Encoding.Unicode.GetByteCount(text3); return(new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = targetFolderId }, Items = new NonEmptyArrayOfAllItemsType { Items = new ItemType[] { new MessageType { ItemClass = "IPM.AuditLog", Subject = text, Body = new BodyType { Value = asString, BodyType1 = BodyTypeType.Text }, From = new SingleRecipientType { Item = new EmailAddressType { Name = text2 } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { Name = text3 } } } } } }); }
public ItemType[] FindItems(BaseFolderIdType parentFolderId, ItemResponseShapeType itemShape, FieldOrderType[] sortOrder, RestrictionType restriction) { FindItemType findItemType = new FindItemType { ItemShape = EwsAuditClient.IdOnlyItemShape, ParentFolderIds = new BaseFolderIdType[] { parentFolderId }, Traversal = ItemQueryTraversalType.Shallow, Restriction = restriction, SortOrder = sortOrder }; return(this.InternalFindItems(findItemType, itemShape)); }
public ItemType[] FindItemsWithFAST(BaseFolderIdType parentFolderId, ItemResponseShapeType itemShape, FieldOrderType[] sortOrder, QueryStringType queryString) { FindItemType findItemType = new FindItemType { ItemShape = EwsAuditClient.IdOnlyItemShape, ParentFolderIds = new BaseFolderIdType[] { parentFolderId }, Traversal = ItemQueryTraversalType.Shallow, QueryString = queryString, SortOrder = sortOrder }; return(this.InternalFindItems(findItemType, itemShape)); }
// Token: 0x0600057C RID: 1404 RVA: 0x00029EF4 File Offset: 0x000280F4 public IEnumerable <BaseFolderType> GetFolderHierarchy(BaseFolderIdType parentFolderId, bool isDeepTraversal, BasePathToElementType[] additionalProperties) { List <BaseFolderType> folderList = new List <BaseFolderType>(); FindFolderType findFolder = new FindFolderType(); FolderResponseShapeType folderResponseShapeType = new FolderResponseShapeType(); folderResponseShapeType.BaseShape = DefaultShapeNamesType.IdOnly; folderResponseShapeType.AdditionalProperties = additionalProperties; findFolder.FolderShape = folderResponseShapeType; findFolder.ParentFolderIds = new BaseFolderIdType[] { parentFolderId }; findFolder.Traversal = (isDeepTraversal ? FolderQueryTraversalType.Deep : FolderQueryTraversalType.Shallow); bool morePage = true; int offset = 0; while (morePage) { findFolder.Item = new IndexedPageViewType { BasePoint = IndexBasePointType.Beginning, Offset = offset }; this.CallService(() => this.ServiceBinding.FindFolder(findFolder), delegate(ResponseMessageType responseMessage, int messageIndex) { FindFolderResponseMessageType findFolderResponseMessageType = (FindFolderResponseMessageType)responseMessage; if (responseMessage.ResponseClass == ResponseClassType.Error) { throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToGetFolderHierarchy, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText), false); } folderList.AddRange(findFolderResponseMessageType.RootFolder.Folders); if (findFolderResponseMessageType.RootFolder.IncludesLastItemInRange || !findFolderResponseMessageType.RootFolder.IncludesLastItemInRangeSpecified) { morePage = false; } else { offset = findFolderResponseMessageType.RootFolder.IndexedPagingOffset; } return(false); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToGetFolderHierarchy, exception)); } return(folderList); }
/// <summary> /// Overloaded constructor which helps in the creation of the Subscribe /// request for a Pull Subscription /// </summary> /// <param name="subscriptionFolders">The Distinguished folders /// you wish to subscribe to</param> /// <param name="eventTypes">The events to subscribe for</param> /// <param name="watermark">Watermark for recreating a previous /// Subscription</param> /// <param name="timeout">Timeout for Subscription in minutes</param> /// public PullSubscriptionRequestType( BaseFolderIdType[] subscriptionFolders, NotificationEventTypeType[] eventTypes, string watermark, int timeout) { this.FolderIds = subscriptionFolders; this.EventTypes = eventTypes; // If we have a Watermark then set it on the Subscribe request // if (!string.IsNullOrEmpty(watermark)) { this.Watermark = watermark; } this.Timeout = timeout; }
/// Overloaded constructor which helps in the creation of the Subscribe /// request for a Push Subscription /// </summary> /// <param name="subscriptionFolders">The folders you wish to subscribe to</param> /// <param name="eventTypes">The events to subscribe for</param> /// <param name="statusFrequency">Frequency in minutes of server ping</param> /// <param name="url">URL for client Notifications web service</param> /// <param name="watermark">Watermark for recreating a previous Subscription</param> /// public PushSubscriptionRequestType( BaseFolderIdType[] subscriptionFolders, NotificationEventTypeType[] eventTypes, int statusFrequency, string url, string watermark) { this.FolderIds = subscriptionFolders; this.EventTypes = eventTypes; this.StatusFrequency = statusFrequency; this.URL = url; // If we have a Watermark then set it on the Subscribe request // if (!string.IsNullOrEmpty(watermark)) { this.Watermark = watermark; } }
// Token: 0x0600057A RID: 1402 RVA: 0x00029C40 File Offset: 0x00027E40 public void DeleteMrmConfiguration(BaseFolderIdType folderId) { DeleteUserConfigurationType deleteUserConfiguration = new DeleteUserConfigurationType { UserConfigurationName = new UserConfigurationNameType { Name = "MRM", Item = folderId } }; this.CallService(() => this.ServiceBinding.DeleteUserConfiguration(deleteUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Error && responseMessage.ResponseCode != ResponseCodeType.ErrorItemNotFound) { throw new ElcEwsException(ElcEwsErrorType.FailedToDeleteUserConfiguration, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText); } return(false); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToDeleteUserConfiguration, exception)); }
// Token: 0x06000577 RID: 1399 RVA: 0x00029938 File Offset: 0x00027B38 public byte[] GetMrmConfiguration(BaseFolderIdType folderId) { byte[] userConfiguration = null; GetUserConfigurationType getUserConfiguration = new GetUserConfigurationType { UserConfigurationName = new UserConfigurationNameType { Name = "MRM", Item = folderId }, UserConfigurationProperties = (UserConfigurationPropertyType.Dictionary | UserConfigurationPropertyType.XmlData | UserConfigurationPropertyType.BinaryData) }; this.CallService(() => this.ServiceBinding.GetUserConfiguration(getUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Error) { if (responseMessage.ResponseCode != ResponseCodeType.ErrorItemNotFound) { throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToGetUserConfiguration, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText), false); } ElcEwsClient.Tracer.TraceDebug <string>(0L, "MRM user configuration was not found in the mailbox of {0}.", this.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); } else { GetUserConfigurationResponseMessageType getUserConfigurationResponseMessageType = responseMessage as GetUserConfigurationResponseMessageType; if (getUserConfigurationResponseMessageType != null && getUserConfigurationResponseMessageType.UserConfiguration != null && getUserConfigurationResponseMessageType.UserConfiguration.XmlData != null) { userConfiguration = getUserConfigurationResponseMessageType.UserConfiguration.XmlData; } else { ElcEwsClient.Tracer.TraceDebug <string>(0L, "MRM user configuration was not in the GetUserConfiguration response of {0}", this.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); } } return(false); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToGetUserConfiguration, exception)); return(userConfiguration); }
// Token: 0x0600057B RID: 1403 RVA: 0x00029D74 File Offset: 0x00027F74 public BaseFolderType GetFolderById(BaseFolderIdType folderId, BasePathToElementType[] additionalProperties) { GetFolderType getFolder = new GetFolderType(); FolderResponseShapeType folderResponseShapeType = new FolderResponseShapeType(); folderResponseShapeType.BaseShape = DefaultShapeNamesType.IdOnly; folderResponseShapeType.AdditionalProperties = additionalProperties; getFolder.FolderShape = folderResponseShapeType; getFolder.FolderIds = new BaseFolderIdType[] { folderId }; List <BaseFolderType> folders = new List <BaseFolderType>(1); this.CallService(() => this.ServiceBinding.GetFolder(getFolder), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Error) { if (responseMessage.ResponseCode != ResponseCodeType.ErrorItemNotFound) { folders.Clear(); throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToGetFolderById, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText), false); } } else { FolderInfoResponseMessageType folderInfoResponseMessageType = (FolderInfoResponseMessageType)responseMessage; folders.Add(folderInfoResponseMessageType.Folders[0]); } return(true); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToGetFolderById, exception)); if (folders.Count <= 0) { return(null); } return(folders[0]); }
// Token: 0x06000578 RID: 1400 RVA: 0x00029A2C File Offset: 0x00027C2C public void CreateMrmConfiguration(BaseFolderIdType folderId, byte[] userConfiguration) { CreateUserConfigurationType createUserConfiguration = new CreateUserConfigurationType { UserConfiguration = new UserConfigurationType { UserConfigurationName = new UserConfigurationNameType { Name = "MRM", Item = folderId }, XmlData = userConfiguration } }; this.CallService(() => this.ServiceBinding.CreateUserConfiguration(createUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage.ResponseClass == ResponseClassType.Error) { throw new ElcEwsException(ElcEwsErrorType.FailedToCreateUserConfiguration, responseMessage.ResponseCode.ToString() + " : " + responseMessage.MessageText); } return(false); }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToCreateUserConfiguration, exception)); }
public BaseFolderType[] GetSubFolders(BaseFolderIdType parentFolderId, FolderResponseShapeType folderShape) { if (folderShape == null) { folderShape = EwsAuditClient.DefaultFolderShape; } IndexedPageViewType pageView = new IndexedPageViewType { Offset = 0, BasePoint = IndexBasePointType.Beginning, MaxEntriesReturnedSpecified = true, MaxEntriesReturned = 256 }; FindFolderType findFolderType = new FindFolderType { FolderShape = folderShape, Item = pageView, ParentFolderIds = new BaseFolderIdType[] { parentFolderId }, Traversal = FolderQueryTraversalType.Shallow }; HashSet <string> hashSet = null; List <BaseFolderType> list = null; bool haveMore; do { findFolderType.Item = pageView; BaseFolderType[] localFoldersList = null; haveMore = false; this.CallEwsWithRetries((LID)43196U, () => this.binding.FindFolder(findFolderType), delegate(ResponseMessageType responseMessage, int messageIndex) { FindFolderResponseMessageType findFolderResponseMessageType = responseMessage as FindFolderResponseMessageType; if (findFolderResponseMessageType != null && findFolderResponseMessageType.ResponseClass == ResponseClassType.Success && findFolderResponseMessageType.RootFolder != null) { localFoldersList = findFolderResponseMessageType.RootFolder.Folders; haveMore = !findFolderResponseMessageType.RootFolder.IncludesLastItemInRange; if (haveMore) { pageView.Offset = findFolderResponseMessageType.RootFolder.IndexedPagingOffset; } return(true); } return(false); }, null); if (localFoldersList != null && localFoldersList.Length > 0) { foreach (BaseFolderType baseFolderType in localFoldersList) { if (baseFolderType != null && baseFolderType.FolderId != null && !string.IsNullOrEmpty(baseFolderType.FolderId.Id)) { if (hashSet == null) { hashSet = new HashSet <string>(); } else if (hashSet.Contains(baseFolderType.FolderId.Id)) { goto IL_18B; } if (list == null) { list = new List <BaseFolderType>(localFoldersList.Length); } hashSet.Add(baseFolderType.FolderId.Id); list.Add(baseFolderType); } IL_18B :; } } }while (haveMore); if (list != null && list.Count > 0) { return(list.ToArray()); } return(Array <BaseFolderType> .Empty); }
public override PXSyncMovingCondition InitialiseFolder(BaseFolderIdType folder) { return(new PXSyncMovingMessageCondition(Command, ParentFolder, folder, Incomming, Outgoing)); }
protected PXSyncMovingMessageCondition(ExchangeEmailsSyncCommand command, DistinguishedFolderIdNameType parent, BaseFolderIdType folder, bool incomming, bool outgoing) : base(parent, folder) { Incomming = incomming; Outgoing = outgoing; Command = command; }
public abstract PXSyncMovingCondition InitialiseFolder(BaseFolderIdType folder);
protected PXSyncMovingCondition(DistinguishedFolderIdNameType parent, BaseFolderIdType folder) { ParentFolder = parent; FolderId = folder; }
public bool FindFolder(string folderName, BaseFolderIdType parentFolderId, out FolderIdType folderId) { folderId = null; FindFolderType findFolderType = new FindFolderType { FolderShape = new FolderResponseShapeType { BaseShape = DefaultShapeNamesType.IdOnly }, Item = new IndexedPageViewType { Offset = 0, BasePoint = IndexBasePointType.Beginning }, ParentFolderIds = new BaseFolderIdType[] { parentFolderId }, Traversal = FolderQueryTraversalType.Shallow, Restriction = new RestrictionType { Item = new IsEqualToType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.folderDisplayName }, FieldURIOrConstant = new FieldURIOrConstantType { Item = new ConstantValueType { Value = folderName } } } } }; FolderIdType localTargetFolderId = null; this.CallEwsWithRetries((LID)55484U, () => this.binding.FindFolder(findFolderType), delegate(ResponseMessageType responseMessage, int messageIndex) { FindFolderResponseMessageType findFolderResponseMessageType = responseMessage as FindFolderResponseMessageType; if (findFolderResponseMessageType != null && findFolderResponseMessageType.ResponseClass == ResponseClassType.Success && findFolderResponseMessageType.RootFolder != null && findFolderResponseMessageType.RootFolder.Folders != null && findFolderResponseMessageType.RootFolder.Folders.Length == 1) { localTargetFolderId = findFolderResponseMessageType.RootFolder.Folders[0].FolderId; if (this.IsTraceEnabled(TraceType.DebugTrace)) { this.Tracer.TraceDebug <string, string>(0L, "Found the folder '{0}' with the id {1}", folderName, localTargetFolderId.Id); } return(true); } if (findFolderResponseMessageType != null && findFolderResponseMessageType.ResponseClass == ResponseClassType.Error && findFolderResponseMessageType.ResponseCode == ResponseCodeType.ErrorFolderNotFound) { localTargetFolderId = null; return(true); } return(false); }, null); folderId = localTargetFolderId; return(localTargetFolderId != null); }
/// <summary> /// Empty a specific folder. /// </summary> /// <param name="folderId">The folder identifier of the folder need to be emptied.</param> /// <param name="deleteType">How an item is deleted.</param> /// <param name="deleteSubfolder">Indicates whether the subfolders are also to be deleted. </param> /// <returns>Empty folder response instance that will send to server.</returns> protected EmptyFolderResponseType CallEmptyFolderOperation(BaseFolderIdType folderId, DisposalType deleteType, bool deleteSubfolder) { // EmptyFolder request. EmptyFolderType emptyFolderRequest = new EmptyFolderType(); // Specify the delete type. emptyFolderRequest.DeleteType = deleteType; // Specify which folder will be emptied. emptyFolderRequest.FolderIds = new BaseFolderIdType[1]; emptyFolderRequest.FolderIds[0] = folderId; emptyFolderRequest.DeleteSubFolders = deleteSubfolder; // Empty the specific folder EmptyFolderResponseType emptyFolderResponse = this.FOLDAdapter.EmptyFolder(emptyFolderRequest); return emptyFolderResponse; }
public void MSOXWSCORE_S04_TC20_VerifyOperationsWithSOAPHeaderSuccessful() { #region Step 1: Create one item with recipient. // Clear the soap header. this.ClearSoapHeaders(); // Configure the SOAP headers for CreateItem and UpdateItem operations. Dictionary<string, object> headerValues = new Dictionary<string, object>(); headerValues = this.ConfigureSOAPHeader(); // Configure the TimeZoneContext SOAP Header. TimeZoneContextType timeZoneContext = new TimeZoneContextType(); timeZoneContext.TimeZoneDefinition = new TimeZoneDefinitionType(); timeZoneContext.TimeZoneDefinition.Id = TestSuiteHelper.TimeZoneID; headerValues.Add("TimeZoneContext", timeZoneContext); this.COREAdapter.ConfigureSOAPHeader(headerValues); // Call the CreateItem operation and save the item to Drafts folder. MessageType[] items = new MessageType[] { this.CreateItemWithOneRecipient() }; CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.drafts, items); // Check the operation response. Common.CheckOperationSuccess(createItemResponse, 1, this.Site); MessageType[] createdItems = Common.GetItemsFromInfoResponse<MessageType>(createItemResponse); // One created items should be returned. Site.Assert.AreEqual<int>( 1, createdItems.GetLength(0), "One created item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 1, createdItems.GetLength(0)); #endregion #region Step 2: Update the item which is created in Step 1. ItemChangeType[] itemChanges = new ItemChangeType[] { TestSuiteHelper.CreateItemChangeItem(createdItems[0], 1) }; // Clear ExistItemIds list for MoveItem. this.InitializeCollection(); // Call UpdateItem operation to update the subject of the created item, by using the ItemId in CreateItem response. UpdateItemResponseType updateItemResponse = this.CallUpdateItemOperation( DistinguishedFolderIdNameType.drafts, true, itemChanges); // Check the operation response. Common.CheckOperationSuccess(updateItemResponse, 1, this.Site); // Clear the soap header. this.ClearSoapHeaders(); #endregion #region Step 3: Move the item updated in Step 2 from Drafts folder to Inbox folder. // Configure the SOAP headers for MoveItem and MarkAllItemsAsRead operations. headerValues.Remove("TimeZoneContext"); this.COREAdapter.ConfigureSOAPHeader(headerValues); // Call the MoveItem operation, by using the ItemId in UpdateItem response. ItemIdType[] draftsItem = new ItemIdType[this.ExistItemIds.Count]; this.ExistItemIds.CopyTo(draftsItem, 0); this.InitializeCollection(); MoveItemResponseType moveItemResponse = this.CallMoveItemOperation(DistinguishedFolderIdNameType.inbox, draftsItem); // Check the operation response. Common.CheckOperationSuccess(moveItemResponse, 1, this.Site); #endregion #region Step 4: Mark all items in Inbox folder as read. // Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation. if (Common.IsRequirementEnabled(1290, this.Site)) { // Configure Inbox folder as the target folder. BaseFolderIdType[] folderIds = new BaseFolderIdType[1]; DistinguishedFolderIdType distinguishedFolder = new DistinguishedFolderIdType(); distinguishedFolder.Id = DistinguishedFolderIdNameType.inbox; folderIds[0] = distinguishedFolder; // Mark all items in Inbox folder as unread, and suppress the receive receipts. MarkAllItemsAsReadResponseType markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(true, true, folderIds); // Check the operation response. Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1290"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1290 // The MarkAllItemsAsRead operation was executed successfully, so this requirement can be captured. this.Site.CaptureRequirementIfIsTrue( this.IsSchemaValidated, 1290, @"[In Appendix C: Product Behavior] Implementation does support the MarkAllItemsAsRead operation which marks all items in a folder as read. (Exchange 2013 and above follow this behavior.)"); } // Clear the soap header. this.ClearSoapHeaders(); #endregion #region Step 5: Get the item in Inbox folder. // Configure the SOAP headers for GetItem. headerValues.Add("TimeZoneContext", timeZoneContext); this.COREAdapter.ConfigureSOAPHeader(headerValues); // Call the GetItem operation, by using the ItemId in MoveItem response. ItemIdType[] itemArray = new ItemIdType[this.ExistItemIds.Count]; this.ExistItemIds.CopyTo(itemArray, 0); GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 1, this.Site); // Clear the soap header. this.ClearSoapHeaders(); #endregion #region Step 6: Copy the message type item from Inbox folder to Drafts folder. // Configure the SOAP headers for CopyItem, SendItem and DeleteItem. headerValues.Remove("TimeZoneContext"); this.COREAdapter.ConfigureSOAPHeader(headerValues); // Save the ID of the item in Inbox folder and call the CopyItem operation. itemArray = new ItemIdType[this.ExistItemIds.Count]; this.ExistItemIds.CopyTo(itemArray, 0); CopyItemResponseType copyItemResponse = this.CallCopyItemOperation(DistinguishedFolderIdNameType.drafts, itemArray); // Check the operation response. Common.CheckOperationSuccess(copyItemResponse, 1, this.Site); ItemIdType[] copiedItemIds = Common.GetItemIdsFromInfoResponse(copyItemResponse); // One copied item should be returned. Site.Assert.AreEqual<int>( 1, copiedItemIds.GetLength(0), "One copied item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 1, copiedItemIds.GetLength(0)); #endregion #region Step 7: Send the item in Drafts folder. // Call SendItem to send the copied item in Drafts folder, by using copiedItemIds in CopyItem response. SendItemResponseType sendResponse = this.CallSendItemOperation( copiedItemIds, DistinguishedFolderIdNameType.sentitems, false); // Check the operation response. Common.CheckOperationSuccess(sendResponse, 1, this.Site); // Remove the sent itemId from ExistItemIds list, since the item has been sent out and no copy remains. this.ExistItemIds.Remove(copiedItemIds[0] as ItemIdType); #endregion #region Step 8: Delete the item in Inbox folder and clean all items sent out. // Delete the item in Inbox folder and clear the ExistItemIds list. DeleteItemResponseType deleteItemResponse = this.CallDeleteItemOperation(); // Check the operation response. Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); this.InitializeCollection(); // Clear the soap header. this.ClearSoapHeaders(); // Clean the items sent out. this.CleanItemsSentOut(new string[] { items[0].Subject }); #endregion }
/// <summary> /// Copy items to a destination folder and return the new ids for these items (Listing 5-14) /// </summary> /// <param name="binding">Exchange binding to use for the call</param> /// <param name="destinationFolderId">Destination for the items</param> /// <param name="itemsToCopy">Items to copy</param> /// <returns>List of new item ids</returns> /// public List<ItemIdType> CopyItemEx( BaseFolderIdType destinationFolderId, List<BaseItemIdType> itemsToCopy) { // STEP 1: First, we need to retrieve some unique information about // each item. Let's use the PR_SEARCH_KEY. Note that extended properties are // discussed in Chapter 13, "Extended Properties" // GetItemType getSearchKeyRequest = new GetItemType(); PathToExtendedFieldType searchKeyPath = new PathToExtendedFieldType(); searchKeyPath.PropertyTag = "0x300B"; searchKeyPath.PropertyType = MapiPropertyTypeType.Binary; // Use ItemResponseShapeType overload from chapter 3. We want the Id and the // search key // ItemResponseShapeType idAndSearchKeyShape = new ItemResponseShapeType( DefaultShapeNamesType.IdOnly, searchKeyPath); getSearchKeyRequest.ItemShape = idAndSearchKeyShape; getSearchKeyRequest.ItemIds = itemsToCopy.ToArray(); // Get the items // GetItemResponseType getSearchKeyResponse = this.GetItem(getSearchKeyRequest); List<string> base64SearchKeys = new List<string>( getSearchKeyResponse.ResponseMessages.Items.Length); // For each item, add the search keys to our list // foreach (ItemInfoResponseMessageType searchKeyMessage in getSearchKeyResponse.ResponseMessages.Items) { ExtendedPropertyType searchKeyProperty = searchKeyMessage.Items.Items[0].ExtendedProperty[0]; base64SearchKeys.Add((string)searchKeyProperty.Item); } // Now we have a list of the search keys for the items that we want to // copy. // STEP 2: Perform the copy CopyItemType copyItemRequest = new CopyItemType(); copyItemRequest.ToFolderId = new TargetFolderIdType(); copyItemRequest.ToFolderId.Item = destinationFolderId; // just copy the array from our GetItem request rather than building a // new one. // copyItemRequest.ItemIds = getSearchKeyRequest.ItemIds; CopyItemResponseType copyResponse = this.CopyItem(copyItemRequest); // Now, we know that we do not get new ids from the above request, but // we (read: you) SHOULD check the response code for each of the copies // operations. // // STEP 3: For each successful copy, we want to find the items by // search key. // FindItemType findBySearchKey = new FindItemType(); findBySearchKey.ItemShape = idAndSearchKeyShape; findBySearchKey.ParentFolderIds = new BaseFolderIdType[] { destinationFolderId }; findBySearchKey.Traversal = ItemQueryTraversalType.Shallow; findBySearchKey.Restriction = new RestrictionType(); // Here we need to build up our query. Rather than issuing several // FindItem calls, let's build up a single OR restriction here with a // bunch of items. Note that EWS restricts filter depths, so we // might need to break this up depending on how many items we are // copying... // if (base64SearchKeys.Count > 1) { OrType or = new OrType(); List<IsEqualToType> orChildren = new List<IsEqualToType>(); foreach (string searchKey in base64SearchKeys) { // Note that CreateIsEqualToSearchKey is implemented on the partial class // extension of RestrictionType. // IsEqualToType isEqualTo = RestrictionType.CreateIsEqualToSearchKey( searchKeyPath, searchKey); orChildren.Add(isEqualTo); } or.Items = orChildren.ToArray(); findBySearchKey.Restriction.Item = or; } else { // we only have one item. No need for the OR clause // IsEqualToType isEqualTo = RestrictionType.CreateIsEqualToSearchKey( searchKeyPath, base64SearchKeys[0]); findBySearchKey.Restriction.Item = isEqualTo; } FindItemResponseType findResponse = this.FindItem(findBySearchKey); // Since we searched in a single target folder, we will have a single // response message // FindItemResponseMessageType findResponseMessage = findResponse.ResponseMessages.Items[0] as FindItemResponseMessageType; ItemType[] foundItems = (findResponseMessage.RootFolder.Item as ArrayOfRealItemsType).Items; List<ItemIdType> newIds = new List<ItemIdType>(); foreach (ItemType item in foundItems) { newIds.Add(item.ItemId); } return newIds; }
/// <summary> /// A new, improved ContactsView method (Listing 6-16) /// </summary> /// <param name="folderId">Folder to perform FindItem in</param> /// <param name="responseShape">ResponseShape for returned contacts</param> /// <param name="pathForRestriction">The property path to compare against</param> /// <param name="lowerBounds">lower bounds string (inclusive)</param> /// <param name="upperBounds">upper bounds string (exclusive)</param> /// <param name="offset">For indexed paging, the offset into the result set to start at</param> /// <param name="maxEntries">Max entries to return for each page. Zero for unbounded</param> /// <returns>FindItemResponseMessageType</returns> /// public FindItemResponseMessageType SuperContactsView( BaseFolderIdType folderId, ItemResponseShapeType responseShape, BasePathToElementType pathForRestriction, string lowerBounds, string upperBounds, int offset, int maxEntries) { FindItemType request = new FindItemType(); request.ItemShape = responseShape; // If they set a maxEntries > 0, use indexed paging just to limit the results. // if (maxEntries > 0) { IndexedPageViewType paging = new IndexedPageViewType(); paging.BasePoint = IndexBasePointType.Beginning; paging.Offset = offset; paging.MaxEntriesReturned = maxEntries; paging.MaxEntriesReturnedSpecified = true; request.Item = paging; } request.ParentFolderIds = new BaseFolderIdType[] { folderId }; request.Traversal = ItemQueryTraversalType.Shallow; // Build up our restriction // AndType and = new AndType(); IsGreaterThanOrEqualToType lowerBoundsFilter = new IsGreaterThanOrEqualToType(); lowerBoundsFilter.Item = pathForRestriction; lowerBoundsFilter.FieldURIOrConstant = new FieldURIOrConstantType(); ConstantValueType lowerBoundsValue = new ConstantValueType(); lowerBoundsValue.Value = lowerBounds; lowerBoundsFilter.FieldURIOrConstant.Item = lowerBoundsValue; IsLessThanType upperBoundsFilter = new IsLessThanType(); upperBoundsFilter.Item = pathForRestriction; upperBoundsFilter.FieldURIOrConstant = new FieldURIOrConstantType(); ConstantValueType upperBoundsValue = new ConstantValueType(); upperBoundsValue.Value = upperBounds; upperBoundsFilter.FieldURIOrConstant.Item = upperBoundsValue; and.Items = new SearchExpressionType[] { lowerBoundsFilter, upperBoundsFilter }; request.Restriction = new RestrictionType(); request.Restriction.Item = and; // Make the request // FindItemResponseType response = this.FindItem(request); return response.ResponseMessages.Items[0] as FindItemResponseMessageType; }
public BaseFolderType GetFolderByName(BaseFolderIdType parentFolderId, string folderName) { return(this.ewsClient.GetFolderByName(this.PrimarySmtpAddress, parentFolderId, folderName)); }
/// <summary> /// Constructor /// </summary> /// <param name="folderId">Id of the target folder</param> /// public TargetFolderIdType(BaseFolderIdType folderId) { this.Item = folderId; }
public void MSOXWSCORE_S01_TC05_MarkAllItemsAsReadSuccessfully() { Site.Assume.IsTrue(Common.IsRequirementEnabled(1290, this.Site), "Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation."); #region Step 1: Create two items. ItemType[] createdItems = new ItemType[] { new ItemType(), new ItemType() }; createdItems[0].Subject = Common.GenerateResourceName( this.Site, TestSuiteHelper.SubjectForCreateItem, 1); createdItems[1].Subject = Common.GenerateResourceName( this.Site, TestSuiteHelper.SubjectForCreateItem, 2); CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.drafts, createdItems); // Check the operation response. Common.CheckOperationSuccess(createItemResponse, 2, this.Site); ItemIdType[] createdItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse); // Two created items should be returned. Site.Assert.AreEqual<int>( 2, createdItemIds.GetLength(0), "Two created item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, createdItemIds.GetLength(0)); #endregion #region Step 2: Get two items. // Call the GetItem operation. GetItemResponseType getItemResponse = this.CallGetItemOperation(createdItemIds); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); ItemIdType[] getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); // Two items should be returned. Site.Assert.AreEqual<int>( 2, getItemIds.GetLength(0), "Two item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, getItemIds.GetLength(0)); #endregion #region Step 3: Mark all items as unread, and suppress the receive receipts. BaseFolderIdType[] folderIds = new BaseFolderIdType[1]; DistinguishedFolderIdType distinguishedFolderId = new DistinguishedFolderIdType(); distinguishedFolderId.Id = DistinguishedFolderIdNameType.drafts; folderIds[0] = distinguishedFolderId; // Mark all items in drafts folder as unread, and suppress the receive receipts. MarkAllItemsAsReadResponseType markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(false, true, folderIds); // Check the operation response. Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site); Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated."); if (Common.IsRequirementEnabled(1054011, this.Site)) { // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1054011"); // Verify MS-OXWSCORE requirement: MS-OXWSCDATA_R1054011 // The MarkAllItemsAsReadResponseMessage is not null and the schema is validated, so this requirement can be captured. this.Site.CaptureRequirementIfIsNotNull( markAllItemsAsReadResponse.ResponseMessages.Items[0], "MS-OXWSCDATA", 1054011, @"[In Appendix C: Product Behavior] Implementation does use the element ""MarkAllItemsAsReadResponseMessage"" with type ""m:ResponseMessageType"", which specifies the response message for the MarkAllItemsAsRead operation.(Exchange 2013 and above follow this behavior.)"); } // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1212"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1212 // The schema is validated and the response is not null, so this requirement can be captured. this.Site.CaptureRequirementIfIsNotNull( markAllItemsAsReadResponse, 1212, @"[In m:MarkAllItemsAsReadResponseType Complex Type] The MarkAllItemsAsReadResponseType complex type extends the BaseResponseMessageType complex type ([MS-OXWSCDATA] section 2.2.4.16)."); #endregion #region Step 4: Get two items and check the updates. // Call the GetItem operation. getItemResponse = this.CallGetItemOperation(createdItemIds); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); // Two items should be returned. Site.Assert.AreEqual<int>( 2, getItemIds.GetLength(0), "Two item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, getItemIds.GetLength(0)); #endregion #region Step 5: Mark all items as read, and suppress the receive receipts. // Mark all items in drafts folder as read, and suppress the receive receipts. markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(true, true, folderIds); // Check the operation response. Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site); #endregion #region Step 6:Get two items and check the updates // Call the GetItem operation. getItemResponse = this.CallGetItemOperation(createdItemIds); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); // Two items should be returned. Site.Assert.AreEqual<int>( 2, getItemIds.GetLength(0), "Two item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, getItemIds.GetLength(0)); #endregion #region Step 7: Mark all items as unread, and don't suppress the receive receipts. // Mark all items in drafts folder as unread, and don't suppress the receive receipts markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(false, false, folderIds); // Check the operation response. Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site); #endregion #region Step 8: Get two items and check the updates. // Call the GetItem operation. getItemResponse = this.CallGetItemOperation(createdItemIds); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); // Two items should be returned. Site.Assert.AreEqual<int>( 2, getItemIds.GetLength(0), "Two item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, getItemIds.GetLength(0)); #endregion #region Step 9: Mark all items as read, and don't suppress the receive receipts. // Mark all items in drafts folder as read, and don't suppress the receive receipts. markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(true, false, folderIds); // Check the operation response. Common.CheckOperationSuccess(markAllItemsAsReadResponse, 1, this.Site); #endregion #region Step 10: Get two items and check the updates. // Call the GetItem operation. getItemResponse = this.CallGetItemOperation(createdItemIds); // Check the operation response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); // Two items should be returned. Site.Assert.AreEqual<int>( 2, getItemIds.GetLength(0), "Two item should be returned! Expected Item Count: {0}, Actual Item Count: {1}", 2, getItemIds.GetLength(0)); #endregion }