public bool DelMNodePService(string identify, int type, string pluginname) { MongoHelper <MNodePService> helpernps = new MongoHelper <MNodePService>(dbName); MNodePService ps = helpernps.FindAll(x => x.identify == identify).FirstOrDefault(); if (ps != null) { if (type == 0)//本地 { if (ps.localplugin.FindIndex(x => x == pluginname) != -1) { ps.localplugin.Remove(pluginname); } } else//远程 { RemotePService rps = ps.remoteplugin.Find(x => x.pluginname == pluginname); if (rps != null) { ps.remoteplugin.Remove(rps); } } helpernps.Update(ps); return(true); } return(false); }
public bool AddMNodePService(string identify, int type, string data) { MongoHelper <MNodePService> helpernps = new MongoHelper <MNodePService>(dbName); MNodePService ps = helpernps.FindAll(x => x.identify == identify).FirstOrDefault(); if (ps == null)//新增 { ps = new MNodePService(); //ps.id = ObjectId.Empty; ps.identify = identify; ps.pathstrategy = 0; ps.localplugin = new List <string>(); ps.remoteplugin = new List <RemotePService>(); helpernps.Insert(ps); } if (type == 0)//本地 { List <string> add_lp = JsonConvert.DeserializeObject <List <string> >(data); foreach (string p in add_lp) { if (ps.localplugin.FindIndex(x => x == p) == -1) { ps.localplugin.Add(p); } } } else//远程 { RemotePService add_rp = JsonConvert.DeserializeObject <RemotePService>(data); RemotePService rps = ps.remoteplugin.Find(x => x.pluginname == add_rp.pluginname); if (rps == null) { ps.remoteplugin.Add(add_rp); } else { rps = add_rp; } } helpernps.Update(ps); return(true); }
public Object GetMNodePService(string identify) { List <amazeuitreenode> tree = new List <amazeuitreenode>(); MongoHelper <MNodePService> helpernps = new MongoHelper <MNodePService>(dbName); MNodePService ps = helpernps.FindAll(x => x.identify == identify).FirstOrDefault(); if (ps != null) { MongoHelper <MidNode> helperNode = new MongoHelper <MidNode>(dbName); List <MidNode> nodeList = helperNode.FindAll(); amazeuitreenode root = new amazeuitreenode(); root.title = nodeList.Find(x => x.identify == ps.identify).nodename + "(" + ps.identify + ")"; root.type = "folder"; root.childs = new List <amazeuitreenode>(); tree.Add(root); //本地插件 amazeuitreenode l_root = new amazeuitreenode(); l_root.title = "本地插件服务"; l_root.type = "folder"; l_root.childs = new List <amazeuitreenode>(); root.childs.Add(l_root); foreach (string p in ps.localplugin) { amazeuitreenode node_lp = new amazeuitreenode(); node_lp.title = p; node_lp.type = "item"; node_lp.attr = new Dictionary <string, string>(); node_lp.attr.Add("type", "localplugin"); node_lp.attr.Add("value", p); l_root.childs.Add(node_lp); } //远程插件 amazeuitreenode r_root = new amazeuitreenode(); r_root.title = "远程插件服务"; r_root.type = "folder"; r_root.childs = new List <amazeuitreenode>(); root.childs.Add(r_root); foreach (var p in ps.remoteplugin) { amazeuitreenode node_rp = new amazeuitreenode(); node_rp.title = p.pluginname; node_rp.type = "folder"; //node_rp.attr = new Dictionary<string, string>(); //node_rp.attr.Add("type", "remoteplugin"); //node_rp.attr.Add("value", p.pluginname); node_rp.childs = new List <amazeuitreenode>(); r_root.childs.Add(node_rp); foreach (string i in p.mnodeidentify) { amazeuitreenode node = new amazeuitreenode(); node.title = nodeList.Find(x => x.identify == i).nodename; node.type = "item"; node.attr = new Dictionary <string, string>(); node.attr.Add("type", "remoteplugin"); node.attr.Add("value", p.pluginname); node_rp.childs.Add(node); } } } return(tree); }