public async Task <GeocodedAddress> GetById(int id)
        {
            using (SqlConnection sqlConnec = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetAddressById", sqlConnec))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@id", id));
                    GeocodedAddress address = null;
                    await sqlConnec.OpenAsync();

                    using (var reader = await cmd.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            address = MapToGeocodedAddress(reader);
                        }
                        else
                        {
                            address = new GeocodedAddress()
                            {
                                State = "PROCESANDO"
                            };
                        }
                    }

                    return(address);
                }
            }
        }
Exemplo n.º 2
0
        public async Task InsertCoordinates(GeocodedAddress geocodedAddress)
        {
            using (SqlConnection sqlConnec = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("InsertGeocodedAddress", sqlConnec))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@id", geocodedAddress.Id));
                    cmd.Parameters.Add(new SqlParameter("@latitude", geocodedAddress.Latitude));
                    cmd.Parameters.Add(new SqlParameter("@longitude", geocodedAddress.Longitude));

                    await sqlConnec.OpenAsync();

                    await cmd.ExecuteNonQueryAsync();
                }
            }
        }
Exemplo n.º 3
0
        public void SendGeocodedAddres(GeocodedAddress gaddress)
        {
            var factory = new ConnectionFactory()
            {
                Uri = new Uri($"amqp://{_username}:{_password}@{_hostname}:{_port}")
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: _queueName, durable: false, exclusive: false, autoDelete: false, arguments: null);

                    var json = JsonConvert.SerializeObject(gaddress);
                    var body = Encoding.UTF8.GetBytes(json);

                    channel.BasicPublish(exchange: "", routingKey: _queueName, basicProperties: null, body: body);
                }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load the saved information from the previous postback.
        /// </summary>
        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);

            this.Center           = (GeocodedAddress)ViewState["Center"];
            this._Loaders         = (List <PlacemarkLoader>)ViewState["Loaders"];
            this._Placemarks      = (List <Placemark>)ViewState["Placemarks"];
            this.HideControls     = (Boolean)ViewState["HideControls"];
            this.HideDownload     = (Boolean)ViewState["HideDownload"];
            this.HideAddToTag     = (Boolean)ViewState["HideAddToTag"];
            this.Height           = (Int32)ViewState["Height"];
            this.Width            = (Int32)ViewState["Width"];
            this.StaticMap        = (Boolean)ViewState["StaticMap"];
            this.ShowStreetView   = (Boolean)ViewState["ShowStreetView"];
            this.ShowPanControls  = (Boolean)ViewState["ShowPanControls"];
            this.ShowZoomControls = (Boolean)ViewState["ShowZoomControls"];
            this.ShowMapType      = (Boolean)ViewState["ShowMapType"];
            this.MinZoomLevel     = (Int32)ViewState["MinZoomLevel"];
            this.MaxZoomLevel     = (Int32)ViewState["MaxZoomLevel"];
        }
Exemplo n.º 5
0
 /// <summary>
 /// Create a new GoogleMap instance. Set some defaults and other things.
 /// </summary>
 public GoogleMap()
     : base()
 {
     this.Width            = 480;
     this.Height           = 360;
     this._Placemarks      = new List <Placemark>();
     this._Loaders         = new List <PlacemarkLoader>();
     this.Center           = new GeocodedAddress();
     this.Center.Latitude  = ArenaContext.Current.Organization.Address.Latitude;
     this.Center.Longitude = ArenaContext.Current.Organization.Address.Longitude;
     this.ZoomLevel        = 12;
     this.MinZoomLevel     = -1;
     this.MaxZoomLevel     = -1;
     this.StaticMap        = false;
     this.ShowStreetView   = true;
     this.ShowPanControls  = true;
     this.ShowZoomControls = true;
     this.ShowMapType      = true;
     this.HideAddToTag     = false;
     this.HideDownload     = false;
 }
Exemplo n.º 6
0
 private void HandleMessage(GeocodedAddress gAddress)
 {
     _addCoordinatesRepository.InsertCoordinates(gAddress);
 }