예제 #1
0
        public async Task <string> Command(ExecuteCommandRequest request)
        {
            var chandnel = await _channelService.Get(request.Id);

            if (chandnel == null)
            {
                return("命令发送失败");
            }
            List <CommandDto> data = new List <CommandDto>();

            if (request.CommandType == CommandTypeEnum.Stop)
            {
                data.Add(new CommandDto {
                    ChanneId = request.Id, CommandType = request.CommandType, FactoryCode = chandnel.FactoryCode
                });
            }
            else
            {
                data = _pullInfoService.GetPullInfoPageList(new PullInfoSearchDto {
                    ChannelId = request.Id, ResultCount = 999
                })
                       .Items.Select(s => new CommandDto
                {
                    ChanneId    = request.Id,
                    CommandType = request.CommandType,
                    FactoryCode = chandnel.FactoryCode,
                    PullAddress = s.Url,
                    PushAddress = chandnel.PushUrl
                }).ToList();
            }
            if (data.Count > 0)
            {
                var model = LiveChannelManager.Data.FirstOrDefault(m => m.Id == request.Id);
                if (model != null)
                {
                    _commandService.ExecuteCommand(data[model.PullIndex]);
                }
                else
                {
                    _commandService.ExecuteCommand(data.FirstOrDefault());
                }
                return("命令已发送");
            }
            else
            {
                return("命令发送失败,为查询到对应的数据");
            }
        }
        public async Task <LiveChannelDto> GetModel(Guid id)
        {
            var result = await _liveChannelService.Get(id);

            return(result);
        }