Пример #1
0
        public JsonResult OnOrOffDvrPlanById(long id, bool enable)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { id, enable });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.OnOrOffDvrPlanById(id, enable, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #2
0
        public JsonResult SetDvrPlanById(int id, ReqStreamDvrPlan sdp)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { id, sdp });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.SetDvrPlanById(id, sdp, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #3
0
        public JsonResult GetDvrVideoList(ReqGetDvrVideo rgdv)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { rgdv });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.GetDvrVideoList(rgdv, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #4
0
        public JsonResult UndoSoftDelete(long dvrVideoId)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { dvrVideoId });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.UndoSoftDelete(dvrVideoId, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #5
0
        public JsonResult CutOrMergeVideoFile(ReqCutOrMergeVideoFile rcmv)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { rcmv });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.CutOrMergeVideoFile(rcmv, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #6
0
        public JsonResult GetMergeTaskStatus(string taskId)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { taskId });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = DvrPlanApis.GetMergeTaskStatus(taskId, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Пример #7
0
        private void Run()
        {
            while (true)
            {
                var srsDeviceIdList = SystemApis.GetAllSrsManagerDeviceId();
                if (srsDeviceIdList == null || srsDeviceIdList.Count == 0)
                {
                    Thread.Sleep(interval);
                    continue;
                }

                foreach (var deviceId in srsDeviceIdList)
                {
                    clearNofileDir(deviceId);//清除空的目录
                    ReqGetDvrPlan rgdp = new ReqGetDvrPlan();
                    rgdp.DeviceId = deviceId;

                    var dvrPlanList = DvrPlanApis.GetDvrPlanList(rgdp, out ResponseStruct rs);

                    if (dvrPlanList == null || dvrPlanList.Count == 0)
                    {
                        continue;
                    }
                    foreach (var dvrPlan in dvrPlanList)
                    {
                        if (dvrPlan == null)
                        {
                            continue;
                        }

                        execDelete(dvrPlan);
                        execOnOrOff(dvrPlan);
                        Thread.Sleep(2000);
                    }
                }

                Thread.Sleep(interval);
            }
        }
        private void Run()
        {
            int i = 0;

            while (true)
            {
                try
                {
                    i++;
                    if (Common.MediaServerList == null || Common.MediaServerList.Count <= 0)
                    {
                        Thread.Sleep(5000);
                        continue;
                    }
                    foreach (var mediaServer in Common.MediaServerList)
                    {
                        if (mediaServer != null && mediaServer.IsRunning)
                        {
                            if (i % 50 == 0)
                            {
                                mediaServer.ClearNoFileDir(out _);     //清除空目录
                            }

                            ReqGetDvrPlan rgdp = new ReqGetDvrPlan();
                            rgdp.MediaServerId = mediaServer.MediaServerId;
                            var dvrPlanList = DvrPlanApis.GetDvrPlanList(rgdp, out ResponseStruct rs);
                            if (dvrPlanList == null || dvrPlanList.Count == 0)
                            {
                                continue;
                            }
                            foreach (var dvrPlan in dvrPlanList)
                            {
                                if (dvrPlan == null || dvrPlan.Enable == false)
                                {
                                    var ret = getDvrOnorOff(
                                        dvrPlan);     //如果录制计划为停止状态,在处理下一个计划任务前要查看该录制计划是否正在执行,正在扫行的话,要停掉它
                                    if (ret)
                                    {
                                        setDvrOnorOff(dvrPlan, false);
                                    }

                                    continue;
                                }

                                CameraInstance camera = null;
                                lock (Common.CameraInstanceList)
                                {
                                    camera =
                                        Common.CameraInstanceList.FindLast(x =>
                                                                           x.CameraId.Equals(dvrPlan.CameraId));
                                }

                                if (camera != null)
                                {
                                    ExecDelete(dvrPlan);
                                    if (camera.EnableLive &&
                                        getCameraSessionStatus(camera.PushMediaServerId, camera.CameraId))
                                    {
                                        execOnOrOff(dvrPlan);
                                    }
                                }

                                Thread.Sleep(2000);
                            }
                        }
                    }

                    Thread.Sleep(5000);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("报错了:\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                    continue;
                }
            }
        }