コード例 #1
0
        private static HtmlBuilder Parts(
            this HtmlBuilder hb, Context context, SiteSettings ss, Aggregations aggregations)
        {
            var allowedColumns = Permissions.AllowedColumns(ss);

            aggregations.AggregationCollection
            .Where(o => o.Target.IsNullOrEmpty() || allowedColumns.Contains(o.Target))
            .Where(o => o.GroupBy == "[NotGroupBy]" || allowedColumns.Contains(o.GroupBy))
            .Where(o => o.Data.Count > 0)
            .ForEach(aggregation =>
            {
                var html    = string.Empty;
                var groupBy = ss.GetColumn(
                    context: context,
                    columnName: aggregation.GroupBy);
                var targetColumn = ss.GetColumn(
                    context: context,
                    columnName: aggregation.Target);
                var linkedLabelHash = LinkedLabelHash(
                    context: context,
                    ss: ss,
                    groupBy: groupBy,
                    aggregation: aggregation);
                if (aggregation.Data.Count > 0)
                {
                    hb.GroupBy(
                        context: context,
                        groupBy: groupBy,
                        targetColumn: targetColumn,
                        aggregation: aggregation);
                }
                aggregation.Data.OrderByDescending(o => o.Value).ForEach(data =>
                                                                         hb.LabelValue(
                                                                             label: groupBy != null
                                ? Label(
                                                                                 context: context,
                                                                                 groupBy: groupBy,
                                                                                 selectedValue: data.Key,
                                                                                 linkedLabelHash: linkedLabelHash)
                                : string.Empty,
                                                                             value: (targetColumn != null
                                ? targetColumn.Display(
                                                                                         context: context,
                                                                                         value: data.Value)
                                : data.Value.ToString()) +
                                                                             (aggregation.Type != Aggregation.Types.Count
                                        ? targetColumn?.Unit
                                        : string.Empty),
                                                                             bold: Bold(
                                                                                 groupBy: groupBy,
                                                                                 key: data.Key,
                                                                                 linkedLabelHash: linkedLabelHash),
                                                                             attributes: new HtmlAttributes()
                                                                             .Attributes(ss, aggregation, groupBy, data.Key)));
            });
            return(hb);
        }