Exemplo n.º 1
0
        /// <summary>
        /// 记录删除的设备(如果有设备被删除,备份时会被记录下来,TypeCode="DeleteDev",还原时这些设备不会被还原)
        /// 作用(当出现错误删除时,可以利用这些删除记录还原)
        /// </summary>
        /// <param name="devInfoList"></param>
        /// <returns></returns>
        private List <DevInfoBackup> AddDeleteDev(List <Location.TModel.Location.AreaAndDev.DevInfo> devInfoList)
        {
            //1.加载上一次的设备备份信息
            string filePath = GetSaveDevDirectory() + "DevInfoBackup.xml";
            var    initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);
            List <DevInfoBackup>        devInfos    = initInfo.DevList;
            List <DevInfoBackup>        deleteInfos = new List <DevInfoBackup>();
            Dictionary <string, string> devDic      = TryGetDevDic(devInfoList);

            if (devInfos != null)
            {
                foreach (var item in devInfos)
                {
                    if (item.TypeCode == DeleteTypeCode)
                    {
                        continue;
                    }
                    //2.如果上一次备份的设备,在现在的数据库找不到。说明被删除了,记录下来。
                    if (!string.IsNullOrEmpty(item.DevId) && !devDic.ContainsKey(item.DevId))
                    {
                        deleteInfos.Add(item);
                    }
                }
            }
            string deleteInfoPath = GetSaveDevDirectory() + "DeleteInfoBackup.xml";

            if (deleteInfos.Count != 0)
            {
                var deleteBackup = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);
                if (deleteBackup == null)
                {
                    deleteBackup         = new DevInfoBackupList();
                    deleteBackup.DevList = new List <DevInfoBackup>();
                }
                deleteBackup.DevList.AddRange(deleteInfos);
                XmlSerializeHelper.Save(deleteBackup, deleteInfoPath, Encoding.UTF8);
                foreach (var item in deleteInfos)
                {
                    item.TypeCode = DeleteTypeCode;
                }
            }
            return(deleteInfos);
        }
