示例#1
0
        /// <summary>
        /// Get all tasks.
        /// </summary>
        /// <returns></returns>
        public static UserTask[] GetTasks()
        {
            XmlNodeList tsks = db.Doc.GetElementsByTagName(TaskTag);

            int count = tsks.Count;

            if (count != 0)
            {
                UserTask[] tasks = new UserTask[count];

                for (int i = 0; i < count; i++)
                {
                    //
                    // <t />
                    //
                    XmlNode node = tsks.Item(i);
                    XmlAttributeCollection attribs = node.Attributes;

                    tasks[i]    = new UserTask(false);
                    tasks[i].ID = attribs[XmlDatabase.IdAttribute].Value;

                    if (node.ParentNode.Name != "nodate")
                    {
                        tasks[i].DueDate = FormatHelpers.SplitDateString(node.ParentNode.Name);
                    }
                    else
                    {
                        tasks[i].DueDate = null;
                    }

                    if (attribs[StartDateAttribute].Value == "")
                    {
                        tasks[i].StartDate = null;
                    }
                    else
                    {
                        tasks[i].StartDate = FormatHelpers.ParseShortDateTime(attribs[StartDateAttribute].Value);
                    }

                    tasks[i].Subject           = attribs[SubjectAttribute].Value;
                    tasks[i].Reminder          = FormatHelpers.ParseDateTime(attribs[ReminderAttribute].Value);
                    tasks[i].IsReminderEnabled = FormatHelpers.ParseBool(attribs[IsReminderEnabledAttribute].Value);
                    tasks[i].Status            = (UserTask.StatusPhase) byte.Parse(attribs[StatusAttribute].Value);
                    tasks[i].Priority          = (Priority)byte.Parse(attribs[PriorityAttribute].Value);
                    tasks[i].Progress          = double.Parse(attribs[ProgressAttribute].Value);
                    tasks[i].CategoryID        = attribs[CategoryAttribute].Value;
                    tasks[i].Owner             = attribs[OwnerAttribute].Value;
                    tasks[i].ReadOnly          = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
                    tasks[i].Private           = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
                    tasks[i].LastModified      = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);
                }

                return(tasks);
            }

            return(null);
        }
示例#2
0
        public static UserTask GetTask(string id)
        {
            XmlElement element = db.Doc.GetElementById(id);

            if (element == null)
            {
                return(null);
            }

            XmlAttributeCollection attribs = element.Attributes;

            UserTask task = new UserTask(false);

            task.ID = id;

            if (element.ParentNode.Name != "nodate")
            {
                task.DueDate = FormatHelpers.SplitDateString(element.ParentNode.Name);
            }
            else
            {
                task.DueDate = null;
            }

            if (attribs[StartDateAttribute].Value == "")
            {
                task.StartDate = null;
            }
            else
            {
                task.StartDate = FormatHelpers.ParseShortDateTime(attribs[StartDateAttribute].Value);
            }

            task.Subject           = attribs[SubjectAttribute].Value;
            task.Reminder          = FormatHelpers.ParseDateTime(attribs[ReminderAttribute].Value);
            task.IsReminderEnabled = FormatHelpers.ParseBool(attribs[IsReminderEnabledAttribute].Value);
            task.Status            = (UserTask.StatusPhase) byte.Parse(attribs[StatusAttribute].Value);
            task.Priority          = (Priority)byte.Parse(attribs[PriorityAttribute].Value);
            task.Progress          = double.Parse(attribs[ProgressAttribute].Value);
            task.CategoryID        = attribs[CategoryAttribute].Value;
            task.Owner             = attribs[OwnerAttribute].Value;
            task.ReadOnly          = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            task.Private           = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            task.LastModified      = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);

            return(task);
        }
示例#3
0
        public static NotebookPage GetPage(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }

            XmlAttributeCollection attribs = node.Attributes;

            NotebookPage page = new NotebookPage(false);

            page.ID           = attribs[XmlDatabase.IdAttribute].Value;
            page.SectionID    = node.ParentNode.Attributes[XmlDatabase.IdAttribute].Value;
            page.Title        = attribs[TitleAttribute].Value;
            page.ReadOnly     = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            page.Private      = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            page.Created      = FormatHelpers.ParseDateTime(attribs[CreatedAttribute].Value);
            page.LastModified = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);

            return(page);
        }
