예제 #1
0
 public DebugCommand(IScriptRunner scriptRunner, IDebugger debugger, BuildScriptHost host)
 {
     _scriptRunner = scriptRunner;
     _debugger     = debugger;
     _host         = host;
     _log          = _host.Context.Log;
 }
예제 #2
0
 public void Migrate(IEnumerable<IStep> migrationSteps, DatabaseVersion currentVersion, long? targetVersion, IScriptRunner scriptRunner, string schema, string tablespace)
 {
     if (_databaseMetadataProvider.SchemaExists(schema))
     {
         TerminateDatabase(migrationSteps.Select(m => m.BackwardScript), scriptRunner, schema);
     }
 }
        private void BrowserIsAttached(IWebBrowser browser)
        {
            NavigationItemViewModel.SetBrowser(browser);
            TabHeaderViewModel.SetBrowser(browser);
            ScriptRunner = new CefScriptRunner(browser);

            browser.FrameLoadEnd   += BrowserOnFrameLoadEnd;
            browser.ConsoleMessage += BrowserOnConsoleMessage;
            browser.LoadError      += BrowserLoadError;
            browser.DisplayHandler  = new DisplayHandler((favIcon) =>
            {
                _dispatcher.Invoke(() =>
                {
                    TabHeaderViewModel.FavIcon = favIcon;
                });
            });
            LazyRegisterWebObserver();

            WebPageObserver = new WebPageObserver(ScriptRunner, Id);

            WebPageObserver.FocusChanged     += WebPageObserverOnFocusChanged;
            WebPageObserver.Mutated          += WebPageObserverOnMutated;
            WebPageObserver.MouseOverChanged += WebPageObserverOnMouseOverChanged;
            WebPageObserver.BeaconEvent      += WebPageObserverOnBeaconEvent;
        }
        public ScriptExecutionService(
            ITargetService targetService,
            ICredentialService credentialService,
            IVariableService variableService,
            ITargetCommandSender targetCommandSender,
            IScriptRunner scriptRunner)
        {
            if (targetService == null)
            {
                throw new ArgumentNullException("targetService");
            }
            _targetService = targetService;

            if (credentialService == null)
            {
                throw new ArgumentNullException("credentialService");
            }
            _credentialService = credentialService;

            if (targetCommandSender == null)
            {
                throw new ArgumentNullException("targetCommandSender");
            }
            _targetCommandSender = targetCommandSender;

            if (scriptRunner == null)
            {
                throw new ArgumentNullException("scriptRunner");
            }
            _scriptRunner = scriptRunner;
        }
예제 #5
0
 public UIEventHub(IScriptRunner runner, UIElement control,
                   bool startIsEnabled = true, params UIEventProcessorBase[] eventProcessors)
 {
     Control          = control;
     _eventProcessors = new List <UIEventProcessorBase>(eventProcessors);
     _inputProcessors = new UIInputManager(
         new FlickInputProcessor(),
         new ClickCountInputProcessor(),
         new DropInputProcessor(),
         new DragInputProcessor()
     {
         DragStartedFunc = inp =>
         {
             if (inp.InputType == UIInputType.Touch)
             {
                 Control_TouchDrag(inp.Sender, inp.EventArgs as InputEventArgs);
             }
             else
             {
                 Control_MouseDrag(inp.Sender, inp.EventArgs as InputEventArgs);
             }
             //ScrollViewer.SetPanningRatio(inp.Sender as DependencyObject, 0);
             ScrollViewer.SetPanningMode(inp.Sender as DependencyObject, PanningMode.None);
         },
         DragStoppedFunc = inp =>
         {
             //ScrollViewer.SetPanningRatio(inp.Sender as DependencyObject, 1);
             ScrollViewer.SetPanningMode(inp.Sender as DependencyObject, PanningMode.Both);
         }
     },
         new TouchDragMoveCountInputProcessor()
         );
     _scriptRunner = runner;
     IsEnabled     = startIsEnabled;
 }
예제 #6
0
 public RunScript(string scriptPath, IFileSystemOperations fileSystemOperations,
                  IDeploymentContext deploymentContext, IOperationContext operationContext, IScriptRunner scriptRunner, IScriptParser scriptParser) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.scriptPath   = scriptPath;
     this.scriptRunner = scriptRunner;
     this.scriptParser = scriptParser;
 }
