Beispiel #1
0
 private static IntSet <PartyId> SearchByMembership(
     List <int> externalPartyMembershipTypeIds)
 {
     return(IntSet <PartyId> .IntersectionOfMany(
                externalPartyMembershipTypeIds
                .ConvertAll <IntSet <PartyId> >(Cache.Cache.MembershipMappings.PartyIds)
                .ToArray()));
 }
Beispiel #2
0
        //----------------------------------------------------------------------
        private static ResultSet SearchByParty <ProfileType>(
            Timer t,
            IEnumerable <string> nameSearchNoiseWords,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            IntSet <PartyId> externalPartyMembershipTypeMatches,
            IntSet <PartyId> profileSpecificParties,
            double nonGeoMatchAbsDensity,
            ref Comparison <Result> sortOrder)
            where ProfileType : ISearch, new()
        {
            IntSet <PartyId> nameMatches      = null;
            IntSet <PartyId> locationMatches  = null;
            IntSet <PartyId> geoOrNameMatches = null;
            Location         centroid         = null;
            double?          maxRadiusMi      = null;
            ResultSet        rs = null;


            if (StringX.IsNotEmpty(searchLocale.PartyName))
            {
                nameMatches = SearchByName(t, searchLocale, nameSearchNoiseWords);
            }


            if (searchLocale.Type == Snap.Data.Controller.SearchType.PartyName)
            {
                geoOrNameMatches = nameMatches;
                sortOrder        = Result.NameAscending;
            }
            else
            {
                switch (new ProfileType().GeoSearch)
                {
                case GeoSearchType.Point:

                    locationMatches = SearchForLocations(
                        t, nameSearchNoiseWords, searchLocale, desiredResultCount,
                        maxResultCount, nonGeoMatchAbsDensity,
                        out centroid, out maxRadiusMi);
                    break;

                case GeoSearchType.ServiceArea:
                    locationMatches = SearchForServiceArea(t, searchLocale);
                    break;

                case GeoSearchType.All:
                    var pointMatches = SearchForLocations(
                        t, nameSearchNoiseWords, searchLocale, desiredResultCount,
                        maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi);
                    var svcAreaMatches = SearchForServiceArea(t, searchLocale);
                    locationMatches = IntSet <PartyId> .Union(pointMatches, svcAreaMatches);

                    sortOrder = Result.ShowServiceAreaMatchesFirst(svcAreaMatches, sortOrder);
                    break;

                default:
                    throw new ArgumentException(String.Format(
                                                    "Unexpected value of 'ISearch.GeoSearch': {0}",
                                                    new ProfileType().GeoSearch.ToString()));
                }
                geoOrNameMatches = StringX.IsNotEmpty(searchLocale.PartyName) ? IntSet <PartyId> .Intersection(nameMatches, locationMatches) : locationMatches;
            }



            rs = ResultSet.From(
                centroid,
                maxRadiusMi,
                IntSet <PartyId> .IntersectionOfMany(
                    geoOrNameMatches,
                    externalPartyMembershipTypeMatches,
                    profileSpecificParties));

            if (Snap.Data.Controller.SearchType.Membership == searchLocale.Type)
            {
                rs.UnfilteredMatchCount = externalPartyMembershipTypeMatches.Count;
            }
            else if (IntSet <PartyId> .IsEmpty(geoOrNameMatches))
            {
                rs.UnfilteredMatchCount = 0;
            }
            else
            {
                rs.UnfilteredMatchCount = geoOrNameMatches.Count;
            }


            return(rs);
        }