Beispiel #1
0
        /// <summary>
        /// 视频下载记录
        /// </summary>
        /// <param name="handleRecordId"></param>
        /// <param name="eventId"></param>
        /// <param name="alarmTime"></param>
        /// <param name="deviceInfo"></param>
        /// <returns></returns>
        public bool VideoDownload(int handleRecordId, int eventId, DateTime alarmTime, List <ServDeviceInfoModel> deviceInfo)
        {
            try
            {
                ServAlarmVideoTimeDAL   videoTimeDal = new ServAlarmVideoTimeDAL();
                ServAlarmVideoTimeModel videoTime    = videoTimeDal.GetEntityByEventId(eventId);
                if (videoTime != null)
                {
                    DateTime startTime = alarmTime.AddSeconds(-videoTime.start_time);
                    DateTime endTime   = alarmTime.AddSeconds(videoTime.end_time);
                    if (startTime == endTime)
                    {
                        Log4NetHelp.Info("开始下载时间与结束时间一致!请重新配置事件,事件ID:" + eventId);
                        return(false);
                    }

                    //循环调用视频下载接口,
                    //记录存入视频下载表和关联表
                    if (deviceInfo != null)
                    {
                        ServVideoPlanHandleRecordDAL dal = new ServVideoPlanHandleRecordDAL();
                        for (int i = 0; i < deviceInfo.Count; i++)
                        {
                            try
                            {
                                //增加视频下载记录及报警视频关联记录
                                if (!dal.AddPlanVideoDownRecord(handleRecordId, "", DateTime.Now, deviceInfo[i].device_code, deviceInfo[i].device_name, (int)EnumClass.VideoDownLoadStatus.未开始下载, 1, endTime, startTime, (int)EnumClass.VideoDownLoadType.报警))
                                {
                                    Log4NetHelp.Info("视频下载记录写入下载记录表失败!处理记录ID:" + handleRecordId + " 设备名称:" + deviceInfo[i].device_name);
                                }
                            }
                            catch (Exception ex)
                            {
                                Log4NetHelp.Info("视频下载记录写入下载记录表失败!处理记录ID:" + handleRecordId + " 设备名称:" + deviceInfo[i].device_name + " 错误:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        Log4NetHelp.Info("待下载摄像头数据为空!");
                    }
                    return(true);
                }
                else
                {
                    Log4NetHelp.Info("根据报警事件ID未找到事件!无法找到视频下载时间配置!");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log4NetHelp.Error("处理预案视频下载失败!" + ex.Message);
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 根据事件ID获取视频下载时间
 /// </summary>
 /// <param name="eventId"></param>
 /// <returns></returns>
 public ServAlarmVideoTimeModel GetAlarmVideoTime(int eventId)
 {
     try
     {
         ServAlarmVideoTimeDAL alarmVideoTimeDal = new ServAlarmVideoTimeDAL();
         return(alarmVideoTimeDal.GetEntityByEventId(eventId));
     }
     catch (Exception ex)
     {
         Log4NetHelp.Error("根据事件ID查找视频播放时间失败!事件ID:" + eventId + " 错误信息:" + ex.Message);
         return(null);
     }
 }
Beispiel #3
0
        /// <summary>
        ///预案处置项记录结果转换
        /// </summary>
        /// <param name="planType"></param>
        /// <param name="ItemList"></param>
        /// <returns></returns>
        private PlanItemHandledInfo TranPlanItemRecord(int planType, List <ServPlanItemResultModel> ItemList, string eventCode, DateTime alarmTime)
        {
            PlanItemHandledInfo       handleInfoModel   = new PlanItemHandledInfo();
            List <TranPlanItemResult> retList           = new List <TranPlanItemResult>();
            TranPlanItemResult        retModel          = null;
            ServAlarmVideoTimeDAL     alarmVideoTimeDal = new ServAlarmVideoTimeDAL();
            BaseEventTypeBLL          baseEventTypeBll  = new BaseEventTypeBLL();
            List <BaseEventTypeModel> eventList         = baseEventTypeBll.GetAllEventType(); //获取全部事件类型

            #region 查找事件  旧版
            //int queryEventId = eventId;
            //var alarmEvent = eventList.FirstOrDefault(n => n.id == eventId); //查询当前事件
            //if (alarmEvent != null && alarmEvent.pid != -1)  //判断是否是父级事件
            //{
            //    var rootEvent = eventList.FirstOrDefault(n => n.id == alarmEvent.pid);//查询父级事件,目前事件只保留两级
            //    if (rootEvent != null)
            //    {
            //        queryEventId = rootEvent.id;
            //    }
            //    else
            //    {
            //        queryEventId = -1;
            //    }
            //}

            #endregion

            #region 查找事件  新版
            int queryEventId = -1;
            if (!string.IsNullOrEmpty(eventCode) && eventCode != "")
            {
                var alarmEvent = eventList.FirstOrDefault(n => n.event_code == eventCode);//查找事件
                if (alarmEvent != null)
                {
                    if (alarmEvent.pid == -1)
                    {
                        queryEventId = alarmEvent.id;
                    }
                    else
                    {
                        var rootEvent = eventList.FirstOrDefault(n => n.id == alarmEvent.pid);
                        if (rootEvent != null)   //找到父级事件
                        {
                            queryEventId = rootEvent.id;
                        }
                        else                    //未找到父级事件
                        {
                            queryEventId = -1;
                        }
                    }
                }
                else
                {
                    queryEventId = -1;
                }
            }
            else
            {
                queryEventId = -1;
            }
            #endregion
            //查询摄像头播放视频时长
            var videoTimeModel = alarmVideoTimeDal.GetEntityByEventId(queryEventId);
            handleInfoModel.videoTime = new ServAlarmVideoTimeCustom();
            handleInfoModel.videoTime.videoTimeModel = videoTimeModel;
            handleInfoModel.videoTime.videoStartTime = alarmTime.AddSeconds(-handleInfoModel.videoTime.videoTimeModel.start_time);
            handleInfoModel.videoTime.videoEndTime   = alarmTime.AddSeconds(handleInfoModel.videoTime.videoTimeModel.start_time);

            foreach (ServPlanItemResultModel item in ItemList)
            {
                retModel = new TranPlanItemResult();
                retModel.itemRecordId = item.id;
                retModel.content      = item.content;
                retModel.executeTime  = item.execute_time.ToString();
                retModel.confirm_type = item.confirm_type;
                retModel.itemResult   = Enum.IsDefined(typeof(EnumClass.PlanItemResult), item.item_result) ? Enum.ToObject(typeof(EnumClass.PlanItemResult), item.item_result).ToString() : "";

                #region  设备预案与事件预案分开处理,防止处置项类型不一致
                switch (planType)
                {
                case (int)EnumClass.PlanType.设备预案:
                    switch (item.confirm_type)
                    {
                    case (int)EnumClass.PlanHandleTime.确警前:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        //case (int)EnumClass.DevicePlanDefaultOptions.关联摄像头:
                        //    //查找关联的摄像头名称以及报警时长
                        //    ServPlanHandleItemCameraDAL planHandleItemCameraDal = new ServPlanHandleItemCameraDAL();
                        //    handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(item.handleitem_id);
                        //    break;
                        case (int)EnumClass.DevicePlanDefaultOptions.告警视频下载:
                            //查找视频下载记录状态
                            ServVideoPlanHandleRecordDAL servVideoPlanHandleRecordDal = new ServVideoPlanHandleRecordDAL();
                            handleInfoModel.videoList = servVideoPlanHandleRecordDal.GetDownLoadVideoListByItemId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanDefaultOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanDefaultOptions.通知设备网格第一负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    case (int)EnumClass.PlanHandleTime.确警后:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.DevicePlanConfirmOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.DevicePlanConfirmOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        case (int)EnumClass.DevicePlanConfirmOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanConfirmOptions.通知设备网格第一负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    default: break;
                    }
                    break;

                case (int)EnumClass.PlanType.事件预案:
                    switch (item.confirm_type)
                    {
                    case (int)EnumClass.PlanHandleTime.确警前:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.EventPlanDefaultOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.EventPlanDefaultOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        //case (int)EnumClass.EventPlanDefaultOptions.关联摄像头:
                        //    //查找关联的摄像头名称以及报警时长
                        //    ServPlanHandleItemCameraDAL planHandleItemCameraDal = new ServPlanHandleItemCameraDAL();
                        //    handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(item.handleitem_id);
                        //    break;
                        case (int)EnumClass.EventPlanDefaultOptions.告警视频下载:
                            //查找视频下载记录状态
                            ServVideoPlanHandleRecordDAL servVideoPlanHandleRecordDal = new ServVideoPlanHandleRecordDAL();
                            handleInfoModel.videoList = servVideoPlanHandleRecordDal.GetDownLoadVideoListByItemId(item.id);
                            break;

                        case (int)EnumClass.EventPlanDefaultOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.EventPlanDefaultOptions.通知设备网格第一负责人:
                            //查找短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    case (int)EnumClass.PlanHandleTime.确警后:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.EventPlanConfirmOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.EventPlanConfirmOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        case (int)EnumClass.EventPlanConfirmOptions.通知其他负责人:
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.EventPlanConfirmOptions.通知设备网格第一负责人:
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    default: break;
                    }
                    break;

                default: break;
                }

                #endregion

                retList.Add(retModel);
            }
            handleInfoModel.resultList = retList;
            return(handleInfoModel);
        }