Esempio n. 1
0
        /// <summary>
        /// Parses a dialog for exporting
        /// </summary>
        /// <param name="projectId">Project Id</param>
        /// <param name="objectId">Object Id</param>
        /// <param name="dialog">Dialog to parse</param>
        /// <param name="errorCollection">Error Collection to send errors to</param>
        /// <returns>Parsed dialog</returns>
        public async Task <ExportDialogData> GenerateFunctions(string projectId, string objectId, ExportDialogData dialog, ExportPlaceholderErrorCollection errorCollection)
        {
            DialogFunctionGenerationConditionCollection dialogFunctionGenerationConditions = await _dialogFunctionGenerationConditionProvider.GetDialogFunctionGenerationConditions(projectId);

            HashSet <string>         usedDialogSteps   = new HashSet <string>();
            Queue <ExportDialogData> dialogDataToQueue = new Queue <ExportDialogData>();

            dialogDataToQueue.Enqueue(dialog);

            while (dialogDataToQueue.Any())
            {
                ExportDialogData curData = dialogDataToQueue.Dequeue();

                await CheckAndBuildFunctionForDialogStep(curData, dialogFunctionGenerationConditions, projectId, objectId, errorCollection);

                foreach (ExportDialogDataChild curChild in curData.Children)
                {
                    if (!usedDialogSteps.Contains(curChild.Child.Id))
                    {
                        dialogDataToQueue.Enqueue(curChild.Child);
                        usedDialogSteps.Add(curChild.Child.Id);
                    }
                }
            }

            return(dialog);
        }
Esempio n. 2
0
        public async Task <IActionResult> GetDialogFunctionGenerationConditions()
        {
            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            DialogFunctionGenerationConditionCollection dialogFunctionGenerationConditionCollection = await _dialogFunctionGenerationConditionProvider.GetDialogFunctionGenerationConditions(project.Id);

            return(Ok(dialogFunctionGenerationConditionCollection));
        }
Esempio n. 3
0
        public async Task <IActionResult> SaveDialogFunctionGenerationConditions([FromBody] DialogFunctionGenerationConditionCollection functionGenerationConditionCollection)
        {
            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            await this.SetModifiedData(_userManager, functionGenerationConditionCollection);

            await _dialogFunctionDbAccess.SaveDialogFunctionGenerationCondition(project.Id, functionGenerationConditionCollection);

            await _timelineService.AddTimelineEntry(TimelineEvent.ExportDialogFunctionGenerationConditionsUpdated);

            return(Ok());
        }
Esempio n. 4
0
        /// <summary>
        /// Checks and builds the function for a dialog step
        /// </summary>
        /// <param name="dialogData">Dialog data for the step</param>
        /// <param name="dialogFunctionGenerationConditions">Dialog Function Generation Conditions</param>
        /// <param name="projectId">Project Id</param>
        /// <param name="objectId">Object Id</param>
        /// <param name="errorCollection">Error Collection to send errors to</param>
        private async Task CheckAndBuildFunctionForDialogStep(ExportDialogData dialogData, DialogFunctionGenerationConditionCollection dialogFunctionGenerationConditions, string projectId, string objectId, ExportPlaceholderErrorCollection errorCollection)
        {
            if (EvaluateConditions(dialogData, dialogFunctionGenerationConditions.PreventGenerationRules, errorCollection))
            {
                return;
            }

            if (EvaluateConditions(dialogData, dialogFunctionGenerationConditions.GenerateRules, errorCollection))
            {
                dialogData.DialogStepFunctionName = await _functionNameGenerator.GetNewDialogStepFunction(GetNodeType(dialogData, errorCollection), projectId, objectId, dialogData.Id);
            }
        }