示例#1
0
        /// <summary>
        /// Checks the place.
        /// </summary>
        /// <param name="placeName">Name of the place.</param>
        /// <returns></returns>
        public Place CheckPlace(string placeName)
        {
            Geocoder geoCoder = new Geocoder();
            GeocodeResponse response = geoCoder.GeocodeByAddress(placeName + ", Italia");
            AddressComponent ac = response.Result.AddressComponents.FindByType("locality");

            if (ac != null)
            {
                Place p = this.LoadPlace(ac.LongName);

                if (p != null)
                    return p;
                else
                {
                    p = new Place();
                    p.Name = ac.LongName;
                    p.GeolocationInfo = response.Result.Geometry;
                    p.Latitude = response.Result.Geometry.Location.Latitude;
                    p.Longitude = response.Result.Geometry.Location.Longitude;
                    p.MapZoom = 13;
                    p.Open311ApiKey = string.Empty;
                    p.Open311CityID = string.Empty;
                    p.Open311URL = string.Empty;
                    p.Status = true;

                    this.CreatePlace(p);

                    return p;
                }
            }

            return null;
        }
示例#2
0
        /// <summary>
        /// Creates the place.
        /// </summary>
        /// <param name="p">The p.</param>
        public void CreatePlace(Place p)
        {
            try
            {
                OpenSession();
                OpenTransaction();
                p.RewritedName = PlacesUtils.RewritePlaceName(p.Name);
                Session.Save(p);
                CommitTransaction();

            }
            catch (Exception ex)
            {
                RollbackTransaction();
                throw ex;
            }
        }
示例#3
0
        public Place AddPlace(JsonObject param)
        {
            CheckRequest(param["ajaxSessionKey"].ToString());

            Place p = new Place();
            p.Open311ApiKey = string.Empty;
            p.Open311CityID = string.Empty;
            p.Open311URL = string.Empty;

            p.Latitude = Convert.ToDecimal(param["lat"]);
            p.Longitude = Convert.ToDecimal(param["lng"]);
            p.MapZoom = Convert.ToInt32(param["zoom"]);
            p.Name = param["name"].ToString();
            p.Status = false;
            PlaceManager pm = new PlaceManager();
            pm.CreatePlace(p);

            CitySubmissionEmail cse = new CitySubmissionEmail();
            cse.Send(param["name"].ToString(), param["email"].ToString());

            return p;
        }
示例#4
0
        /// <summary>
        /// Gets the current city.
        /// </summary>
        public void InitClientObjects()
        {
            PlaceManager pm = new PlaceManager();
            string defaultCity = ConfigurationOptions.Current.GetString("system_default_city");

            if (QueryStringContains("city"))
                defaultCity = GetFromQueryString("city");

            _currentCity = pm.LoadPlaceByRewritedName(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));

            if (_currentCity != null)
            {

            }
            else
            {
                _currentCity = pm.LoadPlace(ConfigurationOptions.Current.GetString("system_default_city"));

                RegisterDocumentReadyFunction("notExistingCity", JsUtils.CreateJsFunction("showNotExistingCityDialog", false, defaultCity));
            }

            JsonObject o = new JsonObject();
            o["name"] = _currentCity.Name;
            o["link"] = _currentCity.Link;
            o["id"] = _currentCity.PlaceID;
            o["lat"] = _currentCity.GeolocationInfo.Location.Latitude;
            o["lng"] = _currentCity.GeolocationInfo.Location.Longitude;
            o["zoom"] = _currentCity.MapZoom;

            ClientScript.RegisterClientScriptBlock(this.GetType(), "clientPageObjects", "var currentCity = " + o.ToString() + ";", true);

            //if (SessionContains("CurrentCity"))
            //{
            //    _currentCity = (Place)GetFromSession("CurrentCity");
            //    if (QueryStringContains("city") && GetFromQueryString("city") != _currentCity.Name)
            //    {

            //        _currentCity = pm.LoadPlace(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));
            //        AddToSession("CurrentCity", _currentCity);
            //    }
            //}
            //else
            //{
            //    _currentCity = pm.LoadPlace(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));

            //    if (_currentCity != null)
            //        AddToSession("CurrentCity", _currentCity);
            //    else
            //    {
            //        _currentCity = pm.LoadPlace(ConfigurationOptions.Current.GetString("system_default_city"));
            //        RegisterDocumentReadyFunction("notExistingCity", JsUtils.CreateJsFunction("showNotExistingCityDialog", false, defaultCity));
            //    }
            //}

            List<Place> places = pm.GetActivePlaces();

            JsonArray citiesArr = new JsonArray();
            foreach (Place p in places)
            {
                JsonObject c = new JsonObject();
                c["label"] = p.Name;
                c["link"] = p.Link;
                citiesArr.Add(c);
            }

            ClientScript.RegisterClientScriptBlock(this.GetType(), "cities", "var places = " + citiesArr.ToString() + ";", true);
        }