예제 #1
0
        /// <summary>
        /// Выполнить команду
        /// </summary>
        protected override async Task InternalExecute(Channel channel, StasisStartEventArgs args)
        {
            if (!(args is RecordingEventArgs eventArgs))
            {
                throw new ArgumentException($"RecordingEndedCommand. Incorrect argument type {nameof(args)}");
            }

            try
            {
                var audioRecord = await AudioRecordRepository.GetRecordByName(eventArgs.RecordName);

                if (audioRecord == null || audioRecord.RecordingStartTime.HasValue == false)
                {
                    Logger.Warning($"Record with name {eventArgs.RecordName} not found");
                    return;
                }

                Logger.Information($"Audio record created. RecordName: {eventArgs.RecordName};");
                await _queueSender.Publish(new AudioRecordedIntegrationEvent
                {
                    LineId             = audioRecord.LineId,
                    CallId             = audioRecord.CallId,
                    FileName           = $"{eventArgs.RecordName}.{AsteriskAriClient.RecordingFormat}",
                    RecordingStartTime = audioRecord.RecordingStartTime.Value,
                    RecordingEndTime   = eventArgs.EventTime
                });

                audioRecord.RecordingEndTime = eventArgs.EventTime;
                await AudioRecordRepository.UpdateRecord(audioRecord);
            }
            catch (Exception ex)
            {
                Logger.Warning("RecordingEndedCommand.Error.", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Выполнить команду
        /// </summary>
        protected override async Task InternalExecute(Channel channel, StasisStartEventArgs args)
        {
            if (!(args is RecordingEventArgs eventArgs))
            {
                throw new ArgumentException($"RecordingStartedCommand. Incorrect argument type {nameof(args)}");
            }

            try
            {
                var audioRecord = await AudioRecordRepository.GetRecordByName(eventArgs.RecordName);

                if (audioRecord != null)
                {
                    audioRecord.RecordingStartTime = eventArgs.EventTime;
                    await AudioRecordRepository.UpdateRecord(audioRecord);
                }
                else
                {
                    Logger.Warning($"RecordingStartedCommand. AudioRecord not found. RecordName: {eventArgs.RecordName}.");
                }
            }
            catch (Exception ex)
            {
                Logger.Warning("RecordingStartedCommand.Error.", ex);
            }
        }
예제 #3
0
        private async Task UpdateAudioRecords(string mainBridgeId, Guid initCallId, Guid?lineId)
        {
            var commonBridgeId = GetCommonRecordingBridgeId(mainBridgeId);

            var audioRecord = await AudioRecordRepository.GetRecordByName(commonBridgeId);

            if (audioRecord != null)
            {
                audioRecord.LineId = lineId;
                await AudioRecordRepository.UpdateRecord(audioRecord);
            }

            var initCallRecord = await AudioRecordRepository.GetRecordByCallId(initCallId);

            if (initCallRecord != null)
            {
                initCallRecord.LineId = lineId;
                await AudioRecordRepository.UpdateRecord(initCallRecord);
            }
        }