예제 #7
0
        // Functions
        /// <summary>
        /// Constructor which uses TabControl.
        /// 
        /// TabControl so can add and remove tab content.
        /// </summary>
        /// <param name="_ideTabs">TabControl used in main program in the IDE.</param>
        public IDEViewModel()
        {
            obsCollectionTabs = new ObservableCollection<TabItem>();
            newTab_Executed();
            currentlySelectedTab = obsCollectionTabs[0];

            // Members settings
            isrScriptRunner = Factory.getScriptRunnerInstance;
            Factory.getThreadHandlingInstance.addThread(executeCodeThread, "ExecuteScript");

            #region Commands

            saveAs = new RelayCommand(
                    () => saveAs_Executed(),
                    () => saveAs_CanExecute);

            open = new RelayCommand(
                    () => open_Executed(),
                    () => open_CanExecute);

            closeTab = new RelayCommand(
                    () => closeTab_Executed(),
                    () => closeTab_CanExecute);

            newTab = new RelayCommand(
                    () => newTab_Executed(),
                    () => newTab_CanExecute);

            ecDelegateComd = new DelegateCommand(executeCode);
            #endregion
        }
예제 #8
0
 public WoaDeployer(IScriptRunner scriptRunner, IScriptParser parser, ITooling tooling, IPhone phone)
 {
     this.scriptRunner = scriptRunner;
     this.parser       = parser;
     this.tooling      = tooling;
     this.phone        = phone;
 }
예제 #9
0
 /// <summary>
 /// Adds a runner to the manager
 /// </summary>
 public void AddRunner(IScriptRunner runner)
 {
     if (runners.IndexOf(runner) < 0)
     {
         runners.Add(runner);
     }
 }
 public TargetCommandProcessor(IScriptRunner scriptRunner)
 {
     if (scriptRunner == null)
     {
         throw new ArgumentNullException("scriptRunner");
     }
     _scriptRunner = scriptRunner;
 }
예제 #11
0
 public WoaDeployer(IScriptRunner scriptRunner, IScriptParser parser, ITooling tooling,
                    IFileSystemOperations fileSystemOperations)
 {
     this.scriptRunner         = scriptRunner;
     this.parser               = parser;
     this.tooling              = tooling;
     this.fileSystemOperations = fileSystemOperations;
 }
        /// <summary>
        /// Execute command from commandManager.CommandDictionary.CommandVariable,
        /// or if not found, from ParameterDic[CommandVariable].
        /// </summary>
        /// <param name="commandManager"></param>
        /// <param name="commandVariable"></param>
        /// <param name="parameterDic"></param>
        /// <param name="scriptRunner"></param>
        /// <returns></returns>
        public static async Task ExecuteAsync(this ICommandManager commandManager, string commandVariable = "{Command2Run}",
                                              ParameterDic parameterDic = null, IScriptRunner scriptRunner = null)
        {
            IScriptCommand cmd = commandManager.GetCommandFromDictionary(commandVariable, null);

            cmd = cmd ?? ScriptCommands.Run(commandVariable);
            await commandManager.ExecuteAsync(cmd, parameterDic, scriptRunner);
        }
		void _worker_DoWork(object sender, DoWorkEventArgs e)
		{
			_scriptRunner = ObjectFactory.GetInstance<IScriptRunner>();
			_scriptRunner.FileRan += _scriptRunner_FileRan;

			if (_runAtomic) _scriptRunner.RunScriptsAtomic(_server, _scripts);
			else _scriptRunner.RunScripts(_server, _scripts);
		}
예제 #14
0
 public ScriptController(IScriptRunner runner, ScriptRunMode mode = ScriptRunMode.OneShot)
 {
     runner_ = runner;
     runner_.StatusChanged   += Runner_StatusChanged;
     runner_.MessageAppended += Runner_MessageAppended;
     runner_.CommentUpdated  += Runner_CommentUpdated;
     Mode = mode;
 }
예제 #15
0
        public ScriptingWindow(IContextFactory contextFactory, IScriptRunner scriptRunner, DataContainer data)
        {
            InitializeComponent();

            SearchPanel.Install(TextEditor);

            ViewModel   = new ScriptingViewModel(contextFactory, scriptRunner, data, DialogCoordinator.Instance);
            DataContext = ViewModel;
        }
예제 #16
0
 public App(IDBAccess dbAccess, IStager stager, IScriptRunner scriptRunner, IMessageBroker messageBroker, IDataValidation dataValidation, ILogger <App> log)
 {
     Stager         = stager;
     ScriptRunner   = scriptRunner;
     DBAccess       = dbAccess;
     MessageBroker  = messageBroker;
     DataValidation = dataValidation;
     _log           = log;
 }
