public static async Task <TArgs> AddAndBroadcast <TArgs>(TArgs msg)
            where TArgs : IRtcmMsg
        {
            IRtcmMsg addedMsg;

            List <String> domains;

            switch (msg.Header.EventCode)
            {
            case CtrlMsgType.WM_CTRL_MSG_EVENT_CALLSTART:
                EventCallStartMsg callStartMsg = msg as EventCallStartMsg;
                addedMsg = CircuitsMsgHandler.AddNewMsg(callStartMsg);

                domains = Caching.GetDomains(addedMsg.Header.SiteId);
                await _circuitsHub.Clients.Groups(domains).BroadcastAddCallStartMsg(addedMsg);

                break;

            case CtrlMsgType.WM_CTRL_MSG_EVENT_CALLEND:
                EventCallEndMsg callEndMsg = msg as EventCallEndMsg;
                addedMsg = CircuitsMsgHandler.AddNewMsg(callEndMsg);

                domains = Caching.GetDomains(addedMsg.Header.SiteId);
                await _circuitsHub.Clients.Groups(domains).BroadcastAddCallEndMsg(addedMsg);

                break;

            default:
                throw new ArgumentException($"Message type {msg.Header.EventCode} not supported");
            }

            return((TArgs)addedMsg);
        }
        public static void SetIsRecorded(this EventCallStartMsg msg)
        {
            if (!msg.IsDataValid() || String.IsNullOrWhiteSpace(msg.Header?.CalledNumber))
            {
                return;
            }

            GetInteractionArguments args = new GetInteractionArguments();

            args.Ani                = msg.Header.Ani;
            args.InmateId           = msg.Header.Pin;
            args.ExternalIdentifier = msg.Header.CalledNumber;
            args.SiteId             = msg.Header.SiteId;

            RecordingLevel recordingLevel = CircuitRepo.GetRecordingLevel(args);

            msg.Data.Recorded = recordingLevel != RecordingLevel.DoNotRecord;
        }
示例#3
0
        public async Task <IHttpActionResult> AddCallStartMessage([FromBody] EventCallStartMsg msg)
        {
            try
            {
                if (msg?.Header == null || msg.Data == null)
                {
                    _logger.LogWarning("Unable to deserialize EventCallStartMsg object. msg, msg.header or msg.data was null.");
                    return(BadRequest("Unable to deserialize EventCallStartMsg object."));
                }

                try
                {
                    msg.PopulateInmateNames();
                    msg.SetIsRecorded();
                }
                catch (Exception prodigyEx)
                {
                    _logger.LogError(prodigyEx, $"Error getting inmate info within AddCallStartMessage pin: {msg.Header?.Pin ?? "null"} | site ID: {msg.Header?.SiteId ?? "null"}");
                }

                EventCallStartMsg addedMsg = await CircuitsMsgRepo.AddAndBroadcast(msg);

                if (addedMsg == null)
                {
                    ArgumentException argEx = new ArgumentException("Unable to broadcast event call start message");
                    _logger.LogError(argEx, "addedMsg returned null in add call-start message.");
                    return(InternalServerError(argEx));
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error adding RTCM call-start message.");
                return(InternalServerError(ex));
            }
        }