public ExportController(IUnitOfWork unitOfWork, IMapper mapper, IExportRepository repository, PriceAdvisorDbContext context) { this.context = context; this.unitOfWork = unitOfWork; this.mapper = mapper; this.repository = repository; }
public SampleDataController(IUnitOfWork unitOfWork, PriceAdvisorDbContext context) { this.context = context; this.unitOfWork = unitOfWork; skytech = new Skytech(unitOfWork, context); kilobaitas = new Kilobaitas(unitOfWork, context); fortakas = new Fortakas(unitOfWork, context); topocentras = new TopoCentras(unitOfWork, context); for (int i = 0; i < 1000; i++) { BackgroundJob.Delete(i.ToString()); } }
public Fortakas(IUnitOfWork unitOfWork, PriceAdvisorDbContext context) { this.unitOfWork = unitOfWork; this.context = context; }
public async Task GetDataFromEshop(IWebDriver driver, HtmlDocument page) { var optionsBuilder = new DbContextOptionsBuilder <PriceAdvisorDbContext>(); optionsBuilder.UseSqlServer("Server=localhost\\SQLEXPRESS;Database=PriceAdviser;Trusted_Connection=True;MultipleActiveResultSets=True;"); using (var db = new PriceAdvisorDbContext(optionsBuilder.Options)) { var FindEShop = db.Eshops.FirstOrDefault(shop => shop.Name == EshopName); int psl = 1; IWebElement ie; IWebElement next; IJavaScriptExecutor js = (IJavaScriptExecutor)driver; ie = driver.FindElement(By.XPath("//html")); string innerHtml = ie.GetAttribute("innerHTML"); page.LoadHtml(innerHtml); var codesNodes = page.DocumentNode.SelectNodes( "//td[@class='mainContent']//div[@class='itemNormal']//div[@class='itemCode']"); var pricesNodes = page.DocumentNode.SelectNodes( "//td[@class='mainContent']//div[@class='itemNormal']//div[@class='itemCode']//parent::div//div[@class='itemBoxPrice']//div[2]"); var datosNodes = page.DocumentNode.SelectNodes("//span[@class='DeliveryDate']"); if (datosNodes != null) { foreach (HtmlNode node in datosNodes) { node.Remove(); } } var codes = codesNodes.Select(node => node.InnerText.Replace("kodas", "").Replace(" ", "").Replace(": ", "").Replace("\n", "") .Replace("\t", "").Replace("\r", "")); var prices = pricesNodes.Select(node => node.InnerText.Replace(" ", "").Replace(" €", "").Replace("\n", "").Replace("\t", "") .Replace("\r", "").Replace(",", ".")); var line = ""; List <Data> sets = codes.Zip(prices, (code, price) => new Data() { Code = code, Price = price }).ToList(); foreach (var set in sets) { var FindProduct = await db.Products.FirstOrDefaultAsync(product => product.Code == set.Code); if (FindProduct == null) { } else { var FindPriceExists = await db.Prices.FirstOrDefaultAsync(price => price.ProductId == FindProduct.Id && price.EshopId == FindEShop.Id); if (FindPriceExists != null && FindPriceExists.EshopId == FindEShop.Id) { FindPriceExists.Value = set.Price; FindPriceExists.UpdatedAt = DateNow.AddTicks(-(DateNow.Ticks % TimeSpan.TicksPerSecond)); } else { var Price = new Price { Value = set.Price, UpdatedAt = DateNow.AddTicks(-(DateNow.Ticks % TimeSpan.TicksPerSecond)), EshopId = FindEShop.Id, ProductId = FindProduct.Id }; db.Prices.Add(Price); } line = String.Format("{0,-40} {1}", set.Code, set.Price); Console.WriteLine(line); } await db.SaveChangesAsync(); } if (driver.FindElements(By.XPath("(//input[contains(@onmouseover,'NextOverBottom')])[1]")).Count != 0) { next = driver.FindElement(By.XPath("(//input[contains(@onmouseover,'NextOverBottom')])[1]")); js.ExecuteScript("arguments[0].click();", next); ie = driver.FindElement(By.XPath("//html")); psl++; Console.WriteLine("=========================" + psl + "==========================="); } } }
public Kilobaitas(IUnitOfWork unitOfWork, PriceAdvisorDbContext context) { this.unitOfWork = unitOfWork; this.context = context; }
public TopoCentras(IUnitOfWork unitOfWork, PriceAdvisorDbContext context) { this.unitOfWork = unitOfWork; this.context = context; sw.Start(); }
public Skytech(IUnitOfWork unitOfWork, PriceAdvisorDbContext context) { this.unitOfWork = unitOfWork; this.context = context; }