public void GetPlaceDetails(int countryId) { var placeDetails = dALSchedulers.Scheduler_GetPlaceDetails(countryId); countryInformation = dALSchedulers.Scheduler_GetCountryOnId(countryId); foreach (GetPlaceDetails details in placeDetails) { try { GetPlaceDetails(details.PlaceId, details.AttractionsId, countryId); //GetAutoCompleteInformation(countryId, details, countryInformation, details.AttractionsId); } catch (Exception ex) { exceptionLogging.InsertExceptionInformation(new LoggingEntity { CreatedBy = "scheduler", ExceptionMessage = ex.Message, ExceptionStackTrace = ex.StackTrace, MethodName = "GetPlaceDetails", Parameters = "countryId = " + countryId.ToString(), CountryId = countryId }); } } //getDistanceCalculation.CalculateDistance(countryId); }
public MasterCountryScheduler Scheduler_GetCountryOnId(int countryId) { try { MasterCountryScheduler _returnResult = SqlHelper.QuerySP <MasterCountryScheduler>("Scheduler_GetCountryOnId", new { CountryId = countryId }).ToList().FirstOrDefault(); return(_returnResult); } catch (Exception ex) { throw ex; } }
public void GetAutoCompleteInformation(int countryId, GetPlaceDetails details, MasterCountryScheduler masterCountryScheduler, int attractionsId, int userTripId = 0) { try { //var googleCounter = dALSchedulers.Scheduler_GetGoogleMapsMethodCount("geocode"); //if (googleCounter == null || googleCounter.Counter < Convert.ToInt32(ConfigurationManager.AppSettings["recordCount"])) { AttractionsDTO attractionDto; string retsult = string.Empty; string googleUrl = "https://maps.googleapis.com/maps/api/geocode/json?address=" + details.AttractionName + " " + details.GoogleSearchText + "&components=country:" + masterCountryScheduler.CountryShortName + "&key=" + ConfigurationManager.AppSettings["apiKey"]; retsult = webRequest.WebServiceInformation(googleUrl); var placeDetailsInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <EntityPlaceSearch>(retsult); if (placeDetailsInfo.results != null && placeDetailsInfo.results.Count > 0) { //dALSchedulers.Scheduler_GoogleLogging("geocode", "GetAutoCompleteInformation", // details.AttractionName, "", "", // false); } else { //dALSchedulers.Scheduler_GoogleLogging("geocode", "GetAutoCompleteInformation", // details.AttractionName, "", "", // true); } if (placeDetailsInfo != null) { if (masterCountryScheduler.CountryName != GetLongNameAddressElement(placeDetailsInfo.results .FirstOrDefault() .address_components, "country")) { dALSchedulers.SchedulerDeleteAttraction(attractionsId, countryId); } else { attractionDto = new AttractionsDTO(); attractionDto.Latitude = placeDetailsInfo.results.FirstOrDefault().geometry.location.lat; attractionDto.AddressOne = GetLongNameAddressElement(placeDetailsInfo.results .FirstOrDefault() .address_components, "street_number") + " " + GetLongNameAddressElement(placeDetailsInfo.results .FirstOrDefault() .address_components, "route"); attractionDto.AddressTwo = GetLongNameAddressElement(placeDetailsInfo.results .FirstOrDefault() .address_components, "administrative_area_level_2"); attractionDto.CityName = GetLongNameAddressElement(placeDetailsInfo.results.FirstOrDefault() .address_components, "locality"); if (string.IsNullOrEmpty(attractionDto.CityName)) { attractionDto.CityName = GetLongNameAddressElement(placeDetailsInfo.results.FirstOrDefault() .address_components, "administrative_area_level_2"); } attractionDto.CreatedBy = "schedule"; attractionDto.Longitude = placeDetailsInfo.results.FirstOrDefault().geometry.location.lng; attractionDto.PlaceId = placeDetailsInfo.results.FirstOrDefault().place_id; attractionDto.StateName = GetLongNameAddressElement(placeDetailsInfo.results .FirstOrDefault() .address_components, "administrative_area_level_1"); attractionDto.CountryId = countryId; attractionDto.AttractionsId = attractionsId; attractionDto.StateShortName = GetShortNameAddressElement(placeDetailsInfo.results.FirstOrDefault() .address_components, "administrative_area_level_1"); attractionDto.CityShortName = GetShortNameAddressElement(placeDetailsInfo.results.FirstOrDefault() .address_components, "locality"); if (string.IsNullOrEmpty(attractionDto.CityShortName)) { attractionDto.CityShortName = GetLongNameAddressElement(placeDetailsInfo.results.FirstOrDefault() .address_components, "administrative_area_level_2"); } dALSchedulers.Scheduler_InsertAttractionAuto(attractionDto, countryId, userTripId); GetPlaceDetails(attractionDto.PlaceId, attractionsId, countryId); } } else { dALSchedulers.SchedulerDeleteAttraction(attractionsId, countryId); } } } catch (Exception e) { throw e; } }