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; } }
private void SaveAdditionalInfoAction(QueueItem queueItem) { try { _tenantManager.SetCurrentTenant(queueItem.TenantID); var voipEngine = new VoipEngine(_daoFactory, _crmSecurity, _tenantUtil, null, _securityContext, null, _tenantManager, _voipDao); var dao = _daoFactory.GetVoipDao(); var call = dao.GetCall(queueItem.CallID); GetPriceAndDuration(call); if (call.ChildCalls.Any()) { call.ChildCalls.ForEach(r => { GetPriceAndDuration(r); voipEngine.SaveOrUpdateCall(r); }); } call = voipEngine.SaveOrUpdateCall(call); if (!string.IsNullOrEmpty(call.VoipRecord.Id)) { call.VoipRecord = _voipDao.GetProvider().GetRecord((string)call.Id, (string)call.VoipRecord.Id); voipEngine.SaveOrUpdateCall(call); } _securityContext.AuthenticateMeWithoutCookie(call.AnsweredBy); AddHistoryToCallContact(call, _daoFactory); } catch (Exception ex) { _logger.ErrorFormat("SaveAdditionalInfo {0}, {1}", ex, ex.StackTrace); } }
private static void SaveAdditionalInfoAction(QueueItem queueItem) { try { CoreContext.TenantManager.SetCurrentTenant(queueItem.TenantID); using (var scope = DIHelper.Resolve()) { var daoFactory = scope.Resolve <DaoFactory>(); var voipEngine = new VoipEngine(daoFactory); var dao = daoFactory.VoipDao; var call = dao.GetCall(queueItem.CallID); GetPriceAndDuration(call); if (call.ChildCalls.Any()) { call.ChildCalls.ForEach(r => { GetPriceAndDuration(r); voipEngine.SaveOrUpdateCall(r); }); } call = voipEngine.SaveOrUpdateCall(call); if (!string.IsNullOrEmpty(call.VoipRecord.Id)) { call.VoipRecord = VoipDao.GetProvider().GetRecord(call.Id, call.VoipRecord.Id); voipEngine.SaveOrUpdateCall(call); } SecurityContext.AuthenticateMe(call.AnsweredBy); AddHistoryToCallContact(call, daoFactory); } } catch (Exception ex) { LogManager.GetLogger("ASC").ErrorFormat("SaveAdditionalInfo {0}, {1}", ex, ex.StackTrace); } }
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); }
public HttpResponseMessage Dial(TwilioVoiceRequest request, [FromUri] Guid callerId, [FromUri] int contactId = 0, [FromUri] string reject = null) { try { using (var scope = DIHelper.Resolve()) { var daoFactory = scope.Resolve <DaoFactory>(); var voipEngine = new VoipEngine(daoFactory); request.AddAdditionalFields(callerId, contactId, reject); var call = CallFromTwilioRequest(request); call = voipEngine.SaveOrUpdateCall(call); var parentCall = daoFactory.VoipDao.GetCall(call.ParentID); if (!string.IsNullOrEmpty(request.RecordingSid)) { if (parentCall.VoipRecord == null || string.IsNullOrEmpty(parentCall.VoipRecord.Id)) { parentCall.VoipRecord = new VoipRecord { Id = request.RecordingSid }; } daoFactory.VoipDao.SaveOrUpdateCall(parentCall); } voipEngine.SaveAdditionalInfo(parentCall.Id); return(GetHttpResponse(request.Dial())); } } catch (Exception e) { Log.Error(e); throw; } }
public HttpResponseMessage Wait(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0, [FromUri] string redirectTo = null) { try { using (var scope = DIHelper.Resolve()) { var daoFactory = scope.Resolve <DaoFactory>(); var voipEngine = new VoipEngine(daoFactory); 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; } }