コード例 #1
0
        /// <summary>
        /// Add new contact
        /// </summary>
        /// <param name="contact">the contact to add</param>
        public static XmlElement Add(Contact contact)
        {
            if (!ContactExists(contact))
            {
                //
                // <c />
                //
                XmlElement ct = db.Doc.CreateElement(ContactTag);

                ct.SetAttribute(XmlDatabase.IdAttribute, contact.ID);
                ct.SetAttribute(NameAttribute, contact.RawName);
                ct.SetAttribute(WorkAttribute, contact.RawWork);
                ct.SetAttribute(EmailAttribute, contact.RawEmail);
                ct.SetAttribute(WebSiteAttribute, contact.RawWebsite);
                ct.SetAttribute(IMAttribute, contact.RawIM);
                ct.SetAttribute(PhoneAttribute, contact.RawPhone);
                ct.SetAttribute(AddressAttribute, contact.RawAddress);
                ct.SetAttribute(DateAttribute, contact.RawSpecialDate);
                ct.SetAttribute(TileAttribute, contact.RawTile);
                ct.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(contact.ReadOnly));
                ct.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(contact.Private));
                ct.SetAttribute(GenderAttribute, ((byte)contact.Gender).ToString());

                SmartInsert(db.Doc.DocumentElement, ct, contact);

                return(ct);
            }

            return(null);
        }
コード例 #2
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Add a new page.
        /// </summary>
        /// <param name="page">the page to add</param>
        public static XmlElement Add(NotebookPage page)
        {
            if (!PageExists(page))
            {
                //
                // <p />
                //
                XmlElement nt = db.Doc.CreateElement(PageTag);

                nt.SetAttribute(XmlDatabase.IdAttribute, page.ID);
                nt.SetAttribute(TitleAttribute, page.Title);
                nt.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(page.ReadOnly));
                nt.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(page.Private));
                nt.SetAttribute(CreatedAttribute, FormatHelpers.DateTimeToString(page.Created));
                nt.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(page.LastModified));

                // If section has been deleted, ignore requests to add page.
                XmlElement section = db.Doc.GetElementById(page.SectionID);

                if (section != null)
                {
                    section.AppendChild(nt);
                }

                return(nt);
            }

            return(null);
        }
コード例 #3
0
ファイル: TaskDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Update the values on an existing task.
        /// </summary>
        /// <param name="task"></param>
        public static void UpdateTask(UserTask task)
        {
            if (task != null)
            {
                XmlElement tsk = db.Doc.GetElementById(task.ID);

                if (tsk != null)
                {
                    XmlNode parent = tsk.ParentNode;

                    DateTime?tskDate = null;

                    if (parent.Name != "nodate")
                    {
                        tskDate = FormatHelpers.SplitDateString(parent.Name);
                    }

                    if (task.DueDate == tskDate)
                    {
                        tsk.SetAttribute(SubjectAttribute, task.Subject);

                        if (task.StartDate == null)
                        {
                            tsk.SetAttribute(StartDateAttribute, "");
                        }
                        else
                        {
                            tsk.SetAttribute(StartDateAttribute, FormatHelpers.DateTimeToShortString(task.StartDate.Value));
                        }

                        tsk.SetAttribute(ReminderAttribute, FormatHelpers.DateTimeToString(task.Reminder));
                        tsk.SetAttribute(IsReminderEnabledAttribute, FormatHelpers.BoolToString(task.IsReminderEnabled));
                        tsk.SetAttribute(StatusAttribute, ((byte)task.Status).ToString());
                        tsk.SetAttribute(PriorityAttribute, ((byte)task.Priority).ToString());
                        tsk.SetAttribute(ProgressAttribute, task.Progress.ToString());
                        tsk.SetAttribute(CategoryAttribute, task.CategoryID);
                        tsk.SetAttribute(OwnerAttribute, task.Owner);
                        tsk.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(task.ReadOnly));
                        tsk.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(task.Private));
                        tsk.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(task.LastModified));
                    }
                    else
                    {
                        parent.RemoveChild(tsk);

                        if (!parent.HasChildNodes)
                        {
                            parent.ParentNode.RemoveChild(parent);
                        }

                        Add(task);
                    }
                }
                else
                {
                    Add(task);
                }
            }
        }
