コード例 #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
        public HttpResponseMessage Dequeue(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0, [FromUri] string reject = "")
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    var voipEngine = new VoipEngine(scope.Resolve <DaoFactory>());
                    request.AddAdditionalFields(callerId, contactId, reject);

                    if (Convert.ToBoolean(request.Reject))
                    {
                        MissCall(request, voipEngine);
                        return(GetHttpResponse(request.Leave()));
                    }


                    voipEngine.AnswerCall(CallFromTwilioRequest(request));

                    return(GetHttpResponse(request.Dequeue()));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #3
0
        public HttpResponseMessage Wait(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0, [FromUri] string redirectTo = null)
        {
            try
            {
                request.AddAdditionalFields(callerId, contactId, redirectTo: redirectTo);
                if (Convert.ToInt32(request.QueueTime) == 0)
                {
                    var history = CallFromTwilioRequest(request);
                    history.ParentID = history.Id;
                    voipEngine.SaveOrUpdateCall(history);

                    var to = request.RedirectTo;
                    if (string.IsNullOrEmpty(to))
                    {
                        request.GetSignalRHelper().Enqueue(request.CallSid, callerId.HasValue ? callerId.Value.ToString() : "");
                    }
                    else
                    {
                        request.GetSignalRHelper().Incoming(request.CallSid, to);
                    }
                }

                return(GetHttpResponse(request.Wait()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #4
0
 public HttpResponseMessage Redirect(TwilioVoiceRequest request, [FromUri] string redirectTo, [FromUri] Guid?callerId = null)
 {
     try
     {
         request.AddAdditionalFields(callerId, redirectTo: redirectTo);
         return(GetHttpResponse(request.Redirect()));
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
コード例 #5
0
 public HttpResponseMessage GatherQueue(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
 {
     try
     {
         request.AddAdditionalFields(callerId, contactId);
         return(GetHttpResponse(request.GatherQueue()));
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
コード例 #6
0
        public HttpResponseMessage Client(TwilioVoiceRequest request, [FromUri] Guid callerId)
        {
            try
            {
                request.AddAdditionalFields(callerId);

                voipEngine.SaveOrUpdateCall(CallFromTwilioRequest(request));

                return(GetHttpResponse(new VoiceResponse()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #7
0
 public HttpResponseMessage Index(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
 {
     try
     {
         lock (LockObj)
         {
             request.AddAdditionalFields(callerId, contactId);
             var response = request.IsInbound ? Inbound(request) : Outbound(request);
             return(GetHttpResponse(response));
         }
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
コード例 #8
0
        public HttpResponseMessage Enqueue(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
        {
            try
            {
                request.AddAdditionalFields(callerId, contactId);
                if (request.QueueResult != "bridged" && request.QueueResult != "redirected")
                {
                    MissCall(request);
                }

                return(GetHttpResponse(request.Enqueue(request.QueueResult)));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #9
0
        public HttpResponseMessage Client(TwilioVoiceRequest request, [FromUri] Guid callerId)
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    request.AddAdditionalFields(callerId);

                    new VoipEngine(scope.Resolve <DaoFactory>()).SaveOrUpdateCall(CallFromTwilioRequest(request));

                    return(GetHttpResponse(new VoiceResponse()));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #10
0
 public HttpResponseMessage Index(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
 {
     try
     {
         lock (LockObj)
         {
             using (var scope = DIHelper.Resolve())
             {
                 var daoFactory = scope.Resolve <DaoFactory>();
                 request.AddAdditionalFields(callerId, contactId);
                 var response = request.IsInbound ? Inbound(request, daoFactory) : Outbound(request, daoFactory);
                 return(GetHttpResponse(response));
             }
         }
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
コード例 #11
0
        public HttpResponseMessage VoiceMail(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    var daoFactory = scope.Resolve <DaoFactory>();
                    var voipEngine = new VoipEngine(daoFactory);
                    request.AddAdditionalFields(callerId, contactId);

                    MissCall(request, voipEngine);

                    return(GetHttpResponse(request.VoiceMail()));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #12
0
        public HttpResponseMessage Enqueue(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    var daoFactory = scope.Resolve <DaoFactory>();
                    var voipEngine = new VoipEngine(daoFactory);

                    request.AddAdditionalFields(callerId, contactId);
                    if (request.QueueResult != "bridged" && request.QueueResult != "redirected")
                    {
                        MissCall(request, voipEngine);
                    }

                    return(GetHttpResponse(request.Enqueue(request.QueueResult)));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }