Exemplo n.º 1
0
        public static ScriptStatus CreateScript(
            UnitPriceStatus Status,
            FilteredPriceMap Prices,
            SenStayPropertyIndex Units,
            StreamlineSeasonGroup Seasons)
        {
            var script = new PriceScript()
            {
                UnitId = Status.Unit
            };
            var unitInfo = Units.GetBySenStayID(Status.Unit);

            if (unitInfo == null)
            {
                return(ScriptStatus.NOT_CREATED);
            }

            script.StreamlineEditId = unitInfo.StreamlineEditID;

            if (Status.IsNew)
            {
                script.Commands.Add(
                    new PriceScriptCommand()
                {
                    Type             = PriceScriptCommand.TYPE_SEASON_GROUP,
                    SeasonGroupID    = Seasons.ID,
                    StreamlineEditId = unitInfo.StreamlineEditID
                }
                    );
            }

            foreach (var p in Prices.Values)
            {
                script.Commands.Add(
                    new PriceScriptCommand()
                {
                    Type     = PriceScriptCommand.TYPE_PRICE,
                    Price    = p.Price,
                    SeasonId = p.SeasonId
                }
                    );
            }

            script.Generated = DateTime.UtcNow;
            if (script.Commands.Count > 0)
            {
                script.Save();
                return(ScriptStatus.CREATED);
            }
            return(ScriptStatus.NOT_UPDATED);
        }
Exemplo n.º 2
0
        public static List <PriceScript> LoadAllScripts()
        {
            var files = Temp.GetFileList("*" + FILE_EXT, Config.I.PriceScriptsDirectory);
            var list  = new List <PriceScript>();

            foreach (var f in files)
            {
                var script = PriceScript.Load(f.FullName);
                if (script != null)
                {
                    list.Add(script);
                }
            }
            return(list);
        }
Exemplo 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
            {
            }
        }