예제 #17
0
 public GitVersionedFileService(ILogger <GitVersionedFileService> logger
                                , IOptions <GitVersionedFileServiceOptions> optionsAccessor
                                , IScriptRunner scriptRunner)
 {
     this.scriptRunner = scriptRunner;
     this.testDataPath = Path.Combine(optionsAccessor.Value.GitRepoDirectory, optionsAccessor.Value.TestDataDirectroy);
     logger.LogInformation("Git Repo specified at {Path}", optionsAccessor.Value.GitRepoDirectory);
     this.logger = logger;
 }
예제 #18
0
 public Worker(ILogger <Worker> logger,
               Options options,
               IStorageRepository storageRepository,
               IScriptRunner scriptRunner)
 {
     _logger            = logger;
     _storageRepository = storageRepository;
     _options           = options;
     _scriptRunner      = scriptRunner;
 }
예제 #19
0
        private void Complete(IScriptRunner sender)
        {
            ScriptRunnerComplete(this, new EventArgs <string>(sender.ScriptFile));

            _view.FinishUI();

            bool isLocal = !_profilesProvider.SelectedProfile.RemotingEnabled;

            UpdatePluginsMenu(isLocal);
        }
예제 #20
0
        private void Complete(IScriptRunner sender)
        {
            ScriptRunnerComplete(this, new EventArgs <string>(sender.ScriptFile));

            _view.FinishUI();

            bool isLocal = !_profilesProvider.SelectedProfile.RemotingEnabled;

            _view.PopulateToolStripMenuItemWithPluginsAndScripts(GetPluginsAndScripts(Folders.Plugins), isLocal);
        }
예제 #21
0
 private void SetupScriptRunner()
 {
     _scriptRunner = CurrentLanguage switch
     {
         ScriptLanguage.CSharp => new CSharpScriptRunner(),
         ScriptLanguage.Javascript => new JavascriptRunner(),
         ScriptLanguage.Python => new PythonScriptRunner(),
         _ => throw new NotSupportedException($"No script runner for script of type '{CurrentLanguage}'")
     };
 }
예제 #22
0
        //, Func<ProjectExplorerViewModel> projectExplorerViewModelBuilder, Func<EventAggregatorDebugViewModel> eventsDebugBuilder,)
        public MenuViewModel(IEventAggregator eventAggregator, Func<TeapotViewModel> teapotBuilder, IScriptRunner script, ProjectManager manager)
        {
            _eventAggregator = eventAggregator;
            Items = new BindableCollection<MenuItemViewModel> {
                new MenuItemViewModel {
                    Header = "_FILE",
                    Items = new BindableCollection<MenuItemViewModel> {
                        new MenuItemViewModel {
                            Header = "_Open",
                            Items = new BindableCollection<MenuItemViewModel> {
                                new MenuItemViewModel {
                                    Header = "_Project",
                                    Action = () => _eventAggregator.Publish(new OpenProjectDialog())
                                },
                                new MenuItemViewModel {
                                    Header = "Teapot",
                                    Action = () => _eventAggregator.Publish(new AddTabViewCommand {Model = teapotBuilder()})
                                },

                            }
                        },
                        new MenuItemViewModel {
                            Header = "Close",
                            Action = () => _eventAggregator.Publish(new DebugCommand("close"))
                        }
                    }
                },
                new MenuItemViewModel {
                    Header = "_EDIT"
                },
                new MenuItemViewModel {
                    Header = "_VIEW"
                },
                new MenuItemViewModel {
                    Header = "_BUILD",
                    Items = new BindableCollection<MenuItemViewModel> {
                        new MenuItemViewModel {
                            Header = "_Build Project",
                            Action = () => script.Execute(manager.Project)
                        },
                        new MenuItemViewModel {
                            Header = "Teapot",
                            Action = () => _eventAggregator.Publish(new AddTabViewCommand {Model = teapotBuilder()})
                        },

                    }
                },
                new MenuItemViewModel {
                    Header = "_WINDOW"
                },
                new MenuItemViewModel {
                    Header = "_HELP"
                }
            };
        }
예제 #23
0
파일: Session.cs 프로젝트: wiltaylor/FCE
 public Session(IScriptRunner runner, IConsole console, IGraphManager graphManager, IGatherManager gatherManager, IDataStore dataStore, IFileSystem fileSystem, IConfigManager configManager, IEnvironmentHelper environmentHelper)
 {
     _runner            = runner;
     _console           = console;
     _graphManager      = graphManager;
     _gatherManager     = gatherManager;
     _dataStore         = dataStore;
     _fileSystem        = fileSystem;
     _configManager     = configManager;
     _environmentHelper = environmentHelper;
 }
