/// <summary> /// Builds the action content /// </summary> /// <param name="actionRenderer">Action Renderer</param> /// <param name="actionNode">Action Node</param> /// <param name="data">Dialog data</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Action content</returns> private async Task <string> BuildActionContent(ActionRendererDispatcher actionRenderer, ActionNode actionNode, ExportDialogData data, FlexFieldObject flexFieldObject, IActionStepRenderer stepRenderer) { if (actionRenderer == null) { return(string.Empty); } return(await actionRenderer.BuildActionElement(actionNode, data, _project, _errorCollection, flexFieldObject, _exportSettings, stepRenderer)); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="flexFieldObject">Flex Field to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject) { ActionNode actionNode = data.Action; if (actionNode == null) { return(null); } ActionRendererDispatcher actionRenderer = GetActionRenderForNode(actionNode); ExportDialogDataChild nextStep = null; if (data.Children != null) { if (actionRenderer != null) { nextStep = actionRenderer.GetNextStep(data.Children); } else { nextStep = data.Children.FirstOrDefault(); } } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction); if (!_renderers.ContainsKey(template.RenderingEngine)) { throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ActionNode", template.RenderingEngine.ToString())); } IActionStepRenderer stepRenderer = _renderers[template.RenderingEngine]; stepRenderer.ResetStepRenderingValues(); string oldContext = _errorCollection.CurrentErrorContext; _errorCollection.CurrentErrorContext = _localizer["ErrorContextAction", _actionTranslator.TranslateActionType((ActionType)actionNode.ActionType)]; try { string actionContent = await BuildActionContent(actionRenderer, actionNode, data, flexFieldObject, stepRenderer); return(await stepRenderer.RenderDialogStep(template, data, nextStep, flexFieldObject, actionContent)); } catch (Exception ex) { _errorCollection.AddException(ex); return(new ExportDialogStepRenderResult { StepCode = "<<ERROR_RENDERING_ACTION>>" }); } finally { _errorCollection.CurrentErrorContext = oldContext; } }
/// <summary> /// Builds a parent text preview for the a dialog step /// </summary> /// <param name="child">Child node</param> /// <param name="parent">Parent</param> /// <param name="flexFieldObject">Flex Field to which the dialog belongs</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Parent text preview for the dialog step</returns> public async Task <string> BuildParentTextPreview(ExportDialogData child, ExportDialogData parent, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection) { ActionNode actionNode = parent.Action; if (actionNode == null) { return(null); } ActionRendererDispatcher actionRenderer = GetActionRenderForNode(actionNode); if (actionRenderer == null) { return(string.Empty); } return(await actionRenderer.BuildPreviewText(actionNode, flexFieldObject, errorCollection, child, parent)); }