Exemple #1
0
        public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
        {
            var userQuery = Database.Query <UserQueryEntity>().SingleOrDefault(a => a.Guid == Guid.Parse(suffix));

            using (CurrentEntityConverter.SetCurrentEntity(context.Entity))
            {
                var         request     = UserQueryLogic.ToQueryRequest(userQuery);
                ResultTable resultTable = DynamicQueryManager.Current.ExecuteQuery(request);
                var         dataTable   = resultTable.ToDataTable();
                return(dataTable);
            }
        }
Exemple #2
0
        public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
        {
            var userChart = Database.Query <UserChartEntity>().SingleOrDefault(a => a.Guid == Guid.Parse(suffix));

            using (CurrentEntityConverter.SetCurrentEntity(context.Entity))
            {
                var         chartRequest = UserChartLogic.ToChartRequest(userChart);
                ResultTable result       = ChartLogic.ExecuteChartAsync(chartRequest, CancellationToken.None).Result;
                var         tokens       = chartRequest.Columns.Where(a => a.Token != null).ToList();

                if (chartRequest.GroupResults && tokens.Count(a => a.IsGroupKey.Value) == 2 && tokens.Count(a => !a.IsGroupKey.Value) == 1)
                {
                    var firstKeyIndex  = tokens.FindIndex(a => a.IsGroupKey.Value);
                    var secondKeyIndex = tokens.FindIndex(firstKeyIndex + 1, a => a.IsGroupKey.Value);
                    var valueIndex     = tokens.FindIndex(a => !a.IsGroupKey.Value);
                    return(result.ToDataTablePivot(secondKeyIndex, firstKeyIndex, valueIndex));
                }
                else
                {
                    return(result.ToDataTable());
                }
            }
        }
Exemple #3
0
        public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext ctx)
        {
            MethodInfo mi = GetMethod(ctx.Template, suffix);

            object result;

            try
            {
                result = mi.Invoke(ctx.SystemWordTemplate, null);
            }
            catch (TargetInvocationException e)
            {
                e.InnerException.PreserveStackTrace();

                throw e.InnerException;
            }

            if (!(result is Data.DataTable))
            {
                throw new InvalidOperationException($"Method '{suffix}' on '{ctx.SystemWordTemplate.GetType().Name}' did not return a DataTable");
            }

            return((Data.DataTable)result);
        }
Exemple #4
0
        public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
        {
            var userChart = Database.Query <UserChartEntity>().SingleOrDefault(a => a.Guid == Guid.Parse(suffix));

            using (CurrentEntityConverter.SetCurrentEntity(context.Entity))
            {
                var         chartRequest = UserChartLogic.ToChartRequest(userChart);
                ResultTable result       = ChartLogic.ExecuteChartAsync(chartRequest, CancellationToken.None).Result;
                var         tokens       = chartRequest.Columns.Select(a => a.Token).NotNull().ToList();

                //TODO: Too specific. Will be better if controlled by some parameters.
                if (chartRequest.HasAggregates() && tokens.Count(a => !(a.Token is AggregateToken)) == 2 && tokens.Count(a => a.Token is AggregateToken) == 1)
                {
                    var firstKeyIndex  = tokens.FindIndex(a => !(a.Token is AggregateToken));
                    var secondKeyIndex = tokens.FindIndex(firstKeyIndex + 1, a => !(a.Token is AggregateToken));
                    var valueIndex     = tokens.FindIndex(a => a.Token is AggregateToken);
                    return(result.ToDataTablePivot(secondKeyIndex, firstKeyIndex, valueIndex));
                }
                else
                {
                    return(result.ToDataTable());
                }
            }
        }
Exemple #5
0
 public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
 {
     return(GetDataTable(suffix, context.Entity !));
 }