public static RemoteGroupingResult Run(IEnumerable<IRemoteGroup> flatGroups, int groupCount, SummaryInfo[] totalSummary, SummaryInfo[] groupSummary) {
            var accessor = new RemoteGroupAccessor();

            List<Group> hierGroups = null;

            if(groupCount > 0) {
                hierGroups = new GroupHelper<IRemoteGroup>(accessor).Group(
                    flatGroups,
                    Enumerable.Range(0, groupCount).Select(i => new GroupingInfo { Selector = "K" + i }).ToArray()
                );
            }

            IEnumerable dataToAggregate = hierGroups;
            if(dataToAggregate == null)
                dataToAggregate = flatGroups;

            var transformedTotalSummary = TransformSummary(totalSummary, "T");
            var transformedGroupSummary = TransformSummary(groupSummary, "G");

            transformedTotalSummary.Add(new SummaryInfo { SummaryType = "remoteCount" });

            var totals = new AggregateCalculator<IRemoteGroup>(dataToAggregate, accessor, transformedTotalSummary, transformedGroupSummary).Run();
            var totalCount = (int)totals.Last();

            totals = totals.Take(totals.Length - 1).ToArray();
            if(totals.Length < 1)
                totals = null;

            return new RemoteGroupingResult {
                Groups = hierGroups,
                Totals = totals,
                TotalCount = totalCount
            };
        }
Beispiel #2
0
        public static RemoteGroupingResult Run(IEnumerable <AnonType> flatGroups, int groupCount, ContosoRetail.SharedKernel.DataAccess.DataLoader.SummaryInfo[] totalSummary, ContosoRetail.SharedKernel.DataAccess.DataLoader.SummaryInfo[] groupSummary)
        {
            var accessor = new AnonTypeAccessor();

            var markup = new RemoteGroupTypeMarkup(
                groupCount,
                totalSummary != null ? totalSummary.Length : 0,
                groupSummary != null ? groupSummary.Length : 0
                );

            List <Group> hierGroups = null;

            if (groupCount > 0)
            {
                hierGroups = new GroupHelper <AnonType>(accessor).Group(
                    flatGroups,
                    Enumerable.Range(0, groupCount).Select(i => new ContosoRetail.SharedKernel.DataAccess.DataLoader.GroupingInfo {
                    Selector = AnonType.ITEM_PREFIX + (RemoteGroupTypeMarkup.KeysStartIndex + i)
                }).ToArray()
                    );
            }

            IEnumerable dataToAggregate = hierGroups;

            if (dataToAggregate == null)
            {
                dataToAggregate = flatGroups;
            }

            var transformedTotalSummary = TransformSummary(totalSummary, markup.TotalSummaryStartIndex);
            var transformedGroupSummary = TransformSummary(groupSummary, markup.GroupSummaryStartIndex);

            transformedTotalSummary.Add(new SummaryInfo {
                SummaryType = "remoteCount"
            });

            var totals     = new AggregateCalculator <AnonType>(dataToAggregate, accessor, transformedTotalSummary, transformedGroupSummary).Run();
            var totalCount = (int)totals.Last();

            totals = totals.Take(totals.Length - 1).ToArray();
            if (totals.Length < 1)
            {
                totals = null;
            }

            return(new RemoteGroupingResult
            {
                Groups = hierGroups,
                Totals = totals,
                TotalCount = totalCount
            });
        }
Beispiel #3
0
        public static RemoteGroupingResult Run(Type sourceItemType, IEnumerable <AnonType> flatGroups, int groupCount, SummaryInfo[] totalSummary, SummaryInfo[] groupSummary)
        {
            List <Group> hierGroups = null;

            if (groupCount > 0)
            {
                hierGroups = new GroupHelper <AnonType>(AnonTypeAccessor.Instance).Group(
                    flatGroups,
                    Enumerable.Range(0, groupCount).Select(i => new GroupingInfo {
                    Selector = AnonType.IndexToField(1 + i)
                }).ToArray()
                    );
            }

            IEnumerable dataToAggregate = hierGroups;

            if (dataToAggregate == null)
            {
                dataToAggregate = flatGroups;
            }

            var fieldIndex = 1 + groupCount;
            var transformedTotalSummary = TransformSummary(totalSummary, ref fieldIndex);
            var transformedGroupSummary = TransformSummary(groupSummary, ref fieldIndex);

            transformedTotalSummary = transformedTotalSummary ?? new List <SummaryInfo>();
            transformedTotalSummary.Add(new SummaryInfo {
                SummaryType = AggregateName.REMOTE_COUNT
            });

            var sumFix     = new SumFix(sourceItemType, totalSummary, groupSummary);
            var totals     = new AggregateCalculator <AnonType>(dataToAggregate, AnonTypeAccessor.Instance, transformedTotalSummary, transformedGroupSummary, sumFix).Run();
            var totalCount = (int)totals.Last();

            totals = totals.Take(totals.Length - 1).ToArray();
            if (totals.Length < 1)
            {
                totals = null;
            }

            return(new RemoteGroupingResult {
                Groups = hierGroups,
                Totals = totals,
                TotalCount = totalCount
            });
        }
Beispiel #4
0
        public static RemoteGroupingResult Run(IEnumerable <IRemoteGroup> flatGroups, int groupCount, SummaryInfo[] totalSummary, SummaryInfo[] groupSummary)
        {
            var accessor = new RemoteGroupAccessor();

            List <Group> hierGroups = null;

            if (groupCount > 0)
            {
                hierGroups = new GroupHelper <IRemoteGroup>(accessor).Group(
                    flatGroups,
                    Enumerable.Range(0, groupCount).Select(i => new GroupingInfo {
                    Selector = "K" + i
                }).ToArray()
                    );
            }

            IEnumerable dataToAggregate = hierGroups;

            if (dataToAggregate == null)
            {
                dataToAggregate = flatGroups;
            }

            var transformedTotalSummary = TransformSummary(totalSummary, "T");
            var transformedGroupSummary = TransformSummary(groupSummary, "G");

            transformedTotalSummary.Add(new SummaryInfo {
                SummaryType = "remoteCount"
            });

            var totals     = new AggregateCalculator <IRemoteGroup>(dataToAggregate, accessor, transformedTotalSummary, transformedGroupSummary).Run();
            var totalCount = (int)totals.Last();

            totals = totals.Take(totals.Length - 1).ToArray();
            if (totals.Length < 1)
            {
                totals = null;
            }

            return(new RemoteGroupingResult {
                Groups = hierGroups,
                Totals = totals,
                TotalCount = totalCount
            });
        }