public VoipCallHistory UpdateCallHistoryId(VoipCallHistory callHistory) { using (var db = GetDb()) { var query = Update("crm_voip_calls_history") .Set("id", callHistory.ID) .Where(Exp.Eq("id", callHistory.ParentID)); db.ExecuteNonQuery(query); } return(callHistory); }
public VoipCallHistory SaveOrUpdateCallHistory(VoipCallHistory callHistory) { using (var db = GetDb()) { var query = Insert(callsHistoryTable) .InColumnValue("id", callHistory.ID) .InColumnValue("parent_call_id", callHistory.ParentID) .InColumnValue("answered_by", callHistory.AnsweredBy) .InColumnValue("queue_date", TenantUtil.DateTimeToUtc(callHistory.QueueDate)) .InColumnValue("answer_date", TenantUtil.DateTimeToUtc(callHistory.AnswerDate)) .InColumnValue("end_dial_date", TenantUtil.DateTimeToUtc(callHistory.EndDialDate)) .InColumnValue("record_url", callHistory.RecordUrl) .InColumnValue("record_duration", callHistory.RecordDuration) .InColumnValue("price", callHistory.Price); db.ExecuteNonQuery(query); } return(callHistory); }
public VoipCallHistory UpdateCallHistoryId(VoipCallHistory callHistory) { using (var db = GetDb()) { var query = Update(callsHistoryTable) .Set("id", callHistory.ID) .Where(Exp.Eq("id", callHistory.ParentID)); db.ExecuteNonQuery(query); } return callHistory; }
public VoipCallHistory SaveOrUpdateCallHistory(VoipCallHistory callHistory) { using (var db = GetDb()) { var query = Insert(callsHistoryTable) .InColumnValue("id", callHistory.ID) .InColumnValue("parent_call_id", callHistory.ParentID) .InColumnValue("answered_by", callHistory.AnsweredBy) .InColumnValue("queue_date", TenantUtil.DateTimeToUtc(callHistory.QueueDate)) .InColumnValue("answer_date", TenantUtil.DateTimeToUtc(callHistory.AnswerDate)) .InColumnValue("end_dial_date", TenantUtil.DateTimeToUtc(callHistory.EndDialDate)) .InColumnValue("record_url", callHistory.RecordUrl) .InColumnValue("record_duration", callHistory.RecordDuration) .InColumnValue("price", callHistory.Price); db.ExecuteNonQuery(query); } return callHistory; }
public VoipCallHistory SaveCallHistory(string callId, string parentCallId, Guid?answeredBy, string recordUrl, int recordDuration, decimal?price, ApiDateTime queueDate = null, ApiDateTime answerDate = null, ApiDateTime endDialDate = null) { var dao = DaoFactory.GetVoipDao(); var parentCall = dao.GetCall(parentCallId).NotFoundIfNull(); var listItemDao = DaoFactory.GetListItemDao(); var call = dao.GetCallHistoryById(parentCallId, callId); if (call == null) { if (parentCallId != callId) { call = dao.GetCallHistoryById(parentCallId, parentCallId); } if (call == null) { call = new VoipCallHistory { ID = callId }; } else { call.ID = callId; dao.UpdateCallHistoryId(call); } } call.ParentID = parentCallId; if (answeredBy.HasValue) { call.AnsweredBy = answeredBy.Value; } call.QueueDate = Update.IfNotEmptyAndNotEquals(call.QueueDate, queueDate); call.AnswerDate = Update.IfNotEmptyAndNotEquals(call.AnswerDate, answerDate); if (endDialDate != null) { call.EndDialDate = endDialDate; var note = parentCall.Status == VoipCallStatus.Incoming ? CRMContactResource.HistoryVoipIncomingNote : CRMContactResource.HistoryVoipOutcomingNote; var category = listItemDao.GetByTitle(ListType.HistoryCategory, CRMCommonResource.HistoryCategory_Call); if (category == null) { category = new ListItem(CRMCommonResource.HistoryCategory_Call, "event_category_call.png"); category.ID = listItemDao.CreateItem(ListType.HistoryCategory, category); } AddHistoryTo(null, 0, parentCall.ContactId, string.Format(note, call.EndDialDate.Subtract(call.AnswerDate).Seconds.ToString(CultureInfo.InvariantCulture)), category.ID, (ApiDateTime)(DateTime.UtcNow), null, null); } call.RecordUrl = Update.IfNotEmptyAndNotEquals(call.RecordUrl, recordUrl); if (recordDuration != 0) { call.RecordDuration = recordDuration; } if (call.Price == 0 && price.HasValue) { call.Price = price.Value; VoipPaymentSettings.Increment((int)(price.Value * 1000)); } return(dao.SaveOrUpdateCallHistory(call)); }