Ejemplo n.º 1
0
 public override void AfterExecute(ScriptEngine scriptEngine, IronConsoleResult result)
 {
     base.AfterExecute(scriptEngine, result);
     var consoleOut = scriptEngine.Execute(String.Format("out '{0}' if respond_to? :out", Environment.NewLine));
     result.Output = Convert.ToString(consoleOut);
     result.Result = result.Result ?? "nil";
 }
Ejemplo n.º 2
0
        public override void AfterExecute(ScriptEngine scriptEngine, IronConsoleResult result)
        {
            base.AfterExecute(scriptEngine, result);
            var consoleOut = scriptEngine.Execute(String.Format("out '{0}' if respond_to? :out", Environment.NewLine));

            result.Output = Convert.ToString(consoleOut);
            result.Result = result.Result ?? "nil";
        }
Ejemplo n.º 3
0
        public void FromJson()
        {
            Sut = IronConsoleResult.FromJson(Assets.Load("response.json"));

            Assert.AreEqual("Error", Sut.Error);
            Assert.AreEqual(true, Sut.HasError);
            Assert.AreEqual("Output", Sut.Output);
            Assert.AreEqual("Result", Sut.Result);
            Assert.AreEqual("StackTrace", Sut.StackTrace);
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     Sut = new IronConsoleResult
     {
         Error      = "Error",
         Output     = "Output",
         Result     = "Result",
         StackTrace = "StackTrace"
     };
 }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            var response     = new IronConsoleResult();
            var jsonResponse = string.Empty;

            try
            {
                var site = SPContext.Current.Site;
                var web  = SPContext.Current.Web;
                if (!web.CurrentUser.IsSiteAdmin)
                {
                    context.Response.Write("Only Site Admins are allowed to use the Console");
                    return;
                }

                IronHiveRegistry.Local.EnsureTrustedHive(site.ID);

                //var ironRuntime = IronRuntime.GetIronRuntime(site, site.ID);
                var ironRuntime = IronRuntime.GetDefaultIronRuntime(site);
                var extension   = HttpContext.Current.Request["ext"];
                var expression  = HttpContext.Current.Request["expression"];

                if (expression == "_ = (kill);_.inspect")
                {
                    ironRuntime.Dispose();
                    response.Output = "Runtime disposed.";
                }
                else if (expression == "_ = (sp_status);_.inspect")
                {
                }
                else
                {
                    response = ironRuntime.IronConsole.Execute(expression, extension);
                }
            }
            catch (Exception ex)
            {
                response.Error      = ex.Message;
                response.StackTrace = ex.StackTrace;
            }
            finally
            {
                if (response == null)
                {
                    response       = new IronConsoleResult();
                    response.Error = "Request timed out";
                }

                jsonResponse = response.ToJson();
            }

            context.Response.Write(jsonResponse);
        }
Ejemplo n.º 6
0
        public override void BeforeExecute(ScriptEngine scriptEngine, IronConsoleResult result)
        {
            base.BeforeExecute(scriptEngine, result);
            /*
            scriptEngine.Execute(
                @"
                    unless respond_to? :out
                      begin
                        include IronSharePoint::Console::Utils 
                      rescue
#raise 'Could not load console utils'
                      end
                    end");
            */
        }
Ejemplo n.º 7
0
        public override void BeforeExecute(ScriptEngine scriptEngine, IronConsoleResult result)
        {
            base.BeforeExecute(scriptEngine, result);

            /*
             * scriptEngine.Execute(
             *  @"
             *      unless respond_to? :out
             *        begin
             *          include IronSharePoint::Console::Utils
             *        rescue
             #raise 'Could not load console utils'
             *        end
             *      end");
             */
        }
Ejemplo n.º 8
0
 public virtual void AfterExecute(ScriptEngine scriptEngine, IronConsoleResult result)
 {
 }