예제 #24
0
        public static Task RunScriptAsync(ParameterDic initialParameters, bool cloneParameters, params IScriptCommand[] commands)
        {
            if (cloneParameters)
            {
                initialParameters = initialParameters.Clone();
            }

            IScriptRunner runner = initialParameters.GetValue <IScriptRunner>("{ScriptRunner}", Instance);

            return(runner.RunAsync(new Queue <IScriptCommand>(commands), initialParameters));
        }
예제 #25
0
        public static void RunScript(ParameterDic initialParameters, bool cloneParameters, params IScriptCommand[] commands)
        {
            if (cloneParameters)
            {
                initialParameters = initialParameters.Clone();
            }

            IScriptRunner runner = initialParameters.GetValue <IScriptRunner>("{ScriptRunner}", Instance);

            runner.Run(new Queue <IScriptCommand>(commands), initialParameters);
        }
예제 #26
0
 public WoaDeployer(IScriptRunner scriptRunner, IScriptParser parser, ITooling tooling, IPhone phone,
                    IDeploymentContext context,
                    IFileSystemOperations fileSystemOperations)
 {
     this.scriptRunner         = scriptRunner;
     this.parser               = parser;
     this.tooling              = tooling;
     this.phone                = phone;
     this.context              = context;
     this.fileSystemOperations = fileSystemOperations;
 }
 /// <summary>
 /// Construct a FileSystemScriptsMigrationProvider using the given directories and glob patterns.
 /// </summary>
 /// <param name="migrationsDirectory">The directory containing migration scripts</param>
 /// <param name="migrationsFileWildcard">The filename pattern to identify migration scripts in the directory</param>
 /// <param name="storedCodeDefinitionsDirectory">The directory containing stored code definition scripts</param>
 /// <param name="storedCodeDefinitionFileWildcard">The filename pattern to identify the stored code definition scripts in the directory</param>
 /// <param name="scriptRunner">The script runner that has the ability to execute the text of the scripts for the target data store</param>
 public FileSystemScriptsMigrationProvider(
     string migrationsDirectory,
     string migrationsFileWildcard,
     string storedCodeDefinitionsDirectory,
     string storedCodeDefinitionFileWildcard,
     IScriptRunner scriptRunner)
 {
     _migrationsDirectory              = migrationsDirectory;
     _migrationsFileWildcard           = migrationsFileWildcard;
     _storedCodeDefinitionsDirectory   = storedCodeDefinitionsDirectory;
     _storedCodeDefinitionFileWildcard = storedCodeDefinitionFileWildcard;
     _scriptRunner = scriptRunner;
 }
예제 #28
0
파일: Robot.cs 프로젝트: tonycompton/mmbot
 public Robot(string name, IDictionary <string, string> config, LoggerConfigurator logConfig, IDictionary <string, IAdapter> adapters, IRouter router, IBrain brain, IScriptStore scriptStore, IScriptRunner scriptRunner)
     : this(logConfig)
 {
     _name         = name;
     _config       = config;
     _scriptStore  = scriptStore;
     _adapters     = adapters;
     _brain        = brain;
     _router       = router;
     _scriptRunner = scriptRunner;
     _isConfigured = true;
     Initialize(adapters.Values.ToArray().Concat(new object[] { router, brain, scriptRunner }).ToArray());
 }
예제 #29
0
 public void Migrate(IEnumerable<IStep> migrationSteps, DatabaseVersion currentVersion, long? targetVersionNumber, IScriptRunner scriptRunner, string schema, string tablespace)
 {
     if (_databaseMetadataProvider.SchemaExists(schema))
     {
         if (_versionRespository.GetCurrentVersion(schema).IsNotNull())
         {
             var orderByDescending = migrationSteps.Select(m => m.BackwardScript).Where(m => m.IsNotNull()).OrderByDescending(m => m.Version);
             DowngradeDatabase(orderByDescending, currentVersion, targetVersionNumber, scriptRunner, schema);
         }
         else
         {
             Output.Warn("Database schema '{0}' exists, but there are no recorded database versions. Database was most likely not terminated.".FormatWith(schema));
         }
     }
 }
예제 #30
0
        public void StartScript(int scriptIndex)
        {
            ClearErrors();

            _currentScript = _scriptStore.GetScript(scriptIndex);

            _logger.LogStart(_currentScript.Name);

            _currentRunner = _scriptRunnerFactory.CreateScriptRunner(_currentScript);

            _currentRunner.OutputDataReceived += WriteOutput;
            _currentRunner.ErrorReceived      += WriteErrorOutput;
            _currentRunner.Done += Done;

            _currentRunner.RunScript();
        }
