// 20130329 // running the StopAction script after timeout expired internal bool InterruptOnTimeoutExpiration(WizardRunCmdletBase cmdlet, Wizard wizard) { // 20130712 bool interrupt = false; DateTime nowDate = DateTime.Now; if (!((nowDate - cmdlet.StartDate).TotalSeconds > Preferences.Timeout / 1000)) { return(interrupt); } cmdlet.WriteVerbose( cmdlet, "Timout expired. Running the StopAction scriptblock"); cmdlet.RunWizardStopScriptBlocks(cmdlet, wizard, wizard.StopActionParameters, false); cmdlet.WriteVerbose( cmdlet, "outputting the wizard"); if (Quiet) { cmdlet.WriteObject(cmdlet, false); return(interrupt); } else { cmdlet.WriteError(cmdlet, "Timeout expired", "TimeoutExpired", ErrorCategory.OperationTimeout, true); } interrupt = true; return(interrupt); }
public static void InvokeWizard(WizardRunCmdletBase cmdlet) { cmdlet.WriteVerbose( cmdlet, "Getting the wizard"); Wizard wzd = cmdlet.GetWizard(cmdlet.Name); if (null == wzd) { cmdlet.WriteError(cmdlet, "Couldn't get the wizard you asked for", "NoSuchWizard", ErrorCategory.InvalidArgument, true); } else { cmdlet.WriteVerbose( cmdlet, "The wizard has been obtained from the collection"); // publish the wizard as a global variable WizardCollection.CurrentWizard = wzd; cmdlet.WriteInfo(cmdlet, "the current wizard is '" + WizardCollection.CurrentWizard.Name + "'"); #region commented // try { // // System.Management.Automation.Runspaces.Runspace.DefaultRunspace.SessionStateProxy.GetVariable(".SessionStateProxy.PSVariable.Set( // "Wizard", // wzd); // //// testRunSpace.SessionStateProxy.SetVariable( //// variableName, //// variableValue); //// result = true; // } // catch (Exception eWizardVariable) { // // cmdlet.WriteError( // cmdlet, // eWizardVariable.Message, // "VariablePublishingFailed", // ErrorCategory.InvalidOperation, // true); // } #endregion commented if (null != cmdlet.Directions && 0 < cmdlet.DirectionsDictionaries.Count) { cmdlet.WriteVerbose(cmdlet, "Preparing step directions"); PrepareStepDirections(cmdlet, wzd); } // scriptblocks' parameters if (null != cmdlet.ParametersDictionaries && 0 < cmdlet.ParametersDictionaries.Count) { cmdlet.WriteVerbose(cmdlet, "Preparing step parameters"); PrepareStepParameters(cmdlet, wzd); } // 20130508 // temporary cmdlet.WriteInfo(cmdlet, "running Wizard StartAction scriptblocks"); cmdlet.WriteInfo(cmdlet, "parameters: " + cmdlet.ConvertObjectArrayToString(wzd.StartActionParameters)); cmdlet.RunWizardStartScriptBlocks(cmdlet, wzd, wzd.StartActionParameters); cmdlet.WriteVerbose(cmdlet, "running Wizard in the automated mode"); cmdlet.WriteInfo(cmdlet, "working in unattended mode"); cmdlet.RunWizardInAutomaticMode(cmdlet, wzd); if (cmdlet.Quiet) { cmdlet.WriteObject(cmdlet, true); } else { cmdlet.WriteObject(cmdlet, wzd); } } }
// 20130329 // running the StopAction script after timeout expired internal bool InterruptOnTimeoutExpiration(WizardRunCmdletBase cmdlet, Wizard wizard) { // 20130712 bool interrupt = false; DateTime nowDate = DateTime.Now; if (!((nowDate - cmdlet.StartDate).TotalSeconds > Preferences.Timeout/1000)) return interrupt; cmdlet.WriteVerbose( cmdlet, "Timout expired. Running the StopAction scriptblock"); cmdlet.RunWizardStopScriptBlocks(cmdlet, wizard, wizard.StopActionParameters, false); cmdlet.WriteVerbose( cmdlet, "outputting the wizard"); if (Quiet) { cmdlet.WriteObject(cmdlet, false); return interrupt; } else { cmdlet.WriteError(cmdlet, "Timeout expired", "TimeoutExpired", ErrorCategory.OperationTimeout, true); } interrupt = true; return interrupt; }
// 20130329 // running the StopAction script after timeout expired internal void InterruptOnTimeoutExpiration(WizardRunCmdletBase cmdlet, Wizard wizard) { System.DateTime nowDate = System.DateTime.Now; if ((nowDate - cmdlet.StartDate).TotalSeconds > (Preferences.Timeout / 1000)) { cmdlet.WriteVerbose( cmdlet, "Timout expired. Running the StopAction scriptblock"); cmdlet.RunWizardStopScriptBlocks(cmdlet, wizard, wizard.StopActionParameters); cmdlet.WriteVerbose( cmdlet, "outputting the wizard"); if (this.Quiet) { cmdlet.WriteObject(cmdlet, false); return; } else { cmdlet.WriteError(cmdlet, "Timeout expired", "TimeoutExpired", ErrorCategory.OperationTimeout, true); } } }
public static void InvokeWizard(WizardRunCmdletBase cmdlet) { Wizard wzd = cmdlet.GetWizard(cmdlet.Name); if (null == wzd) { cmdlet.WriteError(cmdlet, "Couldn't get the wizard you asked for", "NoSuchWizard", ErrorCategory.InvalidArgument, true); } else { // publish the wizard as a global variable WizardCollection.CurrentWizard = wzd; #region commented // try { // // System.Management.Automation.Runspaces.Runspace.DefaultRunspace.SessionStateProxy.GetVariable(".SessionStateProxy.PSVariable.Set( // "Wizard", // wzd); // //// testRunSpace.SessionStateProxy.SetVariable( //// variableName, //// variableValue); //// result = true; // } // catch (Exception eWizardVariable) { // // cmdlet.WriteError( // cmdlet, // eWizardVariable.Message, // "VariablePublishingFailed", // ErrorCategory.InvalidOperation, // true); // } #endregion commented // 20130322 //wzd.Automatic = cmdlet.Automatic; //wzd.ForwardDirection = cmdlet.ForwardDirection; // 20130322 if (null != cmdlet.Directions && 0 < cmdlet.DirectionsDictionaries.Count) { PrepareStepDirections(cmdlet, wzd); } // scriptblocks' parameters if (null != cmdlet.ParametersDictionaries && 0 < cmdlet.ParametersDictionaries.Count) { PrepareStepParameters(cmdlet, wzd); } cmdlet.WriteVerbose(cmdlet, "running Wizard StartAction scriptblocks"); // 20130318 //cmdlet.RunWizardStartScriptBlocks(cmdlet, wzd); // 20130325 //cmdlet.RunWizardStartScriptBlocks(cmdlet, wzd, null); cmdlet.RunWizardStartScriptBlocks(cmdlet, wzd, wzd.StartActionParameters); cmdlet.WriteVerbose(cmdlet, "running Wizard in the automated mode"); cmdlet.RunWizardInAutomaticMode(cmdlet, wzd); if (cmdlet.Quiet) { cmdlet.WriteObject(cmdlet, true); } else { cmdlet.WriteObject(cmdlet, wzd); } } }
public static void InvokeWizard(WizardRunCmdletBase cmdlet) { cmdlet.WriteVerbose( cmdlet, "Getting the wizard"); Wizard wzd = cmdlet.GetWizard(cmdlet.Name); if (null == wzd) { cmdlet.WriteError(cmdlet, "Couldn't get the wizard you asked for", "NoSuchWizard", ErrorCategory.InvalidArgument, true); } else { cmdlet.WriteVerbose( cmdlet, "The wizard has been obtained from the collection"); // publish the wizard as a global variable WizardCollection.CurrentWizard = wzd; cmdlet.WriteInfo(cmdlet, "the current wizard is '" + WizardCollection.CurrentWizard.Name + "'"); #region commented // try { // // System.Management.Automation.Runspaces.Runspace.DefaultRunspace.SessionStateProxy.GetVariable(".SessionStateProxy.PSVariable.Set( // "Wizard", // wzd); // //// testRunSpace.SessionStateProxy.SetVariable( //// variableName, //// variableValue); //// result = true; // } // catch (Exception eWizardVariable) { // // cmdlet.WriteError( // cmdlet, // eWizardVariable.Message, // "VariablePublishingFailed", // ErrorCategory.InvalidOperation, // true); // } #endregion commented if (null != cmdlet.Directions && 0 < cmdlet.DirectionsDictionaries.Count) { cmdlet.WriteVerbose(cmdlet, "Preparing step directions"); PrepareStepDirections(cmdlet, wzd); } // scriptblocks' parameters if (null != cmdlet.ParametersDictionaries && 0 < cmdlet.ParametersDictionaries.Count) { cmdlet.WriteVerbose(cmdlet, "Preparing step parameters"); PrepareStepParameters(cmdlet, wzd); } // 20130508 // temporary cmdlet.WriteInfo(cmdlet, "running Wizard StartAction scriptblocks"); cmdlet.WriteInfo(cmdlet, "parameters: " + cmdlet.ConvertObjectArrayToString(wzd.StartActionParameters)); cmdlet.RunWizardStartScriptBlocks(cmdlet, wzd, wzd.StartActionParameters); cmdlet.WriteVerbose(cmdlet, "running Wizard in the automated mode"); cmdlet.WriteInfo(cmdlet, "working in unattended mode"); cmdlet.RunWizardInAutomaticMode(cmdlet, wzd); if (cmdlet.Quiet) { cmdlet.WriteObject(cmdlet, true); } else { cmdlet.WriteObject(cmdlet, wzd); } } }