示例#4
0
        public static Notebook GetNotebook(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }

            XmlAttributeCollection attribs = node.Attributes;

            Notebook notebook = new Notebook(false);

            notebook.ID                    = attribs[XmlDatabase.IdAttribute].Value;
            notebook.Title                 = attribs[TitleAttribute].Value;
            notebook.Color                 = (Color)ColorConverter.ConvertFromString(attribs[ColorAttribute].Value);
            notebook.ReadOnly              = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            notebook.Private               = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            notebook.LastModified          = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);
            notebook.LastSelectedSectionID = attribs[LastSelectedAttribute].Value;

            return(notebook);
        }
示例#5
0
        public static NotebookSection GetSection(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }

            XmlAttributeCollection attribs = node.Attributes;

            NotebookSection section = new NotebookSection(false);

            section.ID                 = attribs[XmlDatabase.IdAttribute].Value;
            section.NotebookID         = node.ParentNode.Attributes[XmlDatabase.IdAttribute].Value;
            section.Title              = attribs[TitleAttribute].Value;
            section.Color              = (Color)ColorConverter.ConvertFromString(attribs[ColorAttribute].Value);
            section.ReadOnly           = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            section.Private            = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            section.LastModified       = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);
            section.LastSelectedPageID = attribs[LastSelectedAttribute].Value;

            return(section);
        }
示例#6
0
        /// <summary>
        /// Get all tasks tagged with the specified date.
        /// </summary>
        /// <param name="dueDate">the date tasks should be returned for</param>
        public static UserTask[] GetTasks(DateTime?dueDate)
        {
            //
            // <yyyymmdd></yyyymmdd>
            //
            string datestring = "nodate";

            if (dueDate != null)
            {
                datestring = FormatHelpers.DateString((DateTime)dueDate);
            }

            XmlNode existingDate = db.Doc.SelectSingleNode("/db/" + datestring);

            if (existingDate != null)
            {
                XmlNodeList tsks = existingDate.ChildNodes;

                int count = tsks.Count;

                if (count != 0)
                {
                    UserTask[] tasks = new UserTask[count];

                    for (int i = 0; i < count; i++)
                    {
                        //
                        // <t />
                        //
                        XmlNode node = tsks.Item(i);
                        XmlAttributeCollection attribs = node.Attributes;

                        tasks[i]         = new UserTask(false);
                        tasks[i].ID      = attribs[XmlDatabase.IdAttribute].Value;
                        tasks[i].DueDate = dueDate;

                        if (attribs[StartDateAttribute].Value == "")
                        {
                            tasks[i].StartDate = null;
                        }
                        else
                        {
                            tasks[i].StartDate = FormatHelpers.ParseShortDateTime(attribs[StartDateAttribute].Value);
                        }

                        tasks[i].Subject           = attribs[SubjectAttribute].Value;
                        tasks[i].Reminder          = FormatHelpers.ParseDateTime(attribs[ReminderAttribute].Value);
                        tasks[i].IsReminderEnabled = FormatHelpers.ParseBool(attribs[IsReminderEnabledAttribute].Value);
                        tasks[i].Status            = (UserTask.StatusPhase) byte.Parse(attribs[StatusAttribute].Value);
                        tasks[i].Priority          = (Priority)byte.Parse(attribs[PriorityAttribute].Value);
                        tasks[i].Progress          = double.Parse(attribs[ProgressAttribute].Value);
                        tasks[i].CategoryID        = attribs[CategoryAttribute].Value;
                        tasks[i].Owner             = attribs[OwnerAttribute].Value;
                        tasks[i].ReadOnly          = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
                        tasks[i].Private           = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
                        tasks[i].LastModified      = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);
                    }

                    return(tasks);
                }

                return(null);
            }

            return(null);
        }