/// <summary> /// This event handler method calls /// the ProcessLocation method of the ProcessorClass class /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SearchLocationButton_Click(object sender, EventArgs e) { //ProcessorClass.ProcessSearchLocation(); try { String results = NoOfDaysDropDownList.SelectedValue.ToString(); String Format = "JSON"; /*Set input parameters for the API*/ LocationSearchInput input = new LocationSearchInput(); input.query = SearchTextBox.Text; input.num_of_results = results; input.format = Format; /* Call the SearchLocation method and pass in the input parameters*/ API_Implementation api = new API_Implementation(); LocationSearch locationSearch = api.SearchLocation(input); /*Display Results*/ DisplayResultsTextBox.Text = "\r\n Area Name: " + locationSearch.search_API.result[0].areaName[0].value; DisplayResultsTextBox.Text += "\r\n Country: " + locationSearch.search_API.result[0].country[0].value; DisplayResultsTextBox.Text += "\r\n Latitude: " + locationSearch.search_API.result[0].latitude; DisplayResultsTextBox.Text += "\r\n Longitude: " + locationSearch.search_API.result[0].longitude; DisplayResultsTextBox.Text += "\r\n Population: " + locationSearch.search_API.result[0].population; DisplayResultsTextBox.Text += "\r\n Region: " + locationSearch.search_API.result[0].region[0].value; } catch (Exception ex) { ex.GetBaseException(); } }
public Location(string locationName) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; LocationSearch locSearch = new LocationSearch(); SearchStringField locName = new SearchStringField(); locName.@operator = SearchStringFieldOperator.@is; locName.operatorSpecified = true; locName.searchValue = locationName; LocationSearchBasic locSearchBasic = new LocationSearchBasic(); locSearchBasic.name = locName; locSearch.basic = locSearchBasic; SearchResult locationResult = service.search(locSearch); if (locationResult.status.isSuccess != true) throw new Exception("Cannot find Item " + locationName + " " + locationResult.status.statusDetail[0].message); if (locationResult.recordList.Count() != 1) throw new Exception("More than one item found for item " + locationName); this.locationRecord = new RecordRef(); this.locationRecord.type = RecordType.location; this.locationRecord.typeSpecified = true; this.locationRecord.internalId = ((com.netsuite.webservices.Location)locationResult.recordList[0]).internalId; }
public PagedResponse <LocationDto> Execute(LocationSearch search) { var query = _context.Locations.AsQueryable(); if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name)) { query = query.Where(x => x.CityName.ToLower().Contains(search.Name.ToLower())); } var currentPage = search.Page; var perPage = search.PerPage; var skip = perPage * (currentPage - 1); return(new PagedResponse <LocationDto> { CurrentPage = currentPage, ItemsPerPage = perPage, TotalCount = query.Count(), Items = query.Skip(skip).Take(perPage).Select(x => new LocationDto { Id = x.Id, CityName = x.CityName }) }); }
private void Location_String_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == (char)Keys.Return) { LocationSearch.PerformClick(); } }
public ActionResult <IEnumerable <LocationResponseDTO> > Get([FromQuery] LocationSearch search) { try { var transmissions = _getLocations.Execute(search); return(Ok(transmissions)); } catch (Exception) { return(StatusCode(500, "Server error")); } }
public LocationSearch SearchLocation(LocationSearchInput input) { // create URL based on input paramters string apiURL = ApiBaseURL + "search.ashx?q=" + input.query + "&format=" + input.format + "&timezone=" + input.timezone + "&popular=" + input.popular + "&num_of_results=" + input.num_of_results + "&callback=" + input.callback + "&key=" + PremiumAPIKey; // get the web response string result = RequestHandler.Process(apiURL); // serialize the json output and parse in the helper class LocationSearch locationSearch = (LocationSearch) new JavaScriptSerializer().Deserialize(result, typeof(LocationSearch)); return(locationSearch); }
public async Task <IActionResult> Search(LocationSearch newSearch) { var client = new RestClient("https://maps.googleapis.com/maps/api/place"); var placesRequest = new RestRequest("/nearbysearch/json?location=" + newSearch.Lat + "," + newSearch.Long + "&radius=1000&name=" + newSearch.Description + "&key=AIzaSyCVSYAYFCgQRLTaigD-y5QZfoZj_LhbbWU", Method.POST); var response = new RestResponse(); Task.Run(async() => { response = await GetResponseContentAsync(client, placesRequest) as RestResponse; }).Wait(); JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(response.Content); Console.WriteLine(jsonResponse); return(Json(jsonResponse)); }
public PagedResponse <LocationQueryDto> Execute(LocationSearch search) { var query = _context.Locations.AsQueryable(); if (!string.IsNullOrEmpty(search.Name) && !string.IsNullOrWhiteSpace(search.Name)) { query = query.Where(x => x.Name.ToLower().Contains(search.Name.ToLower())); } if (search.CityID is int) { query = query.Where(x => x.CityID == search.CityID); } return(query.Paged <LocationQueryDto, Location>(search, _mapper)); }
public string createNewBin(InventoryBin bin) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; LocationSearch locationSearch = new LocationSearch(); LocationSearchBasic locationSearchBasic = new LocationSearchBasic(); SearchStringField locationName = new SearchStringField(); locationName.searchValue = bin.LocationName; locationName.@operator = SearchStringFieldOperator.@is; locationName.operatorSpecified = true; locationSearchBasic.name = locationName; locationSearch.basic = locationSearchBasic; SearchResult sr = new SearchResult(); sr = service.search(locationSearch); if (sr.status.isSuccess != true) Console.WriteLine(sr.status.statusDetail[0].message); Bin newBin = new Bin(); RecordRef newLocation = new RecordRef(); newLocation.type = RecordType.location; newLocation.typeSpecified = true; newLocation.internalId = ((com.netsuite.webservices.Location)sr.recordList[0]).internalId; newBin.binNumber = bin.BinNumber; newBin.location = newLocation; WriteResponse writeResponse = service.add(newBin); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Bin: "+ newBin.binNumber +" has been created."); return "Bin: " + newBin.binNumber + " has been created."; } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); return writeResponse.status.statusDetail[0].message; } return string.Empty; }
public IEnumerable <LocationResponseDTO> Execute(LocationSearch request) { var keyword = request.Keyword; var query = AiContext.Locations .Where(x => x.IsDeleted == 0) .AsQueryable(); if (keyword != null) { query = query .Where(x => x.Adress.ToLower().Contains(keyword.ToLower())); } return(query .Select(x => new LocationResponseDTO { Id = x.Id, Adress = x.Adress, Price = x.Price })); }
/// <summary> /// get all locations in a lat,lng point /// </summary> /// <param name="lat">latitude</param> /// <param name="lng">longtude</param> /// <param name="distance">distance less than 750 meters</param> /// <param name="facebook_places_id">facebook places id</param> /// <returns>all locations</returns> public async Task <LocationSearch> GetLocationSearch(string lat, string lng, string distance = "", string facebook_places_id = "") { LocationSearch location = new LocationSearch(); string URL = _HttpClient.BaseAddress.AbsoluteUri + "locations/search?lat=" + lat + "&lng=" + lng + "&access_token=" + _AccessToken; if (distance != "") { URL += "&distance=" + distance; } if (facebook_places_id != "") { URL += "&facebook_places_id=" + facebook_places_id; } try { _ResponseMessage = await _HttpClient.GetAsync(URL); if (_ResponseMessage.IsSuccessStatusCode) { string responsestring = await _ResponseMessage.Content.ReadAsStringAsync(); location = JsonConvert.DeserializeObject <Models.Location.LocationSearch>(responsestring); } else { location.meta.code = int.Parse(_ResponseMessage.StatusCode.ToString()); } return(location); } catch (Exception ex) { if (_Telemetryclient != null) { _Telemetryclient.TrackException(ex); } location.meta.code = int.Parse(_ResponseMessage.StatusCode.ToString()); } return(location); }
protected void btnLocationSearchPremium_Click(object sender, EventArgs e) { // set input parameters for the API LocationSearchInput input = new LocationSearchInput(); input.query = txtLocation.Text; input.num_of_results = "2"; input.format = "JSON"; if (!string.IsNullOrEmpty(input.query)) { // call the location Search method with input parameters PremiumAPI api = new PremiumAPI(); LocationSearch locationSearch = api.SearchLocation(input); // printing a few values to show how to get the output if (locationSearch.search_API != null && locationSearch.search_API.result != null) { txtOutput.Text = ""; for (int i = 0; i < locationSearch.search_API.result.Count; i++) { txtOutput.Text += "\r\n Area Name: " + locationSearch.search_API.result[i].areaName[0].value; txtOutput.Text += "\r\n Country: " + locationSearch.search_API.result[i].country[0].value; txtOutput.Text += "\r\n Latitude: " + locationSearch.search_API.result[i].latitude; txtOutput.Text += "\r\n Longitude: " + locationSearch.search_API.result[i].longitude; txtOutput.Text += "\r\n Population: " + locationSearch.search_API.result[i].population; txtOutput.Text += "\r\n Region: " + locationSearch.search_API.result[i].region[0].value; txtOutput.Text += "\r\n --------------------------"; } } else { txtOutput.Text = "\r\n Something went wrong. Please make sure you entered city name!"; } } else { txtOutput.Text = "\r\n Please enter location."; } }
public IEnumerable <Location> Get([FromQuery] LocationSearch locationSearch = null) { var listDemo = (List <Location>)LocationRepository.SearchBy(locationSearch); return(listDemo); }
public CopernicusController(CopernicusGetData copernicus, LocationSearch locSearch) { this.copernicus = copernicus; this.locSearch = locSearch; }
private void HName_Leave(object sender, EventArgs e) { Location_String.Text = HName.Text; LocationSearch.PerformClick(); }
/**************************************************************************************************************************/ /// <summary> /// <para>searched for location by geographic coordinate</para> /// </summary> /// <param name="Latitude"></param> /// <param name="Longitude"></param> /// <param name="Parameters"></param> /// <returns></returns> public LocationSearch GetLocationSearchResult(String Latitude, String Longitude, GetLocationSearchResultParameters Parameters) { LocationSearch SearchResult = null; try { // SET UP REQUEST URI UriBuilder BaseUri = new UriBuilder(Config.GetUriScheme() + "://" + Config.GetApiUriString() + "/locations/search"); // SET UP QUERY STRING NameValueCollection QueryString = System.Web.HttpUtility.ParseQueryString(String.Empty); QueryString.Add("access_token", AuthorisedUser.AccessToken); QueryString.Add("lat", Latitude); QueryString.Add("lng", Longitude); QueryString.Add("distance", Parameters.Distance); QueryString.Add("facebook_places_id", Parameters.FacebookPlacesId); QueryString.Add("foursquare_v2_id", Parameters.FoursquareV2Id); // SET THE QUERY STRING BaseUri.Query = QueryString.ToString(); Console.WriteLine(BaseUri.Uri.ToString()); // SEND REQUEST WebClient Client = new WebClient(); byte[] ResponseData = Client.DownloadData(BaseUri.Uri); String Response = Encoding.UTF8.GetString(ResponseData); // PARSE JSON dynamic ParsedJson = JsonConvert.DeserializeObject(Response); // CREATE SEARCH RESULT OBJECT SearchResult = new LocationSearch(); // CREATE META OBJECT MetaData Meta = new MetaData(); Meta.Code = ParsedJson.meta.code; SearchResult.Meta = Meta; // SET DATA FIELD IN SEARCHRESULT List <LocationData> Data = new List <LocationData>(); foreach (dynamic EachLocation in ParsedJson.data) { // CREATE NEW LOCATIONDATA OBJECT LocationData Location = new LocationData(); Location.Id = EachLocation.id; Location.Name = EachLocation.name; Location.Latitude = EachLocation.latitude; Location.Longitude = EachLocation.longitude; // ADD LOCATION TO THE LIST Data.Add(Location); } SearchResult.Data = Data; } catch (WebException WEx) { // FETCHES ANY ERROR THROWN BY INSTAGRAM API Stream ResponseStream = WEx.Response.GetResponseStream(); if (ResponseStream != null) { StreamReader ResponseReader = new StreamReader(ResponseStream); if (ResponseReader != null) { // PARSE JSON dynamic ParsedJson = JsonConvert.DeserializeObject(ResponseReader.ReadToEnd()); // CREATE NEW META OBJECT AND FILL IN DATA MetaData Meta = new MetaData(); Meta.Code = ParsedJson.meta.code; Meta.ErrorType = ParsedJson.meta.error_type; Meta.ErrorMessage = ParsedJson.meta.error_message; SearchResult.Meta = Meta; } } } catch (Exception Ex) { Console.WriteLine(Ex.StackTrace); } return(SearchResult); }
public async Task <IEnumerable <Location> > Get([FromQuery] LocationSearch locationSearch = null) { return(await _locationService.GetAsync(locationSearch)); }
public async Task <IEnumerable <Location> > Post(LocationSearch locationSearch) { return(await _locationService.GetAsync(locationSearch)); }
public IActionResult Get([FromQuery] LocationSearch search, [FromServices] IGetLocationsQuery query) { return(Ok(_executor.ExecuteQuery(query, search))); }
public IActionResult GetAllByLocationOrderByCreatedDate([FromBody] LocationSearch item) { var items = postRepository.GetAllByLocationOrderByCreatedDate(item.lat, item.lng, item.radius).Where(v => v.IsDeleted == false); foreach (var it in items) { var media = mediaRepository.GetByID(it.MediaId); it.MediaUrl = media.MediaUrl; var user = userRepository.GetById(it.UserId); if (user != null) { it.Username = user.UserName; } if (user.MediaId > 0) { var media1 = mediaRepository.GetByID(user.MediaId); if (media1 != null) { it.UserProfileImageUrl = media1.MediaUrl; } } it.HintCount = hintRepository.GetAll().Count(a => a.PostId == it.PostId); var postTags = tagRepository.GetAllPostTags().Where(a => a.PostId == it.PostId); it.Tags = new List <Tag>(); if (postTags.Any()) { foreach (var tag in postTags) { var t = tagRepository.GetByID(tag.TagId); if (t != null) { it.Tags.Add(t); } } } var vote = voteRepository.GetByID(it.PostId, item.UserId); if (vote != null) { it.VoteTypeId = vote.VoteTypeId; } it.Votes = voteRepository.GetAll().Where(a => a.PostId == it.PostId && a.VoteTypeId == 1).ToList(); if (it.Votes.Any(a => a.VoteTypeId == 1)) { foreach (var v in it.Votes) { if (user.MediaId > 0) { var u = userRepository.GetById(v.UserId); if (u != null && u.MediaId > 0) { v.UserProfileImage = mediaRepository.GetByID(u.MediaId); } if (u.MediaId <= 0) { v.UserProfileImage = new Media { MediaTypeId = 1, MediaUrl = "https://thriljunkystorage.blob.core.windows.net/public/avatar-large.png" }; } } } } it.ReportedItems = reportingRepository.GetAllByPostId(it.PostId); var loc = locationRepository.GetByID(it.LocationId); if (loc != null) { it.Name = loc.Name; it.Latitude = loc.Latitude; it.Longitude = loc.Longitude; } } var ret = from val in items orderby val.CreatedDate descending group val by val.LocationId into g select g.Take(5).OrderByDescending(b => b.CreatedDate).ToList(); return(Ok(ret)); }
public async Task <ActionResult <IEnumerable <LocationResult> > > PostLocationResult(LocationSearch locationSearch) { List <LocationResult> locationResults = new List <LocationResult>(); try { int restaurantResultLimit = Convert.ToInt32(_configuration["RestaurantResultLimit"]); double restaurantSearchRadius = Convert.ToDouble(_configuration["RestaurantSearchRadius"]); string distanceUnit = _configuration["DistanceUnit"]; if ((locationSearch.longitude.HasValue || locationSearch.latitude.HasValue) && (locationSearch.locationName == "")) { //Search for geo only. If the range is within the configured range, retrn the first value //var allLocations = await _context.RestaurantLocations.ToListAsync(); var allLocations = await _context.RestaurantLocations.Where(a => a.longitude != 0).ToListAsync(); //for each entry in artists, get artist links foreach (RestaurantLocation restaurantLocation in allLocations) { if (restaurantLocation.latitude.HasValue) { restaurantLocation.distance = new Coordinates(locationSearch.latitude.GetValueOrDefault(), locationSearch.longitude.GetValueOrDefault()).DistanceTo(new Coordinates(restaurantLocation.latitude.Value, restaurantLocation.longitude.Value), UnitOfLength.Miles); } } var distanceInAscOrder = allLocations.OrderBy(s => s.distance).Take(restaurantResultLimit); //for each entry in artists, get artist links foreach (RestaurantLocation restaurantLocation in distanceInAscOrder) { if (restaurantLocation.distance <= restaurantSearchRadius) { LocationResult locationResult = new LocationResult(); locationResult.isCustAtRestaurant = true; locationResult.locationId = restaurantLocation.id; locationResult.locationName = restaurantLocation.locationName; locationResult.distanceFromLocation = restaurantLocation.distance.ToString(); locationResult.distanceUnit = distanceUnit; locationResults.Add(locationResult); break; } else { LocationResult locationResult = new LocationResult(); locationResult.isCustAtRestaurant = false; locationResult.locationId = restaurantLocation.id; locationResult.locationName = restaurantLocation.locationName; locationResult.distanceFromLocation = restaurantLocation.distance.ToString(); locationResult.distanceUnit = distanceUnit; locationResults.Add(locationResult); } } } else { var restaurantLocations = new List <RestaurantLocation>(); if (locationSearch.locationName != "") { restaurantLocations = await _context.RestaurantLocations.Where(a => a.locationName.Contains(locationSearch.locationName)).OrderBy(s => s.locationName).Take(restaurantResultLimit).ToListAsync(); } else { restaurantLocations = await _context.RestaurantLocations.OrderBy(s => s.locationName).Take(restaurantResultLimit).ToListAsync(); } if (restaurantLocations != null) { //for each entry in artists, get artist links foreach (RestaurantLocation restaurantLocation in restaurantLocations) { LocationResult locationResult = new LocationResult(); locationResult.isCustAtRestaurant = false; locationResult.locationId = restaurantLocation.id; locationResult.locationName = restaurantLocation.locationName; locationResult.distanceFromLocation = restaurantLocation.distance.ToString(); locationResult.distanceUnit = distanceUnit; locationResults.Add(locationResult); } } } _log.LogInformation("Identified if customer is present at resturant or not..."); } catch (Exception e) { _log.LogError(e.Message); } return(locationResults); }
public List <Location> Get([FromQuery] LocationSearch locationSearch = null) { return(_locationService.Get(locationSearch)); }
public async Task <IEnumerable <Location> > Get([FromQuery] LocationSearch locationSearch = null) { var listDemo = await locationService.Get(locationSearch); return(listDemo); }