Exemplo n.º 1
0
        public void CloseCall(Guid callId)
        {
            using (var db = GetDbContext())
            {
                var dbCall = db.Calls.SingleOrDefault(c => c.Id == callId);

                if (dbCall == null)
                {
                    log.Warn("Trying to close call but call with id {0} doesn't exist", callId);
                    return;
                }

                dbCall.Updated = DateTime.UtcNow;
                dbCall.Closed  = true;
                // TODO: Is it necessary to save this closing of the call, to then remove it later?
                db.SaveChanges();

                // Save call history
                var callHistory = MapToCallHistory(dbCall, _settingsManager.SipDomain);
                var success     = _callHistoryRepository.Save(callHistory);

                if (success)
                {
                    // Remove the original call
                    db.Calls.Remove(dbCall);
                    db.SaveChanges();
                }
                else
                {
                    log.Error($"Unable to save call history with the call fromSip: {dbCall.FromSip}, toSip: {dbCall.ToSip}, hash id: {dbCall.DlgHashId}, hash ent: {dbCall.DlgHashEnt}");
                }
            }
        }
Exemplo n.º 2
0
        public void CloseCall(Guid callId)
        {
            using (var db = GetDbContext())
            {
                var dbCall = db.Calls.SingleOrDefault(c => c.Id == callId);

                if (dbCall == null)
                {
                    log.Warn("Trying to close call but call with id {0} doesn't exist", callId);
                    return;
                }

                dbCall.Updated = DateTime.UtcNow;
                dbCall.Closed  = true;
                db.SaveChanges();

                // Save call history
                var callHistory = MapToCallHistory(dbCall, _settingsManager.SipDomain);
                var success     = _callHistoryRepository.Save(callHistory);

                if (success)
                {
                    // Remove the original call
                    db.Calls.Remove(dbCall);
                    db.SaveChanges();
                }
            }
        }
        public bool Save(CallHistory callHistory)
        {
            var success = _internalRepository.Save(callHistory);

            _lazyCache.ClearCallHistory();
            return(success);
        }