예제 #31
0
        /// <summary>
        /// Starts the webserver using the specified scriptrunner
        /// </summary>
        /// <param name="scriptRunner">Script runner used</param>
        /// <returns>Task</returns>
        public Task Start(IScriptRunner scriptRunner)
        {
            WebHostBuilder hostBuilder = new WebHostBuilder();

            var loggerFactory = new LoggerFactory();

            hostBuilder.UseKestrel(x =>
            {
                x.AddServerHeader = false;
            });
            hostBuilder.UseUrls(this.baseAddress);
            hostBuilder.ConfigureServices(x => this.ConfigureServices(loggerFactory, scriptRunner, x));
            hostBuilder.Configure(this.Configuration);

            this.host = hostBuilder.Build();
            return(this.host.RunAsync(this.cancel.Token));
        }
예제 #32
0
 /// <summary>
 /// Execute the IScriptRunner.Run method in the compiled_assembly
 /// </summary>
 /// <param name="compiled_assembly">compiled assembly</param>
 /// <param name="args">method arguments</param>
 /// <returns>object returned</returns>
 public static object Run(Assembly compiled_assembly, object[] args, PermissionSet permission_set)
 {
     if (compiled_assembly != null)
     {
         // security is not implemented yet !NIY
         // using Utilties.PrivateStorage was can save but not diaplay in Notepad
         // plus the output is saved in C:\Users\<user>\AppData\Local\IsolatedStorage\...
         // no contral over where to save make QuranCode unportable applicaton, which is a no no
         //// restrict code security
         //permission_set.PermitOnly();
         foreach (Type type in compiled_assembly.GetExportedTypes())
         {
             foreach (Type interface_type in type.GetInterfaces())
             {
                 if (interface_type == typeof(IScriptRunner))
                 {
                     ConstructorInfo constructor = type.GetConstructor(System.Type.EmptyTypes);
                     if ((constructor != null) && (constructor.IsPublic))
                     {
                         // construct object using default constructor
                         IScriptRunner obj = constructor.Invoke(null) as IScriptRunner;
                         if (obj != null)
                         {
                             return(obj.Run(args));
                         }
                         else
                         {
                             throw new Exception("Invalid C# code!");
                         }
                     }
                     else
                     {
                         throw new Exception("No default constructor was found!");
                     }
                 }
                 else
                 {
                     throw new Exception("IScriptRunner is not implemented!");
                 }
             }
         }
         // revert security restrictions
         //CodeAccessPermission.RevertPermitOnly();
     }
     return(null);
 }
예제 #33
0
        private void DowngradeDatabase(IEnumerable<IScript> migrationScripts, DatabaseVersion currentVersion, long? targetVersionNumber, IScriptRunner scriptRunner, string schema)
        {
            var applicableScripts = migrationScripts.Where(s => currentVersion.IsNull() || s.Version <= currentVersion.Version)
                .Where(s => !targetVersionNumber.HasValue || s.Version > targetVersionNumber).ToArray();

            if (applicableScripts.IsNullOrEmpty())
            {
                Output.Warn("No migration scripts need to be run. Nothing will be done.");
            }
            else
            {
                Output.Info("The following scripts will be applied to the database:");
                foreach (var script in applicableScripts)
                {
                    Output.Info(script.Name, 1);
                }

                Output.EmptyLine();
                Prompt.ForAnyKey("Press any key to start the 'down' migration. Ctrl-C to abort.");

                foreach (var script in applicableScripts)
                {
                    Output.Info("Executing script: {0}".FormatWith(script.Path));

                    try
                    {
                        scriptRunner.Execute(script);
                    }
                    catch (SqlPlusException)
                    {
                        if (!_force)
                        {
                            throw;
                        }
                    }

                    Output.Info("Script '{0}' completed.".FormatWith(script.Name));

                    Output.Text("Removing script contents for script '{0}' from applied scripts table".FormatWith(script.Name));
                    _appliedScriptsRepository.RemoveAppliedScript(script.AsDatabaseVersion(), schema);

                    Output.Text("Removing version {0} for script '{1}' from version table".FormatWith(script.Version, script.Name));
                    _versionRespository.RemoveVersion(script.AsDatabaseVersion(), schema);
                }
            }
        }
예제 #34
0
        public Worker(
            ILogger <Worker> logger,
            IQueueHelper queueHelper,
            IStorageRepository storageRepository,
            IScriptRunner scriptRunner,
            IEmailHelper emailHelper,
            Options options)
        {
            _logger            = logger;
            _queueHelper       = queueHelper;
            _storageRepository = storageRepository;
            _scriptRunner      = scriptRunner;
            _emailHelper       = emailHelper;
            _options           = options;

            InitQueue();
        }
