Beispiel #1
0
        static void Main(string[] args)
        {
            Config.I.UseProxy = true;

            AirBnbAccounts.Load();

            var map = AirBnbRoomMap.Load();

            foreach (var airAccount in AirBnbAccounts.Accounts)
            {
                if (map.GetAccount(airAccount.Email) != null)
                {
                    N.Note(airAccount.Email + " skiped");
                    continue;
                }

                for (var proxyNum = 0; proxyNum < 1; proxyNum++)
                {
                    var email = airAccount.Email;
                    N.Note("Processing account " + email + " with proxy " + airAccount.ProxyAddress[proxyNum]);
                    var profile = SeleniumProxy.GetFirefoxProfileWithProxy(airAccount.ProxyAddress, proxyNum);
                    var driver  = SeleniumFactory.GetFirefoxDriver(profile);
                    try
                    {
                        var signInSucceed = AirBnbLogin.Process(driver, airAccount);
                        if (signInSucceed.Status == AirBnbLoginStatus.Failed)
                        {
                            N.Note("Password for " + email + " is wrong or account unreachable");
                            try
                            {
                                driver.Quit();
                            }
                            catch
                            {
                            }
                            break;
                        }
                        var item = AirBnbScrapeRooms.GetRoomList(driver, airAccount);
                        map.List.Add(item);

                        driver.Quit();
                    }
                    catch (Exception e)
                    {
                        N.Note("Error " + airAccount.Email + " : " + e + "".Substring(0, 100) + "...");
                        driver.Quit();
                    }
                }
            }
            map.Save();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Pricing sync for AirBnb");
            Config.I.UseProxy = true;

            AirBnbAccounts.Load();
            var roomsMap             = AirBnbRoomMap.Load();
            var streamlineCollection = StreamlinePropertyCollection.Load();

            PropertyMap.SetMap(roomsMap, streamlineCollection);

            var property = PropertyMap.GetBySenstayID("LA029");
            var proxyNum = 0;

            var airAccount = AirBnbAccounts.GetAccountByEmail(property.AirbnbAccountEmail);

            var email = airAccount.Email;

            N.Note("Processing account " + email + " with proxy " + airAccount.ProxyAddress[proxyNum]);
            var profile = SeleniumProxy.GetFirefoxProfileWithProxy(airAccount.ProxyAddress, proxyNum);

            using (var driver = SeleniumFactory.GetFirefoxDriver(profile))
            {
                var signInSucceed = AirBnbLogin.Process(driver, airAccount);
                if (signInSucceed.Status != AirBnbLoginStatus.Sucess)
                {
                    N.Note("Password for " + email + " is wrong or account unreachable");
                    try
                    {
                        driver.Quit();
                    }
                    catch
                    {
                        // ignored
                    }
                }
                AirBnbCalendar.SetPricesForUnit(driver, property, AirbnbUnitDailyPriceList.Load());
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //Config.I.UseProxy = false;
            Config.I.UseProxy = true;

            DataInit.Init();

            //debug();
            //return;

            //var Account = Data.AirBnbAccounts.GetAccountByEmail("*****@*****.**");
            var account = AirBnbAccounts.GetAccountByEmail("*****@*****.**");
            var profile = SeleniumProxy.GetFirefoxProfileWithProxy(account.ProxyAddress);
            var driver  = SeleniumFactory.GetFirefoxDriver(profile);

            AirBnbLogin.Process(driver, account);

            var items = AirBnbScrapeReservation.GetAllReservationItems(driver);

            AirBnbScrapeReservation.GetFullReservationInfo(items[0], driver, account);

            driver.Quit();
        }
        internal void DownloadTransactions()
        {
            _logger.Info("preparing locks");
            var account = _airAccount;
            var email   = account.Email;
            var date    = DateTime.Now;

            var lockHash        = date.ToString("yyyy\\MMMM-d") + @"\" + email;
            var lockHashSuccess = lockHash + "-sucess";

            if (Temp.IsLocked(lockHashSuccess))
            {
                _logger.Info(string.Format("{0} is processed already", email));
                N.Note(email + " skiped");
                return;
            }

            foreach (var proxy in account.ProxyAddress)
            {
                var lockHashLoginError = string.Format("{0}-{1}-loginerror", lockHash, proxy.Replace(":", "-"));

                _logger.Info(string.Format("Processing account {0} with proxy {1}", email, proxy));
                N.Note("Processing account " + email + " with proxy " + proxy);

                if (Temp.IsLocked(lockHashLoginError))
                {
                    _logger.Info(string.Format("{0} with proxy {1} is locked because of incorrect password", email, proxy));
                    N.Note(email + " (wrong password record)");
                    continue;
                }

                var profile = SeleniumProxy.GetFirefoxProfileWithProxy(proxy);
                _logger.Info("Prepare profile for downloading");
                AirBnbTransactionHistory.PrepareProfileForDownloading(profile);

                try
                {
                    _logger.Info("Creating driver");
                    using (var driver = SeleniumFactory.GetFirefoxDriver(profile))
                    {
                        _logger.Info("Signing in");
                        var signInSucceed = AirBnbLogin.Process(driver, account);

                        _logger.Info(string.Format("Sign in result: {0}", signInSucceed));
                        _loginAttemptsProcessor.Log(new LoginAttempt(email, signInSucceed.Status, signInSucceed.Message, proxy));

                        switch (signInSucceed.Status)
                        {
                        case AirBnbLoginStatus.Failed:
                        case AirBnbLoginStatus.Unable:
                        case AirBnbLoginStatus.VerifyUser:
                        case AirBnbLoginStatus.VerifyBrowser:
                            N.Note("Password for " + email + " is wrong or account unreachable");
                            Temp.Lock(lockHashLoginError);
                            continue;

                        case AirBnbLoginStatus.Sucess:
                            break;

                        case AirBnbLoginStatus.ProxyError:
                            break;

                        case AirBnbLoginStatus.PageError:
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }

                        _logger.Info("Prepare profile for downloading");
                        var completedLoadResult = LoadCompletedCsv(driver, date, email);

                        _logger.Info("Prepare profile for downloading");
                        var pendingLoadResult = LoadPendingCsv(driver, date, email);

                        if (!completedLoadResult || !pendingLoadResult)
                        {
                            continue;
                        }

                        Temp.Lock(lockHashSuccess);
                        _logger.InfoFormat("Account {0} is locked", account.Email);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Error while processing {0} with proxy {1}", account.Email, proxy), ex);
                    N.Note(email + " exception " + (ex + "").Substring(0, 70) + "...");
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Push price to airbnb.
        /// </summary>
        /// <param name="processStartTime">Process start time.</param>
        /// <param name="pricePushLogger">Price push logger.</param>
        /// <param name="airBnbProperties">List of airbnb properties.</param>
        public static void PushPriceToAirBnb(DateTime processStartTime, OperationsJsonLogger <PricePushResult> pricePushLogger, List <Property> airBnbProperties)
        {
            List <PricePushResult> pricePushLogResults = new List <PricePushResult>();

            try
            {
                if (airBnbProperties != null)
                {
                    // Group the properties by their login email id.
                    var propertiesGroupedByEmail = airBnbProperties.GroupBy(x => x.LoginAccount.Email);

                    if (propertiesGroupedByEmail != null)
                    {
                        foreach (var propertyGroup in propertiesGroupedByEmail)
                        {
                            // Get the property list that needs to be updated.
                            List <Property> properties = propertyGroup.ToList();

                            // Setup the login acccount which should be used to login to the account.
                            var           loginAccount = properties[0].LoginAccount;
                            AirBnbAccount account      = new AirBnbAccount
                            {
                                Email        = loginAccount.Email,
                                Password     = loginAccount.Password,
                                ProxyAddress = loginAccount.ProxyAddress,
                                Active       = loginAccount.Active,
                                Test         = loginAccount.Test
                            };

                            // Set the firefox profile.
                            //var firefoxProfile = SeleniumProxy.GetFirefoxProfileWithProxy(account.ProxyAddress[0]);
                            var chromeOptions = SeleniumProxy.GetChromeOptionsWithProxy(account.ProxyAddress[0]);
                            try
                            {
                                using (RemoteWebDriver driver = SeleniumFactory.GetChromeDriver(chromeOptions))
                                //using (RemoteWebDriver driver = SeleniumFactory.GetFirefoxDriver(firefoxProfile))
                                {
                                    N.Note("Trying to login with the user :"******"Login succeeded");

                                        foreach (Property property in properties)
                                        {
                                            var validPropertyPrices = property.Prices.Where(x => (x.SeasonEndDate.Date > DateTime.UtcNow.Date));
                                            if (AirBnbCalendar.NavigateToCalendar(driver, property.AirbnbId))
                                            {
                                                ///AirBnbCalendar.ZoomOut(driver);
                                                if (validPropertyPrices.Count() > 0)
                                                {
                                                    string currentMonthYear = string.Empty;
                                                    bool   navigateToMonth  = true;
                                                    foreach (Price propPrice in validPropertyPrices)
                                                    {
                                                        int noOfDays = propPrice.NoOfDaysToBeUpdated();

                                                        if (string.Compare(currentMonthYear, propPrice.SeasonStartDate.Month.ToString() + propPrice.SeasonStartDate.Year.ToString(), true) != 0)
                                                        {
                                                            navigateToMonth = AirBnbCalendar.NavigateToMonth(driver, propPrice.SeasonStartDate.Month, propPrice.SeasonStartDate.Year);

                                                            if (navigateToMonth)
                                                            {
                                                                currentMonthYear = propPrice.SeasonStartDate.Month.ToString() + propPrice.SeasonStartDate.Year.ToString();
                                                            }

                                                            Thread.Sleep(TimeSpan.FromSeconds(2));
                                                        }

                                                        if (navigateToMonth)
                                                        {
                                                            for (int i = 1; i <= noOfDays; i++)
                                                            {
                                                                DateTime startDate = propPrice.SeasonStartDate.AddDays(i);
                                                                if (string.Compare(currentMonthYear, startDate.Month.ToString() + startDate.Year.ToString(), true) != 0)
                                                                {
                                                                    AirBnbCalendar.NavigateToMonth(driver, startDate.Month, startDate.Year);
                                                                    Thread.Sleep(TimeSpan.FromSeconds(2));
                                                                }

                                                                Thread.Sleep(TimeSpan.FromMilliseconds(700));
                                                                N.Note("Updating price for the day :" + propPrice.SeasonStartDate.AddDays(i).ToString("yyyy-MM-dd"));

                                                                try
                                                                {
                                                                    AirBnbCalendar.UpdateUnitPrice(
                                                                        driver,
                                                                        propPrice.SeasonStartDate.AddDays(i),
                                                                        propPrice.PropertyPrice);
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    PricingPushLogType logType = PricingPushLogType.Error;
                                                                    if (ex.GetType() == typeof(PriceUpdateInformation))
                                                                    {
                                                                        logType = PricingPushLogType.Information;
                                                                    }

                                                                    LogPriceUpdationError(pricePushLogResults, PricePushLogArea.PriceUpdate, logType, property, propPrice.SeasonStartDate.AddDays(i), propPrice.PropertyPrice, ex.Message);
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            for (int startDay = 1; startDay <= noOfDays; startDay++)
                                                            {
                                                                LogPriceUpdationError(pricePushLogResults, PricePushLogArea.PriceUpdate, PricingPushLogType.Error, property, propPrice.SeasonStartDate.AddDays(startDay), propPrice.PropertyPrice, "Navigating to the month " + propPrice.SeasonStartDate.ToString("MMMM") + " in the calendar failed for the property " + property.AirbnbTitle);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                LogError(pricePushLogResults, PricePushLogArea.Property, PricingPushLogType.Error, property, "Listing Id :" + property.AirbnbId + " for the property " + property.AirbnbTitle + " is wrong");
                                            }

                                            RetryFailedPriceUpdates(driver, pricePushLogResults, property.AirbnbId);
                                        }
                                    }
                                    else
                                    {
                                        LogError(pricePushLogResults, PricePushLogArea.Login, PricingPushLogType.Error, signInSucceed.Message.Replace(System.Environment.NewLine, string.Empty));

                                        try
                                        {
                                            driver.Quit();
                                        }
                                        catch (Exception ex)
                                        {
                                            N.Note("Exception while closing the driver : " + ex.Message);
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                LogError(pricePushLogResults, PricePushLogArea.Property, PricingPushLogType.Error, "Pricing push to AirBnb failed", ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(pricePushLogResults, PricePushLogArea.Property, PricingPushLogType.Error, "Pricing push to AirBnb failed", ex.Message);
            }
            finally
            {
                pricePushLogger.Log(pricePushLogResults);
            }
        }