Ejemplo n.º 1
0
        public static bool ProcessLogin(IWebDriver driver, StreamlineAccount account, bool isTest = false)
        {
            bool isSuccessfulLogin = true;

            try
            {
                var url = isTest ? Mock.GetMock("StreamlineLogin1") : @Config.I.StreamLineLoginPageURL;
                driver.GoTo(url);

                var loginInput = driver.FindElement(By.Name("user_login"));

                var passwordInput = driver.FindElement(By.Name("user_password"));
                var submit        = driver.FindElement(By.Name("submit_button"));
                driver.JustWait(3);

                loginInput.SendKeys(account.Login);
                passwordInput.SendKeys(account.Password);
                driver.JustWait(3);
                submit.Click();
                driver.JustWait(5);
            }
            catch
            {
                isSuccessfulLogin = false;
            }
            return(isSuccessfulLogin);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("SenStay Streamline Scraper");

            Config.I.UseProxy           = true;
            Config.I.RegularWaitSeconds = 30;

            Temp.TouchDirectory(Config.I.ImagesFolder);
            var account = new StreamlineAccount
            {
                Login    = "******",
                Password = "******"
            };

            using (var driver = SeleniumFactory.GetFirefoxDriver())
            {
                try
                {
                    StreamlineLogin.Process(driver, account);
                    /////////////KILLL IT
                    StreamlineSeasonProcesser.ScrapeSeasons(driver, "21713");
                    return;

                    /////////////KILLL IT

                    if (args.Length > 0)
                    {
                        if (args[0] == "seasons")
                        {
                            //StreamlineSeasonProcesser.ScrapeSeasons(driver, "20250");
                            //StreamlineSeasonProcesser.ScrapeSeasons(driver, "20826");
                            StreamlineSeasonProcesser.ScrapeSeasons(driver, "21713");
                        }

                        if (args[0] == "additional")
                        {
                            StreamlineScrapeUnits.Process(driver, true);
                        }
                    }
                    else
                    {
                        StreamlineScrapeUnits.Process(driver, false);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex + "");
                }
            }
        }