예제 #35
0
        private void InitialiseDatabase(IEnumerable <IScript> initScripts, IScriptRunner scriptRunner, string schema)
        {
            Output.Warn("*** Target database could not be found and needs to be initialised before the migration can be run... ***");
            Output.EmptyLine();

            var initScriptsList = initScripts as IList <IScript> ?? initScripts.ToList();

            if (initScriptsList.IsNullOrEmpty())
            {
                Output.Warn("No initialisation scripts found to create the database. Nothing will be done.");
            }
            else
            {
                Output.Info("The following scripts will be used to create and initialise the tablespace and schema:");
                foreach (var script in initScriptsList)
                {
                    Output.Info(script.Name, 1);
                }

                Output.EmptyLine();
                Output.Warn("Note: soothsayer assumes that the tablespace and schema share the same name, the versioning table will be created in tablespace '{0}'".FormatWith(schema));

                Prompt.ForAnyKey("Press any key to start the 'init' migration. Ctrl-C to abort.");

                foreach (var script in initScriptsList)
                {
                    Output.Info("Executing script: {0}".FormatWith(script.Path));
                    try
                    {
                        scriptRunner.Execute(script);
                    }
                    catch (SqlPlusException)
                    {
                        if (!_force)
                        {
                            throw;
                        }
                    }
                    Output.Info("Script '{0}' completed.".FormatWith(script.Name));
                }

                Output.Info("Initialisation scripts completed.");
            }

            Output.EmptyLine();
        }
예제 #36
0
        private void InitialiseDatabase(IEnumerable<IScript> initScripts, IScriptRunner scriptRunner, string schema)
        {
            Output.Warn("*** Target database could not be found and needs to be initialised before the migration can be run... ***");
            Output.EmptyLine();

            var initScriptsList = initScripts as IList<IScript> ?? initScripts.ToList();
            if (initScriptsList.IsNullOrEmpty())
            {
                Output.Warn("No initialisation scripts found to create the database. Nothing will be done.");
            }
            else
            {
                Output.Info("The following scripts will be used to create and initialise the tablespace and schema:");
                foreach (var script in initScriptsList)
                {
                    Output.Info(script.Name, 1);
                }

                Output.EmptyLine();
                Output.Warn("Note: soothsayer assumes that the tablespace and schema share the same name, the versioning table will be created in tablespace '{0}'".FormatWith(schema));

                Prompt.ForAnyKey("Press any key to start the 'init' migration. Ctrl-C to abort.");

                foreach (var script in initScriptsList)
                {
                    Output.Info("Executing script: {0}".FormatWith(script.Path));
                    try
                    {
                        scriptRunner.Execute(script);
                    }
                    catch (SqlPlusException)
                    {
                        if (!_force)
                        {
                            throw;
                        }
                    }
                    Output.Info("Script '{0}' completed.".FormatWith(script.Name));
                }

                Output.Info("Initialisation scripts completed.");
            }

            Output.EmptyLine();
        }
예제 #37
0
        public OrdersPageViewModel(IContextFactory contextFactory, IDialogCoordinator dialogService, IDataSourcer datasourcer, IAppSettings settings, DataContainer data, IScriptRunner scriptRunner, IMainViewModel parent)
            : base(dialogService)
        {
            Parent           = parent;
            _contextFactory  = contextFactory;
            Datasourcer      = datasourcer;
            _data            = data;
            _scriptRunner    = scriptRunner;
            TradesRepository = new TradesRepository(contextFactory, datasourcer, settings);

            OrdersSource        = new CollectionViewSource();
            OrdersSource.Source = data.Orders;
            OrdersSource.SortDescriptions.Add(new SortDescription("TradeDate", ListSortDirection.Descending));

            ExecutionStatsGenerator = new ExecutionStatsGenerator(datasourcer);

            CreateCommands();
        }
