Esempio n. 1
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);
     }
 }
Esempio n. 2
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;
            }
        }