Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }