コード例 #1
0
        public HttpResponseMessage Wait()
        {
            try
            {
                LogQueryString("Wait");

                if (Convert.ToInt32(GetQueryParam("QueueTime")) == 0)
                {
                    ApiHelper.SaveOrUpdateCallHistory(GetQueryParam("CallSid"), GetQueryParam("CallSid"), queueDate: DateTime.UtcNow);
                    var to = GetQueryParam("RedirectTo");
                    if (string.IsNullOrEmpty(to))
                    {
                        SignalRHelper.Enqueue(GetQueryParam("CallSid"));
                    }
                    else
                    {
                        SignalRHelper.Incoming(GetQueryParam("CallSid"), to);
                    }
                }

                return(GetHttpResponse(TwilioResponseHelper.Wait(GetQueryParam("QueueSid"), GetQueryParam("QueueTime"), GetQueryParam("CurrentQueueSize"))));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #2
0
        public HttpResponseMessage Dial()
        {
            try
            {
                LogQueryString("Dial");

                ApiHelper.UploadRecord(GetQueryParam("DialCallSid"), GetQueryParam("CallSid"), GetQueryParam("RecordingUrl"));
                ApiHelper.SaveOrUpdateCallHistory(GetQueryParam("DialCallSid"), GetQueryParam("CallSid"), endDialDate: DateTime.UtcNow, recordUrl: GetQueryParam("RecordingUrl"), recordDuration: GetQueryParam("RecordingDuration"));

                if (!Settings.Pause)
                {
                    SignalRHelper.ChangeAgentStatus((int)AgentStatus.Online);
                }

                SignalRHelper.End();

                Task.Run(() => new ApiHelper(GetQueryParam("Tenant"), GetQueryParam("CallerId")).SavePrice(GetQueryParam("DialCallSid"), GetQueryParam("CallSid")));

                return(GetHttpResponse(TwilioResponseHelper.Dial()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #3
0
 public HttpResponseMessage GatherQueue()
 {
     try
     {
         LogQueryString("GatherQueue");
         return(GetHttpResponse(TwilioResponseHelper.GatherQueue(GetQueryParam("Digits"), GetQueryParam("To").Substring(1))));
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
コード例 #4
0
        public HttpResponseMessage Redirect()
        {
            try
            {
                LogQueryString("Redirect");

                return(GetHttpResponse(TwilioResponseHelper.Redirect(GetQueryParam("RedirectTo"))));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #5
0
        public HttpResponseMessage Queue()
        {
            try
            {
                LogQueryString("Queue");

                return(GetHttpResponse(TwilioResponseHelper.Queue()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #6
0
        public HttpResponseMessage VoiceMail()
        {
            try
            {
                LogQueryString("VoiceMail");

                ApiHelper.SaveOrUpdateCall(GetQueryParam("CallSid"), status: VoipCallStatus.Missed);

                SignalRHelper.VoiceMail(GetQueryParam("CallSid"));

                return(GetHttpResponse(TwilioResponseHelper.VoiceMail()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #7
0
        public HttpResponseMessage Enqueue()
        {
            try
            {
                LogQueryString("Enqueue");

                if (GetQueryParam("QueueResult") != "bridged" && GetQueryParam("QueueResult") != "redirected")
                {
                    ApiHelper.SaveOrUpdateCall(GetQueryParam("CallSid"), status: VoipCallStatus.Missed);
                    SignalRHelper.MissCall(GetQueryParam("CallSid"));
                }

                return(GetHttpResponse(TwilioResponseHelper.Enqueue(GetQueryParam("QueueResult"))));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #8
0
        public HttpResponseMessage Dequeue()
        {
            try
            {
                LogQueryString("Dequeue");

                if (Convert.ToBoolean(GetQueryParam("Reject")))
                {
                    ApiHelper.SaveOrUpdateCall(GetQueryParam("CallSid"), status: VoipCallStatus.Missed);
                    SignalRHelper.MissCall(GetQueryParam("CallSid"));
                    return(GetHttpResponse(TwilioResponseHelper.Leave()));
                }

                ApiHelper.AnswerCall(GetQueryParam("CallSid"), GetQueryParam("From"), GetQueryParam("To"));

                return(GetHttpResponse(TwilioResponseHelper.Dequeue()));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
コード例 #9
0
 private HttpResponseMessage Outbound()
 {
     SignalRHelper.ChangeAgentStatus((int)AgentStatus.Paused);
     ApiHelper.SaveOrUpdateCall(GetQueryParam("CallSid"), GetQueryParam("From"), GetQueryParam("To"), GetQueryParam("CallerId"), status: VoipCallStatus.Outcoming, contactId: GetQueryParam("ContactId"));
     return(GetHttpResponse(TwilioResponseHelper.Outbound()));
 }
コード例 #10
0
 private HttpResponseMessage Inbound()
 {
     ApiHelper.SaveCall(GetQueryParam("CallSid"), GetQueryParam("From"), GetQueryParam("To"), VoipCallStatus.Incoming);
     return(GetHttpResponse(TwilioResponseHelper.Inbound()));
 }
コード例 #11
0
 private TwilioResponseHelper GetTwilioResponseHelper()
 {
     return(twilioResponseHelper ?? (twilioResponseHelper = new TwilioResponseHelper(GetSettings(), CommonLinkUtility.GetFullAbsolutePath(""))));
 }