private static void deleteTag() { output += "deleteTag\n"; List <int> list = User2TagManager.getTagListByUserId(sampleUser); foreach (int id in list) { User2Tag u2t2 = new User2Tag(sampleUser.UserId, id); if (!FocusAndCreateTag.deleteTag(u2t2)) { output += "Error! 删除User2Tag记录失败!\n"; errorCount++; } else { output += "Ok! 删除User2Tag记录成功!\n"; } } List <int> list2 = User2TagManager.getTagListByUserId(sampleUser); int list2_len = 0; if (list2 != null) { list2_len = list2.Count; } if (list2_len == list.Count) { output += "Error! 调用deleteTag前后getTagListByUserId返回的列表长度相同!未能真正删除User2Tag记录!\n"; } }
protected void Button1_Click(object sender, EventArgs e) { /* * List<GroupNode> tempList = new List<GroupNode>(); * GroupNode g1 = new GroupNode("a", 0, true, 5, false); * GroupNode g2 = new GroupNode("b", 0, false, 2, false); * GroupNode g3 = new GroupNode("c", 0, false, 1, false); * GroupNode g4 = new GroupNode("d", 1, false, 3, false); * GroupNode g5 = new GroupNode("e", 1, true, 1, false); * GroupNode g6 = new GroupNode("f", 0, false, 4, false); * GroupNode g7 = new GroupNode("g", 1, false, 0, false); * tempList.Add(g1); * tempList.Add(g2); * tempList.Add(g3); * tempList.Add(g4); * tempList.Add(g5); * tempList.Add(g6); * tempList.Add(g7); * tempList.Sort(); * String df = ""; * foreach (GroupNode wu in tempList) * df = df + wu.PrimaryGroupId + wu.Id; * TextBox1.Text = df; * */ //把所有打勾的子分类的主分类都打上勾 foreach (TreeView tv in tvs) { TreeNode ptn = tv.Nodes[0]; TreeNodeCollection ptnc = ptn.ChildNodes; foreach (TreeNode tn in ptnc) { if (tn.Checked) { ptn.Checked = true; break; } } } List <int> focuses = new List <int>(); foreach (TreeNode tn in alltns) { GroupNode gn = (GroupNode)map[tn]; if (gn.IsPrimaryGroup && tn.Checked) { GroupNode pgn = (GroupNode)p2o[tn]; focuses.Add(pgn.Id); continue; } if (gn.IsInterestLabel && !tn.Checked) { FocusAndCreateTag.deleteTag(new User2Tag(user.UserId, gn.Id)); continue; } if (tn.Checked) { focuses.Add(gn.Id); } } /* * foreach (TreeView tv in tvs) * { * TreeNode primary = tv.Nodes[0]; * GroupNode primarygp = (GroupNode)map[primary]; * if (primary.Checked) * { * GroupNode pgn = (GroupNode)p2o[primary]; * focuses.Add(pgn.Id); * } * * * TreeNodeCollection tnc = primary.ChildNodes; * foreach (TreeNode tn in tnc) * { * GroupNode gn = (GroupNode)map[tn]; * if (gn == null) * continue; * * if ((!gn.IsInterestLabel) && tn.Checked) * focuses.Add(gn.Id); * } * } * */ bool answer = FocusAndCreateTag.saveFocus(focuses, user.UserId); //Response.Redirect("FocusSelect.aspx"); }