Ejemplo n.º 1
0
        /// <summary>
        /// 保存设备信息至Xml文件
        /// </summary>
        private void SaveCameraInfoToXml(List <TModel.Location.AreaAndDev.Dev_CameraInfo> cameraList, LocationService service)
        {
            CameraInfoBackUpList backUpList = new CameraInfoBackUpList();

            backUpList.DevList = new List <CameraInfoBackup>();

            foreach (var item in cameraList)
            {
                if (item.DevInfo == null)
                {
                    continue;
                }
                CameraInfoBackup dev = new CameraInfoBackup();
                dev.DevId          = item.DevInfo.DevID;
                dev.KKSCode        = item.DevInfo.KKSCode;
                dev.Abutment_DevID = item.DevInfo.Abutment_DevID;
                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.IP          = item.Ip;
                dev.UserName    = item.UserName;
                dev.PassWord    = item.PassWord;
                dev.CameraIndex = item.CameraIndex.ToString();
                dev.Port        = item.Port.ToString();
                dev.RtspURL     = item.RtspUrl;

                backUpList.DevList.Add(dev);
            }
            //string initFile = GetSaveDevDirectory()+"CameraInfoBackup.xml";
            //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
            SaveCameraDevXml("CameraInfoBackup.xml", backUpList);
        }
Ejemplo n.º 2
0
        private void SaveCameraDevXml(string fileWithExtension, CameraInfoBackUpList backUpList)
        {
            //拷贝到Bin目录下
            string dirctory = GetSaveDevDirectory();
            string initFile = dirctory + fileWithExtension;

            XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);

            //直接保存到Vs目录
            string vsDirctory = GetVsSaveDirctory();

            if (Directory.Exists(vsDirctory))
            {
                string vsSaveFile = vsDirctory + fileWithExtension;
                XmlSerializeHelper.Save(backUpList, vsSaveFile, Encoding.UTF8);
            }
        }