private void LoginButton_Click(object sender, EventArgs e) { string result; if (user_text.Text == "" || passwd_text.Text == "") { MessageBox.Show("请输入用户名和密码"); } else { m_post.PostItems.Clear(); m_post.Url = m_login_url; m_post.PostItems.Add("user", user_text.Text); m_post.PostItems.Add("passwd", passwd_text.Text); m_post.Type = PostSubmitter.PostTypeEnum.Post; result = m_post.Post(); result = "[" + result + "]"; m_userinfo = m_json.Deserialize <List <userinfo> >(result); if (m_userinfo[0].auth != "true") { MessageBox.Show("用户名或密码错误"); } else { m_passwd = passwd_text.Text; this.DialogResult = DialogResult.OK; } } }
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(); }