예제 #1
0
        private void GetLocationData()
        {
            if(_viewSettings.GetListSettingCount("Locations") > 0)
            {
                var searchRequest = new SearchOrgUnitsRequest()
                {
                    PageSize = Constants.MaxRawDataResults,
                    RequestedPage = 1
                };

                var values = new List<int>();
                foreach(var kvp in _viewSettings.GetSetting("Locations").Options)
                {
                    values.Add(Convert.ToInt32(kvp.Value));
                }
                searchRequest.OrgUnitIds = values;

                var searchResponse = _view.ProcessRequest<SearchOrgUnitsResponse>(searchRequest);

                foreach(var orgUnit in searchResponse.Results)
                {
                    var record = new LocationRecord()
                    {
                        LocationId = orgUnit.Id,
                        LocationName = orgUnit.Name
                    };
                    _rawData.LocationRecords.Add(record);
                }
            }
        }
예제 #2
0
        private void PopulateDefaultQuery(SearchOrgUnitsRequest searchRequest)
        {
            var locationType = _viewSettings.GetDropdownSettingValue("LocationType");
            if (locationType.Value != null)
                searchRequest.SpecificOrgUnitTypeId = int.Parse(locationType.Value.ToString());

            var zipCode = _viewSettings.GetSettingValue("ZipCode", string.Empty);
            if (!string.IsNullOrEmpty(zipCode))
                searchRequest.PostalCode = zipCode;

            var searchRadius = GetDropDownValue("SearchWithin");
            if (searchRadius != null)
                if (searchRadius != "Any")
                    searchRequest.SearchRadius = int.Parse(searchRadius);
        }
예제 #3
0
        private SearchOrgUnitsRequest BuildRequest(IDictionary<string, string> parameters, int pageSize, int pageNumber)
        {
            var searchRequest = new SearchOrgUnitsRequest()
            {
                PageSize = pageSize,
                RequestedPage = pageNumber,
            };

            PopulateDefaultQuery(searchRequest);

            //Location Context
            searchRequest.OrgUnitId = LocationContextHelper.ResolveLocationContext(_view, _viewSettings, parameters).Id;
            searchRequest.DescendantOption = LocationContextHelper.ResolveLocationDescendantOption(_viewSettings, parameters);
            //Location Name/Id
            if (parameters.ContainsKey("LocationText"))
                searchRequest.OrgUnitNameCriteria = parameters["LocationText"];
            if (parameters.ContainsKey("LocationId"))
                searchRequest.OrgUnitId = int.Parse(parameters["LocationId"]);

            //City
            if (parameters.ContainsKey("CityId"))
                searchRequest.City = parameters["CityId"];
            //State Id
            if (parameters.ContainsKey("StateId"))
                searchRequest.StateName = parameters["StateId"];
            //Postal Code
            if (parameters.ContainsKey("PostalCode"))
                searchRequest.PostalCode = parameters["PostalCode"];
            //Search Radius
            if (parameters.ContainsKey("RadiusDistance") && !string.IsNullOrEmpty(parameters["RadiusDistance"]))
                searchRequest.SearchRadius = int.Parse(parameters["RadiusDistance"]);
            //Org Unit Type
            if (parameters.ContainsKey("LocationTypeId"))
                searchRequest.SpecificOrgUnitTypeId = int.Parse(parameters["LocationTypeId"]);
            if (parameters.ContainsKey("LocationTypeText"))
                searchRequest.SpecificOrgUnitTypeName = parameters["LocationTypeText"];

            return searchRequest;
        }
예제 #4
0
 private void GetLocations(List<KeyValuePair<object, object>> records)
 {
     var locationsRequest = new SearchOrgUnitsRequest();
     var locationsResponse = _view.ProcessRequest<SearchOrgUnitsResponse>(locationsRequest);
     foreach (var orgUnit in locationsResponse.Results)
         records.Add(new KeyValuePair<object, object>(orgUnit.Name, orgUnit.Id));
 }
예제 #5
0
        private string GetLocations(ConvertServiceRequest request)
        {
            if (request.Parameters.ContainsKey("typeId"))
            {
                var typeRequest = new SearchOrgUnitsRequest
                {
                    SpecificOrgUnitTypeId = int.Parse(request.Parameters["typeId"], CultureInfo.InvariantCulture)
                };
                return CommonUtils.XmlSerialize(ProcessRequest<SearchOrgUnitsResponse>(typeRequest).Results.ToList());
            }
            else
            {
                var apiRequest = new GetOrgUnitsRequestV2();

                if (request.Parameters.ContainsKey("pageSize"))
                    apiRequest.PageSize = int.Parse(request.Parameters["pageSize"]);
                else
                    apiRequest.PageSize = 1000000;

                if (request.Parameters.ContainsKey("pageNumber"))
                    apiRequest.RequestedPage = int.Parse(request.Parameters["pageNumber"]);
                else
                    apiRequest.RequestedPage = 1;

                var response = ProcessRequest<GetOrgUnitsResponseV2>(apiRequest).OrgUnits.ToList();
                return CommonUtils.XmlSerialize(response);
            }
        }