Exemplo n.º 2
0
        private void SaveDoorAccessToXml(IList <Location.TModel.Location.AreaAndDev.Dev_DoorAccess> doorList, LocationService service)
        {
            DoorAccessList backUpList = new DoorAccessList();

            backUpList.DevList = new List <DoorAccess>();
            foreach (var item in doorList)
            {
                if (item.DevInfo == null)
                {
                    continue;
                }
                DoorAccess dev = new DoorAccess();
                dev.DevId      = item.DevInfo.DevID;
                dev.KKSCode    = item.DevInfo.KKSCode;
                dev.ModelName  = item.DevInfo.ModelName;
                dev.Name       = item.DevInfo.Name;
                dev.ParentName = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode   = item.DevInfo.TypeCode.ToString();

                DevPos pos = item.DevInfo.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                dev.DoorId      = item.DoorId;
                dev.Local_DevId = item.DevID;
                backUpList.DevList.Add(dev);
            }
            string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\设备信息\\DoorAccessBackup.xml";

            XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存通用设备
        /// </summary>
        private void SaveNormalDev(List <Location.TModel.Location.AreaAndDev.DevInfo> devInfoList, LocationService service)
        {
            DevInfoBackupList backUpList = new DevInfoBackupList();

            backUpList.DevList = new List <DevInfoBackup>();
            foreach (var item in devInfoList)
            {
                string typeCodeT = item.TypeCode.ToString();
                if (TypeCodeHelper.IsLocationDev(typeCodeT) || TypeCodeHelper.IsCamera(typeCodeT) || TypeCodeHelper.IsDoorAccess(item.ModelName))
                {
                    continue;
                }
                DevInfoBackup dev = new DevInfoBackup();
                dev.DevId      = item.DevID;
                dev.KKSCode    = item.KKSCode;
                dev.ModelName  = item.ModelName;
                dev.Name       = item.Name;
                dev.ParentName = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode   = item.TypeCode.ToString();

                DevPos pos = item.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                backUpList.DevList.Add(dev);
            }
            string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\设备信息\\DevInfoBackup.xml";

            XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
        }
Exemplo n.º 4
0
 internal void SaveArchorList(string path)
 {
     XmlSerializeHelper.Save(archorList, path);
 }
        private void InitAuthorizationFromAreas(string path)
        {
            var parks      = areas.FindAll(i => i.Type == AreaTypes.园区);
            var buildGroup = areas.FindAll(i => i.Type == AreaTypes.分组);
            var buildings  = areas.FindAll(i => i.Type == AreaTypes.大楼);
            var floors     = areas.FindAll(i => i.Type == AreaTypes.楼层);

            CreateAllAuthorization();//所有的区域创建权限
            //CreateAllAuthorizationRecord();//所有的角色分配权限

            //1.超级管理员
            SetRoleAuthorization1(_roles[0]);//AddCardRole("超级管理员", "可以进入全部区域");


            //2.参观人员(一般)
            var areaList = new List <Area>();

            areaList.AddRange(parks);
            SetRoleAuthorization2(areaList); //AddCardRole("参观人员(一般)", "能够进入生活区域和少部分生产区域");

            //3.参观人员(高级)
            areaList.AddRange(buildGroup);
            areaList.AddRange(buildings);
            SetRoleAuthorization3(_roles[6], areaList);//AddCardRole("参观人员(高级)", "能够进入生活区域和大部分生产区域");

            //4.外维人员
            areaList.AddRange(floors);
            SetRoleAuthorization4(areaList, _roles[5]);//role5 = AddCardRole("外维人员", "能够进入生活区域和指定生产区域");

            //5.管理人员,巡检人员,操作人员,维修人员

            /*
             * role1 = AddCardRole("管理人员", "可以进入大部分区域");
             * role2 = AddCardRole("巡检人员", "能够进入生产区域");
             * role3 = AddCardRole("操作人员", "能够进入生产区域");
             * role4 = AddCardRole("维修人员", "能够进入生产区域");
             */
            var rooms = areas.FindAll(i => i.Type == AreaTypes.机房);

            areaList.AddRange(rooms);
            SetRoleAuthorization5(areaList);

            //6.告警范围
            var ranges = areas.FindAll(i => i.Type == AreaTypes.范围);


            foreach (var area in ranges)
            {
                SetAlarmArea(_roles, area.Id);
            }

            var tree = TreeHelper.CreateTree(authorizationAreas);

            XmlSerializeHelper.Save(tree[0], path);

            //角色,区域,卡
            //1.可以进入全部区域
            //2.可以进入生产区域
            //3.可以进入非生产区域
            //4.可以进入多个区域
            //5.可以进入某一个楼层
            //6.可以进入某个房间
        }
        private void MenuExportAll_OnClick(object sender, RoutedEventArgs e)
        {
            Worker.Run(() =>
            {
                try
                {
                    Log.Info(LogTags.DbInfo, "ExportAll Start");
                    Type type = typeof(LocationDb);
                    var ps    = type.GetProperties().Where(j => j.PropertyType.Name.Contains("DbSet"));
                    var db    = GetDb();
                    var ds    = new DataSet();
                    int count = ps.Count();
                    int i     = 0;
                    foreach (var p in ps)
                    {
                        try
                        {
                            i++;
                            var name = p.Name;

                            Log.Info(LogTags.DbInfo, string.Format("Progress {0}({1}/{2})", name, i, count));
                            if (name.Contains("Alarm"))
                            {
                                Log.Info(LogTags.DbInfo, "skip name == " + name);
                                continue;
                            }
                            Log.Info(LogTags.DbInfo, "1 GetList");
                            var list = GetList(p, db);
                            if (list.Count > 0)
                            {
                                Log.Info(LogTags.DbInfo, "2 ExportList");
                                ExcelHelper.ExportList(list, new FileInfo(Path + list[0].GetType().Name + ".xls"));
                            }
                            Log.Info(LogTags.DbInfo, "3 ToTable");
                            var tb = ExcelHelper.ToTable(list);

                            Log.Info(LogTags.DbInfo, "4 SaveList");
                            XmlSerializeHelper.Save(list, new FileInfo(Path + list[0].GetType().Name + ".xml").FullName);

                            if (tb == null)
                            {
                                Log.Info(LogTags.DbInfo, "tb == null");
                                continue;
                            }
                            ds.Tables.Add(tb);
                        }
                        catch (Exception ex1)
                        {
                            Log.Error(LogTags.DbInfo, ex1);
                        }
                    }
                    ExcelHelper.Save(ds, new FileInfo(Path + "DbInfos.xls"), null);

                    Log.Info(LogTags.DbInfo, "ExportAll End");
                }
                catch (Exception ex)
                {
                    Log.Error(LogTags.DbInfo, ex);
                }
            }, () =>
            {
                MessageBox.Show("导出成功");
            });
        }