コード例 #4
0
ファイル: TaskDatabase.cs プロジェクト: mingslogar/dimension4
        public static void UpdateCategory(Category category)
        {
            XmlElement element = db.Doc.GetElementById(category.ID);

            if (element == null)
            {
                AddCategory(category);
            }
            else
            {
                element.SetAttribute(CategoryColorAttribute, category.Color.ToString());
                element.SetAttribute(CategoryNameAttribute, category.Name);
                element.SetAttribute(CategoryDescriptionAttribute, category.Description);
                element.SetAttribute(CategoryReadOnlyAttribute, FormatHelpers.BoolToString(category.ReadOnly));
            }
        }
コード例 #5
0
ファイル: TaskDatabase.cs プロジェクト: mingslogar/dimension4
        public static bool AddCategory(Category category)
        {
            if (GetCategory(category.ID) != null)
            {
                return(false);
            }

            XmlElement element = db.Doc.CreateElement(CategoryTag);

            element.SetAttribute(XmlDatabase.IdAttribute, category.ID);
            element.SetAttribute(CategoryColorAttribute, category.Color.ToString());
            element.SetAttribute(CategoryNameAttribute, category.Name);
            element.SetAttribute(CategoryDescriptionAttribute, category.Description);
            element.SetAttribute(CategoryReadOnlyAttribute, FormatHelpers.BoolToString(category.ReadOnly));

            db.Doc.DocumentElement.PrependChild(element);

            return(true);
        }
コード例 #6
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Update the values on an existing page.
        /// </summary>
        /// <param name="page"></param>
        public static void UpdatePage(NotebookPage page)
        {
            if (page != null)
            {
                XmlElement elem = db.Doc.GetElementById(page.ID);

                if (elem != null)
                {
                    elem.SetAttribute(TitleAttribute, page.Title);
                    elem.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(page.ReadOnly));
                    elem.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(page.Private));
                    elem.SetAttribute(CreatedAttribute, FormatHelpers.DateTimeToString(page.Created));
                    elem.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(page.LastModified));
                }
                else
                {
                    Add(page);
                }
            }
        }
コード例 #7
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Update the values on an existing section.
        /// </summary>
        /// <param name="section"></param>
        public static void UpdateSection(NotebookSection section)
        {
            if (section != null)
            {
                XmlElement elem = db.Doc.GetElementById(section.ID);

                if (elem != null)
                {
                    elem.SetAttribute(TitleAttribute, section.Title);
                    elem.SetAttribute(ColorAttribute, section.Color.ToString());
                    elem.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(section.ReadOnly));
                    elem.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(section.Private));
                    elem.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(section.LastModified));
                    elem.SetAttribute(LastSelectedAttribute, section.LastSelectedPageID);
                }
                else
                {
                    Add(section);
                }
            }
        }
コード例 #8
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Update the values on an existing notebook.
        /// </summary>
        /// <param name="notebook"></param>
        public static void UpdateNotebook(Notebook notebook)
        {
            if (notebook != null)
            {
                XmlElement elem = db.Doc.GetElementById(notebook.ID);

                if (elem != null)
                {
                    elem.SetAttribute(TitleAttribute, notebook.Title);
                    elem.SetAttribute(ColorAttribute, notebook.Color.ToString());
                    elem.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(notebook.ReadOnly));
                    elem.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(notebook.Private));
                    elem.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(notebook.LastModified));
                    elem.SetAttribute(LastSelectedAttribute, notebook.LastSelectedSectionID);
                }
                else
                {
                    Add(notebook);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Update the values on an existing contact.
        /// </summary>
        /// <param name="contact"></param>
        public static void UpdateContact(Contact contact)
        {
            if (contact != null)
            {
                XmlElement elem = db.Doc.GetElementById(contact.ID);

                if (elem != null)
                {
                    string oldName = elem.GetAttribute(NameAttribute);

                    // If the contact name changed, re-insert it into the database
                    // to ensure database stays in alphabetical order.
                    if (oldName != contact.RawName)
                    {
                        elem.SetAttribute(NameAttribute, contact.RawName);
                        elem.ParentNode.RemoveChild(elem);
                        SmartInsert(db.Doc.DocumentElement, elem, contact);
                    }

                    elem.SetAttribute(WorkAttribute, contact.RawWork);
                    elem.SetAttribute(EmailAttribute, contact.RawEmail);
                    elem.SetAttribute(WebSiteAttribute, contact.RawWebsite);
                    elem.SetAttribute(IMAttribute, contact.RawIM);
                    elem.SetAttribute(PhoneAttribute, contact.RawPhone);
                    elem.SetAttribute(AddressAttribute, contact.RawAddress);
                    elem.SetAttribute(DateAttribute, contact.RawSpecialDate);
                    elem.SetAttribute(TileAttribute, contact.RawTile);
                    elem.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(contact.ReadOnly));
                    elem.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(contact.Private));
                    elem.SetAttribute(GenderAttribute, ((byte)contact.Gender).ToString());
                }
                else
                {
                    Add(contact);
                }
            }
        }
