/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { int delaySeconds = SwitchHelper.GetScheduleSeconds(delay); string legString; switch (legs) { case CallLeg.A: legString = "aleg"; break; case CallLeg.B: legString = "bleg"; break; default: case CallLeg.Both: legString = "both"; break; } if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString)); } else { context.Actions.Add(new SwitchExecuteAction(CallID, "sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString)); } }
/// <summary> /// Starts recording the call to the specified file. /// </summary> /// <param name="path"> /// <para> /// Path to the recorded file. /// </para> /// <note> /// The file type must be <b>.wav</b>. Only WAV files are supported by NeonSwitch. /// </note> /// </param> /// <param name="limit">Optionally specifies the maximum length of the recording.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="path" /> is <c>null</c> or empty.</exception> /// <exception cref="ArgumentException">Thrown if the file type is not <b>.wav</b>.</exception> /// <remarks> /// <note> /// That the <paramref name="path" /> must specify the <b>.wav</b> file type. /// NeonSwitch only supports recording to WAV files. /// </note> /// <para> /// Call <see cref="RecordBegin" /> to begin a new recording (automatically stopping any /// recording already in progress). Use the <see cref="RecordPause" /> property to pause /// and restart recording and <see cref="RecordEnd" /> to end recording. /// </para> /// </remarks> public void RecordBegin(string path, TimeSpan?limit) { // Stop any existing recording. if (recordPath != null) { ActionRenderingContext.Execute(new RecordAction(this.CallID, false, path, null)); recordPath = null; } // Validate the parameters. if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path", "Cannot pass [path] as NULL or empty to [RecordBegin]."); } if (String.Compare(Path.GetExtension(path), ".wav", true) != 0) { throw new ArgumentException(string.Format("[RecordBegin] cannot record to [{0}] since it does have the [.wav] file extension.", path)); } // Start recording. recordPath = path; recordPaused = false; ActionRenderingContext.Execute(new RecordAction(this.CallID, true, path, limit)); }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (IsLowLevel) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction(Application, Data)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, Application, Data)); } } else { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("managed", Application + " " + Data)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, "managed", Application + " " + Data)); } } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (context.IsDialplan) { if (delaySeconds > 0) { context.Actions.Add(new SwitchExecuteAction("delay_echo", "{0}", delaySeconds)); } else { context.Actions.Add(new SwitchExecuteAction("echo", "{0}")); } } else { CheckCallID(); if (delaySeconds > 0) { context.Actions.Add(new SwitchExecuteAction(CallID, "delay_echo", "{0}", delaySeconds)); } else { context.Actions.Add(new SwitchExecuteAction(CallID, "echo", "{0}")); } } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var delaySeconds = SwitchHelper.GetScheduleSeconds(Delay); var legString = TransferBothLegs ? "-both" : "-bleg"; if (delaySeconds <= 0) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("transfer", "{0} {1} XML {2}", legString, extension, context)); } else { context.Actions.Add(new SwitchExecuteAction("uuid_transfer", "{0:D} {1} {2} XML {3}", CallID, legString, extension, DialplanContext)); } } else { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("sched_transfer", "+{0} {1} {2} XML {3}", delaySeconds, legString, extension, DialplanContext)); } else { context.Actions.Add(new SwitchExecuteAction("sched_transfer", "+{0} {1:D} {2} {3} XML {4}", delaySeconds, CallID, legString, extension, DialplanContext)); } } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if this action is executed outside of the context of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (!context.IsDialplan) { throw new NotSupportedException("[SleepAction] cannot be executed outside the context of a dialplan."); } if (duration <= TimeSpan.Zero) { return; // Nothing to do. } string sleepEatDigits; bool orgConsumeDTMF; if (!context.Variables.TryGetValue("sleep_eat_digits", out sleepEatDigits) || !bool.TryParse(sleepEatDigits, out orgConsumeDTMF)) { orgConsumeDTMF = false; } if (orgConsumeDTMF != this.consumeDTMF) { new SetVariableAction("sleep_eat_digits", this.consumeDTMF ? "true" : "false").Render(context); } context.Actions.Add(new SwitchExecuteAction("sleep", ((int)duration.TotalMilliseconds).ToString())); if (orgConsumeDTMF != this.consumeDTMF) { new SetVariableAction("sleep_eat_digits", orgConsumeDTMF ? "true" : "false").Render(context); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var reasonString = SwitchHelper.GetSwitchHangupReasonString(reason); int delaySeconds = SwitchHelper.GetScheduleSeconds(delay); if (context.IsDialplan) { if (delaySeconds <= 0) { context.Actions.Add(new SwitchExecuteAction("hangup", reasonString)); } else { context.Actions.Add(new SwitchExecuteAction("sched_hangup", "+{0} {1}", delaySeconds, reasonString)); } } else { CheckCallID(); if (delaySeconds <= 0) { context.Actions.Add(new SwitchExecuteAction(CallID, "hangup", reasonString)); } else { context.Actions.Add(new SwitchExecuteAction(CallID, "sched_hangup", "+{0} {1}", delaySeconds, reasonString)); } } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { string formattedUris; if (sipUris.Length == 1) { formattedUris = sipUris[0]; } else { var sb = new StringBuilder(); foreach (var uri in sipUris) { sb.AppendFormat("{0},", uri); } if (sb.Length > 0) { sb.Length--; } formattedUris = sb.ToString(); } if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("redirect", formattedUris)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, "redirect", formattedUris)); } }
/// <summary> /// Speaks the text passed using the current voice. /// </summary> /// <param name="text">The text to be spoken.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="text" /> is <c>null</c>.</exception> public void Speak(string text) { if (text == null) { throw new ArgumentNullException("text"); } ActionRenderingContext.Execute(new PlayAudioAction(CallID, AudioSource.Speech(Phrase.PhoneVoiceText(Voice, text)))); }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (!context.IsDialplan) { throw new NotSupportedException("[EventAction] is not supported outside of a dialplan. Use [Switch.SendEvent()] instead."); } base.Render(context); }
/// <summary> /// Plays an audio source until it is finished or until <see cref="Break" /> or /// <see cref="BreakAll" /> is called. /// </summary> /// <param name="source">The audio source.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="source" /> is <c>null</c>.</exception> public void PlayAudio(AudioSource source) { if (source == null) { throw new ArgumentNullException("source"); } ActionRenderingContext.Execute(new PlayAudioAction(CallID, source)); }
/// <summary> /// Synchronously executes a <see cref="SwitchAction" /> on the current call. /// </summary> /// <param name="action">The action to be executed.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="action" /> is <c>null</c>.</exception> public void Execute(SwitchAction action) { if (action == null) { throw new ArgumentNullException("action"); } ActionRenderingContext.Execute(action); }
//--------------------------------------------------------------------- // Static members /// <summary> /// Renders and then executes a set of actions. /// </summary> /// <param name="actions">The hig-level actions.</param> internal static void Execute(params SwitchAction[] actions) { var context = new ActionRenderingContext(false); foreach (var action in actions) { action.Render(context); } context.ExecuteActions(); }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (!context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction(hold ? "hold" : "unhold")); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction("uuid_hold", "{0}{1:D}", hold ? string.Empty : "off ", CallID)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("pre_answer")); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, "pre_answer")); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public virtual void Render(ActionRenderingContext context) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction(this.Application, this.Data)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, this.Application, this.Data)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("deflect", sipUri)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction("uuid_deflect", "{0:D} {1}", CallID, sipUri)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("break", all ? "all" : string.Empty)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction("uuid_break", "{0:D}{1}", CallID, all ? " all" : string.Empty)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (!context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("park")); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction("uuid_park", "{1:D}", CallID)); } }
/// <summary> /// Stops recording a call. /// </summary> /// <exception cref="InvalidOperationException">Thrown when no recording is in progress.</exception> public void RecordEnd() { if (recordPath == null) { throw new InvalidOperationException("No recording is in progress."); } ActionRenderingContext.Execute(new RecordAction(false, recordPath, null)); recordPath = null; recordPaused = false; }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var pauseString = pause ? "on" : "off"; if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("pause", "{{$Unique-ID}} {0}", pauseString)); } else { context.Actions.Add(new SwitchExecuteAction(CallID, "pause", pauseString)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var command = enable ? "start_dtmf_generate" : "stop_dtmf_generate"; if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction(command)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, command)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var intervalSeconds = SwitchHelper.GetScheduleSeconds(interval); if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("uuid_session_heartbeat", "${{Unique-ID}} {0}", intervalSeconds)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, "uuid_session_heartbeat", "{0}", intervalSeconds)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { string logLevelString = SwitchHelper.GetSwitchLogLevelString(level); if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("session_loglevel", logLevelString)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction(CallID, "session_loglevel", logLevelString)); } }
/// <summary> /// Speaks the formatted text passed using the current text-to-speech engine and voice. /// </summary> /// <param name="format">The format string.</param> /// <param name="args">The arguments.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="format" /> or <paramref name="args" /> is <c>null</c>.</exception> public void Speak(string format, params object[] args) { if (format == null) { throw new ArgumentNullException("format"); } if (args == null) { throw new ArgumentNullException("args"); } ActionRenderingContext.Execute(new PlayAudioAction(CallID, AudioSource.Speech(Phrase.PhoneVoiceText(Voice, format, args)))); }
/// <summary> /// Speaks the <see cref="Phrase" /> passed using the current voice if the phrase doesn't /// specify a voice. /// </summary> /// <param name="phrase">The phrase to be spoken.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="phrase" /> is <c>null</c>.</exception> public void Speak(Phrase phrase) { if (phrase == null) { throw new ArgumentNullException("phrase"); } if (phrase.Voice == null && this.Voice != null) { phrase = phrase.Clone(Voice); } ActionRenderingContext.Execute(new PlayAudioAction(CallID, AudioSource.Speech(phrase))); }
/// <summary> /// Plays an audio source until it is finished or until one of a set of DTMF /// digits is pressed or until <see cref="Break" /> or <see cref="BreakAll" /> /// is called. /// </summary> /// <param name="source">The audio source.</param> /// <param name="stopDtmf">The set of DTMF digits that will stop the operation (<see cref="Dtmf" />).</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="source" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="stopDtmf"/> includes an invalid DTMF digit.</exception> public void PlayAudio(AudioSource source, string stopDtmf) { if (source == null) { throw new ArgumentNullException("source"); } if (stopDtmf != null) { Dtmf.Validate(stopDtmf); } ActionRenderingContext.Execute(new PlayAudioAction(CallID, source) { StopDtmf = stopDtmf }); }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { if (!context.IsDialplan) { CheckCallID(); } // Always generate [unset] actions since we don't know what the // the initial state of the action variables are and the application // may wish to remove a pre-existing variable. if (value == null) { if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("unset", name)); } else { context.Actions.Add(new SwitchExecuteAction("uuid_setvar", "{0:D} {1}", CallID, name)); } return; } // When setting variable, check to see if the variable has already been // set to the same value. Render an action only if this is not the case. string currentValue; if (!context.Variables.TryGetValue(name, out currentValue) || currentValue != value) { context.Variables[name] = value; if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("set", "{0}={1}", name, value)); } else { context.Actions.Add(new SwitchExecuteAction("uuid_setvar", "{0:D} {1} {2}", CallID, name, value)); } } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { var expandedPath = Switch.ExpandFilePath(path); var limitString = string.Empty; if (start && limit.HasValue) { limitString = " " + SwitchHelper.GetScheduleSeconds(limit.Value).ToString(); } if (context.IsDialplan) { context.Actions.Add(new SwitchExecuteAction("uuid_record", "${{Unique-ID}} {0} '{1}'{2}", start ? "start" : "stop", limitString)); } else { CheckCallID(); context.Actions.Add(new SwitchExecuteAction("uuid_record", "{0} {1} '{2}'{3}", start ? "start" : "stop", limitString)); } }
/// <summary> /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" /> /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" /> /// collection. /// </summary> /// <param name="context">The action rendering context.</param> /// <remarks> /// <note> /// It is perfectly reasonable for an action to render no actions to the /// context or to render multiple actions based on its properties. /// </note> /// </remarks> public override void Render(ActionRenderingContext context) { string app; string args; if (context.IsDialplan) { app = "dump"; args = string.Empty; } else { CheckCallID(); app = "uuid_dump"; args = string.Format("{0:D}", CallID);; } context.Actions.Add(new SwitchExecuteAction(app, args)); }