/// <summary> /// 导入收藏夹 /// </summary> /// <param name="document"></param> public void Import(BookmarkDocument document) { List <Hashtable> fieldsList = new List <Hashtable>(); List <BookmarkLink> links = document.RootFolder.AllChildLinks; foreach (BookmarkLink link in links) { //获取一条数据库空行 Hashtable fields = FavorField.EmptyRow(); fields[FavorField.Username] = Username; fields[FavorField.Title] = link.Title.Length > 250 ? link.Title.Substring(0, 250) : link.Title; fields[FavorField.Href] = link.Href; fields[FavorField.Tag] = link.Tag; fieldsList.Add(fields); } //批量添加 long[] idList = Favors.Add(fieldsList.ToArray()); Console.WriteLine("Insert ID Count: {0}", idList.Length); }
/// <summary> /// 添加收藏 /// </summary> protected void btnAdd_Click(object sender, EventArgs e) { if (!BookmarkContext.IsAuthenticated()) { if (txtUsername.Text != "latermoon" || txtPassword.Text != "1234") { Alert("密码错误"); return; } else { //在这里登陆 } } //在这里添加收藏 List <Hashtable> fieldsList = new List <Hashtable>(); //获取一条数据库空行 Hashtable fields = FavorField.EmptyRow(); fields[FavorField.Username] = txtUsername.Text; string txtTitle = Request["txtTitle"]; fields[FavorField.Title] = txtTitle.Length > 250 ? txtTitle.Substring(0, 250) : txtTitle; fields[FavorField.Href] = txtHref.Text; fields[FavorField.Tag] = Request["txtTag"]; fields["Remark"] = Request["txtRemark"]; fields[FavorField.FavorLevel] = Request["txtFavorLevel"]; fieldsList.Add(fields); BookmarkFavors Favors = new BookmarkFavors(new BookmarkUser(txtUsername.Text)); Favors.Add(fields); //批量添加 //long[] idList = Favors.Add(fieldsList.ToArray()); }