/// <summary>
        /// Parses WSE XModule to get data.
        /// </summary>
        /// <param name="wseModule">WSE XModule</param>
        public void Parse(XModule wseModule)
        {
            try {
                var methodParser = new MethodParser();
                Method = methodParser.Parse(wseModule);

                var addressParser = new AddressParser();
                AddressParserResult addressParserResult = addressParser.Parse(wseModule);
                Endpoint    = addressParserResult.Endpoint;
                Resource    = addressParserResult.Resource;
                QueryParams = addressParserResult.QueryParams;

                var headerParser = new HeaderParser();
                Headers         = headerParser.Parse(wseModule, AddOnConstants.RequestHeadersTql);
                Headers         = CommonUtilities.ModifyContentTypeToEmpty(Headers);
                ResponseHeaders = headerParser.Parse(wseModule, AddOnConstants.ResponseHeadersTql);

                var payloadParser = new XmlPayloadParser();
                RequestPayload  = payloadParser.Parse(wseModule, AddOnConstants.RequestPayloadTql);
                ResponsePayload = payloadParser.Parse(wseModule, AddOnConstants.ResponsePayloadTql);

                var statusCodeParser = new StatusCodeParser();
                ResponseStatus = statusCodeParser.ParseResponseStatus(wseModule);

                HashCode = GetHashCode(wseModule);
            }
            catch (Exception e) {
                FileLogger.Instance.Error(e);
            }
        }
示例#2
0
        /// <summary>
        /// Parse WSE XTestStep to get data.
        /// </summary>
        /// <param name="xTestStep">WSE XTestStep</param>
        /// <param name="payloadParser">XML or Json Payload Parser.
        /// The request payload is extracted from XTestStep.
        /// The response paylod is extracted from Module.
        /// </param>
        public void Parse(XTestStep xTestStep, IPayloadParser payloadParser)
        {
            try {
                var methodParser = new MethodParser();
                Method = methodParser.Parse(xTestStep);

                var addressParser = new AddressParser();
                AddressParserResult addressParserResult = addressParser.Parse(xTestStep);
                Endpoint    = addressParserResult.Endpoint;
                Resource    = addressParserResult.Resource;
                QueryParams = addressParserResult.QueryParams;

                var headerParser = new HeaderParser();
                Headers         = headerParser.Parse(xTestStep, AddOnConstants.TestStepRequestHeadersTql);
                Headers         = CommonUtilities.ModifyContentTypeToEmpty(Headers);
                ResponseHeaders = headerParser.Parse(xTestStep, AddOnConstants.TestStepResponseHeadersTql);

                var statusCodeParser = new StatusCodeParser();
                ResponseStatus = statusCodeParser.ParseResponseStatus(xTestStep);

                RequestPayload = payloadParser.Parse(xTestStep,
                                                     "=>SUBPARTS:XTestStepValue[Name==\"Request\"]->SUBPARTS:XTestStepValue");
                ResponsePayload = payloadParser.Parse(xTestStep.Module, AddOnConstants.ResponsePayloadTql);
                HashCode        = GetHashCode(xTestStep);
            }
            catch (Exception e) {
                FileLogger.Instance.Error(e);
            }
        }
示例#3
0
 //----------------------------------------------------------------------
 // We'd like to make this method obsolete ASAP, but it'll require some
 // refactoring and rework in dependent code. - ESV 2011-12-22
 //[Obsolete("Prefer Do<ProfileType>(Params)")]
 public static ResultSet Do <ProfileType>(
     ITimer timerContext,
     IEnumerable <string> nameSearchNoiseWords,
     Dictionary <string, string> consumerProperties,
     Comparison <Result> sortOrder,
     AddressParserResult searchLocale,
     int desiredResultCount,
     int maxResultCount,
     List <int> externalPartyMembershipTypeIds,
     IntSet <PartyId> profileSpecificParties,
     IntSet <ProfileId> profileSpecificiProfiles)
     where ProfileType : ISearch, new()
 {
     return(Do <ProfileType>(
                timerContext,
                nameSearchNoiseWords,
                consumerProperties,
                sortOrder,
                searchLocale,
                desiredResultCount,
                maxResultCount,
                externalPartyMembershipTypeIds,
                profileSpecificParties,
                profileSpecificiProfiles,
                SearchByMembership,
                SearchByParty <ProfileType>,
                SearchByProfile <ProfileType>,
                null)); // featuredProfileTemplateLabel
 }