예제 #38
0
        private void TerminateDatabase(IEnumerable<IScript> termScripts, IScriptRunner scriptRunner, string schema)
        {
            var termScriptsList = termScripts as IList<IScript> ?? termScripts.ToList();
            if (termScriptsList.IsNullOrEmpty())
            {
                Output.Warn("No termination scripts found to destroy the database. Nothing will be done.");
            }
            else
            {
                Output.Info("The following scripts will be used to terminate the tablespace and schema:");
                foreach (var script in termScriptsList)
                {
                    Output.Info(script.Name, 1);
                }

                Output.EmptyLine();
                Prompt.ForAnyKey("Press any key to start the 'term' migration. Ctrl-C to abort.");

                foreach (var script in termScriptsList)
                {
                    Output.Info("Executing script: {0}".FormatWith(script.Path));
                    try
                    {
                        scriptRunner.Execute(script);
                    }
                    catch (SqlPlusException)
                    {
                        if (!_force)
                        {
                            throw;
                        }
                    }
                    Output.Info("Script '{0}' completed.".FormatWith(script.Name));
                }

                Output.Info("Termination scripts completed.'".FormatWith(schema));
            }

            Output.EmptyLine();
        }
 protected AbstractConnectionDependencies(
     ITableQueryWriter tableQueryWriter,
     IConnectionChecker connectionChecker,
     IEntityRecordsExist entityRecordsExist,
     IEntityDropper entityDropper,
     IEntityCreator entityCreator,
     List<IViewWriter> viewWriters,
     ITflWriter tflWriter,
     IScriptRunner scriptRunner,
     IDataTypeService dataTypeService,
     ILogger logger
     ) {
     TableQueryWriter = tableQueryWriter;
     ConnectionChecker = connectionChecker;
     EntityRecordsExist = entityRecordsExist;
     EntityDropper = entityDropper;
     EntityCreator = entityCreator;
     ViewWriters = viewWriters;
     TflWriter = tflWriter;
     ScriptRunner = scriptRunner;
     DataTypeService = dataTypeService;
     Logger = logger;
 }
        public ScriptExecutionService(
            ITargetService targetService,
            ICredentialService credentialService,
            IVariableService variableService,
            ITargetCommandSender targetCommandSender,
            IScriptRunner scriptRunner)
        {
            if (targetService == null)
                throw new ArgumentNullException("targetService");
            _targetService = targetService;

            if (credentialService == null)
                throw new ArgumentNullException("credentialService");
            _credentialService = credentialService;

            if (targetCommandSender == null)
                throw new ArgumentNullException("targetCommandSender");
            _targetCommandSender = targetCommandSender;

            if (scriptRunner == null)
                throw new ArgumentNullException("scriptRunner");
            _scriptRunner = scriptRunner;
        }
예제 #41
0
        // Work
        public DatabaseUpdater(IDatabaseVersionStore versionStore, IScriptRunner scriptRunner, ScriptStore scripts)
        {
            if (versionStore == null)
            {
                throw new ArgumentNullException("versionStore");
            }

            if (scriptRunner == null)
            {
                throw new ArgumentNullException("scriptRunner");
            }

            if (scripts == null)
            {
                throw new ArgumentNullException("scripts");
            }

            scripts.CalculateAggregations();

            // Accept arguments
            this.versionStore = versionStore;
            this.scriptRunner = scriptRunner;
            this.scripts = scripts;
        }
예제 #42
0
        private static void RunMigration(MigrationInfo migrationInfo, DatabaseVersion currentVersion, IEnumerable<Script> initScripts, IEnumerable<Script> upScripts, IEnumerable<Script> downScripts, IEnumerable<Script> termScripts,
            IList<IStep> storedSteps, IScriptRunner scriptRunner, IDatabaseMetadataProvider databaseMetadataProvider, IVersionRespository versionRespository, IAppliedScriptsRepository appliedScriptsRepository)
        {
            var upDownSteps = upScripts.Select(u => new DatabaseStep(u, downScripts.FirstOrDefault(d => d.Version == u.Version))).ToList();
            var initTermSteps = initScripts.Select(i => new DatabaseStep(i, termScripts.FirstOrDefault(t => t.Version == i.Version))).ToList();

            if (migrationInfo.Direction == MigrationDirection.Down)
            {
                var downMigration = new DownMigration(databaseMetadataProvider, versionRespository, appliedScriptsRepository, migrationInfo.Forced);

                if (storedSteps.Any())
                {
                    Output.Warn("NOTE: Using stored applied scripts to perform downgrade instead of local 'down' scripts.");
                    downMigration.Migrate(storedSteps, currentVersion, migrationInfo.TargetVersion, scriptRunner, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);
                }
                else
                {
                    downMigration.Migrate(upDownSteps, currentVersion, migrationInfo.TargetVersion, scriptRunner, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);
                }

                if (!migrationInfo.TargetVersion.HasValue)
                {
                    var termMigration = new TermMigration(databaseMetadataProvider, migrationInfo.Forced);
                    termMigration.Migrate(initTermSteps, currentVersion, migrationInfo.TargetVersion, scriptRunner, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);
                }
                else
                {
                    Output.Info("A target version was provided, termination scripts will not be executed.");
                }
            }
            else
            {
                var initMigration = new InitMigration(databaseMetadataProvider, migrationInfo.Forced);
                initMigration.Migrate(initTermSteps, currentVersion, migrationInfo.TargetVersion, scriptRunner, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);

                EnsureVersioningTableIsInitialised(versionRespository, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);
                EnsureAppliedScriptsTableIsInitialised(appliedScriptsRepository, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);

                var upMigration = new UpMigration(versionRespository, appliedScriptsRepository, migrationInfo.Forced);
                upMigration.Migrate(upDownSteps, currentVersion, migrationInfo.TargetVersion, scriptRunner, migrationInfo.TargetSchema, migrationInfo.TargetTablespace);
            }
        }
 public ContextToParameterDecorator(IScriptRunner scriptRunner)
 {
     this.scriptRunner = scriptRunner;
 }
 public WinFormsRequestInputParameterDecorator(IScriptRunner scriptRunner)
     : base(scriptRunner)
 {
     this.scriptRunner = scriptRunner;
 }
