public void InitArchorSettings()
        {
            var list2 = DbInfoHelper.GetArchorSettings();

            _bll.ArchorSettings.Clear();
            _bll.ArchorSettings.AddRange(list2);
        }
        private void MenuArchorSetting_Click(object sender, RoutedEventArgs e)
        {
            Bll bll   = new Bll();
            var list2 = DbInfoHelper.GetArchorSettings();

            bll.ArchorSettings.Clear();
            bll.ArchorSettings.AddRange(list2);
            MessageBox.Show("完成");
        }
        private void MenuMergeArchorInfo_Click(object sender, RoutedEventArgs e)
        {
            var win = new AreaTreeWindow();

            if (win.ShowDialog() == true)
            {
                var area    = win.SelectedArea;
                var archors = DbInfoHelper.GetArchors().FindAll(i => i.ParentId == area.Id);
                var devs    = DbInfoHelper.GetDevInfos().FindAll(i => i.ParentId == area.Id);
                foreach (var item in archors)
                {
                    item.DevInfo = devs.Find(i => i.Id == item.DevInfoId);
                }
                var archorSettings = DbInfoHelper.GetArchorSettings().FindAll(i => i.FloorName == area.Name);
                foreach (var item in archorSettings)
                {
                    item.Archor = archors.Find(i => i.Id == item.ArchorId);
                }

                Bll bll             = new Bll();
                var archors2        = bll.Archors.FindAll(i => i.ParentId == area.Id);
                var devs2           = bll.DevInfos.FindAll(i => i.ParentId == area.Id);
                var archorSettings2 = bll.ArchorSettings.FindAll(i => i.FloorName == area.Name);

                bll.Archors.RemoveList(archors2);
                bll.DevInfos.RemoveList(devs2);
                bll.ArchorSettings.RemoveList(archorSettings2);

                bll.DevInfos.AddRange(devs);
                foreach (var item in archors)
                {
                    item.DevInfoId = item.DevInfo.Id;
                }
                bll.Archors.AddRange(archors);

                foreach (var item in archorSettings)
                {
                    if (item.Archor != null)
                    {
                        item.ArchorId = item.Archor.Id;
                    }
                }
                bll.ArchorSettings.AddRange(archorSettings);
            }
        }
