///<inheritdoc /> public ForecastData GetData(Guid forecastId, FilterConfig filterConfig) { filterConfig.CheckArgumentNull(nameof(filterConfig)); filterConfig.RecordIds.CheckArgumentNull(nameof(filterConfig.RecordIds)); var sheet = SheetRepository.GetSheet(forecastId); var recordIds = filterConfig.RecordIds; IEnumerable <Period> periods = PeriodRepository.GetForecastPeriods(filterConfig.PeriodIds, sheet.PeriodTypeId); var periodIds = periods.Select(p => p.Id); var allCells = EntityInForecastCellRepository.GetCellsByRecords(sheet, periodIds, recordIds); var columns = GetColumnInfos(forecastId, periods); List <Row> rows = new List <Row>(); recordIds.ForEach(recordId => { IEnumerable <Cell> cells = allCells.Where(c => c.EntityId == recordId); rows.Add(new Row { Id = recordId, Hierarchy = new [] { new HierarchyItem() }, Cells = cells }); }); return(new ForecastData() { Rows = rows, Columns = columns }); }
private ForecastData InnerGetData(Guid forecastId, IEnumerable <Guid> periodIds, PageableConfig pageableConfig) { forecastId.CheckArgumentEmpty(nameof(forecastId)); Sheet sheet = SheetRepository.GetSheet(forecastId); IEnumerable <Period> periods = PeriodRepository.GetForecastPeriods(periodIds, sheet.PeriodTypeId); IEnumerable <ColumnInfo> columns = GetColumnInfos(forecastId, periods); IEnumerable <HierarchyRow> hierarchyRows = ForecastHierarchyRowDataRepository .GetHierarchyRows(sheet, sheet.Setting?.Hierarchy, pageableConfig); List <Row> rows = new List <Row>(); var maxLevel = sheet.Setting?.Hierarchy?.Count() ?? 0; IEnumerable <Cell> allCells = new List <Cell>(); var hierarchy = new List <HierarchyItem>(); if ((pageableConfig.HierarchyLevel == maxLevel) && (hierarchyRows.Any())) { allCells = EntityInForecastCellRepository.GetCellsByRecords(sheet, periods.Select(e => e.Id), hierarchyRows.Select(r => r.RecordId)); hierarchy.Add(new HierarchyItem { Id = Guid.NewGuid(), Level = maxLevel }); } hierarchyRows.ForEach(hr => { IEnumerable <Cell> cells = allCells.Where(c => c.EntityId == hr.RecordId); rows.Add(new Row { Id = hr.RecordId, Value = hr.Value, Hierarchy = hierarchy, Cells = cells }); }); return(new ForecastData { Columns = columns, Rows = rows }); }