Ejemplo n.º 3
0
        public static void RunCommands()
        {
            try
            {
                //Price
                var Account = new StreamlineAccount
                {
                    Login    = "******",
                    Password = "******"
                };

                var scripts = PriceScript.LoadAllScripts();
                foreach (var script in scripts)
                {
                    IWebDriver driver = null;
                    try
                    {
                        driver = SeleniumFactory.GetFirefoxDriver();
                        driver.JustWait(1);
                        N.Note("Run PriceScript for " + script.UnitId + " generated at " + script.Generated);
                        StreamlineLogin.Process(driver, Account, false);
                        driver.Manage().Window.Maximize();
                        StreamlineDailyPrice.RunPriceScript(driver, script);
                        driver.JustWait(1);
                        driver.Quit();
                        script.Archive();
                    }
                    catch (Exception e)
                    {
                        N.Note(e + "");
                    }
                    finally
                    {
                        if (driver != null)
                        {
                            driver.Quit();
                        }
                    }
                }
            }
            catch
            {
            }
        }
        public static void PushPriceToStreamLine(DateTime processStartTime, OperationsJsonLogger <PricePushResult> pricePushLogger, List <Property> streamLineProperties)
        {
            try
            {
                using (RemoteWebDriver driver = SeleniumFactory.GetFirefoxDriver(null))
                {
                    // Login to the streamline system.
                    StreamlineAccount streamLineAccount = new StreamlineAccount();
                    streamLineAccount.Login    = Config.I.StreamLineAccountLogin;
                    streamLineAccount.Password = Config.I.StreamLineAccountPassword;

                    N.Note("Trying to login with the user :"******"Login succeeded");

                        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
                        wait.Until(ExpectedConditions.ElementExists(By.Id("menu")));

                        N.Note("Check whether news dialog has popped up");
                        // Close the dialog which pop's up as soon as you login.
                        StreamlineLogin.CheckNewsDialogPopup(driver);

                        N.Note("Create season group");

                        List <Season> streamLineSeasons = new List <Season>();
                        string        groupId           = StreamlineSeasonProcesser.CreateSeasonGroup(driver, processStartTime);

                        if (!string.IsNullOrEmpty(groupId) && groupId != "0")
                        {
                            N.Note("Created Group :" + StreamlineSeasonProcesser.GetSeasonGroupName(processStartTime));
                            // Filter the rates based on the valid dates

                            N.Note("Filtering the valid property prices");

                            var validPropertyPrices = streamLineProperties[0].Prices.Where(x => x.SeasonEndDate > DateTime.UtcNow).ToList();

                            N.Note("Create Seasons for the season group");

                            foreach (Price season in validPropertyPrices)
                            {
                                Thread.Sleep(TimeSpan.FromSeconds(1));
                                var seasonId = StreamlineSeasonProcesser.CreateSeason(driver, groupId, season.SeasonStartDate, season.SeasonEndDate, season.MinimumLos);
                                if (!string.IsNullOrEmpty(seasonId) && seasonId != "0")
                                {
                                    N.Note("Created Season : " + StreamlineSeasonProcesser.GetSeasonName(season.SeasonStartDate, season.SeasonEndDate));
                                    streamLineSeasons.Add(new Season {
                                        SeasonStartDate = season.SeasonStartDate,
                                        SeasonEndDate   = season.SeasonEndDate,
                                        SeasonId        = seasonId
                                    });
                                    //season.SeasonId = seasonId;
                                }
                                else
                                {
                                    pricePushLogger.Log(new PricePushResult(Channel.StreamLine, PricePushLogArea.Season, PricingPushLogType.Error, "Season was not created for the dates starting with " + season.SeasonStartDate.ToShortDateString() + " and ending with " + season.SeasonEndDate.ToShortDateString() + " for the season group" + StreamlineSeasonProcesser.GetSeasonGroupName(processStartTime)));
                                }
                            }
                        }
                        else
                        {
                            pricePushLogger.Log(new PricePushResult(
                                                    Channel.StreamLine,
                                                    PricePushLogArea.SeasonGroup,
                                                    PricingPushLogType.Error,
                                                    "Season group was not created : " + StreamlineSeasonProcesser.GetSeasonGroupName(processStartTime)));
                        }

                        foreach (Property streamLineProperty in streamLineProperties)
                        {
                            N.Note("Check whether property exists : " + streamLineProperty.StreamLineHomeName);
                            // Check whether the property exists in streamline or not.
                            if (StreamlineDailyPrice.CheckWhetherPropertyExists(driver, streamLineProperty.StreamLineHomeId))
                            {
                                N.Note("Changing the default season group for the property to the new one");
                                if (StreamlineSeasonProcesser.ChangeSeasonGroup(driver, streamLineProperty.StreamLineHomeId, streamLineProperty.StreamLineHomeName, groupId))
                                {
                                    N.Note("Default season group changed successfully");

                                    // Map the season id's to the corresponding season in the property

                                    foreach (Season season in streamLineSeasons)
                                    {
                                        var mappedPropertySeason = streamLineProperty.Prices.FirstOrDefault(p => p.SeasonStartDate == season.SeasonStartDate && p.SeasonEndDate == season.SeasonEndDate);
                                        if (mappedPropertySeason != null)
                                        {
                                            mappedPropertySeason.SeasonId = season.SeasonId;
                                        }
                                    }

                                    N.Note("Update season price for the unit");
                                    StreamlineDailyPrice.SetPricesForUnit(driver, Convert.ToInt32(streamLineProperty.StreamLineHomeId), streamLineProperty.Prices, pricePushLogger);
                                }
                                else
                                {
                                    N.Note("Changing the default season group failed");
                                    pricePushLogger.Log(new PricePushResult(
                                                            Channel.StreamLine,
                                                            PricePushLogArea.Property,
                                                            PricingPushLogType.Error,
                                                            "The process was not able to update the default Season group of the property : " + streamLineProperty.StreamLineHomeName,
                                                            Config.I.StreamLineAccountLogin,
                                                            streamLineProperty.StreamLineHomeId,
                                                            string.Empty,
                                                            streamLineProperty.StreamLineHomeName,
                                                            streamLineProperty.PropertyCode,
                                                            string.Empty,
                                                            string.Empty,
                                                            string.Empty));
                                }
                            }
                            else
                            {
                                pricePushLogger.Log(new PricePushResult(
                                                        Channel.StreamLine,
                                                        PricePushLogArea.Property,
                                                        PricingPushLogType.Error,
                                                        "The property was not found in Streamline : " + streamLineProperty.StreamLineHomeName,
                                                        streamLineAccount.Login,
                                                        streamLineProperty.StreamLineHomeId,
                                                        string.Empty,
                                                        streamLineProperty.StreamLineHomeName,
                                                        streamLineProperty.PropertyCode,
                                                        string.Empty,
                                                        string.Empty,
                                                        string.Empty));
                            }
                        }
                    }
                    else
                    {
                        pricePushLogger.Log(new PricePushResult(
                                                Channel.StreamLine,
                                                PricePushLogArea.Login,
                                                PricingPushLogType.Error,
                                                "Login failed for the user : "******"Pricing push to Streamline failed", ex.Message));
            }
        }
Ejemplo n.º 5
0
        public static void Process(IWebDriver driver, StreamlineAccount Account, ReservationInfo Reservation, bool IsTest = false)
        {
            string URL = "";

            if (IsTest)
            {
                URL = Mock.GetMock("StreamlineQuickBook1");
            }
            else
            {
                URL = @"https://www.resortpro.net/new/admin/index.html";
            }
            driver.GoTo(URL);

            var wait = driver.CreateWaitDriver();


            // All Quick links panel
            var divQuickLinks = driver.FindElement(By.Id("quick_links"));

            // Quick Book button
            var quickBookLink = divQuickLinks.FindAByHrefStartsWith("javascript:YAHOO.frontdesk.UpdateContent('ds_reservation_new.html',");

            quickBookLink.Click();
            driver.JustWait(2);


            // set type to AirBnb
            var typeOfReservationElement = new SelectElement(driver.FindElement(By.Id("type_id")));

            // 80 is AirBnb's magic number
            typeOfReservationElement.SelectByValue("80");
            driver.JustWait(1);


            var checkInDateFormated  = Reservation.CheckIn.ToString("MM/dd/yyyy");
            var checkOutDateFormated = Reservation.CheckOut.ToString("MM/dd/yyyy");

            driver.ExecuteJS("document.getElementById('startdate').value = \"" + checkInDateFormated + "\";");
            driver.ExecuteJS("document.getElementById('enddate').value = \"" + checkOutDateFormated + "\";");



            var fieldsetElement = driver.FindElement(By.Id("unitnames"));
            var legendElement   = fieldsetElement.FindElement(By.TagName("legend"));

            legendElement.Click();
            driver.JustWait(1);

            // Use filter to find unit by RoomTitle
            var filterUnitNameElement = driver.FindElement(By.Id("unit_name"));

            //filterUnitNameElement.SendKeys(Reservation.RoomTitle);

            Indexes.LoadSenStay();
            var SenStayID = Indexes.SenStay.GetSenStayIDByAirBnbName(Reservation.RoomTitle);

            filterUnitNameElement.SendKeys(SenStayID);


            //driver.FindElements(By.CssSelector(".yui-dt-rec"));

            driver.JustWait(3);
            var tbody   = driver.FindElement(By.CssSelector("tbody.yui-dt-data"));
            var firstTr = tbody.FindElement(By.TagName("tr"));

            firstTr.Click();
            driver.JustWait(3);


            var changeRatesButton = driver.FindElement(By.CssSelector("[name=\"change_rates_button\"]"));

            changeRatesButton.Click();

            driver.JustWait(1);
            var authDialog    = driver.FindElement(By.CssSelector("#AuthenticateDialog"));
            var passwordField = authDialog.FindElement(By.CssSelector("[name=\"password\"]"));

            driver.JustWait(1);
            passwordField.SendKeys(Account.Password);
            passwordField.Submit();
            driver.JustWait(1);



            //#AuthenticateDialog
            //name="password"

            //name="change_rates_button"

            //yui-dt-data
            //yui-dt-rec

            //unit_name

            //

            //Console.Write(quickBookLink.GetAttribute("href"));
            //Console.Read();
            //javascript:YAHOO.frontdesk.UpdateContent('ds_reservation_new.html', '');
        }