public void CreateItem(CreateItemType item) { this.CallEwsWithRetries((LID)63676U, () => this.binding.CreateItem(item), delegate(ResponseMessageType responseMessage, int messageIndex) { if (responseMessage != null && responseMessage.ResponseClass == ResponseClassType.Success) { if (this.IsTraceEnabled(TraceType.DebugTrace)) { this.Tracer.TraceDebug(0L, "Successfully created EWS.CreateItemType"); } return(true); } return(false); }, null); }
/// <summary> /// Create the calendar related item elements. /// </summary> /// <param name="request">A request to the CreateItem operation.</param> /// <returns>The response message returned by CreateItem operation.</returns> public CreateItemResponseType CreateItem(CreateItemType request) { if (request == null) { throw new ArgumentException("The request of operation 'CreateItem' should not be null."); } CreateItemResponseType createItemResponse = this.exchangeServiceBinding.CreateItem(request); Site.Assert.IsNotNull(createItemResponse, "If the operation is successful, the response should not be null."); this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyCreateItemOperation(createItemResponse, this.exchangeServiceBinding.IsSchemaValidated); return(createItemResponse); }
/// <summary> /// Creates Task items in the Exchange store /// </summary> /// <param name="createItemRequest">Specifies a request to create Task items on the server.</param> /// <returns>A response to this operation request.</returns> public CreateItemResponseType CreateItem(CreateItemType createItemRequest) { CreateItemResponseType createItemResponse = this.exchangeServiceBinding.CreateItem(createItemRequest); Site.Assert.IsNotNull(createItemResponse, "If the operation is successful, the response should not be null."); // Verify the create item operation. this.VerifyCreateItemOperation(createItemResponse, this.exchangeServiceBinding.IsSchemaValidated); // Verify Soap version requirements. this.VerifySoapVersion(); // Verify transport requirements. this.VerifyTransportType(); return(createItemResponse); }
/// <summary> /// Create items in the Exchange store /// </summary> /// <param name="createItemRequest">Specify a request to create items on the server.</param> /// <returns>A response to CreateItem operation request.</returns> public CreateItemResponseType CreateItem(CreateItemType createItemRequest) { CreateItemResponseType response = this.exchangeServiceBinding.CreateItem(createItemRequest); Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null."); // SOAP version is set to 1.1, if a response can be received from server, then it means SOAP 1.1 is supported. this.VerifySoapVersion(); // Verify transport type related requirement. this.VerifyTransportType(); this.VerifyServerVersionInfo(this.exchangeServiceBinding.ServerVersionInfoValue, this.exchangeServiceBinding.IsSchemaValidated); this.VerifyCreateItemResponse(response, this.exchangeServiceBinding.IsSchemaValidated); this.VerifyItemId(response); return(response); }
/// <summary> /// Define general CreateItem request message /// </summary> /// <param name="messageDisposition">A value specifies how a message item is handled after it is created or updated</param> /// <param name="savedTargetFolderName">The folder in which new items are saved</param> /// <returns>A request to create an item</returns> protected CreateItemType GetCreateItemType(MessageDispositionType messageDisposition, DistinguishedFolderIdNameType savedTargetFolderName) { CreateItemType createItemRequest = new CreateItemType { MessageDisposition = messageDisposition, MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = savedTargetFolderName } }, Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.recipient1 } }, Subject = this.subject, } } }, }; return(createItemRequest); }
/// <summary> /// Inserts the specified appointment. /// </summary> /// <param name="owner">The owner RadScheduler instance.</param> /// <param name="appointmentToInsert">The appointment to insert.</param> public override void Insert(RadScheduler owner, Appointment appointmentToInsert) { CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext; if (createExceptionContext != null) { Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception); InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate); return; } CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert); CreateItemType createItemRequest = new CreateItemType(); DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType(); destFolder.Id = DistinguishedFolderIdNameType.calendar; EmailAddressType emailAddressType = new EmailAddressType(); emailAddressType.EmailAddress = this.CalendarNames; destFolder.Mailbox = emailAddressType; createItemRequest.SavedItemFolderId = new TargetFolderIdType(); createItemRequest.SavedItemFolderId.Item = destFolder; createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone; createItemRequest.SendMeetingInvitationsSpecified = true; createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new CalendarItemType[] { calendarItem }; CreateItemResponseType response = Service.CreateItem(createItemRequest); ResponseMessageType responseMessage = response.ResponseMessages.Items[0]; if (responseMessage.ResponseCode != ResponseCodeType.NoError) { throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode); } }
public ItemTypes CreateItemType(string userId, CreateItemType addItemType) { var canAdd = this.CanUserAddItemTypes(userId); if (canAdd == false) { throw new UnauthorizedAccessException(); } var newItemType = new ItemTypes { Id = addItemType.ItemTypeId, Name = addItemType.Name, VenueTypeId = addItemType.ItemTypeId }; this.dbContext.ItemTypes.Add(newItemType); return(newItemType); }
/// <summary> /// Отправляет электронное письмо /// </summary> /// <param name="subject">Тема письма</param> /// <param name="body">Текст письма</param> public static void SendMail(string subject, string body) { using (ExchangeServiceBinding bind = new ExchangeServiceBinding()) { bind.Credentials = new NetworkCredential(Username, Password, Domain); bind.Url = "https://" + Host + "/EWS/Exchange.asmx"; bind.RequestServerVersionValue = new RequestServerVersion(); bind.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1; CreateItemType createItemRequest = new CreateItemType { Items = new NonEmptyArrayOfAllItemsType(), MessageDispositionSpecified = true, MessageDisposition = MessageDispositionType.SendOnly }; MessageType message = new MessageType(); message.ToRecipients = new EmailAddressType[1]; message.ToRecipients[0] = new EmailAddressType(); message.ToRecipients[0].EmailAddress = ToRecipient; message.Subject = subject; message.Body = new BodyType(); message.Body.BodyType1 = BodyTypeType.Text; message.Body.Value = body; createItemRequest.Items.Items = new ItemType[1]; createItemRequest.Items.Items[0] = message; CreateItemResponseType createItemResponse = bind.CreateItem(createItemRequest); ArrayOfResponseMessagesType responseMessages = createItemResponse.ResponseMessages; ResponseMessageType[] responseMessage = responseMessages.Items; foreach (ResponseMessageType rmt in responseMessage.Where(rmt => rmt.ResponseClass == ResponseClassType.Error)) { throw new Exception(rmt.MessageText); } } }
public HttpResponseMessage AddVenueItemType(CreateItemType itemType) { return(ErrorFactory.Handle(() => { var userId = User?.Identity?.GetUserId(); if (string.IsNullOrWhiteSpace(userId)) { throw new UnauthorizedAccessException(); } using (var unitOfWork = new UnitOfWork()) { var addVenueItemType = unitOfWork.ItemTypes.CreateItemType(userId, itemType); var outgoingItemType = OutgoingVenueItemType.Parse(addVenueItemType); unitOfWork.Complete(); return JsonFactory.CreateJsonMessage(outgoingItemType, HttpStatusCode.OK, this.Request); } }, this.Request)); }
/// <summary> /// Create a message in inbox . /// </summary> /// <returns>Id of the created message.</returns> protected ItemIdType CreateMessage() { CreateItemType createItemRequest = new CreateItemType() { MessageDisposition = MessageDispositionType.SaveOnly, MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType() { Item = new DistinguishedFolderIdType() { Id = DistinguishedFolderIdNameType.inbox } }, Items = new NonEmptyArrayOfAllItemsType() { Items = new ItemType[] { new MessageType() { Subject = Common.GenerateResourceName(this.Site, "Attachment parent message "), Body = new BodyType() { BodyType1 = BodyTypeType.HTML, Value = "This is a test mail." } } } } }; CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest); ItemInfoResponseMessageType itemInfo = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType; MessageType message = (MessageType)itemInfo.Items.Items[0]; return(message.ItemId); }
public void MSOXWSCORE_S07_TC18_CreateTaskItemWithInvalidItemClass() { #region Step 1: Create the Task item with ItemClass set to IPM.Appointment. CreateItemType createItemRequest = new CreateItemType(); createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); TaskType item = new TaskType(); createItemRequest.Items.Items = new ItemType[] { item }; createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1); createItemRequest.Items.Items[0].ItemClass = "IPM.Appointment"; CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Site.Assert.AreEqual <ResponseCodeType>( ResponseCodeType.ErrorObjectTypeChanged, createItemResponse.ResponseMessages.Items[0].ResponseCode, "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Appointment."); #endregion #region Step 2: Create the Task item with ItemClass set to IPM.Contact. createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2); createItemRequest.Items.Items[0].ItemClass = "IPM.Contact"; createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Site.Assert.AreEqual <ResponseCodeType>( ResponseCodeType.ErrorObjectTypeChanged, createItemResponse.ResponseMessages.Items[0].ResponseCode, "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Contact."); #endregion #region Step 3: Create the Task item with ItemClass set to IPM.Post. createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 3); createItemRequest.Items.Items[0].ItemClass = "IPM.Post"; createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Site.Assert.AreEqual <ResponseCodeType>( ResponseCodeType.ErrorObjectTypeChanged, createItemResponse.ResponseMessages.Items[0].ResponseCode, "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Task."); #endregion #region Step 4: Create the Task item with ItemClass set to IPM.DistList. createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 4); createItemRequest.Items.Items[0].ItemClass = "IPM.DistList"; createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Site.Assert.AreEqual <ResponseCodeType>( ResponseCodeType.ErrorObjectTypeChanged, createItemResponse.ResponseMessages.Items[0].ResponseCode, "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.DistList."); #endregion #region Step 5: Create the Task item with ItemClass set to random string. createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 5); createItemRequest.Items.Items[0].ItemClass = Common.GenerateResourceName(this.Site, "ItemClass"); createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Site.Assert.AreEqual <ResponseCodeType>( ResponseCodeType.ErrorObjectTypeChanged, createItemResponse.ResponseMessages.Items[0].ResponseCode, "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass is set to a random string."); #endregion // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2023"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2023 this.Site.CaptureRequirement( 2023, @"[In t:ItemType Complex Type] If invalid values are set for these items in the CreateItem request, an ErrorObjectTypeChanged ([MS-OXWSCDATA] section 2.2.5.24) response code will be returned in the CreateItem response."); }
/// <remarks/> public void CreateItemAsync(CreateItemType CreateItem1, object userState) { if ((this.CreateItemOperationCompleted == null)) { this.CreateItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateItemOperationCompleted); } this.InvokeAsync("CreateItem", new object[] { CreateItem1}, this.CreateItemOperationCompleted, userState); }
/// <remarks/> public void CreateItemAsync(CreateItemType CreateItem1) { this.CreateItemAsync(CreateItem1, null); }
/// <remarks/> public System.IAsyncResult BeginCreateItem(CreateItemType CreateItem1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CreateItem", new object[] { CreateItem1}, callback, asyncState); }
public void MSOXWSMTGS_S03_TC05_CopyItemErrorCalendarCannotUseIdForRecurringMasterId() { #region Define a meeting int timeInterval = this.TimeInterval; CalendarItemType calendarItem = new CalendarItemType(); calendarItem.UID = Guid.NewGuid().ToString(); calendarItem.Subject = this.Subject; calendarItem.Start = DateTime.UtcNow; calendarItem.StartSpecified = true; timeInterval++; calendarItem.End = DateTime.Now.AddHours(timeInterval); calendarItem.EndSpecified = true; calendarItem.Location = this.Location; calendarItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) }; ItemInfoResponseMessageType item1 = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy); Site.Assert.IsNotNull(item1, "Server should return success for creating a recurring meeting."); CalendarItemType calendarInOrganizer = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem.UID) as CalendarItemType; Site.Assert.IsNotNull(calendarInOrganizer, "The meeting should be found in organizer's Calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendToAllAndSaveCopy."); #endregion #region Define a recurring calendar item DateTime startTime = DateTime.Now; DailyRecurrencePatternType pattern = new DailyRecurrencePatternType(); pattern.Interval = this.PatternInterval; NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType(); range.NumberOfOccurrences = this.NumberOfOccurrences; range.StartDate = startTime; CalendarItemType meetingItem = new CalendarItemType(); meetingItem.UID = Guid.NewGuid().ToString(); meetingItem.Subject = this.Subject; meetingItem.Start = startTime; meetingItem.StartSpecified = true; meetingItem.End = startTime.AddHours(this.TimeInterval); meetingItem.EndSpecified = true; meetingItem.Location = this.Location; meetingItem.Recurrence = new RecurrenceType(); meetingItem.Recurrence.Item = pattern; meetingItem.Recurrence.Item1 = range; meetingItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) }; meetingItem.OptionalAttendees = new AttendeeType[] { GetAttendeeOrResource(this.OrganizerEmailAddress) }; meetingItem.Resources = new AttendeeType[] { GetAttendeeOrResource(this.RoomEmailAddress) }; #endregion #region Organizer creates a recurring calendar item with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll CreateItemType createItemRequest = new CreateItemType(); createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new ItemType[] { meetingItem }; createItemRequest.MessageDispositionSpecified = true; createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly; createItemRequest.SendMeetingInvitationsSpecified = true; createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone; ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll); #endregion #region Organizer copys the RecurringMasterId of the recurring calendar item #region Copy the recurring calendar item to Drafts folder through Id of recurring master getItem DistinguishedFolderIdType folderId = new DistinguishedFolderIdType(); folderId.Id = DistinguishedFolderIdNameType.drafts; TargetFolderIdType targetFolderId = new TargetFolderIdType(); targetFolderId.Item = folderId; OccurrenceItemIdType occurrenceId = new OccurrenceItemIdType(); occurrenceId.RecurringMasterId = calendarInOrganizer.ItemId.Id; occurrenceId.InstanceIndex = 1; CopyItemType copyItemRequest = new CopyItemType(); copyItemRequest.ItemIds = new BaseItemIdType[] { occurrenceId }; copyItemRequest.ToFolderId = targetFolderId; CopyItemResponseType response = this.MTGSAdapter.CopyItem(copyItemRequest); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1223"); //Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1223 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.ErrorCalendarCannotUseIdForRecurringMasterId, response.ResponseMessages.Items[0].ResponseCode, 1223, @"[In Messages] ErrorCalendarCannotUseIdForRecurringMasterId: Specifies that the RecurringMasterId ([MS-OXWSCORE] section 2.2.4.35) does not correspond to a valid recurring master item."); #endregion #region Clean up organizer's calendar, sentitems and deleteditems folders and attendee's calendar, inbox and deleteditems folders. this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType> { DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems }); this.CleanupFoldersByRole(Role.Attendee, new List <DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.deleteditems }); #endregion }
public void MSOXWSMSG_S02_TC01_UpdateMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem returned from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region update ToRecipients property of the original message UpdateItemType updateItemRequest = new UpdateItemType { MessageDisposition = MessageDispositionType.SaveOnly, MessageDispositionSpecified = true, ItemChanges = new ItemChangeType[] { new ItemChangeType { Item = itemIdType, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update the ToRecipients of message from Recipient1 to Recipient2. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } } } } } } } }; UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest); Site.Assert.IsTrue(this.VerifyResponse(updateItemResponse), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the UpdateItem response. if (this.firstItemOfFirstInfoItem != null) { Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; } #region Verify the requirements about UpdateItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R143"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R143 Site.CaptureRequirementIfIsNotNull( updateItemResponse, 143, @"[In UpdateItem] The protocol client sends an UpdateItemSoapIn request WSDL message, and the protocol server responds with an UpdateItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R144"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R144 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 144, @"[In UpdateItem] If the UpdateItem WSDL operation request is successful, the server returns an UpdateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.9.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R145"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R145 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 145, @"[In UpdateItem] [A successful UpdateItem operation request returns an UpdateItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Get the updated message GetItemType getItemRequest = DefineGeneralGetItemRequestMessage(itemIdType, DefaultShapeNamesType.AllProperties); GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(getItemResponse); Site.Assert.IsNotNull(this.infoItems, @"The GetItem response should contain one or more items of ItemInfoResponseMessageType."); ItemType updatedItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(updatedItem, @"The updated message should exist"); string expectedValue = Common.GetConfigurationPropertyValue("Recipient2", this.Site); Site.Assert.AreEqual <string>( expectedValue.ToLower(), updatedItem.DisplayTo.ToLower(), string.Format("The expected value of the DisplayTo property is {0}. The actual value is {1}.", expectedValue, updatedItem.DisplayTo)); #endregion #region Clean up Sender's drafts folder bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Sender", this.Site), Common.GetConfigurationPropertyValue("SenderPassword", this.Site), this.Domain, this.Subject, "drafts"); Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S03_TC01_CopyMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Copy message CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType }, // Save the copy message to inbox folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type from server response should not be null."); // Save the ItemId of message responseMessageItem got from the copyItem response. ItemIdType copyItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #region Verify the requirements about CopyItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R168"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R168 Site.CaptureRequirementIfIsNotNull( copyItemResponse, 168, @"[In CopyItem] The protocol client sends a CopyItemSoapIn request WSDL message, and the protocol server responds with a CopyItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R169"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R169 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, copyItemResponse.ResponseMessages.Items[0].ResponseClass, 169, @"[In CopyItem] If the CreateItem WSDL operation request is successful, the server returns a CreateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.2.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R170"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R170 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, copyItemResponse.ResponseMessages.Items[0].ResponseCode, 170, @"[In CopyItem] [A successful CopyItem operation request returns a CopyItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the copied Email messages DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { itemIdType, copyItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }
/// <summary> /// Sends mail through the exchange server. /// </summary> /// <param name="Config"> ReviewNotifierConfiguration. </param> /// <param name="ExchangeItems"> Mail to send. </param> /// <returns> true if successful. </returns> private static bool SendExchangeMail(ReviewNotifierConfiguration Config, List<MessageType> ExchangeItems) { int maxQuotaNum = Int32.MaxValue; var binding = (ExchangeServicePortType)new ExchangeServicePortTypeClient( new BasicHttpBinding("ExchangeServiceBinding") { MaxReceivedMessageSize = maxQuotaNum, MaxBufferSize = maxQuotaNum, ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxArrayLength = maxQuotaNum, MaxStringContentLength = maxQuotaNum, MaxNameTableCharCount = maxQuotaNum } }, new EndpointAddress(Config.EmailService)); DistinguishedFolderIdType folder = new DistinguishedFolderIdType(); folder.Id = DistinguishedFolderIdNameType.sentitems; TargetFolderIdType targetFolder = new TargetFolderIdType(); targetFolder.Item = folder; CreateItemType createItem = new CreateItemType(); createItem.MessageDisposition = MessageDispositionType.SendAndSaveCopy; createItem.MessageDispositionSpecified = true; createItem.SavedItemFolderId = targetFolder; createItem.Items = new NonEmptyArrayOfAllItemsType(); createItem.Items.Items = ExchangeItems.ToArray(); var createReq = new CreateItemRequest() { CreateItem = createItem }; var response = binding.CreateItem(createReq); bool result = true; foreach (ResponseMessageType r in response.CreateItemResponse1.ResponseMessages.Items) { if (r.ResponseClass != ResponseClassType.Success) { Log.Info("Failed to send the message. "); Log.Info(r.MessageText); result = false; } } return result; }
/// <summary> /// Create an item in the specified folder. /// </summary> /// <param name="parentFolderType">Type of the parent folder.</param> /// <param name="parentFolderId">ID of the parent folder.</param> /// <param name="itemSubject">Subject of the item which should be created.</param> /// <returns>ID of the created item.</returns> protected ItemIdType CreateItem(DistinguishedFolderIdNameType parentFolderType, string parentFolderId, string itemSubject) { // Create a request for the CreateItem operation and initialize the ItemType instance. CreateItemType createItemRequest = new CreateItemType(); ItemType item = null; // Get different values for item based on different parent folder type. switch (parentFolderType) { case DistinguishedFolderIdNameType.contacts: ContactItemType contact = new ContactItemType(); contact.Subject = itemSubject; contact.FileAs = itemSubject; item = contact; break; case DistinguishedFolderIdNameType.calendar: // Set the sendMeetingInvitations property. CalendarItemCreateOrDeleteOperationType sendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone; createItemRequest.SendMeetingInvitations = (CalendarItemCreateOrDeleteOperationType)sendMeetingInvitations; createItemRequest.SendMeetingInvitationsSpecified = true; CalendarItemType calendar = new CalendarItemType(); calendar.Subject = itemSubject; item = calendar; break; case DistinguishedFolderIdNameType.inbox: MessageType message = new MessageType(); message.Subject = itemSubject; item = message; break; case DistinguishedFolderIdNameType.tasks: TaskType taskItem = new TaskType(); taskItem.Subject = itemSubject; item = taskItem; break; default: Site.Assert.Fail("The parent folder type '{0}' is invalid and the valid folder types are: contacts, calendar, inbox and tasks.", parentFolderType.ToString()); break; } // Set the MessageDisposition property. MessageDispositionType messageDisposition = MessageDispositionType.SaveOnly; createItemRequest.MessageDisposition = (MessageDispositionType)messageDisposition; createItemRequest.MessageDispositionSpecified = true; // Specify the folder in which new items are saved. createItemRequest.SavedItemFolderId = new TargetFolderIdType(); FolderIdType folderId = new FolderIdType(); folderId.Id = parentFolderId; createItemRequest.SavedItemFolderId.Item = folderId; // Specify the collection of items to be created. createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new ItemType[] { item }; // Initialize the ID of the created item. ItemIdType createdItemId = null; // Invoke the create item operation and get the response. CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest); if (createItemResponse != null && createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { ItemInfoResponseMessageType info = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType; Site.Assert.IsNotNull(info, "The items in CreateItem response should not be null."); // Get the ID of the created item. createdItemId = info.Items.Items[0].ItemId; } return(createdItemId); }
public void MSOXWSMSG_S05_TC01_SendMessage() { #region Create the message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType = new ItemIdType(); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message SendItemType sendItemRequest = new SendItemType { ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, // Save the message copy in sent items folder. SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyResponse(sendItemResponse), @"Server should return success for sending the email messages."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items, @"Items in the returned response should not be null."); #region Verify the requirements about SendItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R177"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R177 Site.CaptureRequirementIfIsNotNull( sendItemResponse, 177, @"[In SendItem] The protocol client sends a SendItemSoapIn request WSDL message, and the protocol server responds with a SendItemSoapOut response WSDL message."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R178"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R178 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponse.ResponseMessages.Items[0].ResponseClass, 178, @"[In SendItem] A successful SendItem operation request returns a SendItemResponse element with the ResponseClass attribute of the SendItemResponseMessage element set to ""Success""."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R179"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R179 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, sendItemResponse.ResponseMessages.Items[0].ResponseCode, 179, @"[In SendItem] [A successful SendItem operation request returns a SendItemResponse element] The ResponseCode element of the SendItemResponse element is set to ""NoError""."); #endregion #endregion #region Create the invalid message for SendItem operation without ToRecipients element CreateItemType createItemRequestFailed = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, Subject = this.Subject, } } }, }; CreateItemResponseType createItemResponseFailed = this.MSGAdapter.CreateItem(createItemRequestFailed); Site.Assert.IsTrue(this.VerifyResponse(createItemResponseFailed), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponseFailed); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message without ToRecipients element SendItemType sendItemRequestFailed = new SendItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponseFailed = this.MSGAdapter.SendItem(sendItemRequestFailed); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R31"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R31 Site.CaptureRequirementIfAreNotEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponseFailed.ResponseMessages.Items[0].ResponseClass, 31, @"[In t:MessageType Complex Type] [ToRecipients element] This element is required for sending a message."); #endregion #region Delete the invalid message DeleteItemType deleteItemRequest = new DeleteItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Sender's sentitems folder and Recipient1's inbox folder bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Sender", this.Site), Common.GetConfigurationPropertyValue("SenderPassword", this.Site), this.Domain, this.Subject, "sentitems"); Site.Assert.IsTrue(isClear, "Sender's sentitems folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, this.Subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S06_TC01_OperateMultipleMessages() { #region Create multiple message string subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 0); string anotherSubject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 1); CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { // Create an responseMessageItem with two MessageType instances. Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, Subject = subject, }, new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } }, Subject = anotherSubject, } } }, }; CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(createItemResponse), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the first ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType1 = new ItemIdType(); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the second ItemId. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType itemIdType2 = new ItemIdType(); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Get the multiple messages which created GetItemType getItemRequest = new GetItemType { // Set the two ItemIds got from CreateItem response. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(getItemResponse), @"Server should return success for creating the email messages."); #endregion #region Update the multiple messages which created UpdateItemType updateItemRequest = new UpdateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, // Create two ItemChangeType instances. ItemChanges = new ItemChangeType[] { new ItemChangeType { Item = itemIdType1, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the first message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } } } }, } }, new ItemChangeType { Item = itemIdType2, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the second message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } } } }, } } } }; UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(updateItemResponse), @"Server should return success for updating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(updateItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the UpdateItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the UpdateItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Copy the updated multiple message to junkemail CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType1, itemIdType2, }, // Copy the message to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the CopyItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType copyItemIdType1 = new ItemIdType(); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the CopyItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType copyItemIdType2 = new ItemIdType(); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Move the copied multiple message from junkemail to deleteditems MoveItemType moveItemRequest = new MoveItemType { // Set to copied message responseMessageItem id. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 }, // Move the copied messages to deleted items folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.deleteditems } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the MoveItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the MoveItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Send multiple messages SendItemType sendItemRequest = new SendItemType { // Set to the two updated messages' ItemIds. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, // Do not save copy. SaveItemToFolder = false, }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(sendItemResponse), @"Server should return success for sending the email messages."); #endregion #region Delete the copied messages DeleteItemType deleteItemRequest = new DeleteItemType { // Set to the two copied messages' ItemIds. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Recipient1's and Recipient2's inbox folders bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient2", this.Site), Common.GetConfigurationPropertyValue("Recipient2Password", this.Site), this.Domain, subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient2's inbox folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, anotherSubject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }
public ActionResult CreateItemType(CreateItemType itemType) { var Rs = service.Create(itemType); return(Ok(Rs)); }
public void MSOXWSCONT_S05_TC01_OperateMultipleContactItems() { #region Step 1:Create the contact item. CreateItemType createItemRequest = new CreateItemType(); #region Config the contact items createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new ContactItemType[2]; // Create the first contact item. createItemRequest.Items.Items[0] = this.BuildContactItemWithRequiredProperties(); // Create the second contact item. createItemRequest.Items.Items[1] = this.BuildContactItemWithRequiredProperties(); // Configure the SavedItemFolderId of CreateItem request to specify that the created item is saved under which folder. createItemRequest.SavedItemFolderId = new TargetFolderIdType() { Item = new DistinguishedFolderIdType() { Id = DistinguishedFolderIdNameType.contacts, } }; #endregion CreateItemResponseType createItemResponse = this.CONTAdapter.CreateItem(createItemRequest); // Check the response. Common.CheckOperationSuccess(createItemResponse, 2, this.Site); #endregion #region Step 2:Update the contact items. UpdateItemType updateItemRequest = new UpdateItemType() { // Configure ItemIds. ItemChanges = new ItemChangeType[] { new ItemChangeType() { Item = this.ExistContactItems[0], Updates = new ItemChangeDescriptionType[] { new SetItemFieldType() { Item = new PathToUnindexedFieldType() { FieldURI = UnindexedFieldURIType.contactsFileAs }, Item1 = new ContactItemType() { FileAs = FileAsMappingType.LastFirstCompany.ToString() } } } }, new ItemChangeType() { Item = this.ExistContactItems[1], Updates = new ItemChangeDescriptionType[] { new SetItemFieldType() { Item = new PathToUnindexedFieldType() { FieldURI = UnindexedFieldURIType.contactsFileAs }, Item1 = new ContactItemType() { FileAs = FileAsMappingType.LastCommaFirst.ToString() } } } } }, ConflictResolution = ConflictResolutionType.AlwaysOverwrite }; // Clear existContactItems for MoveItem. this.InitializeCollection(); UpdateItemResponseType updateItemResponse = new UpdateItemResponseType(); // Invoke UpdateItem operation. updateItemResponse = this.CONTAdapter.UpdateItem(updateItemRequest); // Check the response. Common.CheckOperationSuccess(updateItemResponse, 2, this.Site); #endregion #region Step 3:Move the contact items. MoveItemType moveItemRequest = new MoveItemType(); MoveItemResponseType moveItemResponse = new MoveItemResponseType(); // Configure ItemIds. moveItemRequest.ItemIds = new BaseItemIdType[2]; moveItemRequest.ItemIds[0] = this.ExistContactItems[0]; moveItemRequest.ItemIds[1] = this.ExistContactItems[1]; // Clear existContactItems for MoveItem. this.InitializeCollection(); // Configure move Distinguished Folder. DistinguishedFolderIdType distinguishedFolderId = new DistinguishedFolderIdType(); distinguishedFolderId.Id = DistinguishedFolderIdNameType.drafts; moveItemRequest.ToFolderId = new TargetFolderIdType(); moveItemRequest.ToFolderId.Item = distinguishedFolderId; moveItemResponse = this.CONTAdapter.MoveItem(moveItemRequest); // Check the response. Common.CheckOperationSuccess(moveItemResponse, 2, this.Site); #endregion #region Step 4:Get the contact items. // The contact item to get. ItemIdType[] itemArray = new ItemIdType[this.ExistContactItems.Count]; this.ExistContactItems.CopyTo(itemArray, 0); GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray); // Check the response. Common.CheckOperationSuccess(getItemResponse, 2, this.Site); #endregion #region Step 5:Copy the contact items. CopyItemType copyItemRequest = new CopyItemType(); CopyItemResponseType copyItemResponse = new CopyItemResponseType(); // Configure ItemIds. copyItemRequest.ItemIds = new BaseItemIdType[2]; copyItemRequest.ItemIds[0] = this.ExistContactItems[0]; copyItemRequest.ItemIds[1] = this.ExistContactItems[1]; // Configure the copy Distinguished Folder. DistinguishedFolderIdType distinguishedFolderIdForCopyItem = new DistinguishedFolderIdType(); distinguishedFolderIdForCopyItem.Id = DistinguishedFolderIdNameType.drafts; copyItemRequest.ToFolderId = new TargetFolderIdType(); copyItemRequest.ToFolderId.Item = distinguishedFolderIdForCopyItem; copyItemResponse = this.CONTAdapter.CopyItem(copyItemRequest); // Check the response. Common.CheckOperationSuccess(copyItemResponse, 2, this.Site); #endregion }
/// <summary> /// Saves the given message to the drafts folder. /// </summary> /// <param name="message"></param> /// <returns></returns> public ItemIdType SaveMessage(ChannelMessage message) { var binding = ChannelHelper.BuildChannel(hostname, username, password); var createItemRequest = new CreateItemType(); // Indicate that we want to save only at first createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly; createItemRequest.MessageDispositionSpecified = true; createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); // Create a single e-mail message. var exchMessage = new MessageType(); exchMessage.Subject = message.Context; exchMessage.Body = new BodyType { BodyType1 = BodyTypeType.HTML, Value = message.BodyHtml.ReadString() }; exchMessage.ItemClass = "IPM.Note"; exchMessage.Sender = new SingleRecipientType(); exchMessage.Sender.Item = new EmailAddressType { EmailAddress = message.From.Address }; exchMessage.ToRecipients = new EmailAddressType[message.To.Count]; exchMessage.CcRecipients = new EmailAddressType[message.CC.Count]; exchMessage.BccRecipients = new EmailAddressType[message.BCC.Count]; for (int i = 0; i < message.To.Count; i++) { exchMessage.ToRecipients[i] = new EmailAddressType { EmailAddress = message.To[i].Address } } ; for (int i = 0; i < message.CC.Count; i++) { exchMessage.CcRecipients[i] = new EmailAddressType { EmailAddress = message.CC[i].Address } } ; for (int i = 0; i < message.BCC.Count; i++) { exchMessage.BccRecipients[i] = new EmailAddressType { EmailAddress = message.BCC[i].Address } } ; exchMessage.Sensitivity = SensitivityChoicesType.Normal; // Add the message to the array of items to be created. createItemRequest.Items.Items = new ItemType[1]; createItemRequest.Items.Items[0] = exchMessage; // Send the request to create and send the e-mail item, and get the response. CreateItemResponseType createItemResponse = binding.CreateItem(createItemRequest); // Determine whether the request was a success. if (createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error) { throw new Exception(createItemResponse.ResponseMessages.Items[0].MessageText); } return(((ItemInfoResponseMessageType)createItemResponse.ResponseMessages.Items[0]).Items.Items[0].ItemId); }
public void MSOXWSMSG_S04_TC02_MoveMessageUnsuccessful() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Delete the message created DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163001"); this.Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Error, moveItemResponse.ResponseMessages.Items[0].ResponseClass, 163001, @"[In MoveItem] If the MoveItem WSDL operation request is not successful, it returns a MoveItemResponse element with the ResponseClass attribute of the MoveItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163002"); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), moveItemResponse.ResponseMessages.Items[0].ResponseCode), 163002, @"[In MoveItem] [A unsuccessful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element of the MoveItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #endregion }
public void MSOXWSMSG_S04_TC01_MoveMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the moveItem response. ItemIdType moveItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); moveItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; moveItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Verify whether the message is moved to junkemail folder. string userName = Common.GetConfigurationPropertyValue("Sender", this.Site); string password = Common.GetConfigurationPropertyValue("SenderPassword", this.Site); string domain = Common.GetConfigurationPropertyValue("Domain", this.Site); bool findItemInDrafts = this.IsItemAvailableAfterMoveOrDelete(userName, password, domain, "drafts", this.Subject, "itemSubject"); Site.Assert.IsFalse(findItemInDrafts, "The item should not be found in the drafts folder of Sender."); bool findItemInJunkemail = this.SearchItems(Role.Sender, "junkemail", this.Subject, "itemSubject"); Site.Assert.IsTrue(findItemInJunkemail, "The item should be found in the junkemail folder of Sender."); #region Verify the requirements about MoveItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R161"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R161 Site.CaptureRequirementIfIsNotNull( moveItemResponse, 161, @"[In MoveItem] The protocol client sends a MoveItemSoapIn request WSDL message, and the protocol server responds with a MoveItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R162"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R162 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 162, @"[In MoveItem] If the MoveItem WSDL operation request is successful, the server returns a MoveItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.7.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R163 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 163, @"[In MoveItem] [A successful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the moved message DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { moveItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }
/// <summary> /// Creates items on the server. /// </summary> /// <param name="createItemRequest">Request message of "CreateItem" operation.</param> /// <returns>Response message of "CreateItem" operation.</returns> public CreateItemResponseType CreateItem(CreateItemType createItemRequest) { CreateItemResponseType createItemResponse = this.exchangeServiceBinding.CreateItem(createItemRequest); return(createItemResponse); }