Beispiel #1
0
        // 获取所有的Notebook、Section、Page
        public List <NoteBook> get_all_page()
        {
            update_xml();
            List <NoteBook> output = new List <NoteBook>();

            // 第一层循环是找到Notebook
            foreach (var notebook in from node in m_OneNote_XML.Descendants(m_namespace + "Notebook") select node)
            {
                NoteBook notebookinfo = new NoteBook();
                notebookinfo.section = new List <Section>();

                notebookinfo.ID = notebook.Attribute("ID").Value;
                notebookinfo.lastmodifiedtime = notebook.Attribute("lastModifiedTime").Value;
                notebookinfo.name             = notebook.Attribute("name").Value;
                notebookinfo.nickname         = notebook.Attribute("nickname").Value;

                // 第二层循环找到Section
                foreach (var section in from node in notebook.Descendants(m_namespace + "Section") select node)
                {
                    Section pSection = new Section();
                    pSection.page             = new List <Page>();
                    pSection.ID               = section.Attribute("ID").Value;
                    pSection.lastModifiedTime = section.Attribute("lastModifiedTime").Value;
                    pSection.name             = section.Attribute("name").Value;

                    // 第三层循环找到page
                    foreach (var page in from node in section.Descendants(m_namespace + "Page") select node)
                    {
                        Page pPage = new Page();
                        pPage.createTime       = page.Attribute("dateTime").Value;
                        pPage.ID               = page.Attribute("ID").Value;
                        pPage.lastModifiedTime = page.Attribute("lastModifiedTime").Value;
                        pPage.name             = page.Attribute("name").Value;
                        pPage.pageLevel        = page.Attribute("pageLevel").Value;
                        pSection.page.Add(pPage);
                    }
                    notebookinfo.section.Add(pSection);
                }
                output.Add(notebookinfo);
            }
            return(output);
        }
Beispiel #2
0
        private void sync_Click(object sender, EventArgs e)
        {
            string          result;
            List <NoteBook> output = new List <NoteBook>();
            int             i, j, k;

            i = 0;
            j = 0;
            k = 0;
            // 检测登录状况
            if (m_userinfo == null || !m_userinfo[0].auth.Equals("true"))
            {
                MessageBox.Show("未登录");
                return;
            }

            // 获得被选中的Notebook、Section、page
            foreach (TreeNode notebook in LocalOneNoteNode.Nodes)
            {
                NoteBook _notebook = new NoteBook();
                _notebook.section = new List <Section>();
                bool isSelect = false;
                j = 0;
                foreach (TreeNode section in notebook.Nodes)
                {
                    Section _section = new Section();
                    _section.page = new List <Page>();
                    bool issselect = false;
                    k = 0;
                    foreach (TreeNode page in section.Nodes)
                    {
                        Page _page     = new Page();
                        bool ispselect = false;
                        if (page.Checked == true)
                        {
                            isSelect  = true;
                            issselect = true;
                            ispselect = true;;
                        }
                        if (ispselect == true)
                        {
                            _page.createTime       = m_OneNote_Info[i].section[j].page[k].createTime;
                            _page.ID               = m_OneNote_Info[i].section[j].page[k].ID;
                            _page.lastModifiedTime = m_OneNote_Info[i].section[j].page[k].lastModifiedTime;
                            _page.name             = m_OneNote_Info[i].section[j].page[k].name;
                            _page.pageLevel        = m_OneNote_Info[i].section[j].page[k].pageLevel;
                            _section.page.Add(_page);
                        }
                        k++;
                    }
                    if (issselect == true)
                    {
                        _section.ID = m_OneNote_Info[i].section[j].ID;
                        _section.lastModifiedTime = m_OneNote_Info[i].section[j].lastModifiedTime;
                        _section.name             = m_OneNote_Info[i].section[j].name;
                        _notebook.section.Add(_section);
                    }
                    j++;
                }
                if (isSelect)
                {
                    _notebook.ID = m_OneNote_Info[i].ID;
                    _notebook.lastmodifiedtime = m_OneNote_Info[i].lastmodifiedtime;
                    _notebook.name             = m_OneNote_Info[i].name;
                    _notebook.nickname         = m_OneNote_Info[i].nickname;
                    output.Add(_notebook);
                }
                i++;
            }
            m_json.MaxJsonLength = 10240000;
            result = m_json.Serialize(output);


            // post
            m_post.PostItems.Clear();
            m_post.Url = m_syncurl;
            m_post.PostItems.Add("user", m_userinfo[0].user);
            m_post.PostItems.Add("passwd", m_passwd);
            m_post.PostItems.Add("content", result);
            m_post.Type = PostSubmitter.PostTypeEnum.Post;
            result      = m_post.Post();
        }