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"); }
private static void saveFocus() { output += "saveFocus\n"; List <int> list1 = new List <int>(); List <int> list2 = new List <int>(); for (int i = 0; i < count / 2; i++) { list1.Add(tags[i].TagId); } for (int i = count / 2; i < count; i++) { list2.Add(tags[i].TagId); } // 第一次测试 output += "第一次测试:\n"; if (!FocusAndCreateTag.saveFocus(list1, sampleUser.UserId)) { output += "Error! saveFocus调用失败!返回false\n"; errorCount++; return; } else { output += "Ok! saveFocus调用成功!返回true\n"; } // 第一次测试成果检查 List <int> result1 = User2TagManager.getTagListByUserId(sampleUser); if (result1 == null) { output += "Error! saveFocus执行失败!getTagListByUserId返回值为null。\n"; errorCount++; return; } if (result1.Count < count / 2 - 1) { output += "Error! 通过getTagListByUserId返回列表长度(=" + result1.Count + ")小于测试用例数量!\n"; errorCount++; } else { output += "Ok! 通过getTagListByUserId返回列表长度(=" + result1.Count + ")不少于测试用例数量!\n"; } // 第二次测试 output += "第二次测试:\n"; if (!FocusAndCreateTag.saveFocus(list2, sampleUser.UserId)) { output += "Error! saveFocus调用失败!返回false\n"; errorCount++; return; } else { output += "Ok! saveFocus调用成功!返回true\n"; } // 第二次测试成果检查 List <int> result2 = User2TagManager.getTagListByUserId(sampleUser); if (result2 == null) { output += "Error! saveFocus执行失败!getTagListByUserId返回值为null。\n"; errorCount++; return; } if (result2.Count < count / 2 - 1) { output += "Error! 通过getTagListByUserId返回列表长度(=" + result2.Count + ")小于测试用例数量!\n"; errorCount++; } else { output += "Ok! 通过getTagListByUserId返回列表长度(=" + result2.Count + ")不少于测试用例数量!\n"; } }