示例#1
0
 public MainWindow(IControllerFactory controllerFactory,
                   ITwitterAuthenticator twitterAuthenticator, IGlobalVariables globalVariables, SettingsViewModel settingsViewModel)
 {
     _controllerFactory = controllerFactory;
     InitializeComponent();
     DataContext = new MainViewModel(controllerFactory, twitterAuthenticator, globalVariables, settingsViewModel);
 }
示例#2
0
        // take a config and convert to runtime
        public ScriptRuntime(IScriptConfig scriptConfig, IGlobalVariables variables)
        {
            // copy basic infos
            ScriptID       = scriptConfig.ScriptID;
            ScreenshotPath = scriptConfig.ScreenshotPath;
            StartingUrl    = scriptConfig.StartingUrl;
            ScriptName     = scriptConfig.ScriptName;

            Steps     = new List <StepRuntime>();
            Variables = variables;
            foreach (var variable in scriptConfig.Variables)
            {
                Variables.Set(variable.Name, variable.Value);
            }

            // convert each step from config to runtime
            foreach (var step in scriptConfig.Steps)
            {
                var newStep = new StepRuntime();

                if (step.EmbeddedScript != null)
                {
                    newStep.EmbeddedScript = new ScriptRuntime(step.EmbeddedScript, Variables);
                }

                configureActions(step, newStep);
                configureExpectations(step, newStep);
                configureGetters(step, newStep);

                configureLoggers(step, newStep);

                Steps.Add(newStep);
            }
        }
示例#3
0
 public SettingsViewModel(ISettingsController settingsController, IGlobalVariables globalVariables, ITweetObserver observer)
 {
     GlobalVariables    = globalVariables;
     _observer          = observer;
     Settings           = settingsController.Settings;
     SettingsController = settingsController;
     LogoutCommand      = new ActionCommand(async() => await Logout());
 }
示例#4
0
        public TweetObserver(ISettingsController settingsController, ITweetProcessor tweetProcessor, IGlobalVariables globalVariables)
        {
            Stream = Tweetinvi.Stream.CreateFilteredStream();
            _settingsController = settingsController;
            _tweetProcessor     = tweetProcessor;
            _globalVariables    = globalVariables;

            Stream.MatchingTweetReceived     += (sender, args) => StreamOnMatchingTweetReceived(args, _addTweet);
            Stream.NonMatchingTweetReceived  += (sender, args) => StreamOnNonMatchingTweetReceived(args, _addTweet);
            Stream.StreamStopped             += StreamOnStreamStopped;
            Stream.DisconnectMessageReceived += StreamOnDisconnectMessageReceived;
        }
示例#5
0
        public ScriptRunner(IWebDriver webDriver, ScriptRuntime script, IGlobalVariables variables)
        {
            // save to module variables
            WebDriver = webDriver;
            Script    = script;
            Variables = variables;

            // setup results
            Results            = new ScriptRunResults();
            Results.Started    = DateTime.Now;
            Results.ScriptName = script.ScriptName;
        }
        /// <summary>
        /// Replace placeholders with variables
        /// </summary>
        /// <param name="variables">Name/Value dictionary</param>
        public void InjectVariables(IGlobalVariables variables)
        {
            Dictionary <IPath, string> tempValues = new Dictionary <IPath, string>();

            foreach (var value in Values)
            {
                Logger.Log($"Before injection: {value.Key} => {value.Value}", MessageTypes.ScriptAction | MessageTypes.Internal);
                tempValues.Add(value.Key, ValueReplacer.InjectVariables(variables, value.Value));
                Logger.Log($"After injection: {value.Key} => {value.Value}", MessageTypes.ScriptAction | MessageTypes.Internal);
            }
            Values.Clear();
            Values = tempValues;
        }
示例#7
0
        public ScriptRunner(IWebDriver webDriver, IScriptConfig script, IGlobalVariables variables, ILogger logger)
        {
            // save to module variables
            WebDriver = webDriver;
            Script    = new ScriptRuntime(script, variables)
            {
                Logger = logger
            };

            Variables = variables;

            // setup results
            Results            = new ScriptRunResults();
            Results.Started    = DateTime.Now;
            Results.ScriptName = script.ScriptName;

            // message types to log
            setDefaultLoggerMessageTypes(Script.Logger);

            // start logging
            Script.Logger.Log($"Log initialized: {DateTime.Now}", MessageTypes.General);
            Script.Logger.Log($"Starting script named: {Script.ScriptName} ({Script.ScriptID})", MessageTypes.General);
        }
示例#8
0
        public static string InjectVariables(IGlobalVariables GlobalVariables, string Value)
        {
            var matches = Regex.Matches(Value, matcher);

            if (matches.Count > 0)
            {
                foreach (Match match in matches)
                {
                    if (GlobalVariables.ContainsKey(match.Value))
                    {
                        Value = Regex.Replace(Value, matcher, GlobalVariables.Get(match.Value));
                    }
                    else
                    {
                        Value = ReplaceValue(Value, match.Value);
                    }
                }
                return(Value);
            }
            else
            {
                return(Value);
            }
        }
示例#9
0
        public MainViewModel(IControllerFactory controllerFactory,
                             ITwitterAuthenticator twitterAuthenticator, IGlobalVariables globalVariables, SettingsViewModel settingsViewModel)
        {
            GlobalVariables  = globalVariables;
            _raidsController = controllerFactory.GetRaidsController;
            _tweetObserver   = controllerFactory.GetTweetObserver;
            var settingsController = controllerFactory.GetSettingsController;

            _blacklistController  = controllerFactory.GetBlacklistController;
            _controllerFactory    = controllerFactory;
            _twitterAuthenticator = twitterAuthenticator;
            Follows             = _raidsController.Follows;
            SettingsDataContext = settingsViewModel;
            RaidListCtx         = new RaidListViewModel(controllerFactory);
            RaidBosses          =
                new ReadOnlyObservableCollection <RaidListItem>(
                    controllerFactory.GetRaidlistController.RaidBossListItems);
            Settings          = settingsController.Settings;
            RemoveCommand     = new ActionCommand(r => Remove((string)r));
            StartLoginCommand = new ActionCommand(async() => await Startup());
            AddNewRaidCommand =
                new ActionCommand(async() => await DialogHost.Show(new AddRaidDialog(controllerFactory
                                                                                     .GetRaidlistController.RaidBossListItems)));
            ChangeViewCommand = new ActionCommand(i => ChangeView((string)i));

            _tweetObserver.SetAddAction(AddTweet);
            CheckUpdate();
            Id = UniqueId.Create();
            if (settingsController.Settings.Autologin &&
                !string.IsNullOrWhiteSpace(settingsController.Settings.AccessToken) &&
                !string.IsNullOrWhiteSpace(settingsController.Settings.AccessTokenSecret))
            {
                Startup().ConfigureAwait(false);
            }
            //Console.WriteLine(new List<string>()[4]);
        }
示例#10
0
 /// <summary>
 /// Replace placeholders with variables
 /// </summary>
 /// <param name="variables">Name/Value dictionary</param>
 public void InjectVariables(IGlobalVariables variables)
 {
     Logger.Log($"Before injection: Text => {Text}", MessageTypes.ScriptAction | MessageTypes.Internal);
     Text = ValueReplacer.InjectVariables(variables, Text);
     Logger.Log($"After injection: Text => {Text}", MessageTypes.ScriptAction | MessageTypes.Internal);
 }