コード例 #10
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Add a new notebook.
        /// </summary>
        /// <param name="section"></param>
        /// <returns></returns>
        public static XmlElement Add(NotebookSection section)
        {
            if (!SectionExists(section))
            {
                //
                // <n />
                //
                XmlElement nt = db.Doc.CreateElement(SectionTag);

                nt.SetAttribute(XmlDatabase.IdAttribute, section.ID);
                nt.SetAttribute(TitleAttribute, section.Title);
                nt.SetAttribute(ColorAttribute, section.Color.ToString());
                nt.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(section.ReadOnly));
                nt.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(section.Private));
                nt.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(section.LastModified));
                nt.SetAttribute(LastSelectedAttribute, section.LastSelectedPageID);

                db.Doc.GetElementById(section.NotebookID).AppendChild(nt);

                return(nt);
            }

            return(null);
        }
コード例 #11
0
ファイル: NoteDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Add a new notebook.
        /// </summary>
        /// <param name="notebook"></param>
        /// <returns></returns>
        public static XmlElement Add(Notebook notebook)
        {
            if (!NotebookExists(notebook))
            {
                //
                // <n />
                //
                XmlElement nt = db.Doc.CreateElement(NotebookTag);

                nt.SetAttribute(XmlDatabase.IdAttribute, notebook.ID);
                nt.SetAttribute(TitleAttribute, notebook.Title);
                nt.SetAttribute(ColorAttribute, notebook.Color.ToString());
                nt.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(notebook.ReadOnly));
                nt.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(notebook.Private));
                nt.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(notebook.LastModified));
                nt.SetAttribute(LastSelectedAttribute, notebook.LastSelectedSectionID);

                db.Doc.DocumentElement.AppendChild(nt);

                return(nt);
            }

            return(null);
        }
コード例 #12
0
ファイル: TaskDatabase.cs プロジェクト: mingslogar/dimension4
        /// <summary>
        /// Add new task.
        /// </summary>
        /// <param name="task">The task to add.</param>
        public static void Add(UserTask task)
        {
            XmlElement existing = db.Doc.GetElementById(task.ID);

            if (existing == null)
            {
                //
                // <yyyymmdd></yyyymmdd>
                //
                string date = "nodate";

                if (task.DueDate != null)
                {
                    date = FormatHelpers.DateString((DateTime)task.DueDate);
                }

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

                //
                // <t />
                //
                XmlElement tsk = db.Doc.CreateElement(TaskTag);

                tsk.SetAttribute(XmlDatabase.IdAttribute, task.ID);
                tsk.SetAttribute(SubjectAttribute, task.Subject);

                if (task.StartDate != null)
                {
                    tsk.SetAttribute(StartDateAttribute, FormatHelpers.DateTimeToShortString(task.StartDate.Value));
                }
                else
                {
                    tsk.SetAttribute(StartDateAttribute, "");
                }

                tsk.SetAttribute(ReminderAttribute, FormatHelpers.DateTimeToString(task.Reminder));
                tsk.SetAttribute(IsReminderEnabledAttribute, FormatHelpers.BoolToString(task.IsReminderEnabled));
                tsk.SetAttribute(StatusAttribute, ((byte)task.Status).ToString());
                tsk.SetAttribute(PriorityAttribute, ((byte)task.Priority).ToString());
                tsk.SetAttribute(ProgressAttribute, task.Progress.ToString());
                tsk.SetAttribute(CategoryAttribute, task.CategoryID);
                tsk.SetAttribute(OwnerAttribute, task.Owner);
                tsk.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(task.ReadOnly));
                tsk.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(task.Private));
                tsk.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(task.LastModified));

                if (existingDate == null)
                {
                    XmlElement elem = db.Doc.CreateElement(date);
                    elem.AppendChild(tsk);

                    if (task.DueDate != null)
                    {
                        db.Doc.SmartInsert(elem, (DateTime)task.DueDate, date);
                    }
                    else
                    {
                        db.Doc.DocumentElement.PrependChild(elem);
                    }
                }
                else
                {
                    existingDate.AppendChild(tsk);
                }
            }
        }