public static RegisteredSipOverviewDto MapToDto(RegisteredSipDto regSip, string sipDomain) { return(new RegisteredSipOverviewDto { InCall = regSip.InCall, Sip = regSip.Sip, Id = regSip.Id, //DisplayName = regSip.DisplayName, DisplayName = DisplayNameHelper.GetDisplayName(regSip.DisplayName, regSip.UserDisplayName, string.Empty, regSip.UserName, regSip.Sip, "", sipDomain), Location = regSip.LocationName, LocationShortName = regSip.LocationShortName, Comment = regSip.Comment, Image = regSip.Image, CodecTypeName = regSip.CodecTypeName, CodecTypeColor = regSip.CodecTypeColor, UserName = regSip.UserName, UserDisplayName = regSip.UserDisplayName, UserComment = regSip.Comment, InCallWithId = regSip.InCallWithId, InCallWithSip = DisplayNameHelper.AnonymizePhonenumber(regSip.InCallWithSip), InCallWithName = DisplayNameHelper.AnonymizeDisplayName(regSip.InCallWithName), RegionName = regSip.RegionName, Updated = regSip.Updated }); }
public void should_reload_registeredSips_when_codec_removed() { // Assign var registeredSipDto = new RegisteredSipDto { Id = Guid.NewGuid(), Sip = "*****@*****.**" }; A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).Returns(new List <RegisteredSipDto> { registeredSipDto }); A.CallTo(() => _internalRegisteredSipRepository.UpdateRegisteredSip(A <RegisteredSip> .Ignored)) .Returns(new KamailioMessageHandlerResult { ChangedObjectId = registeredSipDto.Id, ChangeStatus = KamailioMessageChangeStatus.CodecRemoved }); // Act _sut.GetCachedRegisteredSips(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); _sut.UpdateRegisteredSip(new RegisteredSip { SIP = "*****@*****.**" }); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); _sut.GetCachedRegisteredSips(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Twice); }
public static CodecStatus MapToCodecStatus(RegisteredSipDto rs) { return(new CodecStatus { State = rs.Id == Guid.Empty ? CodecState.NotRegistered : (rs.InCall ? CodecState.InCall : CodecState.Available), SipAddress = rs.Sip, PresentationName = rs.DisplayName, HasGpo = rs.HasGpo, ConnectedToSipAddress = rs.InCallWithSip ?? string.Empty, ConnectedToPresentationName = rs.InCallWithName ?? string.Empty, ConnectedToLocation = rs.InCallWithLocation ?? string.Empty, ConnectedToHasGpo = rs.InCallWithHasGpo, IsCallingPart = rs.IsCallingPart, CallStartedAt = rs.CallStartedAt }); }
private RegisteredSipDto MapToRegisteredSipDto(Entities.RegisteredSipEntity dbSip, List <MetaType> metaList) { if (dbSip == null) { return(null); } var regSip = new RegisteredSipDto { Updated = dbSip.Updated, Id = dbSip.Id, Sip = dbSip.SIP, DisplayName = dbSip.DisplayName, UserDisplayName = dbSip.User != null ? dbSip.User.DisplayName : string.Empty, IpAddress = dbSip.IP, UserAgentHeader = dbSip.UserAgentHead, UserName = dbSip.Username, RegionName = dbSip.Location != null && dbSip.Location.Region != null ? dbSip.Location.Region.Name : string.Empty, CodecTypeName = dbSip.User != null && dbSip.User.CodecType != null ? dbSip.User.CodecType.Name : string.Empty, CodecTypeColor = dbSip.User != null && dbSip.User.CodecType != null ? dbSip.User.CodecType.Color : string.Empty, Comment = dbSip.User != null ? dbSip.User.Comment : string.Empty, Image = dbSip.UserAgent != null ? dbSip.UserAgent.Image : string.Empty, Api = dbSip.UserAgent != null ? dbSip.UserAgent.Api : string.Empty, LocationName = dbSip.Location != null ? dbSip.Location.Name : string.Empty, LocationShortName = dbSip.Location != null ? dbSip.Location.ShortName : string.Empty, // Filtering properties. Not currently used. //OwnerName = dbSip.User != null && dbSip.User.Owner != null ? dbSip.User.Owner.Name : string.Empty, //CityName = dbSip.Location != null && dbSip.Location.City != null ? dbSip.Location.City.Name : string.Empty, //UserAgentName = dbSip.UserAgent != null ? dbSip.UserAgent.Name : string.Empty, HasGpo = dbSip.UserAgent != null && !string.IsNullOrEmpty(dbSip.UserAgent.GpoNames), }; var locationProfiles = dbSip.Location != null?dbSip.Location.ProfileGroup.OrderedProfiles.OrderBy(op => op.SortIndex).Select(p => p.Profile.Name) : Enumerable.Empty <string>(); var userAgentProfiles = dbSip.UserAgent != null?dbSip.UserAgent.OrderedProfiles.OrderBy(op => op.SortIndex).Select(p => p.Profile.Name) : Enumerable.Empty <string>(); // The sort order is most important as it decides the order of recommended profiles in the Discovery service. // Sorting is based on the sort order of the location. regSip.Profiles = locationProfiles.Intersect(userAgentProfiles).ToList(); regSip.MetaData = GetMetaData(metaList, dbSip); return(regSip); }
public CodecStatus Get(string sipId) { RegisteredSipDto regSip = null; if (!string.IsNullOrEmpty(sipId)) { var allRegisteredSips = _registeredSipRepository.GetCachedRegisteredSips(); regSip = allRegisteredSips.FirstOrDefault(s => s.Sip == sipId); } if (regSip == null) { return(new CodecStatus() { SipAddress = sipId, State = CodecState.NotRegistered, HasGpo = false }); } return(CodecStatusMapper.MapToCodecStatus(regSip)); }
public void should_reload_registeredSips_when_codec_added() { var registeredSipDto = new RegisteredSipDto { Id = Guid.NewGuid(), Sip = "*****@*****.**" }; var internalList = new List <RegisteredSipDto>(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).Returns(internalList); A.CallTo(() => _internalRegisteredSipRepository.UpdateRegisteredSip(A <RegisteredSip> .Ignored)).Returns( new KamailioMessageHandlerResult() { ChangedObjectId = Guid.NewGuid(), ChangeStatus = KamailioMessageChangeStatus.CodecAdded }); // Act var regSipList = _sut.GetCachedRegisteredSips(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); Assert.IsNotNull(regSipList); Assert.AreEqual(0, regSipList.Count); internalList.Add(registeredSipDto); _sut.UpdateRegisteredSip(new RegisteredSip() { SIP = "*****@*****.**" }); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); var regSipList2 = _sut.GetCachedRegisteredSips(); Assert.IsNotNull(regSipList2); Assert.AreEqual(1, regSipList2.Count); Assert.AreEqual("*****@*****.**", regSipList2[0].Sip); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Twice); }
public static string GetDisplayName(RegisteredSipDto registeredSip, string sipDomain) { return(GetDisplayName(registeredSip.DisplayName, registeredSip.UserDisplayName, string.Empty, registeredSip.UserName, registeredSip.Sip, "", sipDomain)); }