void InteractProducts(ref HttpRequest request, Account account) { string linkref = _listLinkRef[_random.Next(0, (_listLinkRef.Count - 1))]; bool random = false; lock (_randomAccountObj) { //Debug.WriteLine(_randomAccount, "Số account"); if (_randomAccount == 0) { random = true; _randomAccount = _random.Next(_randomAccountMin + 1, _randomAccountMax + 1); } } foreach (var item in _listLinkProducts) { request.Referer = linkref; Thread.Sleep(_random.Next(_timeSleepMin, _timeSleepMax + 1) * 1000); string linkProduct = item; if (linkProduct.Contains("?")) { linkProduct = linkProduct.Split('?')[0]; } var product = new Product(linkProduct); var interact = new InteractProduct(product); interact.ViewProduct(ref request, linkProduct); interact.AddToWishList(ref request); } if (random) { //Debug.WriteLine(account.Email, "Add to cart"); foreach (var item in _listLinkProducts) { request.Referer = linkref; Thread.Sleep(_random.Next(_timeSleepMin, _timeSleepMax + 1) * 1000); var config = new ConfigXNet(); string linkProduct = item; if (linkProduct.Contains("?")) { linkProduct = linkProduct.Split('?')[0]; } var product = new Product(linkProduct); var interact = new InteractProduct(product); config.AddHeaderXCSRFToken(ref request); interact.AddToCart(ref request); } } }
void RunJOB(Account account, string port, string userAgent) { HttpRequest request = new HttpRequest(); var configXNet = new ConfigXNet(); configXNet.AddUserAgent(ref request, userAgent); var login = new LoginAccount(); if (login.IsSuccessful(ref request, account)) { foreach (var item in _listLinkProducts) { string linkProduct = item; if (linkProduct.Contains("?")) { linkProduct = linkProduct.Split('?')[0]; } var product = new Product(linkProduct); var interact = new InteractProduct(product); interact.ViewProduct(ref request, linkProduct); interact.AddToWishList(ref request); } } }