protected virtual void JobExecute(ClientPipelineArgs args) { ScriptRunning = true; EnterScriptInfo.Visible = false; UpdateRibbon(); Settings = ApplicationSettings.GetInstance(ApplicationNames.IseConsole); var scriptSession = new ScriptSession(Settings.ApplicationName); string contextScript = ScriptSession.GetDataContextSwitch(DataContext.CurrentItem); var parameters = new object[] { scriptSession, contextScript, ScriptItemId }; var progressBoxRunner = new ScriptRunner(ExecuteInternal, parameters, true); var rnd = new Random(); Context.ClientPage.ClientResponse.SetInnerHtml( "ScriptResult", string.Format( "<div align='Center' style='padding:32px 0px 32px 0px'>Please wait, {0}</br>" + "<img src='../../../../../Console/Assets/working.gif' alt='Working' style='padding:32px 0px 32px 0px'/></div>", ExecutionMessages.PleaseWaitMessages[ rnd.Next(ExecutionMessages.PleaseWaitMessages.Length - 1)])); Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run); HttpContext.Current.Session[Monitor.JobHandle.ToString()] = scriptSession; if (Settings.SaveLastScript) { Settings.Load(); Settings.LastScript = Editor.Value; Settings.Save(); } }
private void ListViewAction(Message message) { Database scriptDb = Database.GetDatabase(message.Arguments["scriptDb"]); Item scriptItem = scriptDb.GetItem(message.Arguments["scriptID"]); var scriptSession = ScriptSessionManager.GetSession(scriptItem[ScriptItemFieldNames.PersistentSessionId]); String script = (scriptItem.Fields[ScriptItemFieldNames.Script] != null) ? scriptItem.Fields[ScriptItemFieldNames.Script].Value : string.Empty; var results = ListViewer.SelectedItems.Select(p => { var id = Int32.Parse(p.Value); return ListViewer.Data.Data[id].Original; }).ToList(); scriptSession.SetVariable("resultSet", results); scriptSession.SetVariable("formatProperty", ListViewer.Data.Property); var parameters = new object[] { scriptSession, script, }; var progressBoxRunner = new ScriptRunner(ExecuteInternal, parameters, string.IsNullOrEmpty(scriptItem[ScriptItemFieldNames.PersistentSessionId])); Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run); HttpContext.Current.Session[Monitor.JobHandle.ToString()] = scriptSession; }
public void Execute() { ScriptSession scriptSession = ScriptSessionManager.GetSession(PersistentId, Settings.ApplicationName, false); string contextScript = string.Format("Set-HostProperty -HostWidth {0}\n{1}\n{2}", scriptSession.Settings.HostWidth, scriptSession.Settings.Prescript, ScriptSession.GetDataContextSwitch(CurrentItem)); var parameters = new object[] { scriptSession, contextScript, ScriptItem[ScriptItemFieldNames.Script] }; var runner = new ScriptRunner(ExecuteInternal, parameters, false); Monitor.Start("ScriptExecution", "PowerShellRunner", runner.Run); HttpContext.Current.Session[Monitor.JobHandle.ToString()] = scriptSession; }