private bool SaveWorkItem(TaskUpdate taskUpdate) { var workItem = taskUpdate.DisplayTask.workItem; //Add nonexistant attachments foreach (var attachment in taskUpdate.DisplayTask.Attachments) { var found = false; foreach (Attachment workItemAttachment in workItem.Attachments) { if (attachment.FileName == workItemAttachment.Name) { found = true; } } if (!found) { workItem.Attachments.Add(attachment.Attachment); } } //Delete removed attachments var removedAttachments = new List <Attachment>(); foreach (Attachment workItemAttachment in workItem.Attachments) { var found = false; foreach (var attachment in taskUpdate.DisplayTask.Attachments) { if (attachment.FileName == workItemAttachment.Name) { found = true; } } if (!found) { removedAttachments.Add(workItemAttachment); } } foreach (var removedAttachment in removedAttachments) { workItem.Attachments.Remove(removedAttachment); } var savedCorrectly = SaveWorkItem(workItem); if (savedCorrectly && workItem.Id != 0 && taskUpdate.ParentID != 0) { SaveWorkItemToParent(workItem.Id, taskUpdate.ParentID); } return(savedCorrectly); }
public DisplayTask(string taskType) { var WIC = UICommon.GetProperty("WIC") as WorkItemController; workItem = WIC.GetNewWorkItem(taskType); workItem["Stack Rank"] = 500; LinkedTasks = new ObservableCollection <DisplayTask>(); Attachments = new ObservableCollection <TaskAttachment>(); Update = new TaskUpdate(); borderColor = DefaultBorderColor; BuildFieldList(); }
public DisplayTask(WorkItem workItem) { this.workItem = workItem; LinkedTasks = new ObservableCollection <DisplayTask>(); Attachments = new ObservableCollection <TaskAttachment>(); Update = new TaskUpdate(); Attachments = new ObservableCollection <TaskAttachment>(); if (workItem.Attachments != null) { foreach (Attachment attachment in workItem.Attachments) { Attachments.Add(new TaskAttachment(attachment, this)); } } borderColor = DefaultBorderColor; BuildFieldList(); }
public void QueueTaskUpdate(TaskUpdate task) { UpdateQueue.Add(task); mainWindow.UpdateQueueCount(); }