Ejemplo n.º 1
0
        /// <summary>
        /// 执行设备预案处置项
        /// </summary>
        /// <param name="itemList"></param>
        /// <returns></returns>
        public void HandleDevicePlanItem(int planRecordId, int eventId, BaseRegionConfigModel regionModel, List <ServPlanHandleItemModel> itemList, ServDeviceInfoModel deviceInfo, ServAlarmRecordModel alarmRecord, out List <ServDeviceInfoModel> camerasList, out string ledMessage)
        {
            try
            {
                PlanItemBLL             planItemBll     = new PlanItemBLL();
                ServPlanHandleItemModel handleItemModel = itemList.FirstOrDefault(n => n.item_type == (int)EnumClass.DevicePlanDefaultOptions.关联摄像头);
                if (handleItemModel != null)
                {
                    HandleCamerasBLL camerasbll = new HandleCamerasBLL();
                    camerasList = camerasbll.GetCameras(handleItemModel.id);
                }
                else
                {
                    camerasList = null;
                }
                LEDHandle ledHandle = new LEDHandle(deviceInfo, alarmRecord);
                ledMessage = ledHandle.GetAlarmText();

                foreach (ServPlanHandleItemModel item in itemList)
                {
                    switch (item.item_type)
                    {
                    case (int)EnumClass.DevicePlanDefaultOptions.中控室LED信息显示:
                        // string content = "";
                        // LEDHandle ledHandle = new LEDHandle(deviceInfo, alarmRecord);
                        bool ledResult = ledHandle.HandleLedItem(ledMessage, regionModel.region_code);      //处理LED
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, ledMessage);
                        //if (!ht.ContainsKey(item.item_type))
                        //{
                        //    ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        //}
                        //else
                        //{
                        //    Log4NetHelp.Info("处置项重复:" + Enum.Parse(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type.ToString()).ToString());
                        //}
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.关联摄像头:

                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.告警视频下载:
                        int handleDownloadRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, "");
                        if (handleDownloadRecordId > 0)     //插入处置项记录成功,开始执行处置项
                        {
                            VideoDownloadBLL videoDownloadBll = new VideoDownloadBLL();
                            bool             bl = videoDownloadBll.VideoDownload(handleDownloadRecordId, eventId, alarmRecord.alarm_time.ToLocalTime(), camerasList);
                        }
                        //  ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.打开告警设备附近视频:
                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.控制中心声光蜂鸣器开启:
                        HandleRelayBLL handleRelayBll = new HandleRelayBLL();
                        handleRelayBll.HandleRelay(item.ext1, regionModel.region_code);
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, "");
                        //  ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.相关摄像头上大屏:
                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.通知其他负责人:
                        PlanPersonBLL planPersonBll        = new PlanPersonBLL();
                        int           handlePersonRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        if (handlePersonRecordId > 0)      //插入处置项记录成功,开始执行处置项
                        {
                            bool bl = planPersonBll.HandlePlanPerson(item.id, alarmRecord, handlePersonRecordId);
                        }
                        // ht.Add(item.item_type, new { status = 1, info = "" });
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.通知设备网格第一负责人:
                        //查找第一负责人,发送短信,记录短信记录与执行结果
                        // planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, item.item_type, planRecordId, "");
                        // ht.Add(item.item_type, new { status = 1, info = "" });
                        int dutyPersonRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    default: break;
                    }
                }
            }
            catch (Exception ex)
            {
                camerasList = null;
                ledMessage  = "";
                Log4NetHelp.Info("处理设备预案失败!报警记录ID:" + planRecordId + " " + ex.Message);
            }
            // return ht;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查找事件预案并处理
        /// </summary>
        public void HandleEventPlanItem(int planRecordId, int eventId, BaseRegionConfigModel regionModel, List <ServPlanHandleItemModel> planHandleItemList, ServDeviceInfoModel deviceInfo, ServAlarmRecordModel alarmRecord, out List <ServDeviceInfoModel> camerasList, out string ledMessage)
        {
            try
            {
                PlanItemBLL planItemBll = new PlanItemBLL();
                //ServPlanHandleItemModel handleItemModel = planHandleItemList.FirstOrDefault(n => n.item_type == (int)EnumClass.EventPlanDefaultOptions.打开周围摄像头);
                //if (handleItemModel != null)
                //{
                //    HandleCamerasBLL camerasbll = new HandleCamerasBLL();
                //    camerasList = camerasbll.GetEventPlanCameras(deviceInfo.id, int.Parse(handleItemModel.ext2), int.Parse(handleItemModel.ext3), int.Parse(handleItemModel.ext4));
                //}
                //else
                //{
                //    camerasList = null;
                //}
                camerasList = null;
                LEDHandle ledHandle = new LEDHandle(deviceInfo, alarmRecord);
                ledMessage = ledHandle.GetAlarmText();
                //单独处理打开周围摄像头
                var cameraEventList = planHandleItemList.Where(n => n.item_type == (int)EnumClass.EventPlanDefaultOptions.打开周围摄像头);
                if (cameraEventList != null && cameraEventList.Count() > 0)
                {
                    AddEventHashTable((int)EnumClass.EventPlanDefaultOptions.打开周围摄像头, new { status = 0, planRecordId = planRecordId, model = cameraEventList.ToList() });
                }
                foreach (ServPlanHandleItemModel item in planHandleItemList)
                {
                    switch (item.item_type)
                    {
                    case (int)EnumClass.EventPlanDefaultOptions.中控室LED信息显示:
                        bool ledResult = ledHandle.HandleLedItem(ledMessage, regionModel.region_code);      //处理LED
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, ledMessage);
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.EventPlanDefaultOptions.告警视频下载:
                        //int handleDownloadRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, item.item_type, planRecordId, "");
                        //if (handleDownloadRecordId > 0) //插入处置项记录成功,开始执行处置项
                        //{
                        //    VideoDownloadBLL videoDownloadBll = new VideoDownloadBLL();
                        //    bool bl = videoDownloadBll.VideoDownload(handleDownloadRecordId, eventId, alarmRecord.alarm_time.ToLocalTime(), camerasList);
                        //}
                        //AddHashTable(item.item_type, new { status = 1, info = "" });
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId });
                        break;

                    //case (int)EnumClass.EventPlanDefaultOptions.打开周围摄像头:
                    //    AddEventHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, model = item });
                    //    break;
                    case (int)EnumClass.EventPlanDefaultOptions.控制中心声光蜂鸣器开启:
                        HandleRelayBLL handleRelayBll = new HandleRelayBLL();
                        handleRelayBll.HandleRelay(item.ext1, regionModel.region_code);
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, "");
                        //  ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.EventPlanDefaultOptions.相关摄像头上大屏:
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });
                        break;

                    case (int)EnumClass.EventPlanDefaultOptions.通知其他负责人:
                        PlanPersonBLL planPersonBll        = new PlanPersonBLL();
                        int           handlePersonRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        if (handlePersonRecordId > 0)      //插入处置项记录成功,开始执行处置项
                        {
                            bool bl = planPersonBll.HandlePlanPerson(item.id, alarmRecord, handlePersonRecordId);
                        }
                        // ht.Add(item.item_type, new { status = 1, info = "" });
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.EventPlanDefaultOptions.通知设备网格第一负责人:
                        int firstDutyRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    default: break;
                    }
                }
            }
            catch (Exception ex)
            {
                camerasList = null;
                ledMessage  = "";
                Log4NetHelp.Info("处理事件预案失败!预案执行记录ID:" + planRecordId + " " + ex.Message);
            }
        }