Exemple #1
0
        /// <summary>
        /// Builds a single condition element
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="condition">Current Condition</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">FlexField to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition Build Result</returns>
        private async Task <string> BuildSingleConditionElement(GoNorthProject project, ParsedConditionData condition, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ConditionType conditionType = (ConditionType)condition.ConditionType;

            if (!_elementRenderes.ContainsKey(conditionType))
            {
                errorCollection.AddDialogUnknownConditionTypeError(condition.ConditionType);
                return(string.Empty);
            }

            string oldContext = errorCollection.CurrentErrorContext;

            errorCollection.CurrentErrorContext = _localizer["ErrorContextCondition", _conditionTranslator.TranslateConditionType(conditionType)];
            try
            {
                return(await _elementRenderes[conditionType].BuildSingleConditionElement(condition, project, errorCollection, flexFieldObject, exportSettings));
            }
            catch (Exception ex)
            {
                errorCollection.AddException(ex);
                return("<<ERROR_RENDERING_CONDITION>>");
            }
            finally
            {
                errorCollection.CurrentErrorContext = oldContext;
            }
        }
        /// <summary>
        /// Builds a condition name
        /// </summary>
        /// <param name="conditionElements">Condition elements</param>
        /// <returns>Condition name</returns>
        private string BuildConditionName(string conditionElements)
        {
            List <ParsedConditionData> parsedConditionData = ConditionParsingUtil.ParseConditionElements(conditionElements);

            return(string.Join(",", parsedConditionData.Select(c => _conditionTranslator.TranslateConditionType((ConditionType)c.ConditionType))));
        }