public AssistantResponse Speak(string text, Platform targetPlatform = Platform.All) { OutputObjects.Add(new OutputObject { TargetPlatform = targetPlatform, Type = OutputType.Text, Value = text }); return(this); }
public AssistantResponse Play(string url, Platform targetPlatform = Platform.All) { OutputObjects.Add(new OutputObject { TargetPlatform = targetPlatform, Type = OutputType.Url, Value = url }); return(this); }
public AssistantResponse Break(int second, Platform targetPlatform = Platform.All) { if (second == 0 || second > 10) { throw new Exception("Break time must be set between 1 and 10 seconds."); } OutputObjects.Add(new OutputObject { TargetPlatform = targetPlatform, Type = OutputType.Break, BreakTime = second }); return(this); }
/// <summary> /// Ejecuta un script de PowerShell /// </summary> internal void Process() { // Ejecuta el script try { using (PowerShell instance = PowerShell.Create()) { Collection <PSObject> outputItems; // Añade el script a PowerShell instance.AddScript(Script); // Añade los parámetros de entrada if (InputParameters != null) { foreach (KeyValuePair <string, object> parameter in InputParameters) { instance.AddParameter(parameter.Key, parameter.Value); } } // Llama a la ejecución de PowerShell outputItems = instance.Invoke(); // Guarda los valores de salida foreach (PSObject outputItem in outputItems) { OutputObjects.Add(outputItem.BaseObject); } // Guarda los errores if (instance.Streams.Error.Count > 0) { foreach (ErrorRecord error in instance.Streams.Error) { Errors.Add(error.ToString()); } } } } catch (Exception exception) { Errors.Add(exception.Message); } // Llama al evento de fin de proceso EndExecute?.Invoke(this, EventArgs.Empty); }