コード例 #1
0
        private string GetOfficeLine(PoliticianInfo pi)
        {
            OfficeInfo officeInfo;

            _OfficeDictionary.TryGetValue(pi.OfficeKey, out officeInfo);
            if (officeInfo == null)
            {
                return(string.Empty);
            }
            return(pi.OfficeStatus.GetOfficeStatusDescription() +
                   officeInfo.OfficeDescription);
        }
コード例 #2
0
        private void LoadPoliticians()
        {
            _StateDictionary = StateCache.All51StateCodes.ToDictionary(state => state,
                                                                       state =>
                                                                       new StateInfo
            {
                StateCode  = state,
                Unaccented = new Dictionary <string, List <PoliticianInfo> >(),
                Metaphone  = new Dictionary <string, List <PoliticianInfo> >(),
                Stripped   = new Dictionary <string, List <PoliticianInfo> >()
            },
                                                                       StringComparer.OrdinalIgnoreCase);

            var politicians = Politicians.GetAllNameSearchData();

            foreach (var row in politicians)
            {
                var lname = row.LastName.ToLowerInvariant();
                var uname = GetUnaccentedName(row.LastName);
                var mname = row.LastName.DoubleMetaphone()
                            .ToLowerInvariant();
                var sname = GetStrippedName(uname);

                var pi = new PoliticianInfo
                {
                    PoliticianKey      = row.PoliticianKey,
                    LowerLastName      = lname,
                    UnaccentedLastName = uname,
                    MetaphoneLastName  = mname,
                    StrippedLastName   = sname,
                    OfficeKey          = row.LiveOfficeKey,
                    OfficeStatus       = row.LiveOfficeStatus.ToPoliticianStatus(),
                    DisplayName        = Politicians.FormatName(row)
                };

                var stateCode = Politicians.GetStateCodeFromKey(pi.PoliticianKey);
                var si        = _StateDictionary[stateCode];
                List <PoliticianInfo> list;

                var twoCharacterKey = GetTwoCharacterKey(uname);
                if (!si.Unaccented.TryGetValue(twoCharacterKey, out list))
                {
                    list = new List <PoliticianInfo>();
                    si.Unaccented.Add(twoCharacterKey, list);
                }
                list.Add(pi);

                twoCharacterKey = GetTwoCharacterKey(mname);
                if (!si.Metaphone.TryGetValue(twoCharacterKey, out list))
                {
                    list = new List <PoliticianInfo>();
                    si.Metaphone.Add(twoCharacterKey, list);
                }
                list.Add(pi);

                twoCharacterKey = GetTwoCharacterKey(uname);
                if (!si.Stripped.TryGetValue(twoCharacterKey, out list))
                {
                    list = new List <PoliticianInfo>();
                    si.Stripped.Add(twoCharacterKey, list);
                }
                list.Add(pi);
            }

            _OfficeDictionary = Offices.GetAllNameSearchData()
                                .ToDictionary(row => row.OfficeKey,
                                              row =>
                                              new OfficeInfo
            {
                OfficeKey            = row.OfficeKey,
                OfficeLine1          = row.OfficeLine1,
                OfficeLine2          = row.OfficeLine2,
                OfficeClass          = row.OfficeLevel.ToOfficeClass(),
                AlternateOfficeClass = row.AlternateOfficeLevel.ToOfficeClass(),
                CountyCode           = row.CountyCode,
                LocalCode            = row.LocalCode
            });
        }