示例#4
0
        public ResultSet Search(
            ITimer timerContext,
            IEnumerable <string> nameSearchNoiseWords,
            Dictionary <string, string> consumerProperties,
            Comparison <Result> sortOrder,
            bool showIndependentLiving,
            bool showAssistedLiving,
            bool showSkilledNursing,
            bool showOnlyCCRCs,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            List <int> externalPartyMembershipTypeIds)
        {
            var ps = new Params()
            {
                timerContext                   = timerContext,
                nameSearchNoiseWords           = nameSearchNoiseWords,
                consumerProperties             = consumerProperties,
                sortOrder                      = sortOrder,
                searchLocale                   = searchLocale,
                desiredResultCount             = desiredResultCount,
                maxResultCount                 = maxResultCount,
                externalPartyMembershipTypeIds = externalPartyMembershipTypeIds,
            };

            return(Search(ps,
                          showIndependentLiving,
                          showAssistedLiving,
                          showSkilledNursing,
                          showOnlyCCRCs));
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchByCity(
            Timer t,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            double nonGeoMatchAbsDensity,
            out Location centroid,
            out double?maxRadiusMi)
        {
            maxRadiusMi = null;

            if (desiredResultCount == ExactMatchResultCount)
            {
                IntSet <PartyId> partiesInCity = null;
                t.Measure("Search by City", delegate() {
                    partiesInCity = Snap.Cache.Cache.City(searchLocale);
                });
                centroid = null;
                return(partiesInCity);
            }
            else
            {
                IGeoCoder geocoder = GeoCoderFactory.CreateGeoCoder();
                centroid = geocoder.GeoCode(
                    searchLocale.City,
                    searchLocale.StateCode);
                return(SearchNearLocation(
                           t,
                           desiredResultCount,
                           centroid,
                           nonGeoMatchAbsDensity,
                           out maxRadiusMi));
            }
        }
示例#6
0
        /// <summary>
        /// Get Endpoint, Resource and Query Params from WSE Module
        /// </summary>
        /// <param name="wseModule"></param>
        /// <returns>AddressParserResult object which contains Endpoint, Resource and Query Params</returns>
        public AddressParserResult Parse(XModule wseModule)
        {
            var addressParserResult = new AddressParserResult();

            try {
                TCObject addressValueTql =
                    wseModule.Search(AddOnConstants.AddressValueTql).FirstOrDefault();
                if (addressValueTql == null)
                {
                    return(addressParserResult);
                }

                XModuleAttribute addressValue = addressValueTql as XModuleAttribute;

                if (string.IsNullOrEmpty(addressValue?.DefaultValue))
                {
                    return(addressParserResult);
                }
                ParseAddressInternal(addressParserResult, addressValue.DefaultValue);
            }
            catch (Exception ex) {
                FileLogger.Instance.Error(ex);
            }

            return(addressParserResult);
        }
        //-------------------------------------------------------------------------
        private static IntSet <PartyId> SearchByName(
            Timer t,
            AddressParserResult apr,
            IEnumerable <string> noiseWords)
        {
            Precondition.IsNotNull(apr, "apr");

            // this is not used becasue now name search can happen even with SearchType=postcode,city,zip etc.

            //if (Snap.Data.Controller.SearchType.PartyName != apr.Type) {
            //    throw new ArgumentException("apr.Type must be PartyName");
            //}

            string searchTerms =
                Snap.Util.StringX.CollapseWhitespace(
                    RemoveNameSearchNoiseTerms(apr.PartyName, noiseWords));

            IntSet <PartyId> partiesByName = null;

            t.Measure("Search by Name", delegate() {
                //partiesByName = Snap.Cache.Cache.PartyName(searchTerms);
                partiesByName = new Snap.Data.LuceneController().LuceneSearchIds(searchTerms, Snap.ForSeniors.Constants.SnapPartyLuceneTableName, Snap.ForSeniors.Constants.SnapPartyLuceneSearchField, Snap.ForSeniors.Constants.SnapPartyLuceneResultField);
            });
            if (partiesByName.Count == 0)
            {
                throw new InvalidPartyNameException(apr.PartyName);
            }

            return(partiesByName);
        }
 //-----------------------------------------------------------------------
 private static IntSet <PartyId> SearchForServiceArea(
     Timer t,
     AddressParserResult searchLocale)
 {
     return(RegionSearchFactory
            .Create()
            .Search(t, searchLocale));
 }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchByState(
            Timer t,
            AddressParserResult searchLocale)
        {
            IntSet <PartyId> partiesInState = null;

            t.Measure("Search by State", delegate() {
                partiesInState = Snap.Cache.Cache.State(searchLocale.StateCode);
            });
            return(partiesInState);
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchForLocations(
            Timer t,
            IEnumerable <string> nameSearchNoiseWords,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            double nonGeoMatchAbsDensity,
            out Location centroid,
            out double?maxRadiusMi)
        {
            centroid    = null;
            maxRadiusMi = null;
            switch (searchLocale.Type)
            {
            case Snap.Data.Controller.SearchType.City:
                return(SearchByCity(
                           t, searchLocale, desiredResultCount, maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi));

            case Snap.Data.Controller.SearchType.PostalCode:
                return(SearchByPostalCode(
                           t, searchLocale, desiredResultCount, maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi));

            case Snap.Data.Controller.SearchType.StreetAddress:
                return(SearchNearStreetAddress(
                           t, searchLocale, desiredResultCount, maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi));

            case Snap.Data.Controller.SearchType.County:
                return(SearchByCounty(
                           t, searchLocale, desiredResultCount, maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi));

            case Snap.Data.Controller.SearchType.BoundingBox:
                return(SearchByBoundingBox(t, searchLocale, out centroid));

            case Snap.Data.Controller.SearchType.PartyName:
                return(SearchByName(t, searchLocale, nameSearchNoiseWords));

            case Snap.Data.Controller.SearchType.Membership:
                return(IntSet <PartyId> .Universe);

            case Snap.Data.Controller.SearchType.State:
                return(SearchByState(t, searchLocale));

            case Snap.Data.Controller.SearchType.Location:
                return(SearchNearLocation(
                           t, desiredResultCount, searchLocale.Location, nonGeoMatchAbsDensity, out maxRadiusMi));

            default:
                throw new NotImplementedException();
            }
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchByBoundingBox(
            Timer t,
            AddressParserResult searchLocale,
            out Location centroid)
        {
            centroid = searchLocale.BoundingBox.Centroid;

            // KLUDGE: Justify this initial array size and make it a constant at
            // least or a configuration setting at best.  This is a wild guess.
            List <int> partyIds = new List <int>(1024);

            Snap.Cache.Cache.PartyLocation.Search(searchLocale.BoundingBox,
                                                  delegate(int partyId) {
                partyIds.Add(partyId);
            });
            return(IntSet <PartyId> .CreateFromUnsorted(partyIds));
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchNearStreetAddress(
            Timer t,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            double nonGeoMatchAbsDensity,
            out Location centroid,
            out double?maxRadiusMi)
        {
            if (null == searchLocale.Location)
            {
                IGeoCoder  geocoder = GeoCoderFactory.CreateGeoCoder();
                Location[] ls       = geocoder.GeoCode(
                    searchLocale.StreetAddress,
                    searchLocale.City,
                    searchLocale.StateCode,
                    searchLocale.PostalCode);

                if (ls.Length == 0)
                {
                    throw new ArgumentException("unknown address");
                }

                if (ls.Length > 1)
                {
                    throw new ArgumentException("ambiguous address");
                }

                centroid = ls[0];
            }
            else
            {
                centroid = searchLocale.Location;
            }

            maxRadiusMi = null;
            return(SearchNearLocation(
                       t,
                       desiredResultCount,
                       centroid,
                       nonGeoMatchAbsDensity,
                       out maxRadiusMi));
        }
示例#13
0
        //----------------------------------------------------------------------
        /// <summary>
        /// Search the SNAP system for matches to the provided criteria.
        /// </summary>
        public static ResultSet Do <ProfileType>(
            ITimer timerContext,
            IEnumerable <string> nameSearchNoiseWords,
            Dictionary <string, string> consumerProperties,
            Comparison <Result> sortOrder,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            List <int> externalPartyMembershipTypeIds,
            IntSet <PartyId> profileSpecificParties,
            IntSet <ProfileId> profileSpecificiProfiles,
            MembershipSearch membershipSearch,
            PartySearch partySearch,
            ProfileSearch <ProfileType> profileSearch,
            string featuredProfileTemplateLabel)
            where ProfileType : ISearch, new()
        {
            Timer t = new Timer(timerContext, "Search.Do() - implicit");

            try {
                return(InnerSearch <ProfileType>(t,
                                                 nameSearchNoiseWords,
                                                 consumerProperties,
                                                 sortOrder,
                                                 searchLocale,
                                                 desiredResultCount,
                                                 maxResultCount,
                                                 externalPartyMembershipTypeIds,
                                                 profileSpecificParties,
                                                 profileSpecificiProfiles,
                                                 membershipSearch,
                                                 partySearch,
                                                 profileSearch,
                                                 featuredProfileTemplateLabel));
            }
            finally {
                t.Stop();
            }
        }
示例#14
0
 public ResultSet Search(
     ITimer timerContext,
     IEnumerable <string> nameSearchNoiseWords,
     Dictionary <string, string> consumerProperties,
     Comparison <Result> sortOrder,
     AddressParserResult searchLocale,
     int desiredResultCount,
     int maxResultCount,
     List <int> externalPartyMembershipTypeIds)
 {
     return(Search(new Params()
     {
         timerContext = timerContext,
         nameSearchNoiseWords = nameSearchNoiseWords,
         consumerProperties = consumerProperties,
         sortOrder = sortOrder,
         searchLocale = searchLocale,
         desiredResultCount = desiredResultCount,
         maxResultCount = maxResultCount,
         externalPartyMembershipTypeIds = externalPartyMembershipTypeIds
     }));
 }
 public ResultSet Search(
     ITimer timerContext,
     IEnumerable <string> nameSearchNoiseWords,
     Dictionary <string, string> consumerProperties,
     Comparison <Result> sortOrder,
     AddressParserResult searchLocale,
     int desiredResultCount,
     int maxResultCount,
     List <int> externalPartyMembershipTypeIds)
 {
     return(Snap.Search2.Search.Do <HomeHealthCare>(
                timerContext,
                nameSearchNoiseWords,
                consumerProperties,
                sortOrder,
                searchLocale,
                desiredResultCount,
                maxResultCount,
                externalPartyMembershipTypeIds,
                null,
                null));
 }
示例#16
0
        /// <summary>
        /// Get Endpoint, Resource and Query Params from WSE XTestStep
        /// </summary>
        /// <param name="xTestStep"></param>
        /// <returns>AddressParserResult object which contains Endpoint, Resource and Query Params</returns>
        public AddressParserResult Parse(XTestStep xTestStep)
        {
            var addressParserResult = new AddressParserResult();

            try {
                XTestStepValue address = (XTestStepValue)
                                         xTestStep.Search(AddOnConstants.TestStepAddressValueTql).FirstOrDefault();
                if (address == null)
                {
                    return(addressParserResult);
                }
                if (string.IsNullOrEmpty(address.Value))
                {
                    return(addressParserResult);
                }
                ParseAddressInternal(addressParserResult, address.Value);
            }
            catch (Exception ex) {
                FileLogger.Instance.Error(ex);
            }

            return(addressParserResult);
        }
示例#17
0
        //----------------------------------------------------------------------
        private static ResultSet InnerSearch <ProfileType>(
            Timer t,
            IEnumerable <string> nameSearchNoiseWords,
            Dictionary <string, string> consumerProperties,
            Comparison <Result> sortOrder,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            List <int> externalPartyMembershipTypeIds,
            IntSet <PartyId> profileSpecificParties,
            IntSet <ProfileId> profileSpecificProfiles,
            MembershipSearch membershipSearch,
            PartySearch partySearch,
            ProfileSearch <ProfileType> profileSearch,
            string featuredProfileTemplateLabel)
            where ProfileType : ISearch, new()
        {
            if (null == profileSpecificProfiles)
            {
                profileSpecificProfiles = IntSet <ProfileId> .Universe;
            }

            if (null == profileSpecificParties)
            {
                profileSpecificParties = IntSet <PartyId> .Universe;
            }

            //Console.WriteLine(Snap.Cache.Cache.ProfileTemplate.Count);
            ISearch profileType = new ProfileType();

            IntSet <PartyId> matchesByProfileType = null;

            try {
                if (String.IsNullOrEmpty(profileType.ProfileTemplateLabel))
                {
                    matchesByProfileType = IntSet <PartyId> .Universe;
                }
                else
                {
                    matchesByProfileType =
                        Snap.Cache.Cache.ProfileTemplate[profileType.ProfileTemplateLabel];
                }
            }
            catch (KeyNotFoundException exc) {
                throw new ApplicationException(
                          "Unknown ProfileTemplateLabel: " + profileType.ProfileTemplateLabel,
                          exc);
            }

            IntSet <PartyId> matchesByMembership = IntSet <PartyId> .Universe;

            t.Measure("Search by membership(s)", delegate() {
                if (!ListX.IsEmpty(externalPartyMembershipTypeIds))
                {
                    matchesByMembership = membershipSearch(externalPartyMembershipTypeIds);
                }
            });

            matchesByMembership =
                IntSet <PartyId> .Intersection(matchesByProfileType, matchesByMembership);

            ResultSet matchesByProfile = null;

            t.Measure("Search by Profile ('advanced' search)", delegate() {
                matchesByProfile = profileSearch(
                    t,
                    consumerProperties,
                    profileSpecificProfiles);
            });

            double nonGeoMatchAbsDensity = NonGeoMatchAbsDensity(
                matchesByMembership,
                matchesByProfile);

            ResultSet matchesByParty = ResultSet.Universe;

            t.Measure("Search by Party (geography,name)", delegate() {
                if (searchLocale == null)
                {
                    matchesByParty = ResultSet.From(null, null, matchesByMembership);
                }
                else
                {
                    matchesByParty = partySearch(
                        t,
                        nameSearchNoiseWords,
                        searchLocale,
                        desiredResultCount,
                        maxResultCount,
                        matchesByMembership,
                        profileSpecificParties,
                        nonGeoMatchAbsDensity,
                        ref sortOrder);
                }
            });

            ResultSet matches = null;

            t.Measure("Combine matches-by-party and matches-by-profile", delegate() {
                matches = ResultSet.Intersection(matchesByParty, matchesByProfile);
            });

            return(FinalizeResultSet(
                       t,
                       sortOrder,
                       desiredResultCount,
                       matches,
                       featuredProfileTemplateLabel));
        }
示例#18
0
        // Token: 0x06000191 RID: 401 RVA: 0x000072A8 File Offset: 0x000054A8
        internal MimeNode ParseNextMailBox(bool fromGroup)
        {
            if (this.parsed)
            {
                return(null);
            }
            DecodingOptions headerDecodingOptions = base.GetHeaderDecodingOptions();

            if (this.parser == null)
            {
                this.parser = new MimeAddressParser();
            }
            if (!this.parser.Initialized)
            {
                this.parser.Initialize(base.Lines, false, false, headerDecodingOptions.AllowUTF8);
            }
            MimeStringList      displayNameFragments = default(MimeStringList);
            MimeStringList      mimeStringList       = default(MimeStringList);
            AddressParserResult addressParserResult  = this.parser.ParseNextMailbox(ref displayNameFragments, ref mimeStringList);

            switch (addressParserResult)
            {
            case AddressParserResult.Mailbox:
            case AddressParserResult.GroupInProgress:
            {
                MimeRecipient mimeRecipient = new MimeRecipient(ref mimeStringList, ref displayNameFragments);
                if (this.staticParsing)
                {
                    MimeRecipient.ConvertDisplayNameBack(mimeRecipient, displayNameFragments, headerDecodingOptions.AllowUTF8);
                }
                if (addressParserResult == AddressParserResult.GroupInProgress)
                {
                    MimeGroup mimeGroup = base.InternalLastChild as MimeGroup;
                    mimeGroup.InternalInsertAfter(mimeRecipient, mimeGroup.InternalLastChild);
                    return(mimeRecipient);
                }
                base.InternalInsertAfter(mimeRecipient, base.InternalLastChild);
                if (!fromGroup)
                {
                    return(mimeRecipient);
                }
                return(null);
            }

            case AddressParserResult.GroupStart:
            {
                MimeGroup mimeGroup = new MimeGroup(ref displayNameFragments);
                if (this.staticParsing)
                {
                    MimeRecipient.ConvertDisplayNameBack(mimeGroup, displayNameFragments, headerDecodingOptions.AllowUTF8);
                }
                base.InternalInsertAfter(mimeGroup, base.InternalLastChild);
                return(mimeGroup);
            }

            case AddressParserResult.End:
                return(null);

            default:
                return(null);
            }
        }
        // Token: 0x06000249 RID: 585 RVA: 0x0000A614 File Offset: 0x00008814
        public AddressParserResult ParseNextMailbox(ref MimeStringList displayName, ref MimeStringList address)
        {
            AddressParserResult result = this.groupInProgress ? AddressParserResult.GroupInProgress : AddressParserResult.Mailbox;

            MimeAddressParser.ParserStage parserStage = MimeAddressParser.ParserStage.BEGIN;
            MimeStringList mimeStringList             = default(MimeStringList);
            MimeStringList mimeStringList2            = default(MimeStringList);
            MimeStringList mimeStringList3            = default(MimeStringList);
            bool           flag           = true;
            bool           flag2          = false;
            bool           ignoreNextByte = false;

            if (!this.parserInit)
            {
                throw new InvalidOperationException(Strings.AddressParserNotInitialized);
            }
            for (;;)
            {
                if (this.valueParser.ParseToDelimiter(ignoreNextByte, !flag && flag2, ref mimeStringList))
                {
                    flag2          = false;
                    ignoreNextByte = false;
                    flag           = false;
                }
                byte b  = this.valueParser.ParseGet();
                byte b2 = b;
                if (b2 <= 34)
                {
                    if (b2 != 0)
                    {
                        switch (b2)
                        {
                        case 9:
                        case 10:
                        case 13:
                            break;

                        case 11:
                        case 12:
                            goto IL_200;

                        default:
                            switch (b2)
                            {
                            case 32:
                                break;

                            case 33:
                                goto IL_200;

                            case 34:
                                this.valueParser.ParseUnget();
                                if (mimeStringList.Length != 0 && !flag)
                                {
                                    this.valueParser.ParseAppendSpace(ref mimeStringList);
                                }
                                else
                                {
                                    flag = false;
                                }
                                this.valueParser.ParseQString(true, ref mimeStringList, true);
                                flag2 = true;
                                continue;

                            default:
                                goto IL_200;
                            }
                            break;
                        }
                        this.valueParser.ParseWhitespace(false, ref mimeStringList3);
                        flag2 = true;
                        continue;
                    }
                    goto IL_213;
                }
                else if (b2 <= 46)
                {
                    if (b2 == 40)
                    {
                        if (mimeStringList2.Length != 0)
                        {
                            mimeStringList2.Reset();
                        }
                        this.valueParser.ParseUnget();
                        if (this.ignoreComments)
                        {
                            this.valueParser.ParseComment(true, false, ref mimeStringList2, true);
                            if (flag2)
                            {
                                mimeStringList.AppendFragment(new MimeString(" "));
                            }
                            mimeStringList.TakeOverAppend(ref mimeStringList2);
                        }
                        else
                        {
                            this.valueParser.ParseComment(true, true, ref mimeStringList2, true);
                        }
                        flag2 = true;
                        continue;
                    }
                    switch (b2)
                    {
                    case 44:
                        goto IL_213;

                    case 46:
                        this.valueParser.ParseAppendLastByte(ref mimeStringList);
                        flag = true;
                        continue;
                    }
                }
                else
                {
                    switch (b2)
                    {
                    case 58:
                    case 59:
                    case 60:
                    case 62:
                    case 64:
                        goto IL_213;

                    case 61:
                    case 63:
                        break;

                    default:
                        switch (b2)
                        {
                        case 91:
                        case 93:
                            goto IL_213;
                        }
                        break;
                    }
                }
IL_200:
                this.valueParser.ParseUnget();
                ignoreNextByte = true;
                continue;
IL_213:
                switch (parserStage)
                {
                case MimeAddressParser.ParserStage.BEGIN:
                {
                    byte b3 = b;
                    if (b3 > 44)
                    {
                        switch (b3)
                        {
                        case 58:
                            if (mimeStringList.GetLength(4026531839U) != 0)
                            {
                                goto Block_26;
                            }
                            continue;

                        case 59:
                            this.groupInProgress = false;
                            result = AddressParserResult.Mailbox;
                            goto IL_28D;

                        case 60:
                            break;

                        case 61:
                        case 63:
                            goto IL_33D;

                        case 62:
                            mimeStringList.Reset();
                            continue;

                        case 64:
                        {
                            int length = mimeStringList.Length;
                            this.valueParser.ParseAppendLastByte(ref mimeStringList);
                            address.TakeOver(ref mimeStringList);
                            parserStage = MimeAddressParser.ParserStage.ADDRSPEC;
                            continue;
                        }

                        default:
                            if (b3 != 91)
                            {
                                goto IL_33D;
                            }
                            if (!this.useSquareBrackets)
                            {
                                this.valueParser.ParseUnget();
                                ignoreNextByte = true;
                                continue;
                            }
                            break;
                        }
                        displayName.TakeOver(ref mimeStringList);
                        parserStage = MimeAddressParser.ParserStage.ANGLEADDR;
                        continue;
                    }
                    if (b3 == 0)
                    {
                        goto IL_330;
                    }
                    if (b3 != 44)
                    {
                        goto IL_33D;
                    }
IL_28D:
                    if (mimeStringList.GetLength(4026531839U) != 0)
                    {
                        goto Block_25;
                    }
                    mimeStringList.Reset();
                    continue;
IL_33D:
                    this.valueParser.ParseUnget();
                    ignoreNextByte = true;
                    continue;
                }

                case MimeAddressParser.ParserStage.ANGLEADDR:
                {
                    byte b4 = b;
                    if (b4 <= 44)
                    {
                        if (b4 == 0)
                        {
                            goto IL_478;
                        }
                        if (b4 == 44)
                        {
                            if (displayName.Length != 0 || mimeStringList.Length != 0)
                            {
                                goto IL_478;
                            }
                            continue;
                        }
                    }
                    else
                    {
                        switch (b4)
                        {
                        case 58:
                            mimeStringList.Reset();
                            continue;

                        case 59:
                        case 61:
                        case 63:
                            goto IL_485;

                        case 60:
                            break;

                        case 62:
                            goto IL_432;

                        case 64:
                            if (mimeStringList.Length == 0)
                            {
                                parserStage = MimeAddressParser.ParserStage.ROUTEDOMAIN;
                                continue;
                            }
                            this.valueParser.ParseAppendLastByte(ref mimeStringList);
                            address.TakeOver(ref mimeStringList);
                            parserStage = MimeAddressParser.ParserStage.ADDRSPEC;
                            continue;

                        default:
                            switch (b4)
                            {
                            case 91:
                                if (!this.useSquareBrackets)
                                {
                                    this.valueParser.ParseUnget();
                                    ignoreNextByte = true;
                                    continue;
                                }
                                break;

                            case 92:
                                goto IL_485;

                            case 93:
                                if (!this.useSquareBrackets)
                                {
                                    this.valueParser.ParseUnget();
                                    ignoreNextByte = true;
                                    continue;
                                }
                                goto IL_432;

                            default:
                                goto IL_485;
                            }
                            break;
                        }
                        if (mimeStringList.Length != 0)
                        {
                            this.valueParser.ParseUnget();
                            ignoreNextByte = true;
                            continue;
                        }
                        continue;
IL_432:
                        address.TakeOver(ref mimeStringList);
                        if (address.Length != 0 || displayName.Length != 0)
                        {
                            parserStage = MimeAddressParser.ParserStage.END;
                            continue;
                        }
                        parserStage = MimeAddressParser.ParserStage.BEGIN;
                        continue;
                    }
IL_485:
                    this.valueParser.ParseUnget();
                    ignoreNextByte = true;
                    continue;
                }

                case MimeAddressParser.ParserStage.ADDRSPEC:
                {
                    byte b5 = b;
                    if (b5 > 44)
                    {
                        switch (b5)
                        {
                        case 59:
                            this.groupInProgress = false;
                            goto IL_58B;

                        case 60:
                            if (displayName.Length == 0)
                            {
                                displayName.TakeOverAppend(ref address);
                                parserStage = MimeAddressParser.ParserStage.ANGLEADDR;
                                continue;
                            }
                            this.valueParser.ParseUnget();
                            ignoreNextByte = true;
                            continue;

                        case 61:
                            goto IL_5B5;

                        case 62:
                            break;

                        default:
                            switch (b5)
                            {
                            case 91:
                                if (mimeStringList.Length == 0)
                                {
                                    this.valueParser.ParseUnget();
                                    this.valueParser.ParseDomainLiteral(true, ref mimeStringList);
                                    address.TakeOverAppend(ref mimeStringList);
                                    parserStage = MimeAddressParser.ParserStage.END;
                                    continue;
                                }
                                this.valueParser.ParseUnget();
                                ignoreNextByte = true;
                                continue;

                            case 92:
                                goto IL_5B5;

                            case 93:
                                if (!this.useSquareBrackets)
                                {
                                    this.valueParser.ParseUnget();
                                    ignoreNextByte = true;
                                    continue;
                                }
                                break;

                            default:
                                goto IL_5B5;
                            }
                            break;
                        }
                        address.TakeOverAppend(ref mimeStringList);
                        parserStage = MimeAddressParser.ParserStage.END;
                        continue;
                    }
                    if (b5 != 0 && b5 != 44)
                    {
                        goto IL_5B5;
                    }
IL_58B:
                    address.TakeOverAppend(ref mimeStringList);
                    if (address.Length == 0 && displayName.Length == 0 && b != 0)
                    {
                        continue;
                    }
                    break;
IL_5B5:
                    this.valueParser.ParseUnget();
                    ignoreNextByte = true;
                    continue;
                }

                case MimeAddressParser.ParserStage.ROUTEDOMAIN:
                {
                    byte b6 = b;
                    if (b6 <= 44)
                    {
                        if (b6 == 0)
                        {
                            break;
                        }
                        if (b6 != 44)
                        {
                            goto IL_665;
                        }
                    }
                    else if (b6 != 58)
                    {
                        if (b6 != 62)
                        {
                            switch (b6)
                            {
                            case 91:
                                mimeStringList.Reset();
                                this.valueParser.ParseUnget();
                                this.valueParser.ParseDomainLiteral(false, ref mimeStringList3);
                                continue;

                            case 92:
                                goto IL_665;

                            case 93:
                                if (!this.useSquareBrackets)
                                {
                                    this.valueParser.ParseUnget();
                                    ignoreNextByte = true;
                                    continue;
                                }
                                break;

                            default:
                                goto IL_665;
                            }
                        }
                        mimeStringList.Reset();
                        parserStage = MimeAddressParser.ParserStage.END;
                        continue;
                    }
                    mimeStringList.Reset();
                    parserStage = MimeAddressParser.ParserStage.ANGLEADDR;
                    continue;
IL_665:
                    this.valueParser.ParseUnget();
                    ignoreNextByte = true;
                    continue;
                }

                case MimeAddressParser.ParserStage.END:
                {
                    mimeStringList.Reset();
                    byte b7 = b;
                    if (b7 != 0 && b7 != 44)
                    {
                        if (b7 != 59)
                        {
                            continue;
                        }
                        this.groupInProgress = false;
                    }
                    if (address.Length == 0 && displayName.Length == 0 && b != 0)
                    {
                        parserStage = MimeAddressParser.ParserStage.BEGIN;
                        continue;
                    }
                    break;
                }
                }
                break;
            }
            goto IL_6B9;
Block_25:
            displayName.TakeOver(ref mimeStringList);
            goto IL_6B9;
Block_26:
            displayName.TakeOver(ref mimeStringList);
            this.groupInProgress = true;
            return(AddressParserResult.GroupStart);

IL_330:
            displayName.TakeOver(ref mimeStringList);
            goto IL_6B9;
IL_478:
            address.TakeOver(ref mimeStringList);
IL_6B9:
            if (displayName.Length == 0 && mimeStringList2.Length != 0 && address.Length != 0)
            {
                displayName.TakeOver(ref mimeStringList2);
            }
            if (address.Length == 0 && displayName.Length == 0)
            {
                result = AddressParserResult.End;
            }
            return(result);
        }
示例#20
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);
        }
示例#21
0
 private static void ParseAddressInternal(AddressParserResult addressParserResult, string addressValue)
 {
     addressParserResult.Endpoint    = UriHelper.GetEndPoint(addressValue);
     addressParserResult.Resource    = UriHelper.GetResource(addressValue);
     addressParserResult.QueryParams = UriHelper.DecodeQueryParameters(addressValue);
 }