Esempio n. 1
0
        private static XlsxStyle GetStyle(ADOTabularColumn col)
        {
            // check for special case formatting
            switch (col.DataType.Name.ToLower())
            {
            case "long":
            case "double":
            case "decimal":
                if (!string.IsNullOrEmpty(col.FormatString))
                {
                    return(XlsxStyle.Default.With(new XlsxNumberFormat(col.FormatString)));
                }
                break;

            case "datetime":
                if (col.FormatString == "G")
                {
                    return(XlsxStyle.Default.With(XlsxNumberFormat.ShortDateTime));
                }
                if (!string.IsNullOrEmpty(col.FormatString))
                {
                    return(XlsxStyle.Default.With(new XlsxNumberFormat(col.FormatString)));
                }

                // default to short datetime
                return(XlsxStyle.Default.With(XlsxNumberFormat.ShortDateTime));

            case "string":
                var stringAlignment = new XlsxAlignment(vertical: Vertical.Top, wrapText: true);
                var stringStyle     = XlsxStyle.Default.With(stringAlignment).With(XlsxNumberFormat.Text);
                return(stringStyle);
            }
            // if nothing else matches return the default style
            return(XlsxStyle.Default);
        }
Esempio n. 2
0
        public void ColumnTooltipOpening(TreeViewColumn column)
        {
            if (column == null)
            {
                return;
            }

            if (column?.Column.GetType() != typeof(ADOTabularColumn))
            {
                return;
            }
            ADOTabularColumn col = (ADOTabularColumn)column?.Column;

            if (col.ObjectType != ADOTabularObjectType.Column)
            {
                return;
            }
            // TODO - make an option for the sample size
            if (_globalOptions == null)
            {
                return;
            }
            if (_globalOptions.ShowTooltipSampleData && !column.HasSampleData)
            {
                column.GetSampleDataAsync(Connection, 10);
            }
            if (_globalOptions.ShowTooltipBasicStats && !column.HasBasicStats)
            {
                column.UpdateBasicStatsAsync(Connection);
            }
        }
Esempio n. 3
0
 public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren) : base(getChildren)
 {
     _column        = column;
     Description    = column.Description;
     DataTypeName   = column.DataTypeName;
     MetadataImage  = column.MetadataImage;
     FormatString   = column.FormatString;
     MinValue       = column.MinValue;
     MaxValue       = column.MaxValue;
     DistinctValues = column.DistinctValueCount;
 }
        private string ExpandDependentMeasure(ADOTabularColumn column, IEventAggregator eventAggregator, bool ignoreNonUniqueMeasureNames)
        {
            string measureName = column.Name;
            //var model = Connection.Database.Models.BaseModel;
            var model         = column.Table.Model;
            var modelMeasures = (from t in model.Tables
                                 from m in t.Measures
                                 select m).ToList();
            var distinctColumns = (from t in model.Tables
                                   from c in t.Columns
                                   where c.ColumnType == ADOTabularColumnType.Column
                                   select c.Name).Distinct().ToList();

            var finalMeasure = modelMeasures.First(m => m.Name == measureName);

            var resultExpression = finalMeasure.Expression;

            bool foundDependentMeasures;

            do
            {
                foundDependentMeasures = false;
                foreach (var modelMeasure in modelMeasures)
                {
                    //string daxMeasureName = "[" + modelMeasure.Name + "]";
                    //string newExpression = resultExpression.Replace(daxMeasureName, " CALCULATE ( " + modelMeasure.Expression + " )");
                    Regex daxMeasureRegex = new Regex(@"[^\w']?\[" + modelMeasure.Name + "]");

                    string newExpression = daxMeasureRegex.Replace(resultExpression, " CALCULATE ( " + modelMeasure.Expression + " )");

                    if (newExpression != resultExpression)
                    {
                        resultExpression       = newExpression;
                        foundDependentMeasures = true;
                        if (!ignoreNonUniqueMeasureNames)
                        {
                            if (distinctColumns.Contains(modelMeasure.Name))
                            {
                                // todo - prompt user to see whether to continue
                                var msg = "The measure name: '" + modelMeasure.Name + "' is also used as a column name in one or more of the tables in this model";
                                eventAggregator.PublishOnUIThread(new OutputMessage(MessageType.Warning, msg));
                                throw new InvalidOperationException(msg);
                            }
                        }
                    }
                }
            } while (foundDependentMeasures);

            return(resultExpression);
        }
Esempio n. 5
0
 public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator) : base(getChildren, options, eventAggregator)
 {
     _eventAggregator = eventAggregator;
     _sampleData      = new List <string>();
     Column           = column;
     _column          = column;
     Options          = options;
     Description      = column.Description;
     DataTypeName     = column.DataTypeName;
     MetadataImage    = column.MetadataImage;
     FormatString     = column.FormatString;
     MinValue         = column.MinValue;
     MaxValue         = column.MaxValue;
     DistinctValues   = column.DistinctValues;
 }
Esempio n. 6
0
        public static IEnumerable <FilterableTreeViewItem> TreeViewColumnChildren(this ADOTabularColumn column, IADOTabularObject table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
        {
            var lst  = new List <FilterableTreeViewItem>();
            var hier = column as ADOTabularHierarchy;

            if (hier != null)
            {
                foreach (var lvl in hier.Levels)
                {
                    lst.Add(new TreeViewColumn(lvl, options, eventAggregator, metadataPane));
                }
            }
            var kpi = column as ADOTabularKpi;

            if (kpi != null)
            {
                foreach (var comp in kpi.Components)
                {
                    lst.Add(new TreeViewColumn(comp, options, eventAggregator, metadataPane));
                }
            }
            return(lst);
        }
Esempio n. 7
0
        public static IEnumerable <FilterableTreeViewItem> TreeViewColumnChildren(this ADOTabularColumn column)
        {
            var lst  = new List <FilterableTreeViewItem>();
            var hier = column as ADOTabularHierarchy;

            if (hier != null)
            {
                foreach (var lvl in hier.Levels)
                {
                    lst.Add(new TreeViewColumn(lvl));
                }
            }
            var kpi = column as ADOTabularKpi;

            if (kpi != null)
            {
                foreach (var comp in kpi.Components)
                {
                    lst.Add(new TreeViewColumn(comp));
                }
            }
            return(lst);
        }
Esempio n. 8
0
 public ADOTabularLevel(ADOTabularColumn column)
 {
     Column = column;
 }
Esempio n. 9
0
 private string ExpandDependentMeasure(ADOTabularColumn column)
 {
     return(ExpandDependentMeasure(column, false));
 }
Esempio n. 10
0
 public static FilterableTreeViewItem Create(ADOTabularColumn col)
 {
     //TODO create folder hierarchy if DisplayFolder is not empty string
     // else return raw column
     return(null);
 }
Esempio n. 11
0
 private string ExpandDependentMeasure(ADOTabularColumn column, IEventAggregator eventAggregator)
 {
     return(ExpandDependentMeasure(column, eventAggregator, false));
 }