Exemplo n.º 1
0
 /// <summary>
 /// Sets the DueDate or Completion Date depending on status (pending or complete)
 /// </summary>
 /// <param name="node"></param>
 /// <param name="value"></param>
 public static void SetEndDate(this MapNode node, DateTime value)
 {
     if (node.IsTaskComplete())
     {
         CompletionDateAttribute.SetCompletionDate(node, value);
     }
     else
     {
         DueDateAttribute.SetDueDate(node, value);
     }
 }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if Due Date attribute exists on the given node
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public static bool DueDateExists(this MapNode node)
 {
     MapTree.AttributeSpec aspec = DueDateAttribute.GetAttributeSpec(node.Tree);
     if (aspec != null)
     {
         return(node.ContainsAttribute(aspec));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Get the date on which task is to be due.
 /// Throws exception if there is no Due Date attribute.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public static DateTime GetDueDate(this MapNode node)
 {
     MapNode.Attribute att;
     DueDateAttribute.GetAttribute(node, out att);
     return(DateHelper.ToDateTime(att.ValueString));
 }