Example #1
0
        /// <summary>
        /// 根据ID修改视频轮播计划任务
        /// </summary>
        /// <param name="id"></param>
        /// <param name="scheduleName"></param>
        /// <param name="regionId"></param>
        /// <param name="scheduleType"></param>
        /// <param name="endTime"></param>
        /// <param name="startTime"></param>
        /// <param name="groupId"></param>
        /// <param name="timeType"></param>
        /// <param name="frequency"></param>
        /// <param name="cameraPatrolType"></param>
        /// <param name="galleryCode"></param>
        /// <param name="galleryInterval"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public bool UpdateScheduleById(int id, string scheduleName, int regionId, int scheduleType, string endTime, string startTime, int groupId, string startExecuteTime, string periodExpression, int cameraPatrolType, string galleryCode, int galleryInterval, string content, int spanTime, string scheduleDate)
        {
            try
            {
                CameraScheduleCustom custom = new CameraScheduleCustom();
                custom.id                 = id;
                custom.content            = content;
                custom.create_time        = DateTime.Now;
                custom.end_execute_time   = "";
                custom.end_time           = DateTime.Parse(endTime);
                custom.ext1               = groupId.ToString();          //摄像头组ID
                custom.ext2               = cameraPatrolType.ToString(); //轮询或者轮切
                custom.ext3               = galleryCode;                 //轮切时屏编码
                custom.ext4               = galleryInterval.ToString();  //轮切时间隔/s
                custom.period_expression  = periodExpression;
                custom.region_id          = regionId;
                custom.schedule_name      = scheduleName;
                custom.schedule_state     = (int)EnumClass.ScheduleState.启用;
                custom.schedule_type      = scheduleType;
                custom.start_execute_time = startExecuteTime;
                custom.start_time         = DateTime.Parse(startTime);
                custom.span_time          = spanTime;
                custom.schedule_date      = scheduleDate;
                return(servScheduleDal.UpdateCameraPatrolSchedule(custom));

                #region  旧
                //ServScheduleModel model = new ServScheduleModel();
                //model.id = id;
                //model.create_time = DateTime.Now;
                //model.start_time = DateTime.Parse(startTime);
                //model.end_time = DateTime.Parse(endTime);
                ////string executeTime = TimeExpression.ToTimeExpression(model.start_time, timeType, frequency);  //获取执行时间表达式
                //model.start_execute_time = startExecuteTime;
                //model.end_execute_time = endExecuteTime;
                //model.period_expression = periodExpression;
                //model.ext1 = groupId.ToString();            //摄像头组ID
                //model.ext2 = cameraPatrolType.ToString();  //轮询或者轮切
                //model.ext3 = galleryCode;                  //轮切时屏编码
                //model.ext4 = galleryInterval.ToString();         //轮切时间隔/s
                //model.region_id = regionId;
                //model.schedule_name = scheduleName;
                //model.schedule_state = (int)EnumClass.ScheduleState.启用;
                //model.schedule_type = (int)EnumClass.ScheduleType.视频轮播;
                //model.content = content;
                //int res = servScheduleDal.UpdateCameraPatrolSchedule(model);
                //if (res > 0)
                //{
                //    return true;
                //}
                //else
                //{
                //    return false;
                //}
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        /// <summary>
        /// 新增视频轮播计划任务
        /// </summary>
        /// <param name="custom"></param>
        /// <returns></returns>
        public bool InsertCameraPatrolSchedule(CameraScheduleCustom custom)
        {
            mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务
            ServScheduleTimeConfigDAL timeConfigDal = new ServScheduleTimeConfigDAL();

            try
            {
                ServScheduleModel schedule = new ServScheduleModel();
                schedule.content           = custom.content;
                schedule.create_time       = custom.create_time;
                schedule.end_time          = custom.end_time;
                schedule.ext1              = custom.ext1;
                schedule.ext10             = custom.ext10;
                schedule.ext2              = custom.ext2;
                schedule.ext3              = custom.ext3;
                schedule.ext4              = custom.ext4;
                schedule.ext5              = custom.ext5;
                schedule.ext6              = custom.ext6;
                schedule.ext7              = custom.ext7;
                schedule.ext8              = custom.ext8;
                schedule.ext9              = custom.ext9;
                schedule.period_expression = custom.period_expression;
                schedule.region_id         = custom.region_id;
                schedule.schedule_name     = custom.schedule_name;
                schedule.schedule_state    = custom.schedule_state;
                schedule.schedule_type     = custom.schedule_type;
                schedule.start_time        = custom.start_time;
                schedule.span_time         = custom.span_time;
                int scheduleId = AddEntity(schedule);
                if (scheduleId > 0)
                {
                    ServScheduleTimeConfigModel timeModel = new ServScheduleTimeConfigModel();
                    timeModel.schedule_id   = scheduleId;
                    timeModel.schedule_time = custom.start_execute_time;
                    timeModel.schedule_date = custom.schedule_date;
                    timeModel.time_type     = 1;//开始时间
                    if (timeConfigDal.AddEntity(timeModel) > 0)
                    {
                        mapContext.CommitTransaction();
                        return(true);
                    }
                    else
                    {
                        mapContext.RollBackTransaction();
                        return(false);
                    }
                }
                else
                {
                    mapContext.RollBackTransaction();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                mapContext.RollBackTransaction();
                throw ex;
            }
        }
Example #3
0
        /// <summary>
        /// 更新视频轮播计划任务
        /// </summary>
        /// <param name="custom"></param>
        /// <returns></returns>
        public bool UpdateCameraPatrolSchedule(CameraScheduleCustom custom)
        {
            mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务
            ServScheduleTimeConfigDAL timeConfigDal = new ServScheduleTimeConfigDAL();

            try
            {
                ServScheduleModel schedule = new ServScheduleModel();
                schedule.id                = custom.id;
                schedule.content           = custom.content;
                schedule.create_time       = custom.create_time;
                schedule.end_time          = custom.end_time;
                schedule.ext1              = custom.ext1;
                schedule.ext10             = custom.ext10;
                schedule.ext2              = custom.ext2;
                schedule.ext3              = custom.ext3;
                schedule.ext4              = custom.ext4;
                schedule.ext5              = custom.ext5;
                schedule.ext6              = custom.ext6;
                schedule.ext7              = custom.ext7;
                schedule.ext8              = custom.ext8;
                schedule.ext9              = custom.ext9;
                schedule.period_expression = custom.period_expression;
                schedule.region_id         = custom.region_id;
                schedule.schedule_name     = custom.schedule_name;
                schedule.schedule_state    = custom.schedule_state;
                schedule.schedule_type     = custom.schedule_type;
                schedule.start_time        = custom.start_time;
                schedule.span_time         = custom.span_time;
                int res = UpdateScheduleById(schedule);
                if (res > 0)
                {
                    ServScheduleTimeConfigModel timeModel = timeConfigDal.GetScheduleTimeConfigByScheduleId(custom.id).FirstOrDefault(); //获取第一个视频轮播计划任务时间配置
                    //如果未找到当前时间配置,则新增时间配置记录;找到时间配置,进行更新操作
                    if (timeModel != null)
                    {
                        timeModel.schedule_time = custom.start_execute_time;
                        timeModel.schedule_date = custom.schedule_date;
                        if (timeConfigDal.UpdateTimeConfig(timeModel) > 0)
                        {
                            mapContext.CommitTransaction();
                            return(true);
                        }
                        else
                        {
                            mapContext.RollBackTransaction();
                            return(false);
                        }
                    }
                    else
                    {
                        timeModel               = new ServScheduleTimeConfigModel();
                        timeModel.schedule_id   = custom.id;
                        timeModel.schedule_time = custom.start_execute_time;
                        timeModel.schedule_date = custom.schedule_date;
                        timeModel.time_type     = 1;//开始时间
                        if (timeConfigDal.AddEntity(timeModel) > 0)
                        {
                            mapContext.CommitTransaction();
                            return(true);
                        }
                        else
                        {
                            mapContext.RollBackTransaction();
                            return(false);
                        }
                    }
                }
                else
                {
                    mapContext.RollBackTransaction();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                mapContext.RollBackTransaction();
                throw ex;
            }
        }