示例#1
0
        public static Contact GetContact(string id)
        {
            XmlElement element = db.Doc.GetElementById(id);

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

            XmlAttributeCollection attribs = element.Attributes;

            Contact contact = new Contact(false);

            contact.ID             = id;
            contact.RawName        = attribs[NameAttribute].Value;
            contact.RawWork        = attribs[WorkAttribute].Value;
            contact.RawEmail       = attribs[EmailAttribute].Value;
            contact.RawWebsite     = attribs[WebSiteAttribute].Value;
            contact.RawIM          = attribs[IMAttribute].Value;
            contact.RawPhone       = attribs[PhoneAttribute].Value;
            contact.RawAddress     = attribs[AddressAttribute].Value;
            contact.RawSpecialDate = attribs.GetValue(DateAttribute, DateAttributeDefault);
            contact.RawTile        = attribs[TileAttribute].Value;
            contact.ReadOnly       = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            contact.Private        = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            contact.Gender         = (Gender)byte.Parse(attribs.GetValue(GenderAttribute, GenderAttributeDefault));

            return(contact);
        }
示例#2
0
        /// <summary>
        /// Get all contacts.
        /// </summary>
        public static IEnumerable <Contact> GetContacts()
        {
            XmlNodeList contacts = db.Doc.SelectNodes("/db/" + ContactTag);

            foreach (XmlNode node in contacts)
            {
                //
                // <c />
                //
                XmlAttributeCollection attribs = node.Attributes;

                Contact c = new Contact(false);
                c.ID             = attribs[XmlDatabase.IdAttribute].Value;
                c.RawName        = attribs[NameAttribute].Value;
                c.RawWork        = attribs[WorkAttribute].Value;
                c.RawEmail       = attribs[EmailAttribute].Value;
                c.RawWebsite     = attribs[WebSiteAttribute].Value;
                c.RawIM          = attribs[IMAttribute].Value;
                c.RawPhone       = attribs[PhoneAttribute].Value;
                c.RawAddress     = attribs[AddressAttribute].Value;
                c.RawSpecialDate = attribs.GetValue(DateAttribute, DateAttributeDefault);
                c.RawTile        = attribs[TileAttribute].Value;
                c.ReadOnly       = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
                c.Private        = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);

                yield return(c);
            }
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        public static Category GetCategory(string id)
        {
            XmlElement element = db.Doc.GetElementById(id);

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

            XmlAttributeCollection attribs = element.Attributes;

            Category category = new Category(false);

            category.ID       = id;
            category.Name     = attribs[CategoryNameAttribute].Value;
            category.Color    = (Color)ColorConverter.ConvertFromString(attribs[CategoryColorAttribute].Value);
            category.ReadOnly = FormatHelpers.ParseBool(attribs[CategoryReadOnlyAttribute].Value);

            return(category);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
        public static Category[] GetCategories()
        {
            XmlNodeList elems = db.Doc.SelectNodes("/db/" + CategoryTag);

            Category[] categories = new Category[elems.Count];

            for (int i = 0; i < elems.Count; i++)
            {
                XmlAttributeCollection attribs = elems[i].Attributes;

                Category c = new Category(false);
                c.ID       = attribs[XmlDatabase.IdAttribute].Value;
                c.Color    = (Color)ColorConverter.ConvertFromString(attribs[CategoryColorAttribute].Value);
                c.Name     = attribs[CategoryNameAttribute].Value;
                c.ReadOnly = FormatHelpers.ParseBool(attribs[CategoryReadOnlyAttribute].Value);

                categories[i] = c;
            }

            return(categories);
        }
示例#9
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);
        }
示例#10
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);
        }