Exemplo n.º 1
0
 /// <summary>
 /// 2D设备注册
 /// </summary>
 /// <returns></returns>
 public ServDeviceInfoModel AddDevice2D(ServDeviceInfoQuery deviceInfo, int deviceTempID)
 {
     try
     {
         if (deviceInfo.device_code == "")//其他设备(非摄像头)
         {
             //提取中文首字母
             ConvertChinese chinese = new ConvertChinese();
             string         codes   = chinese.GetHeadOfChs(Enum.GetName(typeof(BaseDeviceType), deviceInfo.device_type));
             //根据基础设备类型取出设备表中该类型所有的设备计算设备code
             List <ServDeviceInfoModel> servDeviceList = servDeviceInfoDAL.GetDeviceInfoLikeCode(codes);
             string lastDeviceCode = "";
             if (servDeviceList.Count > 0)
             {
                 for (int i = servDeviceList.Count - 1; i >= 0; i--)//取出最后一条设备数据
                 {
                     if (servDeviceList[i].device_code.Substring(0, codes.Length) == codes)
                     {
                         lastDeviceCode = servDeviceList[i].device_code;
                         break;
                     }
                 }
                 if (lastDeviceCode.IndexOf(codes) >= 0)
                 {
                     int codeID = Convert.ToInt32(lastDeviceCode.Substring(codes.Length, lastDeviceCode.Length - codes.Length));
                     deviceInfo.device_code = codes + (codeID + 1);
                 }
             }
             else
             {
                 deviceInfo.device_code = codes + 1;
             }
         }
         int id = servDeviceInfoDAL.AddEntity(deviceInfo);
         if (id != 0)
         {
             //删除设备临时表数据
             int num = servTempDeviceDAL.DeleteTempDeviceById(deviceTempID);
         }
         ServDeviceInfoModel model = new ServDeviceInfoModel();
         model.id          = id;
         model.device_code = deviceInfo.device_code;
         return(model);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 楼内图注册
 /// </summary>
 /// <param name="floorModel">楼层model</param>
 /// <param name="buildingName">楼宇名称</param>
 public int AddFloorInfo(ServFloorInfoModel floorModel, string buildingName)
 {
     try
     {
         //根据楼名称加上层名称生产层code
         ConvertChinese chinese = new ConvertChinese();
         string         codes   = chinese.GetHeadOfChs(buildingName + floorModel.floor_name);
         floorModel.floor_code = codes;
         int id = servFloorInfoDAL.AddEntity(floorModel);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 添加设备分组
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddDeviceGroup(ServDeviceGroupInfoModel model)
 {
     try
     {
         bool result = false;
         //提取中文首字母当code
         ConvertChinese chinese = new ConvertChinese();
         string         codes   = chinese.GetHeadOfChs(model.group_name);
         model.group_code = codes;
         int id = servDeviceGroupInfoDAL.AddEntity(model);
         result = true;
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 修改楼内图
 /// </summary>
 /// <param name="floorModel">楼层model</param>
 /// <param name="buildingName">楼宇名称</param>
 /// <returns></returns>
 public bool UpdateFloorInfo(ServFloorInfoModel floorModel, string buildingName)
 {
     try
     {
         //根据楼名称加上层名称生产层code
         ConvertChinese chinese = new ConvertChinese();
         string         codes   = chinese.GetHeadOfChs(buildingName + floorModel.floor_name);
         floorModel.floor_code = codes;
         int  num    = servFloorInfoDAL.UpdateFloorInfoById(floorModel);
         bool result = false;
         if (num != 0)
         {
             result = true;
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 宇视更新未注册设备列表
 /// </summary>
 /// <param name="xml"></param>
 public void UpdateUnRegisterDevice(string xml, string servIp, int regionId, out int total)
 {
     try
     {
         XmlDocument videoXml = new XmlDocument();
         videoXml.LoadXml(xml);
         XmlNode resNode = videoXml.SelectSingleNode("ResList");
         //资源总数
         total = Convert.ToInt32(((XmlElement)resNode).GetAttribute("count"));
         XmlNodeList itemList = resNode.ChildNodes;
         foreach (XmlNode item in itemList)
         {
             ServTempDeviceModel model   = new ServTempDeviceModel();
             XmlElement          resCode = (XmlElement)item.SelectSingleNode("ResCode");
             model.device_code = resCode.InnerText;
             XmlElement resName = (XmlElement)item.SelectSingleNode("ResName");
             model.device_name = resName.InnerText;
             XmlElement ResType = (XmlElement)item.SelectSingleNode("ResType");
             string     resType = ResType.InnerText;
             if (resType == "1001")
             {
                 XmlElement resSubType = (XmlElement)item.SelectSingleNode("ResSubType");
                 model.device_type = Convert.ToInt32(resSubType.InnerText);
             }
             else if (resType == "14")
             {
                 model.device_type = 5;
             }
             model.subsystem_id = (int)SubSystem.视频子系统;
             model.create_time  = DateTime.Now;
             ConvertChinese convertchinese = new ConvertChinese();
             model.search_code = convertchinese.GetHeadOfChs(model.device_name);
             model.ext1        = servIp;
             //判断该条数据是否在未注册设备表
             int num       = servTempDeviceDAL.GetTempDeviceByCode(model.device_code);
             int deviceNum = 0;
             //判断该条数据是否在已注册设备表中已存在
             ServDeviceInfoModel deviceModel = servDeviceInfoDAL.GetEntity(model.device_code);
             if (deviceModel != null)
             {
                 deviceNum = 1;
             }
             //在设备临时表和已注册的设备列表中都不存在则往临时表中写入数据
             if (model.device_type == 5)//监视器
             {
                 if (deviceNum == 0 && num == 0)
                 {
                     //直接添加到已注册设备列表中
                     ServDeviceInfoModel deviceInfo = new ServDeviceInfoModel();
                     deviceInfo.device_name        = model.device_name;
                     deviceInfo.device_code        = model.device_code;
                     deviceInfo.device_type        = 5;
                     deviceInfo.device_status      = Convert.ToInt32(((XmlElement)item.SelectSingleNode("ResStatus")).InnerText);
                     deviceInfo.subsystem_id       = model.subsystem_id;
                     deviceInfo.is_parts           = -2;
                     deviceInfo.register_time      = DateTime.Now;
                     deviceInfo.create_time        = DateTime.Now;
                     deviceInfo.search_code        = convertchinese.GetHeadOfChs(deviceInfo.device_name);
                     deviceInfo.region_id          = regionId;
                     deviceInfo.local_longitude    = "";
                     deviceInfo.local_latitude     = "";
                     deviceInfo.cover_range        = 0;
                     deviceInfo.update_status_time = DateTime.Now;
                     deviceInfo.camera_towards     = 0;
                     deviceInfo.visual_range       = 0;
                     deviceInfo.asset_code         = "";
                     deviceInfo.org_id             = 0;
                     deviceInfo.guarantee_time     = DateTime.Now;
                     deviceInfo.asset_status       = 1;
                     deviceInfo.manager_id         = 0;
                     deviceInfo.is_inbuilding      = 0;
                     deviceInfo.room_id            = 0;
                     deviceInfo.area_id            = 0;
                     int deId = servDeviceInfoDAL.AddEntity(deviceInfo);
                 }
             }
             else
             {
                 if (deviceNum == 0 && num == 0)
                 {
                     servTempDeviceDAL.AddEntity(model);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 处理丛文设备数据
 /// </summary>
 /// <returns></returns>
 private bool HandleCowinDeviceData(object message, string mark)
 {
     try
     {
         List <DeviceModel>         deviceList    = JsonHelper.StringToObject <List <DeviceModel> >(message.ToString());
         ServTempDeviceDAL          tempDeviceDal = new ServTempDeviceDAL();
         ServDeviceInfoDAL          deviceInfoDal = new ServDeviceInfoDAL();
         ConvertChinese             convert       = new ConvertChinese();
         List <BaseDeviceTypeModel> typeList      = null;
         try
         {
             typeList = baseMapConfigBLL.GetAllBaseDeviceTypeModel();
         }
         catch (Exception ex)
         {
             Log4NetHelp.Error("获取基本设备类型失败!" + ex.Message);
         }
         for (int i = 0; i < deviceList.Count; i++)
         {
             //int tempNum = tempDeviceDal.GetTempDeviceByCode(deviceList[i].deviceCode);
             ServTempDeviceModel tempDevice = tempDeviceDal.GetTempDeviceByDeviceCode(deviceList[i].deviceCode);
             ServDeviceInfoModel deviceInfo = deviceInfoDal.GetDeviceByDeviceCode(deviceList[i].deviceCode);
             if (tempDevice == null && deviceInfo == null)
             {
                 ServTempDeviceModel model = new ServTempDeviceModel();
                 var type = typeList.Where(n => n.type_name == deviceList[i].typeName).FirstOrDefault();
                 model.device_type  = type == null ? 0 : type.id;
                 model.create_time  = DateTime.Now;
                 model.device_code  = deviceList[i].deviceCode;
                 model.device_name  = deviceList[i].deviceName;
                 model.search_code  = convert.GetHeadOfChs(deviceList[i].deviceName);
                 model.subsystem_id = deviceList[i].subsystemId;
                 model.ext1         = deviceList[i].serverIp;
                 try
                 {
                     int res = tempDeviceDal.AddEntity(model);
                     if (res == 0)
                     {
                         Log4NetHelp.Error("设备code:" + deviceList[i].deviceCode + " 设备名称:" + deviceList[i].deviceName + " 插入临时表失败!");
                     }
                     else
                     {
                         Log4NetHelp.Info("设备code:" + deviceList[i].deviceCode + " 设备名称:" + deviceList[i].deviceName + " 插入临时表成功!");
                     }
                 }
                 catch (Exception ex)
                 {
                     Log4NetHelp.Error("设备code:" + deviceList[i].deviceCode + " 设备名称:" + deviceList[i].deviceName + " 插入临时表失败!" + ex.Message);
                 }
             }
             else if (tempDevice != null)
             {
                 Log4NetHelp.Error("设备code:" + deviceList[i].deviceCode + " 设备名称:" + deviceList[i].deviceName + " 在临时设备表已存在!");
             }
             else if (deviceInfo != null)
             {
                 Log4NetHelp.Error("设备code:" + deviceList[i].deviceCode + " 设备名称:" + deviceList[i].deviceName + " 在设备表已存在!");
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Log4NetHelp.Error("标识为:" + mark + "驱动同步丛文设备数据失败!" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 添加或修改组织架构节点
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="pid"></param>
        /// <param name="pcode"></param>
        /// <returns></returns>
        public bool UpdateOrgNameOrAddOrg(int id, string name, int pid, string pcode)
        {
            try
            {
                bool result = false;
                BaseOrganizitionInfoModel model = new BaseOrganizitionInfoModel();
                model.id       = id;
                model.org_name = name;
                model.pid      = pid;
                //提取中文首字母
                ConvertChinese chinese = new ConvertChinese();
                string         codes   = chinese.GetHeadOfChs(name);
                model.org_code  = codes;
                model.pcode     = pcode;
                model.org_type  = 1;
                model.region_id = 1;

                if (id == 0)//添加节点
                {
                    //往ztree表中添加一条数据
                    int num = baseOrganizationDAL.AddEntity(model);
                    if (num != 0)
                    {
                        ServOrganizationChartModel chartModel = new ServOrganizationChartModel();
                        chartModel.content     = name;
                        chartModel.child_node  = num.ToString();
                        chartModel.parent_node = pid.ToString();
                        chartModel.create_time = DateTime.Now;
                        chartModel.update_time = DateTime.Now;
                        //往gojs表中添加一条数据
                        num = servOrganizationChartDAL.AddEntity(chartModel);
                        if (num != 0)
                        {
                            result = true;
                        }
                    }
                }
                else//修改节点名称
                {
                    //修改ztee表中数据
                    int num = baseOrganizationDAL.UpdateOrganizationName(model);
                    if (num != 0)
                    {
                        ServOrganizationChartModel chartModel = new ServOrganizationChartModel();
                        chartModel.content     = name;
                        chartModel.child_node  = id.ToString();
                        chartModel.update_time = DateTime.Now;
                        //修改gojs表中数据
                        num = servOrganizationChartDAL.UpdateOrgChartByChildNode(chartModel);
                        if (num != 0)
                        {
                            result = true;
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }