Exemple #1
0
        public void Search(string address, string customFilter, string proximity)
        {
            esTransactionScope.IsolationLevel = IsolationLevel.ReadUncommitted;

            int searchRadius;

            if (!int.TryParse(proximity, out searchRadius))
            {
                searchRadius = 10;
            }

            List <ViewAbleMarker> markers = new List <ViewAbleMarker>();

            Coordinates geoResult = new Coordinates()
            {
                GeocodeSuccess = false
            };

            if (!string.IsNullOrEmpty(address))
            {
                geoResult = GeocodeLocation(address);
            }

            if (geoResult.GeocodeSuccess)
            {
                var markersCollection = new MarkerCollection();
                markersCollection.LoadByProximity(geoResult.Latitude, geoResult.Longitude, searchRadius, customFilter, ModuleId);

                markersCollection.ToList().ForEach(marker => markers.Add(new ViewAbleMarker(marker)));
                litMarkers.Text = SerializeMarkers(markers);

                if ((Settings[ModuleSettingNames.SearchResultsTemplate] != null))
                {
                    string template = Convert.ToString(Settings[ModuleSettingNames.SearchResultsTemplate]);

                    litSearchResults.Text = ReplaceTokens(markers, template, ModuleId).ToString();
                }

                if (markers.Count == 0)
                {
                    LoadMembers();
                    LoadControls();
                    litError.Text        = "We currently do not have any locations that match your criteria";
                    pnlNoMatches.Visible = true;
                    litMarkers.Text      = SerializeMarkers(LoadMarkers(ModuleId));
                }
            }
            else
            {
                LoadMembers();
                LoadControls(CustomFilterSelection);
                if (!string.IsNullOrEmpty(address))
                {
                    litError.Text        = "Unable to geocode address";
                    pnlNoMatches.Visible = true;
                }

                litMarkers.Text = !string.IsNullOrEmpty(CustomFilterSelection) ? SerializeMarkers(LoadMarkers(ModuleId, CustomFilterSelection)) : SerializeMarkers(LoadMarkers(ModuleId));
            }
        }