예제 #1
0
        private void Run()
        {
            while (true)
            {
                var srsDeviceIdList = SystemApis.GetAllSrsManagerDeviceId();
                if (srsDeviceIdList == null || srsDeviceIdList.Count == 0)
                {
                    continue;
                }
                foreach (var deviceId in srsDeviceIdList)
                {
                    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;
                        }
                        execDvrDeletePlan(dvrPlan);
                        execDvrOnOrOffPlan(dvrPlan);
                    }
                }

                Thread.Sleep(interval);
            }
        }
예제 #2
0
        public List <StreamDvrPlan> GetDvrPlan(ReqGetDvrPlan rdp)
        {
            ResponseStruct rs;
            var            ret = DvrPlanApis.GetDvrPlanList(rdp, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new HttpResponseException(JsonHelper.ToJson(rs));
            }
            return(ret);
        }
예제 #3
0
        public JsonResult GetDvrPlanList(ReqGetDvrPlan rdp)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { rdp });

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

            var rt = DvrPlanApis.GetDvrPlanList(rdp, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
        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;
                }
            }
        }