Beispiel #4
0
        public static void LoadArchorList(string tag)
        {
            try
            {
                DateTime start = DateTime.Now;
                Log.Info(tag, "LoadArchorList Start");

                var    Path  = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\DbInfos\\";
                string file1 = Path + "DevInfo.xls";
                string file2 = Path + "Archor.xls";
                string file3 = Path + "ArchorSetting.xls";

                Bll bll = Bll.NewBllNoRelation();
                Log.Info(tag, "archors_ms");
                var archors_ms = DbInfoHelper.GetArchors(); //老的SQLServer
                Log.Info(tag, "archors_my");
                var archors_my = bll.Archors.ToList();      //现在的mysql中的基站
                Log.Info(tag, "archors2Dict_my");
                var archors2Dict_my = bll.Archors.ToDictionary();
                Log.Info(tag, "archorSettings_my");
                var archorSettings_my = DbInfoHelper.GetArchorSettings();
                Log.Info(tag, "archors_list");

                var archors_list = ArchorHelper.LoadArchoDevInfo().ArchorList;//清单文件
                Log.Info(tag, "archors_engine");
                var archors_engine0 = bll.bus_anchors.ToList();
                var archors_engine1 = archors_engine0.FindAll(i => i.enabled != 1); //引擎数据
                var archors_engine  = archors_engine0.FindAll(i => i.enabled == 1); //引擎数据
                Log.Info(tag, "archorConfig_engine");
                var archorConfig_engine = bll.bus_anchor_config.ToList().FindAll(i => i.net_gate != null);
                Log.Info(tag, "devs_ms_all");

                var devs_ms_all = DbInfoHelper.GetDevInfos();
                Log.Info(tag, "devs_ms");
                var devs_ms = devs_ms_all.FindAll(i => i.Local_TypeCode == 20180821);

                Log.Info(tag, "devs_my");
                var devs_my = bll.DevInfos.FindAll(i => i.Local_TypeCode == 20180821);
                Log.Info(tag, "archorSettings2");
                var archorSettings2 = bll.ArchorSettings.ToList();

                Log.Info(tag, "areas_ms");
                var areas_ms = DbInfoHelper.GetAreas().ToDictionary(i => i.Id);
                Log.Info(tag, "InitArea(areas_ms)");
                InitArea(areas_ms, tag);

                Log.Info(tag, "areas_my");
                var areas_my_list = bll.Areas.ToList();
                var areas_my      = areas_my_list.ToDictionary(i => i.Id);
                Log.Info(tag, "InitArea(areas_my)");
                InitArea(areas_my, tag);

                foreach (var item in archors_my)
                {
                    item.DevInfo = devs_my.Find(i => i.Id == item.DevInfoId);
                }

                foreach (var item in archors_ms)
                {
                    item.DevInfo = devs_ms.Find(i => i.Id == item.DevInfoId);
                }

                bll.Archors.RemoveList(archors_my);
                bll.DevInfos.RemoveList(devs_my);
                bll.ArchorSettings.RemoveList(archorSettings2);

                //foreach (var item in archors_ms)
                for (int j = 0; j < archors_ms.Count; j++)
                {
                    var item = archors_ms[j];
                    //Log.Info(tag, string.Format("SetParent : {0}/{1}", j, archors_ms.Count));

                    var dev = item.DevInfo;
                    if (dev != null)
                    {
                        item.DevInfoId = dev.Id;

                        if (dev.ParentId != null)
                        {
                            var pid = (int)dev.ParentId;

                            var p1 = areas_ms[pid];
                            var p2 = areas_my_list.Find(i => i.Path == p1.Path);
                            if (p2 != null)
                            {
                                dev.ParentId  = p2.Id;
                                item.ParentId = p2.Id;
                            }
                        }
                    }
                }

                bll.DevInfos.AddRange(devs_ms);

                foreach (var item in archors_ms)
                {
                    item.DevInfoId = item.DevInfo.Id;
                }
                bll.Archors.AddRange(archors_ms);
                archors_my = archors_ms;

                foreach (var item in archorSettings_my)
                {
                    if (item.Archor != null)
                    {
                        item.ArchorId = item.Archor.Id;
                    }
                }
                bll.ArchorSettings.AddRange(archorSettings_my);

                //{
                //    List<Archor> temp11 = new List<Archor>();
                //    List<Archor> temp12 = new List<Archor>();
                //    foreach (var item in archors_my)
                //    {
                //        var old = archors_ms.Find(i => i.Code == item.Code);
                //        if (old != null)
                //        {
                //            temp11.Add(item);
                //            archors_ms.Remove(old);
                //        }
                //        else
                //        {
                //            temp12.Add(item);
                //        }
                //    }
                //}

                //{
                //    List<Archor> temp11 = new List<Archor>();
                //    List<Archor> temp12 = new List<Archor>();
                //    foreach (var item in archors_my)
                //    {
                //        var old = archors_list.Find(i => i.ArchorID == item.Code);
                //        if (old != null)
                //        {
                //            temp11.Add(item);
                //            archors_list.Remove(old);
                //        }
                //        else
                //        {
                //            temp12.Add(item);
                //        }
                //    }
                //}

                {
                    List <Archor> temp11 = new List <Archor>();
                    List <Archor> temp12 = new List <Archor>();
                    foreach (var item in archors_my)
                    {
                        var old = archorConfig_engine.Find(i => i.anchor_id == item.Code);
                        if (old != null)
                        {
                            temp11.Add(item);
                            archorConfig_engine.Remove(old);
                        }
                        else
                        {
                            temp12.Add(item);
                        }
                    }

                    List <DevInfo> devs = new List <DevInfo>();
                    foreach (var item in temp12)
                    {
                        devs.Add(item.DevInfo);
                    }

                    bll.Archors.RemoveList(temp12);
                    bll.DevInfos.RemoveList(devs);
                }

                var time = DateTime.Now - start;
                Log.Info(tag, "LoadArchorList End:" + time);
            }
            catch (Exception ex)
            {
                Log.Error(tag, ex.ToString());
            }
        }