public List <MyTree.MyTitle> BuildRegTree() { var groups = m_groups; var regs = getRegister(); List <MyTree.MyTitle> titleLst = new List <MyTree.MyTitle>(); Dictionary <UInt64, MyUser> userDict = new Dictionary <ulong, MyUser>(); foreach (MyUser user in m_users) { if (userDict.ContainsKey(user.ID)) { } else { userDict.Add(user.ID, user); } } foreach (MyReg reg in regs) { if (!userDict.ContainsKey(reg.userID)) { continue; } reg.user = userDict[reg.userID]; MyGroup grp = groups.Find(x => x.nGroup == reg.user.nGroup); MyTree.MyTitle title = new MyTree.MyTitle(); title.title = reg.user.zUserFb; title.path = string.Format("register/{0}/{1}", grp.zGroup, title.title); title.content = string.Format("{0} ({1})", reg.nStatus, reg.zNote); titleLst.Add(title); userDict.Remove(reg.userID); } foreach (MyUser user in userDict.Values) { MyGroup grp = groups.Find(x => x.nGroup == user.nGroup); MyTree.MyTitle title = new MyTree.MyTitle(); title.title = user.zUserFb; title.path = string.Format("un-register/{0}/{1}", grp.zGroup, title.title); titleLst.Add(title); } return(titleLst); }
void moveNode(MyNode node) { MyNode root = m_nodes["root"]; MyNode regNode = m_nodes["register"]; MyNode unregNode = m_nodes["un-register"]; MyReg reg = node.data as MyReg; MyGroup grp = m_groups.Find(x => x.nGroup == reg.user.nGroup); MyNode grpNode; //register grpNode = regNode.childs.Find(x => x.zTitle == grp.zGroup); if (grpNode != null) { if (!grpNode.childs.Contains(node)) { grpNode.childs.Add(node); } } else { grpNode = new MyNode() { zTitle = grp.zGroup }; regNode.childs.Add(grpNode); grpNode.childs.Add(node); } //un-register grpNode = unregNode.childs.Find(x => x.zTitle == grp.zGroup); if (grpNode != null) { if (grpNode.childs.Contains(node)) { grpNode.childs.Remove(node); if (grpNode.childs.Count == 0) { unregNode.childs.Remove(grpNode); } } } updateTree(root); }
private void AddBtn_Click(object sender, EventArgs e) { int nOpt; string zOpt; var txt = optTxt.Text; bool v = ParseOpt(txt, out zOpt, out nOpt); if (!v) { return; } var zUserFb = userCmb.Text; MyUser user = m_users.Find(x => x.zUserFb == zUserFb); var zProg = progCmb.Text; MyProgram prog = m_programs.Find(x => x.zName == zProg); MyReg myReg = new MyReg(); myReg.userID = user.ID; myReg.programID = prog.ID; myReg.nStatus = nOpt; myReg.zNote = zOpt; int ret = m_cp.AddUpdateReg(myReg); //add to ricktext richTextBox1.SelectedText = user.zUserFb + string.Format("({0}-{1})\n", nOpt, zOpt); richTextBox1.ScrollToCaret(); MyTree.MyTitle title = new MyTree.MyTitle(); MyGroup grp = m_groups.Find(x => x.nGroup == user.nGroup); title.title = user.zUserFb; title.content = string.Format("{0} ({1})", nOpt, zOpt); title.path = string.Format("register/{0}/{1}", grp.zGroup, user.zUserFb); var nRet = m_treeMng.Add(title); if (nRet == 1) { title.path = string.Format("un-register/{0}/{1}", grp.zGroup, user.zUserFb); m_treeMng.Remove(title); } }