private List <CountryLoad> GetListCountryLoad() { List <CountryLoad> listCountry = new List <CountryLoad>(); bool correct = false; int count = 2; while (correct != true) { try { GodLikeHTML.Load(GodLikeClient.OpenRead(linkFirstCountry.Substring(0, linkFirstCountry.Length - 1) + count.ToString()), Encoding); string rusNameCountry = GetTextDataNode(xPathRusName); if (rusNameCountry == "") { break; } string img = GetScrDataNode(xPathScrFlag); SaveFileToServer(img, folderFlag); ImageGPFlag imageGPFlag = new ImageGPFlag(); imageGPFlag.Link = folderFlag.Replace("wwwroot", "") + Path.GetFileName(img); repository.AddImageGPFlag(imageGPFlag); repository.SaveChanges(); listCountry.Add(new CountryLoad(rusNameCountry, imageGPFlag.Id)); } catch { correct = true; } count++; } return(listCountry); }
protected List <string> GetListLink() { List <string> listLink = new List <string>(); for (int i = 65; i <= 90; i++) //90 { bool correct = false; int counterStep = 1; string tmp = Convert.ToChar(i).ToString(); GodLikeHTML.Load(GodLikeClient.OpenRead(IndexLink + Convert.ToChar(i).ToString()), Encoding); while (correct != true) { try { string linkManufacture = GodLikeHTML.DocumentNode.SelectNodes(xPathLinkData1 + counterStep + xPathLinkData2).First().Attributes.First().DeEntitizeValue; listLink.Add(StartPagesSite + linkManufacture); counterStep++; } catch { correct = true; } } } return(listLink); }
private void SaveDataTrack(string link) { GodLikeHTML.Load(GodLikeClient.OpenRead(link), Encoding); Track track = new Track { NameRus = GodLikeHTML.DocumentNode.SelectNodes(xPathRusName)[2].InnerText, NameEn = GodLikeHTML.DocumentNode.SelectNodes(xPathEngName).First().InnerText, IdImageGp = 1 }; string countryName = GodLikeHTML.DocumentNode.SelectNodes(xPathCountry).First().InnerText; try { track.IdCountry = repository.Country.First(d => d.NameRus == countryName).Id; } catch { Country country = new Country { IdImageGpFlag = 1, NameEn = "", NameRus = countryName }; repository.AddCountry(country); repository.SaveChanges(); track.IdCountry = country.Id; } repository.AddTrack(track); repository.SaveChanges(); SaveDataTrackConfiguration(track.Id); }
public override void SaveData() { List <string> linksList = GetListLink(); foreach (var data in linksList) { GodLikeHTML.Load(GodLikeClient.OpenRead(data), Encoding); string mName = GetTextDataNode(xPathMName); Manufacturer manufacturer = CreateManufacturer(mName, firstIdImages); List <ChassiLoad> listChassis = GetChassiLoads(mName, manufacturer.Id); } }
public void GetTracks() { GodLikeHTML.Load(GodLikeClient.OpenRead(firstPage), Encoding); var collectionsLink = GodLikeHTML.DocumentNode.SelectNodes(xPathForCollectionsLink); List <string> coList = new List <string>(); foreach (var VARIABLE in collectionsLink) { coList.Add(StartPagesSite + VARIABLE.Attributes.First().Value); } foreach (var VARIABLE in coList) { SaveDataTrack(VARIABLE); } }
private int SaveFileToServer(string scrFile, string folderUpload) { try { GodLikeClient.DownloadFile(startPagesSite + scrFile, Path.Combine(folderUpload, Path.GetFileName(scrFile))); ImageGPTrackConfiguration imageGpConfiguration = new ImageGPTrackConfiguration(); imageGpConfiguration.Link = FolderTrackConf + scrFile.Replace("img/cir/small/", "").Replace("wwwroot", ""); repository.AddImageGPConfiguration(imageGpConfiguration); repository.SaveChanges(); return(imageGpConfiguration.Id); } catch { return(1); } }
public virtual void SaveData() { List <string> linksList = GetListLink(); foreach (var DATA in linksList) { GodLikeHTML.Load(GodLikeClient.OpenRead(DATA), Encoding); try { SaveFileToServer(GetScrDataNode(XPathMImage), folderImageManuf); } catch { } ImageGP imageGP = SaveImage(folderImageManuf + GetScrDataNode(XPathMImage).Replace("img/cha/small/", "").Replace("wwwroot", "")); string mName = GetTextDataNode(xPathMName); Manufacturer manufacturer = CreateManufacturer(mName, imageGP.Id); List <ChassiLoad> listChassis = GetChassiLoads(mName, manufacturer.Id); } }
public override void SaveData() { List <string> linksList = GetListLink(); foreach (var DATA in linksList) { GodLikeHTML.Load(GodLikeClient.OpenRead(DATA), Encoding); Racer racer = new Racer(); try { SaveFileToServer(GetScrDataNode(XPathMImage), FolderImageLivery); ImageGPRacers imageGP = SaveImageRacers(FolderImageLivery + GetScrDataNode(XPathMImage).Replace("img/drv/", "").Replace("wwwroot", "")); racer.IndexPhoto = imageGP.Id; } catch { racer.IndexPhoto = 1; } string name = GodLikeHTML.DocumentNode.SelectNodes(nameNode).First().InnerText; racer.FirstName = GetFirstName(name); racer.SecondName = GetSecondName(name); string country = GodLikeHTML.DocumentNode.SelectNodes(countryNode).First().InnerText; try { racer.IdCountry = repository.Country.First(d => d.NameRus == country).Id; } catch { Country countryDb = new Country(); countryDb.NameRus = country; countryDb.IdImageGpFlag = 1; countryDb.NameEn = ""; repository.AddCountry(countryDb); repository.SaveChanges(); racer.IdCountry = countryDb.Id; } try { racer.Born = Convert.ToDateTime(GodLikeHTML.DocumentNode.SelectNodes(born).First().InnerText); } catch { racer.Born = new DateTime(); } try { racer.Dead = Convert.ToDateTime(GodLikeHTML.DocumentNode.SelectNodes(dead).First().InnerText); } catch { racer.Dead = new DateTime(); } try { racer.BornIn = GodLikeHTML.DocumentNode.SelectNodes(bornIn).First().InnerText; } catch { racer.BornIn = ""; } try { racer.DeadIn = GodLikeHTML.DocumentNode.SelectNodes(deadIn).First().InnerText; } catch { racer.DeadIn = ""; } racer.TextData = ""; try { var collectionTextData = GodLikeHTML.DocumentNode.SelectNodes("//p[@class='" + XPathLive + "']"); foreach (var VARIABLE in collectionTextData) { racer.TextData += VARIABLE.NextSibling.InnerText; } } catch { } repository.AddRacer(racer); repository.SaveChanges(); } }