public static int join_device_add(int groupid, long id_parent, long id_key, long[] vals) { vals = vals.Where(x => x > 1000000).ToArray(); List <long> ls = new List <long>() { }; if (vals.Length > 0) { List <long> ls0 = new List <long>() { }; lock (lock_ID_device_near) ls0 = dic_ID_device_near.AddListDistinctItem(id_key, vals); update_ID_device_near(id_key, ls0); lock (lock_ID_device_all) ls = dic_ID_device_all.AddListDistinctItem(id_key, vals); update_ID_device_all(id_key, ls); cache_node_set(groupid, id_key); List <long> ls_parent = new List <long>() { }; var dp = dic_ID_parent .Where(x => x.Value.IndexOf(id_parent) != -1) .Select(x => x.Value.ToArray()).ToArray(); foreach (var ids in dp) { ls_parent.AddRange(ids); } ls_parent = ls_parent.Where(x => x != id_key).Distinct().ToArray().Reverse().ToList(); foreach (long id in ls_parent) { if (id > 0) { List <long> lsi = new List <long>() { }; lock (lock_ID_device_all) lsi = dic_ID_device_all.AddListDistinctItem(id, ls.ToArray()); lsi = lsi.Where(x => x > 1000000).ToList(); update_ID_device_all(id, lsi); } } foreach (long id in ls_parent) { cache_node_set(groupid, id); } dbCache.clear(typeof(m_meter).FullName); } return(ls.Count); }