예제 #1
0
        public HttpResponseMessage InboundAction(InboundCallRequest request)
        {
            var destinationUrl = "";
            var response = Request.CreateResponse(HttpStatusCode.Redirect);

            if (ModelState.IsValid && !string.IsNullOrWhiteSpace(request.CallSid))
            {
                    var call = new Call
                    {
                        Sid = request.CallSid,
                        CallStatus = CallStatus.LocatingEndPoint,
                        CallerNumber = request.Caller,
                        IsInbound = true,
                        DateReceived = DateTime.Now,
                        Dialled = request.Called
                    };
                    _callService.LogInboundCall(call, null);
                    var baseUri =
                        new Uri(Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.PathAndQuery, string.Empty));
                    destinationUrl += _endpointResolverService.Resolve(request.Called, request.CallSid, null,
                        baseUri);
            }

            _logger.Debug($"Redirecting twilio request for call {request.CallSid} to url {destinationUrl}");

            response.Headers.Location = new Uri(destinationUrl);
            return response;
        }
예제 #2
0
        public void LogInboundCall(Call call, Customer customer)
        {
            var existingCall = _callRepository.GetBySid(call.Sid);

            if (existingCall != null)
            {
                try
                {
                    _callRepository.Update(call);
                    _logger.Debug($"Updated call {existingCall.Sid} with status {existingCall.CallStatus}");
                }
                catch (Exception ex)
                {
                    _logger.Error($"There was an error updating call {call.CallId}:  {ex}");
                }
            }
            else
            {
                try
                {
                    _callRepository.CreateInbound(call, customer);
                    _logger.Debug($"Created call {call.CallId}, with Sid {call.Sid}, with status {call.CallStatus}");
                }
                catch (Exception ex)
                {
                    _logger.Error($"There was an error creating call {call.CallId}:  {ex}");
                }
            }
        }
예제 #3
0
 public void FlagInboundCallAbandoned(Call call)
 {
     try
     {
         _callRepository.FlagInboundCallAbandoned(call);
     }
     catch (Exception ex)
     {
         _logger.Error($"Exception thrown marking inbound call as abandoned {call.Sid}:  {ex}");
     }
 }
예제 #4
0
 public void FlagInboundCallAbandoned(Call call)
 {
     call.DateUpdated = DateTime.Now;
     using (var db = _dbFactory.GetDatabase())
     {
         try
         {
             db.Execute(new FlagInboundCallAbandoned(call));
         }
         catch (Exception ex)
         {
             _logger.Error($"Error occured executing FlagInboundCallAbandoned - {ex}");
         }
     }
 }
예제 #5
0
 public Call CreateOutbound(Call call)
 {
     using (var db = _dbFactory.GetDatabase())
     {
         try
         {
             call.CallId = db.Query(new CreateOutboundCallCommand(call));
         }
         catch (Exception ex)
         {
             _logger.Error($"Error occured executing CreateOutboundCallCommand - {ex}");
         }
     }
     return call;
 }
예제 #6
0
 public Call CreateInbound(Call call, Customer customer)
 {
     using (var db = _dbFactory.GetDatabase())
     {
         try
         {
             if (customer == null)
             {
                 customer = new Customer();
             }
             call.CallId = db.Query(new CreateCallCommand(call, customer));
         }
         catch (Exception ex)
         {
             _logger.Error($"Error occured executing CreateCallCommand - {ex}");
         }
     }
     return call;
 }
 public UpdateOutboundCallById(Call call)
 {
     _call = call;
 }
예제 #8
0
 public UpdateCallCommand(Call call)
 {
     _call = call;
 }
예제 #9
0
 public Call GetById(string callId)
 {
     var call = new Call();
     using (var db = _dbFactory.GetDatabase())
     {
         try
         {
             call = db.Query(new GetCallById(callId));
             return call;
         }
         catch (Exception ex)
         {
             _logger.Error($"Error occured executing GetCallById with Id {callId} - {ex}");
         }
         return call;
     }
 }
예제 #10
0
 public void UpdateOutboundById(Call call)
 {
     using (var db = _dbFactory.GetDatabase())
     {
         try
         {
             db.Execute(new UpdateOutboundCallById(call));
         }
         catch (Exception ex)
         {
             _logger.Error($"Error occured executing CreateOutboundCallCommand - {ex}");
         }
     }
 }
예제 #11
0
 public bool Update(Call call)
 {
     call.DateUpdated = DateTime.Now;
     using (var db = _dbFactory.GetDatabase())
     {
         if (call.EndTime > DateTime.MinValue)
         {
             try
             {
                 db.Execute(new SetCallInactiveBySid(call));
                 return true;
             }
             catch (Exception ex)
             {
                 _logger.Error($"Exception thrown executing SetCallInactiveBySid - {ex}");
             }
         }
         else if (call.StartTime > DateTime.MinValue)
         {
             try
             {
                 db.Execute(new SetCallActiveBySid(call));
             }
             catch (Exception ex)
             {
                 _logger.Error($"Exception thrown executing SetCallActiveBySid - {ex}");
             }
         }
         else
         {
             try
             {
                 db.Execute(new UpdateCallCommand(call));
                 return true;
             }
             catch (Exception ex)
             {
                 _logger.Error($"Exception thrown executing UpdateCallCommand - {ex}");
             }
         }
         return false;
     }
 }
예제 #12
0
 public void UpdateCallBySid(Call call)
 {
     call.CallId = 0;
     _callRepository.Update(call);
 }
예제 #13
0
 public void UpdateCallById(Call call)
 {
     try
     {
         _callRepository.UpdateOutboundById(call);
     }
     catch (Exception ex)
     {
         _logger.Error($"Exception thrown creating outbound call {call.CallId}:  {ex}");
     }
 }
예제 #14
0
 public Call LogOutboundCall(Call call)
 {
     try
     {
        return _callRepository.CreateOutbound(call);
     }
     catch (Exception ex)
     {
         _logger.Error($"Exception thrown creating outbound call {call.CallId}:  {ex}");
     }
     return null;
 }
예제 #15
0
 public SetCallActiveBySid(Call call)
 {
     _call = call;
 }
 public FlagInboundCallAbandoned(Call call)
 {
     _call = call;
 }