private void CalculatePrice(PriceInput priceInput, int cat, AppraisalOutput appraisalOutput) { string catText = "a3"; /// Call Price Service switch (cat) { case 1: catText = "a1"; break; case 5: catText = "a2"; break; case 6: catText = "a3"; break; case 21: catText = "a21"; break; default: catText = "a2"; break; } string priceUrl = String.Format("{0}/{1}/{2}", ConfigurationManager.AppSettings["Server"], ConfigurationManager.AppSettings["PriceService"], catText); string postData = "[" + JsonConvert.SerializeObject(priceInput) + "]"; string result = iaziClientsync.postApiRequest(priceUrl, postData, token); //PriceOutput priceOutput = Newtonsoft.Json.JsonConvert.DeserializeObject<PriceOutput>(result); parsePriceModelRJson(result, appraisalOutput); }
public AppraisalOutput processDetailInput(DetailInput detailInput, string userAgent) { PriceInput priceInput = MapDetailInputToPriceInput(detailInput); AppraisalOutput appraisalOutput = new AppraisalOutput(); CalculatePrice(priceInput, detailInput.catCode ?? 0, appraisalOutput); appraisalOutput.microRating = detailInput.microRating ?? 0; appraisalOutput.zip = detailInput.zip; appraisalOutput.town = detailInput.town; appraisalOutput.street = detailInput.street; appraisalOutput.CatCode = detailInput.catCode ?? 0; appraisalOutput.country = detailInput.country; ////Saving try { SavePricePropertyDetails(MapPriceBuisnessDataToDatabaseModel(null, null, null, detailInput.deviceId, appraisalOutput), userAgent); } catch (Exception ex) { RealEstateRepository realEstateRepository = new RealEstateRepository(); realEstateRepository.saveException(ex.Message, Convert.ToString(ex.InnerException), ex.StackTrace); return(appraisalOutput); } return(appraisalOutput); }
private PriceInput MapDetailInputToPriceInput(DetailInput detailInput) { PriceInput priceInput = new PriceInput(); priceInput.surfaceLiving = detailInput.surfaceLiving ?? 0; priceInput.surfaceGround = detailInput.landSurface; priceInput.roomNb = detailInput.roomNb ?? 0; priceInput.bathNb = detailInput.bathNb ?? 0; priceInput.buildYear = detailInput.buildYear ?? 0; priceInput.qualityMicro = detailInput.microRating ?? 0; priceInput.zip = detailInput.zip; priceInput.town = detailInput.town; priceInput.street = detailInput.street; return(priceInput); }
public async Task <ApiResult> QuotePrice(PriceInput input) { ApiResult apiResult = new ApiResult(); Hashtable hst = new Hashtable(); if (!Limit(hst, input.BatchId, "QueryViolation_Agent", out string globalKey)) { return(apiResult.Error()); } var batchInfo = await _batchInfoRepository.GetAsync(input.BatchId); var carList = await _batchCarRepository.GetAllListAsync(o => o.WebSiteId == AbpSession.WebSiteId && o.BatchId == input.BatchId); if (carList == null || carList.Count == 0) { return(ApiResult.DataNotFound()); } // 缓存报价进度 var station = new QuotePriceStation { Id = input.BatchId, AllCount = carList.Count, CompleteCount = 0, }; await _cacheManager.GetCache(globalKey).SetAsync(globalKey, station); // 后台处理 await Task.WhenAll(carList.Select(i => { var priceRequest = i.MapTo <IndoorPriceInput>(); priceRequest.UserId = batchInfo.ProxyUserId; priceRequest.WebSiteId = AbpSession.WebSiteId; return(_bus.Send(new IndoorPriceAndSaveCommand { GlobalKey = globalKey, IndoorPrice = priceRequest })); })).ConfigureAwait(false); return(apiResult.Success()); }
public AppraisalOutput processImageLatLon(string imageBase64, double?latitude, double?longitude, string deviceId, string userAgent) { AppraisalOutput appraisalOutput = new AppraisalOutput(); GoogleVisionApi googleVisionApi = new GoogleVisionApi(); PriceInput priceInput = new PriceInput(); ImageCategory imageCategory; string country; string countryCode; double? lat; double? lng; try { imageCategory = googleVisionApi.fetchCategoryForImage(imageBase64); } catch (Exception) { // imageBase64 = getImageAndConvertbase64(); // imageCategory = googleVisionApi.fetchCategoryForImage(imageBase64); imageCategory = new ImageCategory(); imageCategory.CategoryCode = -2; imageCategory.CategoryText = "Invalid Image"; } getAddressForLatLong(latitude ?? 0.0, longitude ?? 0.0); if (reverseGeoCodeResult.Country != "Switzerland") { country = "Switzerland"; countryCode = "CH"; priceInput.zip = appraisalOutput.zip = ConfigurationManager.AppSettings["DefaultZip"]; priceInput.town = appraisalOutput.town = ConfigurationManager.AppSettings["DefaultTown"]; //if country is not switzerland then attach time to street . priceInput.street = appraisalOutput.street = ConfigurationManager.AppSettings["DefaultStreet"] + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; appraisalOutput.minappraisalValue = Convert.ToInt64(latitude.ToString().Replace(".", String.Empty)); appraisalOutput.maxappraisalValue = Convert.ToInt64(longitude.ToString().Replace(".", String.Empty)); lat = Convert.ToDouble(ConfigurationManager.AppSettings["DefaultLatitude"]); lng = Convert.ToDouble(ConfigurationManager.AppSettings["DefaultLongitude"]); } else { country = reverseGeoCodeResult.Country; countryCode = "CH"; priceInput.zip = appraisalOutput.zip = reverseGeoCodeResult.Zip; priceInput.town = appraisalOutput.town = reverseGeoCodeResult.Town; priceInput.street = appraisalOutput.street = reverseGeoCodeResult.Street; lat = (double)latitude; lng = (double)longitude; } if (imageCategory.CategoryCode != -1 && imageCategory.CategoryCode != -2) { getMicroRating(imageCategory.CategoryCode, lat ?? 0.0, lng ?? 0.0, countryCode); priceInput.qualityMicro = appraisalOutput.microRating = ratingResponse.results.microRatingClass1To5 ?? 3; } appraisalOutput.country = country; appraisalOutput.CatCode = imageCategory.CategoryCode; switch (imageCategory.CategoryCode) { case 5: priceInput.surfaceLiving = Convert.ToInt16(ConfigurationManager.AppSettings["A2SurfaceLivingDefault"]); //set default for A2 for Surface appraisalOutput.category = imageCategory.CategoryText; //" Single family House"; break; case 6: priceInput.surfaceLiving = Convert.ToInt16(ConfigurationManager.AppSettings["A3SurfaceLivingDefault"]);; appraisalOutput.category = imageCategory.CategoryText; //" Condominium"; break; case -1: case -2: appraisalOutput.category = imageCategory.CategoryText; //Set the first two labels that are returned by Google break; default: break; } if (imageCategory.CategoryCode != -1 && imageCategory.CategoryCode != -2) { CalculatePrice(priceInput, imageCategory.CategoryCode, appraisalOutput); } //Saving Property Details// try { PriceData priceData = MapPriceBuisnessDataToDatabaseModel(imageBase64, latitude, longitude, deviceId, appraisalOutput); SavePricePropertyDetails(priceData, userAgent); } catch (Exception ex) { RealEstateRepository realEstateRepository = new RealEstateRepository(); realEstateRepository.saveException(ex.Message, Convert.ToString(ex.InnerException), ex.StackTrace); return(appraisalOutput); } return(appraisalOutput); }