Exemplo n.º 1
0
        private VoipCall SaveCall(TwilioVoiceRequest request, VoipCallStatus status, DaoFactory daoFactory)
        {
            var call = CallFromTwilioRequest(request);

            call.Status = status;
            return(daoFactory.VoipDao.SaveOrUpdateCall(call));
        }
Exemplo n.º 2
0
        private VoipCall SaveCall(TwilioVoiceRequest request, VoipCallStatus status)
        {
            var call = CallFromTwilioRequest(request);

            call.Status = status;
            return(Global.DaoFactory.GetVoipDao().SaveOrUpdateCall(call));
        }
Exemplo n.º 3
0
 public JObject SaveCall(string callId, string from, string to, VoipCallStatus status)
 {
     try
     {
         return(SaveOrUpdateCall(callId, from, to, status: status));
     }
     catch (Exception e)
     {
         Log.ErrorFormat("SaveCall: StackTrace:{0}, Message: {1}", e.StackTrace, e.Message);
         return(new JObject());
     }
 }
Exemplo n.º 4
0
 public JObject SaveCall(string callId, string from, string to, VoipCallStatus status)
 {
     try
     {
         return SaveOrUpdateCall(callId, from, to, status: status);
     }
     catch (Exception e)
     {
         Log.ErrorFormat("SaveCall: StackTrace:{0}, Message: {1}", e.StackTrace, e.Message);
         return new JObject();
     }
 }
Exemplo n.º 5
0
        public JObject SaveOrUpdateCall(string callId, string from = null, string to = null, string answeredBy = null,
                                        string dialDuration = null, string recordUrl = null,
                                        string recordDuration = null, VoipCallStatus? status = null,
                                        string contactId = null, decimal? price = null)
        {
            try
            {
                var request = new ApiRequest(string.Format("crm/voip/call/{0}", callId), Cookie)
                    {
                        Method = HttpMethod.Post,
                        ResponseType = ResponseType.Json
                    };

                if (!string.IsNullOrEmpty(from))
                    request.Parameters.Add(new RequestParameter {Name = "from", Value = from});

                if (!string.IsNullOrEmpty(to))
                    request.Parameters.Add(new RequestParameter {Name = "to", Value = to});

                if (status != null)
                    request.Parameters.Add(new RequestParameter {Name = "status", Value = status.Value});

                if (!string.IsNullOrEmpty(dialDuration))
                    request.Parameters.Add(new RequestParameter {Name = "dialDuration", Value = dialDuration});

                if (!string.IsNullOrEmpty(recordUrl))
                    request.Parameters.Add(new RequestParameter {Name = "recordUrl", Value = recordUrl});

                if (!string.IsNullOrEmpty(recordDuration))
                    request.Parameters.Add(new RequestParameter {Name = "recordDuration", Value = recordDuration});

                if (!string.IsNullOrEmpty(answeredBy))
                    request.Parameters.Add(new RequestParameter {Name = "answeredBy", Value = answeredBy});

                if (!string.IsNullOrEmpty(contactId))
                    request.Parameters.Add(new RequestParameter {Name = "contactId", Value = contactId});

                if (price.HasValue)
                    request.Parameters.Add(new RequestParameter { Name = "price", Value = price.Value.ToString(CultureInfo.InvariantCulture) });

                return JObject.Parse(ApiClient.GetResponse(request).Response);
            }
            catch (ApiErrorException e)
            {
                Log.ErrorFormat("SaveOrUpdateCall: StackTrace:{0}, Message: {1}", e.ErrorStackTrace, e.ErrorMessage);
                throw;
            }
        }
Exemplo n.º 6
0
        public VoipCallWrapper SaveCall(string callId, string from, string to, Guid answeredBy, VoipCallStatus? status, string contactId, decimal? price)
        {
            var dao = DaoFactory.GetVoipDao();
            
            var call = dao.GetCall(callId) ?? new VoipCall();

            call.Id = callId;
            call.From = Update.IfNotEmptyAndNotEquals(call.From, from);
            call.To = Update.IfNotEmptyAndNotEquals(call.To, to);
            call.AnsweredBy = Update.IfNotEmptyAndNotEquals(call.AnsweredBy, answeredBy);

            if (call.ContactId == 0)
            {
                var contactPhone = call.Status == VoipCallStatus.Incoming ? from : to;
                if (!string.IsNullOrEmpty(contactId))
                {
                    call.ContactId = Convert.ToInt32(contactId);
                }
                else if (status.HasValue && (status.Value == VoipCallStatus.Incoming || status.Value == VoipCallStatus.Outcoming))
                {
                    call.ContactId = DaoFactory.GetContactDao().GetContactIDsByContactInfo(ContactInfoType.Phone, contactPhone.TrimStart('+'), null, null).FirstOrDefault();
                }

                if (call.ContactId == 0)
                {
                    var person = CreatePerson(contactPhone, TenantUtil.DateTimeFromUtc(DateTime.UtcNow).ToString("yyyy-MM-dd hh:mm"), null, 0, null, ShareType.None, new List<Guid> { SecurityContext.CurrentAccount.ID }, null, null);
                    DaoFactory.GetContactInfoDao().Save(new ContactInfo { ContactID = person.ID, IsPrimary = true, InfoType = ContactInfoType.Phone, Data = contactPhone });
                    call.ContactId = person.ID;
                }
            }

            if (status.HasValue)
            {
                call.Status = status.Value;
            }

            if (call.Price == 0 && price.HasValue)
            {
                call.Price = price.Value;
                VoipPaymentSettings.Increment((int)(price.Value * 1000));
            }

            call = dao.SaveOrUpdateCall(call);

            if (call.ContactId == 0) return new VoipCallWrapper(call);

            var contact = GetContactByID(call.ContactId);
            contact = GetContactWithFotos(contact);

            return new VoipCallWrapper(call, contact);
        }