Пример #1
0
        public HttpResponseMessage Dial(TwilioVoiceRequest request, [FromUri] Guid callerId, [FromUri] int contactId = 0, [FromUri] string reject = null)
        {
            try
            {
                request.AddAdditionalFields(callerId, contactId, reject);

                var call = CallFromTwilioRequest(request);
                call = voipEngine.SaveOrUpdateCall(call);

                var parentCall = Global.DaoFactory.GetVoipDao().GetCall(call.ParentID);

                if (!string.IsNullOrEmpty(request.RecordingSid))
                {
                    if (parentCall.VoipRecord == null || string.IsNullOrEmpty(parentCall.VoipRecord.Id))
                    {
                        parentCall.VoipRecord = new VoipRecord {
                            Id = request.RecordingSid
                        };
                    }

                    Global.DaoFactory.GetVoipDao().SaveOrUpdateCall(parentCall);
                }

                voipEngine.SaveAdditionalInfo(parentCall.Id);

                return(GetHttpResponse(request.Dial()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
Пример #2
0
        private void MissCall(TwilioVoiceRequest request, VoipEngine voipEngine)
        {
            var voipCall = CallFromTwilioRequest(request);

            voipCall.Status = VoipCallStatus.Missed;

            if (!string.IsNullOrEmpty(request.RecordingSid))
            {
                if (voipCall.VoipRecord == null || string.IsNullOrEmpty(voipCall.VoipRecord.Id))
                {
                    voipCall.VoipRecord = new VoipRecord {
                        Id = request.RecordingSid
                    };
                }
            }

            voipCall = voipEngine.SaveOrUpdateCall(voipCall);
            request.GetSignalRHelper().MissCall(request.CallSid, voipCall.AnsweredBy.ToString());
            voipEngine.SaveAdditionalInfo(voipCall.Id);
        }