예제 #45
0
파일: Script.cs 프로젝트: raltamirano/rant
        public void Execute(IScriptRunner scriptRunner)
        {
            using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required))
            {
                internalExecution(scriptRunner);

                if (LastRunWasSuccessful)
                    transaction.Complete();
            }
        }
예제 #46
0
 public FileLoggerDecorator(IScriptRunner scriptRunner, FileInfo logDirectory, bool newFileOnScriptStart)
 {
     this.scriptRunner = scriptRunner;
     this.logDirectory = logDirectory;
     this.newFileOnScriptStart = newFileOnScriptStart;
 }
 public TargetCommandProcessor(IScriptRunner scriptRunner)
 {
     if (scriptRunner == null)
         throw new ArgumentNullException("scriptRunner");
     _scriptRunner = scriptRunner;
 }
 public RequestInputParameterDecorator(IScriptRunner scriptRunner)
 {
     this.scriptRunner = scriptRunner;
 }
 public WinFormsAskConfirmationDecorator(IScriptRunner scriptRunner, String confirmMessage)
     : base(scriptRunner, confirmMessage)
 {
 }
예제 #50
0
 public ManagedCompiler(IScriptRunner scriptRunner, ICommandFactory commandFactory)
 {
     _scriptRunner = scriptRunner;
     _commandFactory = commandFactory;
 }
예제 #51
0
파일: Script.cs 프로젝트: raltamirano/rant
        private void internalExecution(IScriptRunner scriptRunner)
        {
            Step step = null;
            bool stepWithError = false;

            scriptWithErrors = false;
            try
            {
                if (!scriptRunner.ScriptStarting(this))
                    throw new Exception("Script runner decided NOT to start executing this script.");

                if (ScriptStarting != null)
                    ScriptStarting(this);

                for (int stepIndex = 0; stepIndex < steps.Count; stepIndex++)
                {
                    stepWithError = false;
                    step = steps[stepIndex];

                    try
                    {
                        scriptRunner.BeforeStepRun(step);

                        if (StepStarting != null)
                            StepStarting(step);

                        if (scriptRunner.StepRun(step))
                        {
                            if (StepFinished != null)
                                StepFinished(step);
                        }
                        else
                        {
                            if (StepSkipped != null)
                                StepSkipped(step);

                            if (step.Required)
                                throw new RequiredStepNotExecutedException(step);
                        }
                    }
                    catch (RequiredStepNotExecutedException)
                    {
                        // Can't continue with script execution if a required step was not executed.
                        throw;
                    }
                    catch (Exception exception)
                    {
                        scriptWithErrors = true;

                        stepWithError = true;

                        scriptRunner.StepError(step, exception);

                        if (StepError != null)
                            StepError(step, exception);

                        if (step.Required)
                            throw new RequiredStepNotExecutedException(step);
                    }
                    finally
                    {
                        scriptRunner.AfterStepRun(step, stepWithError);
                    }
                }
            }
            catch (Exception exception)
            {
                scriptWithErrors = true;

                scriptRunner.ScriptError(this, exception);

                if (ScriptError != null)
                    ScriptError(this, exception);
            }
            finally
            {
                scriptRunner.ScriptFinished(this, scriptWithErrors);

                if (ScriptFinished != null)
                    ScriptFinished(this, scriptWithErrors);
            }
        }
예제 #52
0
 public AskConfirmationDecorator(IScriptRunner scriptRunner, String confirmMessage)
 {
     this.scriptRunner = scriptRunner;
     this.confirmMessage = confirmMessage;
 }