Esempio n. 1
0
        /// <summary>
        /// 文件一个一个删除
        /// </summary>
        /// <param name="videoSize"></param>
        /// <param name="sdp"></param>
        private void deleteFileOneByOne(decimal videoSize, MediaServerStreamInfo mediaInfo, RecordPlan plan)
        {
            ReqGetRecordFileList req = new ReqGetRecordFileList();

            req.MainId        = mediaInfo.Stream;
            req.MediaServerId = mediaInfo.MediaServerId;
            req.Deleted       = false;
            req.OrderBy       = new List <OrderByStruct>();
            req.OrderBy.Add(new OrderByStruct()
            {
                FieldName  = "starttime",
                OrderByDir = OrderByDir.ASC,
            });
            req.PageIndex = 1;
            req.PageSize  = 100;


            long deleteSize = 0;

            while (videoSize - deleteSize > plan.LimitSpace)
            {
                var recordFileList = MediaServerService.GetRecordFileList(req, out ResponseStruct rs);
                if (!rs.Code.Equals(ErrorNumber.None))
                {
                    break;
                }

                if (recordFileList != null && recordFileList.RecordFileList != null &&
                    recordFileList.RecordFileList.Count > 0)
                {
                    foreach (var ret in recordFileList.RecordFileList)
                    {
                        if (ret != null)
                        {
                            if (MediaServerService.DeleteRecordFile(ret.Id, out rs))
                            {
                                deleteSize += (long)ret.FileSize !;
                                Logger.Info(
                                    $"[{Common.LoggerHead}]->删除一个录制文件->{mediaInfo.MediaServerId}->{mediaInfo.Stream}->DBId:{ret.Id}->FilePath:{ret.VideoPath}");
                            }

                            Thread.Sleep(20);
                        }

                        if ((videoSize - deleteSize) < plan.LimitSpace)
                        {
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public ResGetRecordFileList GetRecordFileList([FromHeader(Name = "AccessKey")] string AccessKey,
                                                      ReqGetRecordFileList req)
        {
            ResponseStruct rs;
            var            ret = MediaServerService.GetRecordFileList(req, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new AkStreamException(rs);
            }

            return(ret);
        }