Example #1
0
        BaseRegionExtendConfigDAL baseRegionExtendConfigDAL = new BaseRegionExtendConfigDAL(); //园区扩展

        /*#region 地图配置
         * /// <summary>
         * /// 根据ID获取地图配置 2016.12.01 张丰刚
         * /// </summary>
         * /// <param name="id">主键ID</param>
         * /// <returns>地图配置数据</returns>
         * public CSM.Model.BaseMapConfigModel GetModelByID(int id)
         * {
         *  BaseMapConfigModel model = new BaseMapConfigModel();
         *  try
         *  {
         *      model = baseMapConfigDAL.GetEntity(id);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *
         *  return model;
         * }
         * /// <summary>
         * /// 获取所有的地图配置数据 2016.12.01 张丰刚
         * /// </summary>
         * /// <returns>地图配置集合</returns>
         * public List<BaseMapConfigModel> GetMapConfig()
         * {
         *  List<BaseMapConfigModel> list = new List<BaseMapConfigModel>();
         *  try
         *  {
         *      BaseMapConfigQuery baseMapConfigQuery = new BaseMapConfigQuery();
         *      list = baseMapConfigDAL.GetEntities(baseMapConfigQuery);
         *  }
         *  catch (Exception ex)
         *  {
         *      throw ex;
         *  }
         *  return list;
         * }
         * /// <summary>
         * /// 新增地图配置 2016.12.01 张丰刚
         * /// </summary>
         * /// <param name="configModel"></param>
         * /// <returns></returns>
         * public int AddMapConfig(BaseMapConfigModel configModel)
         * {
         *  int id = 0;
         *  try
         *  {
         *      id = baseMapConfigDAL.AddEntity(configModel);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return id;
         * }
         * /// <summary>
         * /// 修改地图配置 2016.12.01 张丰刚
         * /// </summary>
         * /// <param name="configModel"></param>
         * /// <returns></returns>
         * public bool UpdateMapConfig(BaseMapConfigModel configModel)
         * {
         *  bool result = false;
         *  try
         *  {
         *      result = baseMapConfigDAL.UpdateEntity(configModel.id, configModel);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return result;
         * }
         * /// <summary>
         * /// 删除地图配置 2016.12.01 张丰刚
         * /// </summary>
         * /// <param name="id">主键ID</param>
         * /// <returns></returns>
         * public bool DelteMapConfig(int id)
         * {
         *  bool result = false;
         *  try
         *  {
         *      result = baseMapConfigDAL.DelEntity(id);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return result;
         * }
         * /// <summary>
         * /// 根据地图引擎和园区类型获取地图配置
         * /// </summary>
         * /// <param name="mapEngine">地图引擎</param>
         * /// <param name="regionType">园区类别(主园区、副园区)</param>
         * /// <param name="mapType">园区类别(主园区、副园区)</param>
         * /// <returns></returns>
         * public BaseMapConfigModel GetMapConfigByMapType(int mapEngine, int regionType, int mapType)
         * {
         *  BaseMapConfigQuery model = new BaseMapConfigQuery();
         *  model.map_engine = mapEngine;
         *  model.region_type = regionType;
         *  model.map_type = mapType;
         *  BaseMapConfigModel configModel = new BaseMapConfigModel();
         *  //实现代码
         *  try
         *  {
         *      configModel = baseMapConfigDAL.GetMapConfigByQuery(model).FirstOrDefault();
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return configModel;
         * }
         * /// <summary>
         * /// 根据地图引擎和园区编码、2.5D类型获取地图配置
         * /// </summary>
         * /// <param name="mapEngine">地图引擎</param>
         * /// <param name="regionCode">园区编号</param>
         * /// <param name="mapType">园区类别(25D)</param>
         * /// <returns></returns>
         * public BaseMapConfigModel GetMapConfigByRegionCode(int mapEngine, string region_code, int mapType, int region_type)
         * {
         *  BaseMapConfigQuery model = new BaseMapConfigQuery();
         *  model.map_engine = mapEngine;
         *  model.region_code = region_code;
         *  model.map_type = mapType;
         *  model.region_type = region_type;
         *  BaseMapConfigModel configModel = new BaseMapConfigModel();
         *  //实现代码
         *  try
         *  {
         *      configModel = baseMapConfigDAL.GetMapConfigByQuery(model).FirstOrDefault();
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return configModel;
         * }
         *
         * /// <summary>
         * /// 获取当前地图引擎  读取XML
         * /// </summary>
         * /// <returns></returns>
         * public int GetMapEngine(string path)
         * {
         *  int type = 0;
         *  try
         *  {
         *      string mapengine = xmlclass.ReadXml(path, "MapEngine");
         *      if (mapengine != "")
         *      {
         *          type = Convert.ToInt32(mapengine);
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *
         *  return type;
         * }
         * /// <summary>
         * /// 修改当前地图引擎配置 写XML文件
         * /// </summary>
         * /// <param name="path">文件地址</param>
         * /// <param name="value">修改值</param>
         * /// <returns></returns>
         * public bool SetMapEngine(string path, string value)
         * {
         *  bool result = false;
         *  try
         *  {
         *      result = xmlclass.WriteXml(path, "MapEngine", value);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         *  return result;
         * }
         * /// <summary>
         * /// 获取当前地图配置
         * /// </summary>
         * /// <param name="path"></param>
         * /// <returns></returns>
         * public BaseMapConfigModel GetNowMapConfig(string path, int mapType)
         * {
         *  try
         *  {
         *      int mapEngine = GetMapEngine(path);
         *      return GetMapConfigByMapEngineTypeRegion(mapEngine, mapType, (int)RegionType.主园区);
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         * }
         * /// <summary>
         * /// 根据地图引擎、类别、园区类别获取当期地图配置
         * /// </summary>
         * /// <param name="mapEngine"></param>
         * /// <param name="mapType"></param>
         * /// <param name="regionType"></param>
         * /// <returns></returns>
         * public BaseMapConfigModel GetMapConfigByMapEngineTypeRegion(int mapEngine, int mapType, int regionType)
         * {
         *  try
         *  {
         *      //如果注册的地图类型为2(2.5D)
         *      if (mapType == 2)
         *      {
         *          //首先查询出2.5D对应的code
         *          BaseMapConfigQuery query2D = new BaseMapConfigQuery();
         *          query2D.map_engine = mapEngine;
         *          query2D.map_type = 1;
         *          query2D.region_type = regionType;
         *          BaseMapConfigModel model2D = baseMapConfigDAL.GetNowMapConfigByQuery(query2D);
         *          if (model2D != null)
         *          {
         *              string region_code = model2D.region_code;
         *              BaseMapConfigQuery query25D = new BaseMapConfigQuery();
         *              query25D.map_engine = mapEngine;
         *              query25D.map_type = 2;//地图类型为2.5D
         *              query25D.region_code = region_code;//园区编号
         *              query25D.region_type = 2;//园区类型为副园区,2.5D在注册的时候都是默认副园区
         *              BaseMapConfigModel model25D = baseMapConfigDAL.GetMapConfigByQuery(query25D).FirstOrDefault();
         *              return model25D;
         *
         *          }
         *          else
         *          {
         *              return null;
         *          }
         *      }
         *      else
         *      {
         *          BaseMapConfigQuery query = new BaseMapConfigQuery();
         *          query.map_engine = mapEngine;
         *          query.map_type = mapType;
         *          query.region_type = regionType;
         *          return baseMapConfigDAL.GetNowMapConfigByQuery(query);
         *      }
         *
         *  }
         *  catch (Exception ex)
         *  {
         *
         *      throw ex;
         *  }
         * }
         *
         *
         #endregion*/

        #region 地图配置新
        /// <summary>
        /// 通过园区的id得到园区
        /// </summary>
        /// <returns></returns>
        public int GetRegionConfigModelByID(int regionID)
        {
            int regionDefaultEngine = -1;

            try
            {
                BaseRegionConfigModel baseRegionConfigModel = baseRegionConfigDAL.GetEntity(regionID);
                if (baseRegionConfigModel == null)
                {
                    regionDefaultEngine = -1;
                }

                else
                {
                    regionDefaultEngine = baseRegionConfigModel.map_engine;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(regionDefaultEngine);
        }
Example #2
0
 /// <summary>
 /// 根据人员id获取权限
 /// </summary>
 /// <param name="personId"></param>
 /// <returns></returns>
 public List <ServPurviewInfoCustom> GetPurviewByPersonId(int personId)
 {
     try
     {
         ServPersonInfoModel          person      = servPersonInfoDAL.GetPersonInfoBySSOId(personId);
         List <ServPurviewInfoCustom> purviewList = new List <ServPurviewInfoCustom>();
         if (person != null)
         {
             if (person.role_id != 0)
             {
                 //根据角色id获取角色所包含的园区权限
                 List <ServRolePurviewModel> rolePurList = servPurviewInfoDAL.GetRoleRegionIdByRoleId(person.role_id);
                 for (int i = 0; i < rolePurList.Count; i++)
                 {
                     ServRolePurviewQuery query = new ServRolePurviewQuery();
                     query.role_id   = person.role_id;
                     query.region_id = rolePurList[i].region_id;
                     List <ServPurviewInfoModel> purviewList1 = servPurviewInfoDAL.GetPurviewInfoByRoleId(query);
                     for (int j = 0; j < purviewList1.Count; j++)
                     {
                         ServPurviewInfoCustom purCus = new ServPurviewInfoCustom();
                         purCus.id           = purviewList1[j].id;
                         purCus.purview_code = purviewList1[j].purview_code;
                         purCus.purview_name = purviewList1[j].purview_name;
                         purCus.sid          = Convert.ToInt32(purviewList1[j].purview_code + "" + rolePurList[i].region_id);
                         if (purviewList1[j].pid == -1)
                         {
                             purCus.pid = rolePurList[i].region_id;
                         }
                         else
                         {
                             purCus.pid = Convert.ToInt32(purviewList1[j].pid + "" + rolePurList[i].region_id);
                         }
                         purCus.region_id = rolePurList[i].region_id;
                         purviewList.Add(purCus);
                     }
                     //根据园区id获取园区信息
                     BaseRegionConfigModel regionModel = baseRegionConfigDAL.GetEntity(rolePurList[i].region_id);
                     ServPurviewInfoCustom purCus1     = new ServPurviewInfoCustom();
                     if (regionModel != null)
                     {
                         purCus1.id           = regionModel.id;
                         purCus1.purview_name = regionModel.region_name;
                         purCus1.purview_code = regionModel.id;
                         purCus1.pid          = -1;
                         purCus1.sid          = regionModel.id;
                     }
                     else
                     {
                         purCus1.purview_name = "超级管理员";
                     }
                     purCus1.region_id = rolePurList[i].region_id;
                     purviewList.Add(purCus1);
                 }
             }
         }
         return(purviewList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
        /// <summary>
        /// 处理报警数据
        /// </summary>
        /// <param name="alarmRecord"></param>
        public void HandlePlan(ServAlarmRecordModel alarmRecord)
        {
            try
            {
                ServExecutionTimeDAL executeTimeDal      = new ServExecutionTimeDAL();
                ServDeviceInfoModel  deviceInfo          = GetDeviceInfo(alarmRecord.alarm_code);
                BaseRegionConfigDAL  baseRegionConfigDal = new BaseRegionConfigDAL();
                if (deviceInfo != null)
                {
                    BaseRegionConfigModel regionModel = baseRegionConfigDal.GetEntity(deviceInfo.region_id); //获取设备所在园区
                    int parentEventId = GetParentEvent(alarmRecord.alarm_event);                             //获取父级事件ID
                    //查找设备预案
                    string alarmTime   = alarmRecord.alarm_time.ToLocalTime().ToString("HH:mm:ss");
                    var    devicePlans = CheckDevicePlanIsExist(deviceInfo.id, (int)EnumClass.PlanStatus.启用, alarmTime);
                    DevicePlanAndTimeConfig devicePlan = devicePlans == null ? null : devicePlans.FirstOrDefault(); //目前取第一条设备预案
                    if (devicePlan != null)
                    {
                        #region  检验时间表达式
                        //if (TimeExpression.TimePointIsExistSpan(alarmRecord.alarm_time.ToLocalTime(), devicePlan.update_time, timeModel.execution_cycle))
                        //{

                        //}
                        //else
                        //{
                        //    Log4NetHelp.Info("报警时间未在设置周期内,报警时间:" + alarmRecord.alarm_time.ToLocalTime().ToString() + " 开始时间:" + devicePlan.update_time + " 时间表达式:" + timeModel.execution_cycle);
                        //}

                        #endregion
                        List <ServPlanHandleItemModel> planHandleItemList = GetPlanHandleItem(devicePlan.id, (int)EnumClass.PlanType.设备预案, (int)EnumClass.PlanHandleTime.确警前);
                        if (planHandleItemList != null && planHandleItemList.Count != 0)
                        {
                            //执行设备预案,写入预案执行记录
                            PlanBLL planBll      = new PlanBLL();
                            int     planRecordId = planBll.AddPlanRecord(alarmRecord.id, devicePlan.id, (int)EnumClass.PlanType.设备预案);
                            if (planRecordId > 0)
                            {
                                List <ServDeviceInfoModel> camerasList = null;
                                string ledMessage = "";
                                HandleDevicePlanItem(planRecordId, parentEventId, regionModel, planHandleItemList, deviceInfo, alarmRecord, out camerasList, out ledMessage);
                                // Hashtable hash = HandleDevicePlanItem(planRecordId, planHandleItemList, deviceInfo, alarmRecord,out camerasList,out ledMessage);
                                if (hash != null && hash.Count != 0)
                                {
                                    WebSocketMsgModel  webMsg        = new WebSocketMsgModel();
                                    DevicePlanMsgModel devicePlanMsg = new DevicePlanMsgModel();
                                    devicePlanMsg.hash       = hash;
                                    devicePlanMsg.alarm      = alarmRecord;
                                    devicePlanMsg.deviceInfo = deviceInfo;
                                    // devicePlanMsg.videoTime = GetAlarmVideoTime(alarmRecord.alarm_event);
                                    devicePlanMsg.videoTime   = GetAlarmVideoTime(parentEventId);
                                    devicePlanMsg.camerasList = camerasList;
                                    devicePlanMsg.ledMessage  = ledMessage;       //用于页面显示滚动条信息
                                                                                  // string devicePlanMsgStr = JsonHelper.ObjectToString(devicePlanMsg);
                                    webMsg.info = devicePlanMsg;
                                    webMsg.type = (int)EnumClass.WebSocketMsgType.设备预案;
                                    string param = JsonHelper.ObjectToString(webMsg);
                                    HttpHelper.PostJsonData(SubSystemRouteBLL.GetToWebsocketRoute(), param, Encoding.UTF8);
                                }
                            }
                        }
                        else
                        {
                            //log:未找到相应设备预案处置项
                            Log4NetHelp.Info("未找到对应设备预案处置项:" + alarmRecord.alarm_code);
                        }
                    }
                    else
                    {
                        //log 未找到设备预案或者设备预案未启用
                        //TODO 查找事件预案
                        Log4NetHelp.Info("未找到当前时间段内配置的设备预案或者设备预案未启用,继续查找事件预案");
                        //int parentEventId = GetParentEvent(alarmRecord.alarm_event);  //获取父级事件ID
                        if (parentEventId != -1)
                        {
                            var eventPlans = CheckEventPlanIsExist(alarmTime, parentEventId, (int)EnumClass.PlanStatus.启用, regionModel.id);
                            EventPlanAndTimeConfig eventPlan = eventPlans == null ? null : eventPlans.FirstOrDefault();//目前取第一条设备预案
                            if (eventPlan != null)
                            {
                                List <ServPlanHandleItemModel> planHandleItemList = GetPlanHandleItem(eventPlan.id, (int)EnumClass.PlanType.事件预案, (int)EnumClass.PlanHandleTime.确警前);//获取事件预案处置项
                                if (planHandleItemList != null && planHandleItemList.Count != 0)
                                {
                                    //执行事件预案,写入预案执行记录
                                    PlanBLL planBll      = new PlanBLL();
                                    int     planRecordId = planBll.AddPlanRecord(alarmRecord.id, eventPlan.id, (int)EnumClass.PlanType.事件预案);
                                    if (planRecordId > 0)
                                    {
                                        List <ServDeviceInfoModel> camerasList = null;
                                        string ledMessage = "";
                                        HandleEventPlanItem(planRecordId, parentEventId, regionModel, planHandleItemList, deviceInfo, alarmRecord, out camerasList, out ledMessage);
                                        // Hashtable hash = HandleDevicePlanItem(planRecordId, planHandleItemList, deviceInfo, alarmRecord,out camerasList,out ledMessage);
                                        if (hash != null && hash.Count != 0)
                                        {
                                            WebSocketMsgModel  webMsg        = new WebSocketMsgModel();
                                            DevicePlanMsgModel devicePlanMsg = new DevicePlanMsgModel();
                                            devicePlanMsg.hash       = hash;
                                            devicePlanMsg.alarm      = alarmRecord;
                                            devicePlanMsg.deviceInfo = deviceInfo;
                                            //  devicePlanMsg.videoTime = GetAlarmVideoTime(alarmRecord.alarm_event);
                                            devicePlanMsg.videoTime   = GetAlarmVideoTime(parentEventId);
                                            devicePlanMsg.camerasList = camerasList;
                                            devicePlanMsg.ledMessage  = ledMessage;       //用于页面显示滚动条信息
                                                                                          // string devicePlanMsgStr = JsonHelper.ObjectToString(devicePlanMsg);
                                            webMsg.info = devicePlanMsg;
                                            webMsg.type = (int)EnumClass.WebSocketMsgType.事件预案;
                                            string param = JsonHelper.ObjectToString(webMsg);
                                            HttpHelper.PostJsonData(SubSystemRouteBLL.GetToWebsocketRoute(), param, Encoding.UTF8);
                                        }
                                    }
                                }
                                else
                                {
                                    Log4NetHelp.Info("未找到对应事件预案处置项,事件ID:" + alarmRecord.alarm_event + " 园区ID:" + regionModel.id + " 报警时间:" + alarmTime);
                                }
                            }
                            else
                            {
                                Log4NetHelp.Info("未找到对应事件预案,事件ID:" + alarmRecord.alarm_event + " 园区ID:" + regionModel.id + " 报警时间:" + alarmTime);
                            }
                        }
                        else
                        {
                            Log4NetHelp.Info("未找到对应事件,事件ID:" + alarmRecord.alarm_event);
                        }
                    }
                }
                else
                {
                    //log:未找到设备alarmRecord.alarm_code
                    Log4NetHelp.Info("未找到设备:" + alarmRecord.alarm_code);
                }
            }
            catch (Exception ex)
            {
                // Log4NetHelp.Error("业务层处理报警数据失败!" + ex.Message);
                Log4NetHelp.Error("业务层处理报警数据失败!" + ex.Message);
            }
        }