public static void CompleteTask(this MapNode node) { node.Tree.ChangeManager.StartBatch("Complete Task"); CompletionDateAttribute.SetCompletionDate(node, DateTime.Now); TaskStatusAttribute.SetTaskStatus(node, TaskStatus.Complete); node.Tree.ChangeManager.EndBatch(); }
public static void RemoveTask(this MapNode node) { node.Tree.ChangeManager.StartBatch("Remove Task"); DueDateAttribute.RemoveDueDate(node); CompletionDateAttribute.RemoveCompletionDate(node); TaskStatusAttribute.RemoveTaskStatus(node); node.RemoveStartDate(); node.Tree.ChangeManager.EndBatch(); }
/// <summary> /// Returns 'None' if TaskStatus is not set /// </summary> /// <param name="node"></param> /// <returns>Returns 'None' if TaskStatus is not set</returns> public static TaskStatus GetTaskStatus(this MapNode node) { MapNode.Attribute att; if (TaskStatusAttribute.GetAttribute(node, out att)) { return((TaskStatus)Enum.Parse(typeof(TaskStatus), att.ValueString)); } else { return(TaskStatus.None); } }
/// <summary> /// Checks if this attribute spec exists on the given node /// </summary> /// <param name="node"></param> /// <returns></returns> public static bool TaskStatusExists(MapNode node) { MapTree.AttributeSpec aspec = TaskStatusAttribute.GetAttributeSpec(node.Tree); if (aspec != null) { return(node.ContainsAttribute(aspec)); } else { return(false); } }
private static void OnAttributeAdded(MapNode node, AttributeChangeEventArgs e) { if (e.AttributeSpec.IsDueDate()) { if (node.GetTaskStatus() == TaskStatus.None) { TaskStatusAttribute.SetTaskStatus(node, TaskStatus.Open); } } else if (e.AttributeSpec.IsTaskStatus()) { if (node.GetTaskStatus() == TaskStatus.Complete && !node.CompletionDateExists()) { CompletionDateAttribute.SetCompletionDate(node, DateTime.Now); } } }
public static void AddTask(this MapNode node, DateTime dateTime) { if (!node.IsTaskPending()) { node.Tree.ChangeManager.StartBatch("Add Task"); DueDateAttribute.SetDueDate(node, dateTime); TaskStatusAttribute.SetTaskStatus(node, TaskStatus.Open); CompletionDateAttribute.RemoveCompletionDate(node); node.Tree.ChangeManager.EndBatch(); //node.AttributeBatchUpdate(new MapNode.Attribute[] // { // new MapNode.Attribute(DueDateAttribute.GetOrCreateAttributeSpec(node.Tree), DateHelper.ToString(dateTime)), // new MapNode.Attribute(TaskStatusAttribute.GetOrCreateAttributeSpec(node.Tree), TaskStatus.Open.ToString()) // }, // new MapTree.AttributeSpec[] // { // CompletionDateAttribute.GetOrCreateAttributeSpec(node.Tree) // }); } else { node.Tree.ChangeManager.StartBatch("Update Task Due Date"); if (node.StartDateExists()) { TimeSpan duration = node.GetDueDate() - node.GetStartDate(); node.SetStartDate(dateTime.Subtract(duration)); } DueDateAttribute.SetDueDate(node, dateTime); node.Tree.ChangeManager.EndBatch(); } }