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 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); }
public async Task <ProductOptionList> Synchronize(SessionList sessionList) { string line = ""; int i = 0; foreach (var sess in sessionList.ProductSessions) { SessionList sessionDetails = new SessionList() { ProductSessions = new List <ExOzSessionResponse>() }; sessionDetails.ProductSessions.Add(sess); SaveExOzSessionCommandResult retSessions = new SaveExOzSessionCommandResult() { SessionList = new List <ExOzProductSession>() }; retSessions = await _commandSender.Send <SaveExOzSessionCommand, SaveExOzSessionCommandResult>(new SaveExOzSessionCommand { SessionList = sessionDetails.ProductSessions, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44793") }); if (sess.ProductOptions != null) { ProductOptionList optionList = new ProductOptionList() { ProductOptions = new List <ExOzProductOptionResponse>() }; foreach (var opt in sess.ProductOptions) { opt.SessionId = sess.Id; opt.SessionName = sess.SessionName; optionList.ProductOptions.Add(opt); } _logger.StartMsg("Options"); await _productOptionSynchronizer.Synchronize(optionList); } i++; line = _logger.Update(i, sessionList.ProductSessions.Count, line); } //Insert Sessions Here //try //{ // _logger.FinishMsg(retSessions.SessionList.Count, "Sessions"); // return optionList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }