public async Task <SaveExOzCountryCommandResult> UpdateCountries() { _logger.StartMsg("Countries"); var postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(""); Contracts.Models.Integrations.ExOz.StateResponseList exOzStateResponse = Mapper <Contracts.Models.Integrations.ExOz.StateResponseList> .MapFromJson(postResponse); var countryList = exOzStateResponse.states.Select(m => m.Country).Distinct(); //Code to insert countries try { var retCountries = await _commandSender.Send <SaveExOzCountryCommand, SaveExOzCountryCommandResult> (new SaveExOzCountryCommand { Names = countryList.ToList() }); _logger.FinishMsg(retCountries.CountryList.Count(), "Countries"); return(retCountries); } catch (Exception e) { _logger.Log($"Exception: {e.Message}"); throw; } }
public async Task <SaveExOzRegionCommandResult> Synchronize(string obj) { string line = ""; _logger.StartMsg("Regions"); var postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(""); ExOzRegionList exOzRegionResponse = Mapper <ExOzRegionList> .MapFromJson(postResponse); var regionList = exOzRegionResponse.regions; //Get Region details and prepare list of Operators List <ExOzRegionResponse> regionDetailsList = new List <ExOzRegionResponse>(); OperatorList operatorList = new OperatorList() { operators = new List <ExOzOperatorResponse>() }; int i = 0; foreach (var region in exOzRegionResponse.regions) { try { string regionDetails = HttpWebRequestHelper.ExOz_WebRequestGet(region.UrlSegment); ExOzRegionResponse objRegion = Mapper <ExOzRegionResponse> .MapFromJson(regionDetails); foreach (var item in objRegion.Operators) { item.RegionId = objRegion.Id; item.RegionUrlSegment = objRegion.UrlSegment; operatorList.operators.Add(item); } regionDetailsList.Add(objRegion); } catch (Exception e) { _logger.Log($"Exceptions: {e.Message}"); } i++; line = _logger.Update(i, exOzRegionResponse.regions.Count, line); } //Code to insert Regions try { SaveExOzRegionCommandResult retRegions = await _commandSender.Send <SaveExOzRegionCommand, SaveExOzRegionCommandResult>(new SaveExOzRegionCommand { RegionList = regionDetailsList }); _logger.FinishMsg(retRegions.RegionList.Count, "Regions"); retRegions.OperatorList = operatorList; return(retRegions); } catch (Exception e) { _logger.Log($"Exception: {e.Message}"); throw; } }
public static T ExecuteWebRequest(string input) { string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); var objDetails = Mapper <T> .MapFromJson(postResponse); if (postResponse == "0") { // TODO: Error } return(objDetails); }
public async Task <SaveExOzStateCommandResult> Synchronize(string obj) { _logger.StartMsg("States"); var postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(""); Contracts.Models.Integrations.ExOz.StateResponseList exOzStateResponse = Mapper <Contracts.Models.Integrations.ExOz.StateResponseList> .MapFromJson(postResponse); var stateList = exOzStateResponse.states; //Code to insert States SaveExOzStateCommandResult retStates = await _commandSender.Send <SaveExOzStateCommand, SaveExOzStateCommandResult> (new SaveExOzStateCommand { StateList = stateList }); _logger.FinishMsg(retStates.StateList.Count(), "States"); //ExOzRegionList exOzRegionResponse = Mapper<ExOzRegionList>.MapFromJson(obj); //return exOzRegionResponse; return(retStates); }
public async Task <SessionList> Synchronize(ProductList productList) { string line = ""; int i = 0; foreach (var prod in productList.Products) { ProductList productDetails = new ProductList() { Products = new List <ExOzProductResponse>() }; string input = prod.CanonicalRegionUrlSegment + "/" + prod.OperatorUrlSegment + "/" + prod.UrlSegment; ExOzProductResponse objProduct = new ExOzProductResponse(); string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); if (postResponse != "0") { objProduct = Mapper <ExOzProductResponse> .MapFromJson(postResponse); } objProduct.Name = CommonFunctions.replaceSingleQuotes(objProduct.Name); objProduct.Summary = CommonFunctions.replaceSingleQuotes(objProduct.Summary); objProduct.OperatorPublicName = CommonFunctions.replaceSingleQuotes(objProduct.OperatorPublicName); objProduct.Title = CommonFunctions.replaceSingleQuotes(objProduct.Title); objProduct.Description = CommonFunctions.replaceSingleQuotes(objProduct.Description); objProduct.MoreInfo = CommonFunctions.replaceSingleQuotes(objProduct.MoreInfo); objProduct.Tips = CommonFunctions.replaceSingleQuotes(objProduct.Tips); productDetails.Products.Add(objProduct); SaveExOzProductCommandResult retProducts = new SaveExOzProductCommandResult() { ProductList = new List <Contracts.DataModels.ExOzProduct>() }; retProducts = await _commandSender.Send <SaveExOzProductCommand, SaveExOzProductCommandResult>(new SaveExOzProductCommand { ProductList = productDetails.Products, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44793") }); if (objProduct.ProductSessions != null) { SessionList sessionList = new SessionList() { ProductSessions = new List <ExOzSessionResponse>() }; foreach (var sess in objProduct.ProductSessions) { sess.ProductId = objProduct.Id; sessionList.ProductSessions.Add(sess); } _logger.StartMsg("Sessions"); ProductOptionList productOptionResponse = await _productSessionSynchronizer.Synchronize(sessionList); } i++; line = _logger.Update(i, productList.Products.Count, line); } //Insert Products Here //try //{ // _logger.FinishMsg(retProducts.ProductList.Count, "Products"); // return sessionList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }
public async Task <ProductList> Synchronize(OperatorList operatorList) { string line = ""; _logger.StartMsg("Operators"); int i = 0; foreach (var op in operatorList.operators) { try { string input = op.CanonicalRegionUrlSegment + "/" + op.UrlSegment; ExOzOperatorResponse opDetails = new ExOzOperatorResponse(); string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); if (postResponse != "0") { opDetails = Mapper <ExOzOperatorResponse> .MapFromJson(postResponse); } if (opDetails.Id != -1 && opDetails.Geolocations != null && opDetails.Geolocations[0].Address != null) { opDetails.RegionId = op.RegionId; opDetails.RegionUrlSegment = op.RegionUrlSegment; CommonFunctions.replaceSingleQuotes(opDetails.Name); CommonFunctions.replaceSingleQuotes(opDetails.PublicName); CommonFunctions.replaceSingleQuotes(opDetails.Summary); CommonFunctions.replaceSingleQuotes(opDetails.Tips); CommonFunctions.replaceSingleQuotes(opDetails.Description); CommonFunctions.replaceSingleQuotes(opDetails.Address); //operatorList.operators = new List<ExOzOperatorResponse>(); OperatorList operatorDetails = new OperatorList() { operators = new List <ExOzOperatorResponse>() }; operatorDetails.operators.Add(opDetails); SaveExOzOperatorCommandResult retOperators = new SaveExOzOperatorCommandResult() { OperatorList = new List <ExOzOperator>() }; retOperators = await _commandSender.Send <SaveExOzOperatorCommand, SaveExOzOperatorCommandResult>(new SaveExOzOperatorCommand { OperatorList = operatorDetails.operators, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44795") }); if (opDetails.Products != null) { ProductList productList = new ProductList { Products = new List <ExOzProductResponse>() }; foreach (var prod in opDetails.Products) { prod.CanonicalRegionUrlSegment = opDetails.CanonicalRegionUrlSegment; prod.OperatorUrlSegment = opDetails.UrlSegment; productList.Products.Add(prod); } _logger.StartMsg("Product"); SessionList sessionResponse = await _productSynchronizer.Synchronize(productList); } } i++; line = _logger.Update(i, operatorList.operators.Count, line); } catch (Exception e) { _logger.Log($"Exception: {e.Message}"); continue; } } ////Insert Operators here //try //{ // _logger.FinishMsg(retOperators.OperatorList.Count, "Operators"); // return productList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }