Пример #1
0
        public void RunRubyScript(ScriptArguments scriptArguments)
        {
            try
            {
                ScriptRuntime runtime = Ruby.CreateRuntime();
                ScriptEngine engine = runtime.GetEngine("IronRuby");

                ScriptScope scriptScope = engine.CreateScope();

                AddTbl(scriptScope, scriptArguments.ConnectionString);

                scriptScope.SetVariable("log", scriptArguments.Logger);
                var initialScript = string.Format(OverrideRubyObject, scriptArguments.ConnectionString.Replace("\\", "\\\\"));
                engine.Execute(initialScript, scriptScope);
                engine.Execute(scriptArguments.Script, scriptScope);
            }
            catch (Exception exception)
            {
                scriptArguments.Logger.Print("\n--- Exception -------------------------------------------\n");
                scriptArguments.Logger.Print(exception.ToString());
                scriptArguments.Logger.Print("\n--- Exception end----------------------------------------\n");
            }
        }
Пример #2
0
        private void RunScript()
        {
            stopwatch.Reset();
            stopwatch.Start();
            ClearOutput();
            ShowProgressIndicator();
            var connectionStringName = ConnectionStringSelector.SelectedItem.ToString();
            var connectionString = Settings.Default.Properties[connectionStringName].DefaultValue.ToString();
            var scriptArguments = new ScriptArguments
                                      {
                                          ConnectionString = connectionString,
                                          Script = textEditor.Text,
                                          Logger = new Log(SetOutput, ClearOutput)
                                      };

            if (_backgroundWorker.IsBusy)
                statusText.Text = "Busy";
            else
                _backgroundWorker.RunWorkerAsync(scriptArguments);
        }