public IEnumerable <CodecStatusViewModel> GetAllCodecsIncludeOffline() { // TODO: Try to remove this one as an endpoint var registeredUserAgents = _registeredSipRepository.GetRegisteredUserAgents(); var sipDomain = _settingsManager.SipDomain; var ongoingCalls = _callRepository.GetOngoingCalls(true); var userAgentsOnline = registeredUserAgents.Select(regSip => { string displayName = DisplayNameHelper.GetDisplayName(regSip.DisplayName, regSip.UserDisplayName, string.Empty, regSip.Username, regSip.SipUri, "", sipDomain); var result = new CodecStatusViewModel { SipAddress = regSip.SipUri, Id = regSip.Id, PresentationName = displayName, DisplayName = displayName }; var call = ongoingCalls.FirstOrDefault(c => c.FromSip == regSip.SipUri || c.ToSip == regSip.SipUri); bool inCall = call != null; result.InCall = inCall; if (inCall) { var isFromCaller = call.FromSip == regSip.SipUri; result.IsCallingPart = isFromCaller; result.ConnectedToSipAddress = isFromCaller ? call.ToSip : call.FromSip; result.ConnectedToPresentationName = isFromCaller ? DisplayNameHelper.GetDisplayName(call.ToDisplayName, null, null, "", call.ToSip, "", sipDomain) : DisplayNameHelper.GetDisplayName(call.FromDisplayName, null, null, "", call.FromSip, "", sipDomain); result.ConnectedToLocation = isFromCaller ? call.ToLocationName : call.FromLocationName; result.CallStartedAt = call.Started; } // TODO: In Call with DisplayName is lacking the actual Display name (on user) entered in CCM. Not sure the importance. result.State = regSip.Id == Guid.Empty ? CodecState.NotRegistered : (inCall ? CodecState.InCall : CodecState.Available); return(result); }).ToList(); // Add the offline accounts to the list var userAgentsIdsOnline = userAgentsOnline.Select(rs => rs.SipAddress); var sipAccounts = _sipAccountRepository.GetAll(); var accountsNotOnline = sipAccounts.Where(a => !userAgentsIdsOnline.Contains(a.UserName)); IEnumerable <CodecStatusViewModel> notRegisteredSips = accountsNotOnline.Select(a => new CodecStatusViewModel { Id = Guid.Empty, SipAddress = a.UserName, DisplayName = DisplayNameHelper.GetDisplayName("", a.DisplayName, string.Empty, "", a.UserName, "", sipDomain), State = CodecState.NotRegistered }); return(userAgentsOnline.Concat(notRegisteredSips).ToList()); }
public ActionResult GetSipAccounts() { var accounts = _sipAccountRepository.GetAll(); return(View(accounts)); }
public List <SipAccount> GetSipUsers() { return(_sipAccountRepository.GetAll()); }
public SipAccount GetSipAccountByUserName(string username) { // TODO: Keep this one. But maybe if nothing can be found, trigger cache reload of sipAccounts and search again. return(_sipAccountRepository.GetAll().ToList().FirstOrDefault(u => u.UserName.ToLower() == username)); }
public List <SipAccount> GetAll() { return(_lazyCache.GetOrAddSipAccounts(() => _internalRepository.GetAll())); }