Ejemplo n.º 1
0
        private static void SearchResponse(IpAddressGeocoder geoCoder, Response response)
        {
            IpAddressLocation ipAddressLocation = null;
            Exception         ex = response.GetException();

            if (ex != null || response.GetCode() != HttpStatusCode.OK)
            {
                if (geoCoder._listener != null)
                {
                    geoCoder._listener.Done(geoCoder._searchAddress, null);
                }
                return;
            }
            try
            {
                Result result = response.GetResult();
                ipAddressLocation = new IpAddressLocation
                {
                    ipaddress    = result.GetAsString("ipaddress"),
                    country      = result.GetAsString("country"),
                    region       = result.GetAsString("region"),
                    city         = result.GetAsString("city"),
                    postal       = result.GetAsString("postal"),
                    latitude     = result.GetAsString("latitude"),
                    longitude    = result.GetAsString("longitude"),
                    metro_code   = result.GetAsString("metro_code"),
                    area_code    = result.GetAsString("area_code"),
                    isp          = result.GetAsString("isp"),
                    organization = result.GetAsString("organization"),
                    error        = result.GetAsString("error")
                };
            }
            catch (Exception)
            {
            }
            if (geoCoder._listener != null)
            {
                geoCoder._listener.Done(geoCoder._searchAddress, ipAddressLocation);
            }
        }
Ejemplo n.º 2
0
        private static void SearchResponse(IpAddressGeocoder geoCoder, Response response)
        {
            IpAddressLocation ipAddressLocation = null;
            Exception ex = response.GetException();
            if (ex != null || response.GetCode() != HttpStatusCode.OK)
            {

                if (geoCoder._listener != null)
                {
                    geoCoder._listener.Done(geoCoder._searchAddress, null);
                }
                return;
            }
            try
            {
                Result result = response.GetResult();
                ipAddressLocation = new IpAddressLocation
                                        {
                                            ipaddress = result.GetAsString("ipaddress"),
                                            country = result.GetAsString("country"),
                                            region = result.GetAsString("region"),
                                            city = result.GetAsString("city"),
                                            postal = result.GetAsString("postal"),
                                            latitude = result.GetAsString("latitude"),
                                            longitude = result.GetAsString("longitude"),
                                            metro_code = result.GetAsString("metro_code"),
                                            area_code = result.GetAsString("area_code"),
                                            isp = result.GetAsString("isp"),
                                            organization = result.GetAsString("organization"),
                                            error = result.GetAsString("error")
                                        };
            }
            catch (Exception)
            {

            }
            if (geoCoder._listener != null)
            {
                geoCoder._listener.Done(geoCoder._searchAddress, ipAddressLocation);
            }
        }
Ejemplo n.º 3
0
        public void Done(Object context, Response response)
        {
            IpAddressGeocoder geoCoder = (IpAddressGeocoder)context;

            SearchResponse(geoCoder, response);
        }
Ejemplo n.º 4
0
        public void ReadProgress(Object context, int bytes, int total)
        {
            IpAddressGeocoder geoCoder = (IpAddressGeocoder)context;

            geoCoder._listener.ReadProgress(bytes, total);
        }