public void Execute() { var scriptSession = ScriptSessionManager.GetSession(PersistentId, Settings.ApplicationName, false); scriptSession.SetItemLocationContext(CurrentItem); scriptSession.SetExecutedScript(ScriptDb, ScriptId); scriptSession.Interactive = true; var parameters = new object[] { scriptSession, ScriptContent }; var runner = new ScriptRunner(ExecuteInternal, parameters, false); Monitor.Start("ScriptExecution", "PowerShellRunner", runner.Run, scriptSession.JobOptions); Monitor.SessionID = scriptSession.Key; }
private void ListViewAction(Message message) { ScriptRunning = true; UpdateRibbon(); var scriptDb = Database.GetDatabase(message.Arguments["scriptDb"]); var scriptItem = scriptDb.GetItem(message.Arguments["scriptID"]); var sessionId = string.IsNullOrEmpty(ListViewer.Data.SessionId) ? scriptItem[ScriptItemFieldNames.PersistentSessionId] : ListViewer.Data.SessionId; var scriptSession = ScriptSessionManager.GetSession(sessionId); var script = (scriptItem.Fields[ScriptItemFieldNames.Script] != null) ? scriptItem.Fields[ScriptItemFieldNames.Script].Value : string.Empty; SetVariables(scriptSession, message); scriptSession.SetExecutedScript(scriptItem); scriptSession.Interactive = true; ScriptSessionId = scriptSession.ID; var parameters = new object[] { scriptSession, script }; var progressBoxRunner = new ScriptRunner(ExecuteInternal, parameters, false); Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run); LvProgressOverlay.Visible = false; Monitor.SessionID = scriptSession.ID; }
private void ExecuteScriptJob(Item scriptItem, ScriptSession scriptSession, Message message, bool autoDispose) { var script = (scriptItem.Fields[ScriptItemFieldNames.Script] != null) ? scriptItem.Fields[ScriptItemFieldNames.Script].Value : string.Empty; SetVariables(scriptSession, message); scriptSession.SetExecutedScript(scriptItem); scriptSession.Interactive = true; ScriptSessionId = scriptSession.ID; var progressBoxRunner = new ScriptRunner(ExecuteInternal, scriptSession, script, autoDispose); Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run); LvProgressOverlay.Visible = false; Monitor.SessionID = scriptSession.ID; }
protected virtual void JobExecuteScript(ClientPipelineArgs args, string scriptToExecute, ScriptSession scriptSession, bool autoDispose) { ScriptRunning = true; EnterScriptInfo.Visible = false; UpdateRibbon(); scriptSession.SetExecutedScript(ScriptItem); var parameters = new object[] { scriptSession, scriptToExecute }; var progressBoxRunner = new ScriptRunner(ExecuteInternal, parameters, autoDispose); var rnd = new Random(); Context.ClientPage.ClientResponse.SetInnerHtml( "ScriptResult", string.Format( "<div id='ResultsClose' onclick='javascript:return cognifide.powershell.closeResults();' >x</div>" + "<div id='PleaseWait'>" + "<img src='../../../../../sitecore modules/PowerShell/Assets/working.gif' alt='Working' />" + "<div>Please wait, {0}</div>" + "</div>" + "<pre ID='ScriptResultCode'></pre>", ExecutionMessages.PleaseWaitMessages[ rnd.Next(ExecutionMessages.PleaseWaitMessages.Length - 1)])); Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run); Monitor.SessionID = scriptSession.ID; SheerResponse.Eval("cognifide.powershell.restoreResults();"); var settings = ApplicationSettings.GetInstance(ApplicationNames.IseConsole); if (settings.SaveLastScript) { settings.Load(); settings.LastScript = Editor.Value; settings.Save(); } }