private IEnumerable <TableCell> CalcSummaryCells(Guid forecastId, TreeTableDataItem record) { var summaryCells = PrepareSummaryCells(record); foreach (var column in ForecastColumns) { if (IsFormulaColumn(column)) { CalcFormulaColumnSummary(column, record.ColumnValues, summaryCells); } else { TableCell summaryCell = GetSummaryCell(summaryCells, column); summaryCell.Value = CalcColumnSummary(record.ColumnValues, column, FunctionConstants.Sum); } } if (ForecastColumns.Any(IsFormulaColumn)) { FormulaSummaryCalculator.CalcFormulaSummary(new FormulaSummaryParams { ForecastId = forecastId, Rows = new [] { new TreeTableDataItem { ColumnValues = summaryCells } }, FormulaResolver = (setting => setting.SummaryValue) }); } return(summaryCells); }
private List <TableCell> PrepareSummaryCells(TreeTableDataItem record) { var summaryCells = new List <TableCell>(); ForecastColumns.ForEach(column => { summaryCells.Add(new TableCell { Id = column.Id, ColumnCode = FormSummaryColumnCode(column), GroupCode = SummaryCode, RecordId = record.RecordId }); }); return(summaryCells); }
private void FillColumnValues(ICollection <TableColumn> columns, Row row, TreeTableDataItem item) { foreach (TableColumn column in columns) { foreach (TableColumn child in column.Children) { var cell = row.Cells .FirstOrDefault(a => a.PeriodId.Equals(column.Id) && a.ColumnId.Equals(child.Id)); var tableCell = new TableCell { ColumnCode = child.Code + "_" + column.Code, GroupCode = column.Id.ToString(), Id = child.Id, RecordId = row.Id }; if (cell != null) { tableCell.Value = (double)cell.Value; } item.ColumnValues.Add(tableCell); } } }
private ForecastSummaryResponse ProcessGetForecastSummary(ForecastSummaryRequestData requestData) { var response = new ForecastSummaryResponse(); try { var sheet = SheetRepository.GetSheet(requestData.ForecastId); var summaryCells = ForecastSummaryProvider.GetSummary(sheet, new FilterConfig { PeriodIds = requestData.Periods }); var record = new TreeTableDataItem { ColumnValues = summaryCells.ToList() }; if (UserConnection.GetIsFeatureEnabled("ForecastSummaryFormula")) { SummaryColumnCalculator.ApplySummaryData(UserConnection, requestData.ForecastId, new [] { record }); } response.Summary = ConvertCellsToSummary(record.ColumnValues); } catch (Exception ex) { response.Exception = ex; } return(response); }