private async Task <Result <CallRecordInfoDto> > GetParticipantRecordInfo(
            List <CallTimeInfoClientDto> participantCalls,
            AudioRecordClientDto participantRecord,
            AudioRecordClientDto fullRecord)
        {
            var participantCallInfo = participantCalls.FirstOrDefault(x => x.CallId == participantRecord.CallId);

            if (participantCallInfo == null)
            {
                _logger.Warning($"GenerateParticipantsList. Participant call not found. CallId: {participantRecord.CallId}");
                return(Result.Failure <CallRecordInfoDto>(ErrorCodes.UnableToGetAudioRecords));
            }

            var participant = await GetParticipant(participantCallInfo.ParticipantId.Value);

            var participantInfo = ParticipantInfoCreator.GetParticipantInfoDto(participant);

            FillParticipantTimeStamps(participantInfo, participantRecord, fullRecord);

            var participantRecordInfo = new CallRecordInfoDto
            {
                Id = participantRecord.Id,
                ParticipantInfo = participantInfo,
                IsEmercoreUser  = participant is User,
                CallId          = participantCallInfo.CallId,
                IsFullRecord    = false
            };

            return(Result.Success(participantRecordInfo));
        }
Esempio n. 2
0
        /// <summary>
        /// Получить линии по caseFolderId
        /// </summary>
        /// <param name="caseFolderId"></param>
        /// <returns></returns>
        public async Task <Result <List <LineByCaseFolderViewDto> > > GetLinesByCaseFolderId(Guid caseFolderId)
        {
            var getLinesByCaseFolderIdResult = await _callManagementServiceClient.GetLinesByCaseFolderId(caseFolderId);

            if (getLinesByCaseFolderIdResult.IsFailure)
            {
                _logger.Warning(getLinesByCaseFolderIdResult.ErrorMessage);
                return(Result.Failure <List <LineByCaseFolderViewDto> >(ErrorCodes.UnableToGetLines));
            }

            using (_unitOfWork.Begin())
            {
                var lineDtos = getLinesByCaseFolderIdResult.Value.Select(x => _mapper.Map <LineByCaseFolderDto>(x)).ToList();

                var linesByCaseFolderView = new List <LineByCaseFolderViewDto>();

                foreach (var lineDto in lineDtos)
                {
                    var lineByCaseFolder = new LineByCaseFolderViewDto
                    {
                        Id             = lineDto.Id,
                        CaseFolderId   = lineDto.CaseFolderId,
                        CreateDateTime = lineDto.CreateDateTime,
                        FirstCallType  = lineDto.FirstCallType
                    };

                    var caller = await GetParticipant(lineDto.CallerId);

                    lineByCaseFolder.CallInitiator  = ParticipantInfoCreator.GetParticipantInfoDto(caller);
                    lineByCaseFolder.IsEmercoreUser = caller is User;

                    linesByCaseFolderView.Add(lineByCaseFolder);
                }

                return(Result.Success(linesByCaseFolderView));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Получить все линии, в которых участвует пользователь
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <Result <List <LineViewDto> > > GetUserLines(Guid userId)
        {
            var userLinesResult = await _callManagementServiceClient.GetUserLines();

            if (userLinesResult.IsFailure)
            {
                _logger.Warning(userLinesResult.ErrorMessage);
                return(Result.Failure <List <LineViewDto> >(ErrorCodes.UnableToGetUserLines));
            }

            using (_unitOfWork.Begin())
            {
                var userLines = userLinesResult.Value.Select(LineViewDto.MapFromClientDto).ToList();
                foreach (var infoDto in userLines.SelectMany(x => x.Participants))
                {
                    var participant = await GetParticipant(infoDto.Id);

                    infoDto.Extension       = participant?.ParticipantExtension;
                    infoDto.ParticipantInfo = ParticipantInfoCreator.GetParticipantInfo(participant);
                }

                return(Result.Success(userLines));
            }
        }