Exemplo n.º 1
0
        public static void load()
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string path_file = path + file_name + ".mmf";

            list_DCU = hostFile.read_file_MMF <m_dcu>(path_file).ToList();

            for (int k = 0; k < list_DCU.Count; k++)
            {
                m_dcu it = list_DCU[k];
                it.is_online = false;
                list_DCU[k]  = it;
            }

            path_file = path + file_name + "_meter.mmf";
            var a = hostFile.read_file_MMF <Tuple <long, long[]> >(path_file);

            for (int k = 0; k < a.Length; k++)
            {
                var o = a[k];
                lock (lock_index)
                    dic_DCU_meter.AddListDistinct(o.Item1, o.Item2);
            }
        }
Exemplo n.º 2
0
        public static void join_ItemSub_Add(long id_key, long[] vals)
        {
            Task.Factory.StartNew(() =>
            {
                int k = 0;

                lock (lock_itemSub)
                {
                    k = dic_DienLuc_ItemSub.AddListDistinct(id_key, vals);
                }

                string s = string.Join(";", vals);
                join_update_itemsub(id_key, s);
            }).Start();
        }
Exemplo n.º 3
0
        public static int join_item_add(long id_key, long[] vals)
        {
            int k = 0;

            lock (lock_item)
            {
                k = dic_Nhom_Item.AddListDistinct(id_key, vals);
            }
            var ss = new List <long>()
            {
            };

            dic_Nhom_Item.TryGetValue(id_key, out ss);

            string s = string.Join(";", ss);

            update_item(id_key, s);
            dbCache.clear(typeof(m_meter).FullName);
            //db_kh_dienluc.join_ItemSub_Add(id_key, vals);

            return(k);
        }
Exemplo n.º 4
0
        public static void load()
        {
            if (!Directory.Exists(path_node))
            {
                Directory.CreateDirectory(path_node);
            }
            else
            {
                var ds = Directory.GetFiles(path_node, "*.mmf");
                for (int k = 0; k < ds.Length; k++)
                {
                    m_node o = hostFile.read_MMF <m_node>(ds[k]);
                    if (o.id != 0)
                    {
                        if (dic_node.ContainsKey(o.id) == false)
                        {
                            dic_node.Add(o.id, o);
                        }
                        if (dic_node_code.ContainsKey(o.code) == false)
                        {
                            dic_node_code.Add(o.code, o.id);
                        }
                    }
                }
            }

            if (!Directory.Exists(path_ID_parent))
            {
                Directory.CreateDirectory(path_ID_parent);
            }
            else
            {
                var ds = Directory.GetFiles(path_ID_parent, "*.mmf");
                for (int k = 0; k < ds.Length; k++)
                {
                    List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList();
                    if (ls.Count > 0)
                    {
                        long id = ls[0];
                        ls = ls.Where(x => x != 0 && x != id).ToList();
                        if (dic_ID_parent.ContainsKey(id) == false)
                        {
                            dic_ID_parent.AddListDistinct(id, ls.ToArray());
                        }
                    }
                }
            }

            if (!Directory.Exists(path_ID_node))
            {
                Directory.CreateDirectory(path_ID_node);
            }
            else
            {
                var ds = Directory.GetFiles(path_ID_node, "*.mmf");
                for (int k = 0; k < ds.Length; k++)
                {
                    List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList();
                    if (ls.Count > 0)
                    {
                        long id = ls[0];
                        ls = ls.Where(x => x != 0 && x != id).ToList();
                        if (dic_ID_node.ContainsKey(id) == false)
                        {
                            dic_ID_node.AddListDistinct(id, ls.ToArray());
                        }
                    }
                }
            }


            if (!Directory.Exists(path_ID_device_all))
            {
                Directory.CreateDirectory(path_ID_device_all);
            }
            else
            {
                var ds = Directory.GetFiles(path_ID_device_all, "*.mmf");
                for (int k = 0; k < ds.Length; k++)
                {
                    List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList();
                    if (ls.Count > 0)
                    {
                        long id = ls[0];
                        ls = ls.Where(x => x != 0 && x != id).ToList();

                        if (dic_ID_device_all.ContainsKey(id) == false)
                        {
                            dic_ID_device_all.AddListDistinct(id, ls.ToArray());
                        }
                    }
                }
            }


            if (!Directory.Exists(path_ID_device_near))
            {
                Directory.CreateDirectory(path_ID_device_near);
            }
            else
            {
                var ds = Directory.GetFiles(path_ID_device_near, "*.mmf");
                for (int k = 0; k < ds.Length; k++)
                {
                    List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList();
                    if (ls.Count > 0)
                    {
                        long id = ls[0];
                        ls = ls.Where(x => x != 0 && x != id).ToList();

                        if (dic_ID_device_near.ContainsKey(id) == false)
                        {
                            dic_ID_device_near.AddListDistinct(id, ls.ToArray());
                        }
                    }
                }
            }

            cache_node_id(1);
        }