コード例 #1
0
        public BaseResponse HangleGetHydrantsByCenterDistance(DynamicDictionary _parameters)
        {
            var response = new BaseResponse {
                Success = false
            };
            User user;

            if (AuthHelper.IsAuthorized(Request, out user))
            {
                double latitude  = Convert.ToDouble((string)_parameters["latitude"]);
                double longitude = Convert.ToDouble((string)_parameters["longitude"]);
                double distance  = Convert.ToDouble((string)_parameters["distance"]);

                HydrantWikiManager hwm    = new HydrantWikiManager();
                GeoPoint           center = new GeoPoint(longitude, latitude);

                List <Hydrant> hydrants = hwm.GetHydrants(center, distance);

                List <HydrantHeader> headers = ProcessHydrants(hydrants, center);

                response = new HydrantQueryResponse {
                    Success = true, Hydrants = headers
                };

                hwm.LogInfo(user.Guid, "Retrieved Hydrants by Center and Distance");

                return(response);
            }
            else
            {
                LogUnauthorized(Request);
            }

            return(response);
        }
コード例 #2
0
        public BaseResponse HangleGetHydrantsByGeobox(DynamicDictionary _parameters)
        {
            var response = new BaseResponse {
                Success = false
            };
            User user;

            if (AuthHelper.IsAuthorized(Request, out user))
            {
                HydrantWikiManager hwm = new HydrantWikiManager();

                double east  = Convert.ToDouble((string)_parameters["east"]);
                double west  = Convert.ToDouble((string)_parameters["west"]);
                double north = Convert.ToDouble((string)_parameters["north"]);
                double south = Convert.ToDouble((string)_parameters["south"]);

                int quantity = 250;
                if (_parameters.ContainsKey("quantity"))
                {
                    quantity = Convert.ToInt32((string)_parameters["quantity"]);
                }
                if (quantity > 500)
                {
                    quantity = 500;
                }

                GeoBox geobox = new GeoBox(east, west, north, south);

                List <Hydrant> hydrants = hwm.GetHydrants(geobox, quantity);

                List <HydrantHeader> headers = ProcessHydrants(hydrants);

                response = new HydrantQueryResponse {
                    Success = true, Hydrants = headers
                };

                hwm.LogInfo(user.Guid, "Retrieved Hydrants by Geobox");

                return(response);
            }
            else
            {
                LogUnauthorized(Request);
            }

            return(response);
        }
コード例 #3
0
ファイル: ApiManager.cs プロジェクト: uptickguru/hwMobileApp
        public HydrantQueryResponse GetHydrantsInCirle(
            User _user, double _latitude, double _longitude, double _radius)
        {
            string url = string.Format("/api/hydrants/circle/{0}/{1}/{2}", _latitude, _longitude, _radius);

            HWRestRequest request = new HWRestRequest();

            request.Method = HWRestMethods.Get;
            request.Host   = m_HWManager.PlatformManager.ApiHost;
            request.Path   = url;
            request.Headers.Add("Username", _user.Username);
            request.Headers.Add("AuthorizationToken", _user.AuthorizationToken);

            var response = m_HWManager.PlatformManager.SendRestRequest(request);
            HydrantQueryResponse responseObject =
                JsonConvert.DeserializeObject <HydrantQueryResponse>(response.Body);

            return(responseObject);
        }