Beispiel #1
0
        public ActionResult Index(string search = "")
        {
            ViewBag.SearchString = search;

            //var profiles = string.IsNullOrWhiteSpace(search) ?
            //    _profileRepository.GetAllProfilesIncludingRelations() :
            //    _profileRepository.FindProfiles(search);
            var profileGroups = _profileGroupRepository.GetAll();

            return(View(profileGroups));
        }
        public ActionResult Index(string search = "")
        {
            ViewBag.SearchString = search;

            // TODO: Enable search? think it is, but this is not working then i guess
            //var profiles = string.IsNullOrWhiteSpace(search) ?
            //    _profileRepository.GetAllProfilesIncludingRelations() :
            //    _profileRepository.FindProfiles(search);
            var profileGroups = _profileGroupRepository.GetAll();

            return(View(profileGroups));
        }
Beispiel #3
0
        private void PopulateProfileGroups(LocationViewModel model, Location location)
        {
            var groups = _profileGroupRepository.GetAll();

            model.ProfileGroups = groups.Select(g => new ListItemViewModel
            {
                Id       = g.Id,
                Name     = g.Name,
                Selected = location?.ProfileGroup != null && location.ProfileGroup.Id == g.Id
            }).ToList();
            model.ProfileGroups.Insert(0, new ListItemViewModel()
            {
                Id = null, Name = string.Empty
            });
        }
Beispiel #4
0
        public IEnumerable <RegisteredUserAgentAndProfilesDiscovery> GetRegisteredUserAgentsAndProfiles()
        {
            var sipDomain = _settingsManager.SipDomain;

            // Registered user agents
            IEnumerable <RegisteredUserAgentDiscovery> registeredUserAgentsList = _registeredSipRepository.GetRegisteredUserAgentsDiscovery();

            if (registeredUserAgentsList == null)
            {
                return(null);
            }

            // User agent types and profiles for each User Agent
            IDictionary <Guid, UserAgentAndProfiles> userAgentsTypesList = _userAgentRepository.GetUserAgentsTypesAndProfiles();

            // Locations and profile groups
            IDictionary <Guid, LocationAndProfiles> locationsAndProfileGroupList = _locationRepository.GetLocationsAndProfiles();

            // Profile groups
            IReadOnlyList <ProfileGroup> profileGroupsList = _profileGroupRepository.GetAll();

            // Ongoing calls
            IReadOnlyCollection <OnGoingCall> callsList = _callRepository.GetOngoingCalls(true);

            return(registeredUserAgentsList.Select(regSip =>
            {
                // 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.

                // Match register user agent user agent profiles
                var profilesUserAgent = Enumerable.Empty <string>();
                if (regSip.UserAgentId != null &&
                    userAgentsTypesList.TryGetValue(regSip.UserAgentId.Value, out var profilesUa))
                {
                    profilesUserAgent = profilesUa.Profiles.OrderBy(z => z.SortIndex).Select(y => y.Name); // TODO: No sort is done here...it's done earlier. trust? Is it the right sort?
                }

                // Match location profiles and add profile names to locations profile groups
                int?profilesLocationSortWeight = null;
                var profilesLocation = Enumerable.Empty <string>();
                if (regSip.LocationId != null &&
                    locationsAndProfileGroupList.TryGetValue(regSip.LocationId.Value, out var profileLoc))
                {
                    //var locMatch = profileGroupsList.FirstOrDefault(x => x.Id == profileLoc.ProfileGroupId)?.Profiles.OrderBy(z => z.SortIndex).Select(y => y.Name);
                    var locMatch = profileGroupsList.FirstOrDefault(x => x.Id == profileLoc.ProfileGroupId)?.Profiles.Select(y => y.Name);
                    if (locMatch != null)
                    {
                        profilesLocation = locMatch;
                    }

                    // Get location profile group sort weight
                    var locMatchGroup = profileGroupsList.FirstOrDefault(x => x.Id == profileLoc.ProfileGroupId);
                    if (locMatchGroup != null)
                    {
                        profilesLocationSortWeight = locMatchGroup.GroupSortWeight;
                    }
                }

                IList <string> filteredProfiles = profilesLocation.Intersect(profilesUserAgent).ToList();

                // Call information
                var call = callsList.FirstOrDefault(c => c.FromSip == regSip.SipUri || c.ToSip == regSip.SipUri);
                bool inCall = call != null;

                string inCallWithId = string.Empty;
                string inCallWithSip = string.Empty;
                string inCallWithName = string.Empty;

                if (inCall)
                {
                    var isFromCaller = call.FromSip == regSip.SipUri;
                    inCallWithId = isFromCaller ? call.ToId : call.FromId;
                    inCallWithSip = isFromCaller ? call.ToSip : call.FromSip;
                    inCallWithName = isFromCaller ? call.ToDisplayName : call.FromDisplayName;
                }

                // Registered user agent
                var dispName = DisplayNameHelper.GetDisplayName(regSip.DisplayName, regSip.UserDisplayName,
                                                                string.Empty, regSip.Username, regSip.SipUri, "", sipDomain);

                return new RegisteredUserAgentAndProfilesDiscovery(
                    id: regSip.Id,
                    sipUri: regSip.SipUri,
                    displayName: dispName,
                    username: regSip.Username,
                    ipAddress: regSip.IpAddress,
                    userAgentHeader: regSip.UserAgentHeader,
                    userAgentName: regSip.UserAgentName,
                    locationName: regSip.LocationName,
                    locationShortName: regSip.LocationShortName,
                    regionName: regSip.RegionName,
                    cityName: regSip.CityName,
                    userOwnerName: regSip.UserOwnerName,
                    userDisplayName: regSip.UserDisplayName,
                    codecTypeName: regSip.CodecTypeName,
                    metaData: regSip.MetaData,
                    orderedProfiles: filteredProfiles,
                    locationProfileGroupSortWeight: profilesLocationSortWeight,
                    inCall: inCall,
                    inCallWithId: inCallWithId,
                    inCallWithSip: inCallWithSip,
                    inCallWithName: inCallWithName);
            }).ToList());
        }
 public List <ProfileGroup> GetAll()
 {
     return(_lazyCache.GetOrAddProfileGroups(() => _internalRepository.GetAll()));
 }