private void AddSettingsFilter(ColumnSettingsData settings, EntitySchemaQuery esq)
        {
            IEntitySchemaQueryFilterItem filterItem = settings.FilterData?.BuildEsqFilter(
                settings.FilterData.RootSchemaName, UserConnection);

            if (filterItem != null)
            {
                esq.Filters.Add(filterItem);
            }
        }
        /// <summary>
        /// Gets the forecast column settings data from forecast column.
        /// </summary>
        /// <param name="userConnection">User connection instance.</param>
        /// <param name="column">Forecast column.</param>
        /// <returns>Column settings data</returns>
        public ColumnSettingsData GetForecastColumnSettingsData(UserConnection userConnection,
                                                                ForecastColumn column)
        {
            column.CheckArgumentNull(nameof(column));
            if (column.Settings.IsNullOrWhiteSpace())
            {
                return(null);
            }
            ColumnSettingsData settings = FillSettings(userConnection, column);

            return(settings);
        }
        private decimal CalcValue(ColumnSettingsData settings, decimal value)
        {
            string operand = settings.PercentOperand;

            if (operand.IsNotNullOrEmpty() && value != 0)
            {
                if (decimal.TryParse(operand, out var decimalValue))
                {
                    value = value / 100 * decimalValue;
                }
            }
            return(value);
        }
        private string GetEntityInCellColumnPath(ColumnSettingsData settings)
        {
            var refColumn = ForecastSheet.GetEntityReferenceColumn(UserConnection);

            if (refColumn == null)
            {
                string message = $"Reference column by schema name {ReferenceSchemaName} not found.";
                _log.Error(message);
                throw new ItemNotFoundException(message);
            }
            var    referenceParts = GetReferenceParts(settings.ReferenceColumnName);
            string columnPath     = $"{referenceParts.EntityPath}" +
                                    $"=[{EntityForecastSchema.Name}:{refColumn.Name}:{referenceParts.ColumnPath}]";

            return(columnPath);
        }
Example #5
0
        private string GetEntityInCellColumnPath(ColumnSettingsData settings)
        {
            var refColumn = EntityForecastSchema.Columns.FirstOrDefault(c =>
                                                                        c.ReferenceSchema?.Name == ReferenceSchemaName && !c.IsInherited);

            if (refColumn == null)
            {
                string message = $"Reference column by schema name {ReferenceSchemaName} not found.";
                _log.Error(message);
                throw new ArgumentNullException(message);
            }
            var    referenceParts = GetReferenceParts(settings.ReferenceColumnName);
            string columnPath     = $"{referenceParts.EntityPath}" +
                                    $"=[{EntityForecastSchema.Name}:{refColumn.Name}:{referenceParts.ColumnPath}]";

            return(columnPath);
        }
        protected virtual ColumnSettingsData FillSettings(UserConnection userConnection, ForecastColumn column)
        {
            ColumnSetting deserialized = Json.Deserialize <ColumnSetting>(column.Settings);

            Core.Entities.EntitySchema schema   = userConnection.EntitySchemaManager.GetInstanceByUId(deserialized.SourceUId);
            ColumnSettingsData         settings = new ColumnSettingsData {
                SourceEntityName    = schema.Name,
                ReferenceColumnName = deserialized.RefColumnPath ?? GetColumnName(schema, deserialized.RefColumnId),
                PeriodColumnName    = deserialized.PeriodColumnPath ?? GetColumnName(schema, deserialized.PeriodColumnId),
                FuncColumnName      = deserialized.FuncColumnPath ?? GetColumnName(schema, deserialized.FuncColumnId),
                FuncCode            = deserialized.FuncCode,
                PercentOperand      = deserialized.PercentOperand,
                FilterData          = deserialized.FilterData.IsNotNullOrEmpty() ?
                                      Json.Deserialize <Filters>(deserialized.FilterData) : null
            };

            return(settings);
        }