Exemplo n.º 1
0
        protected virtual void ClientExecute(ClientPipelineArgs args)
        {
            Settings = ApplicationSettings.GetInstance(ApplicationNames.IseConsole);
            using(var scriptSession = new ScriptSession(Settings.ApplicationName)){
            EnterScriptInfo.Visible = false;

            try
            {
                scriptSession.ExecuteScriptPart(Settings.Prescript);
                scriptSession.SetItemLocationContext(DataContext.CurrentItem);
                scriptSession.ExecuteScriptPart(Editor.Value);

                if (scriptSession.Output != null)
                {
                    Context.ClientPage.ClientResponse.SetInnerHtml("Result", scriptSession.Output.ToHtml());
                }
            }
            catch (Exception exc)
            {
                Context.ClientPage.ClientResponse.SetInnerHtml("Result",
                                                               string.Format("<pre style='background:red;'>{0}</pre>",
                                                                             scriptSession.GetExceptionString(exc)));
            }
            }
            if (Settings.SaveLastScript)
            {
                Settings.Load();
                Settings.LastScript = Editor.Value;
                Settings.Save();
            }
        }