protected static EwsTask CreateSampleEwsTask(bool titleOnly = false) { var title = $"task-{DateTime.Now.ToString("T")}-{Guid.NewGuid()}"; var due = DateTime.Now.AddDays(5); var reminder = due.AddDays(-3); var start = due.AddDays(-2); var ordinal = due.AddDays(-1); var complete = due.AddDays(-0.5); var ewsTask = new EwsTask { Subject = title, }; if (!titleOnly) { ewsTask.Importance = EwsImportance.High; ewsTask.BodyType = EwsBodyType.Text; ewsTask.Body = "body content"; ewsTask.DueDate = due; ewsTask.ReminderDate = reminder; ewsTask.ReminderIsSet = true; ewsTask.StartDate = start; ewsTask.OrdinalDate = ordinal; ewsTask.Categories = new[] { "category1", "category2" }; ewsTask.Complete = true; ewsTask.CompleteDate = complete; } return(ewsTask); }
public static ExchangeTask BuildExchangeTask(this EwsTask ewsTask) { var id = string.Format("{0}{1}{2}", ewsTask.Id, ChangeKeySeparator, ewsTask.ChangeKey); if (ewsTask.Type == EwsItemType.Item) { id = ItemPrefix + id; } var exchangeTask = new ExchangeTask { Id = id, Subject = ewsTask.Subject, Start = ewsTask.StartDate, Due = ewsTask.DueDate, Completed = ewsTask.CompleteDate, Importance = (ExchangeTaskImportance)(int)ewsTask.Importance, }; if (ewsTask.ReminderIsSet && ewsTask.ReminderDate.HasValue && ewsTask.ReminderDate.Value != DateTime.MinValue) { exchangeTask.Alarm = ewsTask.ReminderDate; } if (!string.IsNullOrWhiteSpace(ewsTask.Body)) { exchangeTask.Note = ewsTask.Body; } if (ewsTask.Categories != null && ewsTask.Categories.Length > 0) { exchangeTask.Category = ewsTask.Categories[0]; } if (ewsTask.Recurrence != null && ewsTask.Recurrence.RecurrenceType != ExchangeRecurrencePattern.None) { exchangeTask.IsRecurring = true; exchangeTask.DayOfMonth = ewsTask.Recurrence.DayOfMonth; exchangeTask.DayOfWeekIndex = ewsTask.Recurrence.DayOfWeekIndex; exchangeTask.DaysOfWeek = ewsTask.Recurrence.DaysOfWeek; exchangeTask.Interval = ewsTask.Recurrence.Interval; exchangeTask.Month = ewsTask.Recurrence.Month; exchangeTask.RecurrenceType = ewsTask.Recurrence.RecurrenceType; } return(exchangeTask); }
public async Task Create_timezone_handling() { var due = DateTime.Now.Date; due = due.AddHours(23).AddMinutes(59); // 11:59PM var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), DueDate = due }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.IsTrue(task.DueDate.HasValue); Assert.AreEqual(ewsTask.DueDate.Value.Date, task.DueDate.Value.Date); }
public async Task Update_clear_categories() { var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), Categories = new [] { "category1", "category2" } }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); task.Categories = null; task.Changes = EwsFields.Categories; await this.server.UpdateItemsAsync(new[] { task }); task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.AreEqual(0, task.Categories.Length); }
public async Task Update_clear_body() { var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), BodyType = EwsBodyType.Text, Body = "test body" }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); task.Body = null; task.Changes = EwsFields.Body; await this.server.UpdateItemsAsync(new[] { task }); task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.IsTrue(string.IsNullOrEmpty(task.Body)); }
public async Task Update_clear_start_date() { var start = DateTime.Now.Date; var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), StartDate = start }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); task.StartDate = null; task.Changes = EwsFields.StartDate; await this.server.UpdateItemsAsync(new[] { task }); task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.IsNull(task.StartDate); }
public async Task Update_percent_complete() { var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), PercentComplete = 0.3 }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.AreEqual(ewsTask.PercentComplete, task.PercentComplete); task.PercentComplete = 0.6; task.Changes = EwsFields.PercentComplete; await this.server.UpdateItemAsync(task); var newTask = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.AreEqual(task.PercentComplete, newTask.PercentComplete); }
public async Task <EwsTask> CreateFlaggedItem(string subject) { // setup var createResult = await this.server.CreateEmailAsync(EwsKnownFolderIdentifiers.Inbox, subject, "world", "*****@*****.**"); Assert.IsNotNull(createResult); this.searchFolderIdentifier = await this.service.EnsureSearchFolderAsync(this.server); Assert.IsNotNull(this.searchFolderIdentifier); var ewsTask = new EwsTask { Type = EwsItemType.Item, Id = createResult.Identifiers[0].Id, ChangeKey = createResult.Identifiers[0].ChangeKey, ParentFolderId = createResult.Identifiers[0].ParentFolderId, ParentFolderChangeKey = createResult.Identifiers[0].ParentFolderChangeKey, DueDate = DateTime.Now.Date, Categories = new[] { "cat1", "cat2 " }, Changes = EwsFields.DueDate | EwsFields.Categories }; // act var updateResult = await this.server.UpdateItemAsync(ewsTask); // check Assert.IsNotNull(updateResult); Assert.AreEqual(1, updateResult.Identifiers.Count); Assert.AreEqual(ewsTask.Id, updateResult.Identifiers[0].Id); ewsTask.ChangeKey = updateResult.Identifiers[0].ChangeKey; return(ewsTask); }
public async Task Update_clear_reminder_date() { var reminder = DateTime.Now.Date; var ewsTask = new EwsTask { Subject = "task" + DateTime.Now.ToString("T"), ReminderDate = reminder, ReminderIsSet = true }; await this.server.CreateItemAsync(ewsTask); var task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); task.ReminderIsSet = false; task.Changes = EwsFields.Reminder; await this.server.UpdateItemsAsync(new[] { task }); task = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.IsFalse(task.ReminderIsSet); }
public async Task Delete_task() { var ewsTask = CreateSampleEwsTask(); await this.server.CreateItemAsync(ewsTask); var itemIdentifiers = await this.server.EnumerateFolderContentAsync(this.folderIdentifiers.TaskFolderIdentifier); Assert.IsNotNull(itemIdentifiers, "itemIdentifiers != null"); var tasks = await this.server.DownloadFolderContentAsync(itemIdentifiers, EwsItemType.Task); Assert.IsNotNull(tasks, "tasks != null"); var task = tasks.FirstOrDefault(t => t.Subject == ewsTask.Subject); Assert.IsNotNull(task, "task != null"); await this.server.DeleteItemsAsync(new[] { itemIdentifiers.First(i => i.Id == task.Id) }); EwsTask value = await this.server.GetTask(ewsTask.Subject, this.folderIdentifiers.TaskFolderIdentifier); Assert.IsNull(value, "value != null"); }
public static EwsTask BuildEwsTask(this ExchangeTask exchangeTask) { var ewsTask = new EwsTask { Subject = exchangeTask.Subject, Categories = new[] { exchangeTask.Category }, StartDate = exchangeTask.Start, CompleteDate = exchangeTask.Completed, Importance = (EwsImportance)(int)exchangeTask.Importance }; if (exchangeTask.Due.HasValue) { ewsTask.DueDate = exchangeTask.Due.Value.Date; } if (exchangeTask.Alarm.HasValue) { ewsTask.ReminderDate = exchangeTask.Alarm; ewsTask.ReminderIsSet = true; } if (!string.IsNullOrWhiteSpace(exchangeTask.Note)) { ewsTask.Body = exchangeTask.Note; ewsTask.BodyType = exchangeTask.Note.HasHtml() ? EwsBodyType.HTML : EwsBodyType.Text; } if (!exchangeTask.Properties.HasValue) { throw new NotSupportedException("Task has no properties set"); } if (exchangeTask.IsRecurring && exchangeTask.Due.HasValue) { var recurrence = new EwsRecurrence { RecurrenceType = exchangeTask.RecurrenceType, Interval = exchangeTask.Interval, DayOfMonth = exchangeTask.DayOfMonth, DayOfWeekIndex = exchangeTask.DayOfWeekIndex, DaysOfWeek = exchangeTask.DaysOfWeek, Month = exchangeTask.Month, }; if (!exchangeTask.Start.HasValue) { recurrence.StartDate = exchangeTask.Due.Value; } else { recurrence.StartDate = exchangeTask.Start.Value; } ewsTask.Recurrence = recurrence; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Title)) { ewsTask.Changes |= EwsFields.Subject; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Folder)) { ewsTask.Changes |= EwsFields.Categories; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Due)) { ewsTask.Changes |= EwsFields.DueDate; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Start)) { ewsTask.Changes |= EwsFields.StartDate; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Completed)) { ewsTask.Changes |= EwsFields.CompleteDate; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Priority)) { ewsTask.Changes |= EwsFields.Importance; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.RepeatFrom)) { ewsTask.Changes |= EwsFields.Recurrence; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Alarm)) { ewsTask.Changes |= EwsFields.Reminder; } if (exchangeTask.Properties.Value.HasFlag(ExchangeTaskProperties.Note)) { ewsTask.Changes |= EwsFields.Body; } if (!string.IsNullOrWhiteSpace(exchangeTask.Id)) { string id = exchangeTask.Id; if (exchangeTask.Id.StartsWith(ItemPrefix)) { id = id.Replace(ItemPrefix, string.Empty); ewsTask.Type = EwsItemType.Item; } var identifier = GetEwsItemIdentifier(id); ewsTask.Id = identifier.Id; ewsTask.ChangeKey = identifier.ChangeKey; } return(ewsTask); }
// field ordering available at: http://msdn.microsoft.com/en-us/library/aa563930(v=EXCHG.140).aspx private static string GetXmlForTask(EwsTask task) { const string template = "<t:Task>{0}</t:Task>"; var builder = new StringBuilder(); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.Subject, task.Subject)); if (!string.IsNullOrEmpty(task.Body)) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.Body, task.Body, new EwsAttributes { { BodyTypeAttribute, task.BodyType.ToString() } })); } if (task.Categories != null && task.Categories.Length > 0) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.Categories, task.Categories)); } builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.Importance, task.Importance)); if (task.ReminderDate != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.ReminderDueBy, task.ReminderDate.Value, DateTimeKind.Utc)); } builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.ReminderIsSet, task.ReminderIsSet)); if (task.OrdinalDate != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TagSubject, task.Subject)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TagSubjectPrefix, string.Empty)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.NormalizedSubject, task.Subject)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskOrdinalDate, task.OrdinalDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskSubOrdinalDate, task.SubOrdinalDate)); } if (task.StartDate != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.CommonStart, task.StartDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskStartDate, task.StartDate.Value, DateTimeKind.Local)); } if (task.DueDate != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.CommonEnd, task.DueDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskDueDate, task.DueDate.Value, DateTimeKind.Local)); } builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskIsRecurring, task.IsRecurring)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskIsDeadOccurence, task.IsDeadOccurence)); if (task.IsRecurring && !task.IsDeadOccurence) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TagIconIndex, (int)EwsTagIconIndex.UnassignedRecurringTask)); } else { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TagIconIndex, (int)EwsTagIconIndex.Task)); } if (task.CompleteDate != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskPercentComplete, 1.0)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskComplete, true)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskCompletedDate, task.CompleteDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskStatus, EwsTaskStatus.Completed)); } else { if (task.Recurrence != null) { builder.AppendLine(EwsTaskSchema.BuildSetFieldRawValueXml(EwsFieldUri.Recurrence, task.Recurrence.BuildXml())); } if (task.PercentComplete > 0) { builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskPercentComplete, task.PercentComplete)); builder.AppendLine(EwsTaskSchema.BuildSetFieldValueXml(EwsFieldUri.TaskStatus, EwsTaskStatus.InProgress)); } } string xml = string.Format(template, builder.ToString()); return(xml); }
public async Task <UpdateItemsResult> UpdateItemAsync(EwsTask task) { return(await this.UpdateItemsAsync(new[] { task })); }
public async Task <CreateItemsResult> CreateItemAsync(EwsTask task, EwsFolderIdentifier parentFolder = null) { return(await this.CreateItemAsync(new[] { task }, parentFolder)); }
public EwsTask BuildTask() { var task = new EwsTask(); foreach (var property in this.properties) { int propertyId = property.Item1; string value = property.Item2; var definition = EwsTaskSchema.GetPropertyDefinition(propertyId); switch (definition.FieldUri) { case EwsFieldUri.TaskTitle: task.Subject = EwsXmlHelper.ReadStringAs <string>(value); break; case EwsFieldUri.TaskDueDate: task.DueDate = EwsXmlHelper.ReadStringAs <DateTime>(value); break; case EwsFieldUri.TaskStartDate: task.StartDate = EwsXmlHelper.ReadStringAs <DateTime>(value); break; case EwsFieldUri.TaskOrdinalDate: task.OrdinalDate = EwsXmlHelper.ReadStringAs <DateTime>(value); break; case EwsFieldUri.TaskSubOrdinalDate: task.SubOrdinalDate = EwsXmlHelper.ReadStringAs <string>(value); break; case EwsFieldUri.TaskCompletedDate: task.CompleteDate = EwsXmlHelper.ReadStringAs <DateTime>(value); break; case EwsFieldUri.TaskComplete: task.Complete = EwsXmlHelper.ReadStringAs <bool>(value); break; case EwsFieldUri.TaskIsRecurring: task.IsRecurring = EwsXmlHelper.ReadStringAs <bool>(value); break; case EwsFieldUri.TaskIsDeadOccurence: task.IsDeadOccurence = EwsXmlHelper.ReadStringAs <bool>(value); break; case EwsFieldUri.TaskPercentComplete: task.PercentComplete = EwsXmlHelper.ReadStringAs <double>(value); break; case EwsFieldUri.TaskStatus: task.Status = EwsXmlHelper.ReadStringAs <EwsTaskStatus>(value); break; default: Debugger.Break(); break; } } return(task); }
private string GetTaskXmlChanges(EwsTask task) { var builder = new StringBuilder(); if (task.Changes.HasFlag(EwsFields.Body) && task.Type == EwsItemType.Task) { if (!string.IsNullOrEmpty(task.Body)) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.Body, task.Body, new EwsAttributes { { "BodyType", task.BodyType.ToString() } })); } else { builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.Body)); } } if (task.Changes.HasFlag(EwsFields.Categories)) { if (task.Categories != null) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.Categories, task.Categories)); } else { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.Categories, new string[0])); } } if (task.Changes.HasFlag(EwsFields.Importance)) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.Importance, task.Importance)); } if (task.Changes.HasFlag(EwsFields.Subject)) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagSubject, task.Subject)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagSubjectPrefix, string.Empty)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.NormalizedSubject, task.Subject)); if (task.Type == EwsItemType.Item) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskTitle, task.Subject)); } } if (task.Changes.HasFlag(EwsFields.StartDate)) { if (task.StartDate.HasValue) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.CommonStart, task.StartDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskStartDate, task.StartDate.Value, DateTimeKind.Local)); } else { builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.CommonStart)); builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TaskStartDate)); } } if (task.Changes.HasFlag(EwsFields.DueDate)) { if (task.DueDate.HasValue) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.CommonEnd, task.DueDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskDueDate, task.DueDate.Value, DateTimeKind.Local)); } else { builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.CommonEnd)); builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TaskDueDate)); } } bool hasSetPercentComplete = false; if (task.Type == EwsItemType.Task) { if (task.Changes.HasFlag(EwsFields.CompleteDate)) { if (task.CompleteDate.HasValue) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.FlagRequest, string.Empty)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskCompletedDate, task.CompleteDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskComplete, true)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskStatus, EwsTaskStatus.Completed)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskPercentComplete, 1.0)); hasSetPercentComplete = true; } else { builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TaskCompletedDate)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskComplete, false)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskStatus, EwsTaskStatus.NotStarted)); } } } else { if (task.CompleteDate.HasValue) { //string str = task.CompleteDate.ToExchangeString(DateTimeKind.Utc); //TagFlagStatus "Integer", 4240, (string)null, (object)MapiConstants.PidLidTaskStatusEnum.Completed)); //TagFlagCompleteTime "SystemTime", 4241, (string)null, (object)str)); //ReplyRequested "Boolean", 3095, (string)null, (object)false)); //ResponseRequested "Boolean", 99, (string)null, (object)false)); //TagToDoItemFlags "Integer", 3627, (string)null, (object)1)); //TaskCompletedDate "SystemTime", 33039, "00062003-0000-0000-C000-000000000046", (object)str)); //TaskComplete "Boolean", 33052, "00062003-0000-0000-C000-000000000046", (object)true)); //TaskStatus "Integer", 33025, "00062003-0000-0000-C000-000000000046", (object)MapiConstants.PidLidTaskStatusEnum.Completed)); //TaskPercentComplete "Double", 33026, "00062003-0000-0000-C000-000000000046", (object)1f)); //ReminderSet "Boolean", 34051, "00062008-0000-0000-C000-000000000046", (object)false)); //TagFollowupIcon "Integer", 4245, (string)null)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagFlagStatus, (int)PidLidTaskStatusEnum.Completed)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagFlagCompleteTime, task.CompleteDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReplyRequested, false)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ResponseRequested, false)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagToDoItemFlags, 1)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskCompletedDate, task.CompleteDate.Value, DateTimeKind.Utc)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskComplete, true)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskStatus, (int)PidLidTaskStatusEnum.Completed)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskPercentComplete, 1.0)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReminderSet, false)); builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TagFollowupIcon)); } else { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagFlagStatus, (int)PidTagTaskStatusEnum.Flagged)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReplyRequested, true)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ResponseRequested, true)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagToDoItemFlags, 1)); builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TagFlagCompleteTime)); builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.TaskCompletedDate)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskComplete, false)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskStatus, (int)PidLidTaskStatusEnum.InProgress)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskPercentComplete, 0.0)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReminderSet, false)); builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagFollowupIcon, (int)PidTagFollowupIconEnum.Followup)); } } if (task.Changes.HasFlag(EwsFields.PercentComplete) && !hasSetPercentComplete) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskPercentComplete, task.PercentComplete)); } if (task.Changes.HasFlag(EwsFields.Recurrence) && task.Type == EwsItemType.Task) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskIsRecurring, task.IsRecurring)); if (task.Recurrence != null) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldRawValueXml(EwsFieldUri.Recurrence, task.Recurrence.BuildXml())); } else { builder.AppendLine(EwsTaskSchema.BuildClearFieldValueXml(EwsFieldUri.Recurrence)); } builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TaskIsDeadOccurence, task.IsDeadOccurence)); if (task.IsRecurring && !task.IsDeadOccurence) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagIconIndex, (int)EwsTagIconIndex.UnassignedRecurringTask)); } else { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.TagIconIndex, (int)EwsTagIconIndex.Task)); } } if (task.Changes.HasFlag(EwsFields.Reminder)) { if (task.ReminderDate.HasValue) { builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReminderDueBy, task.ReminderDate.Value, DateTimeKind.Utc)); } // note: delete is not supported for the ReminderDueBy field builder.AppendLine(EwsTaskSchema.BuildUpdateFieldValueXml(EwsFieldUri.ReminderIsSet, task.ReminderIsSet, false)); } var content = builder.ToString(); return(content); }