Ejemplo n.º 1
0
        public ForecastDataResponse GetForecastData(string forecastId, string periods, string offset, string count,
                                                    string lastRow, string hierarchyRows, string filterValue)
        {
            var response = new ForecastDataResponse();

            try {
                var periodIds       = ConvertStringIdentifiersToGuidList(periods);
                var hierarchyRowsId = ConvertStringIdentifiersToGuidList(hierarchyRows);
                int rowCount        = int.TryParse(count, out rowCount) ? rowCount : -1;
                int rowOffset       = int.TryParse(offset, out rowOffset) ? rowOffset : 0;
                int hierarchyLevel  = hierarchyRowsId.Count();
                var pageableConfig  = new PageableConfig()
                {
                    RowCount           = rowCount,
                    RowsOffset         = rowOffset,
                    LastValue          = lastRow,
                    HierarchyRowsId    = hierarchyRowsId,
                    HierarchyLevel     = hierarchyLevel,
                    PrimaryFilterValue = HttpUtility.UrlDecode(filterValue)
                };
                var data = ForecastProvider.GetData(new Guid(forecastId), periodIds, pageableConfig);
                response.Columns    = ForecastDataMapper.GetMapTableColumns(data);
                response.DataSource = ForecastDataMapper.GetMapTreeTableDataItems(data, response.Columns);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        private ForecastDataResponse ProcessGetForecastData(ForecastRequestData requestData)
        {
            var response = new ForecastDataResponse();

            try {
                var periodIds       = requestData.Periods;
                var hierarchyRowsId = requestData.HierarchyRows;
                int rowOffset       = int.TryParse(requestData.Offset, out rowOffset) ? rowOffset : 0;
                int hierarchyLevel  = hierarchyRowsId.Count();
                var pageableConfig  = new PageableConfig()
                {
                    RowCount           = requestData.Count,
                    RowsOffset         = rowOffset,
                    LastValue          = requestData.LastRow,
                    HierarchyRowsId    = hierarchyRowsId,
                    HierarchyLevel     = hierarchyLevel,
                    PrimaryFilterValue = HttpUtility.UrlDecode(requestData.FilterValue)
                };
                var data    = ForecastProvider.GetData(requestData.ForecastId, periodIds, pageableConfig);
                var columns = ForecastDataMapper.GetMapTableColumns(data);
                response.DataSource = ForecastDataMapper.GetMapTreeTableDataItems(data, columns);
                if (UserConnection.GetIsFeatureEnabled("ForecastSummaryFormula"))
                {
                    SummaryColumnCalculator.ApplySummaryColumns(UserConnection, columns);
                    SummaryColumnCalculator.ApplySummaryData(UserConnection, requestData.ForecastId,
                                                             response.DataSource);
                }
                FilterHiddenColumns(columns);
                response.Columns = columns;
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Ejemplo n.º 3
0
        public ForecastDataResponse GetCellValuesByRecords(Guid forecastId, Guid[] periods, Guid[] records)
        {
            var response = new ForecastDataResponse();
            var data     = ForecastProvider.GetData(forecastId, new FilterConfig {
                PeriodIds = periods,
                RecordIds = records
            });

            response.Columns    = ForecastDataMapper.GetMapTableColumns(data);
            response.DataSource = ForecastDataMapper.GetMapTreeTableDataItems(data, response.Columns);
            return(response);
        }
        public ForecastDataResponse GetCellValuesByGroupRecords(Guid forecastId, Guid[] periods,
                                                                GroupRecordsItem[] groupsCollection)
        {
            var response = new ForecastDataResponse();

            if (!UserConnection.GetIsFeatureEnabled("ForecastGroupSummary") || !groupsCollection.Any())
            {
                response.DataSource = new TreeTableDataItem[0];
                return(response);
            }
            var sheet = SheetRepository.GetSheet(forecastId);
            var sheetHierarchyList = sheet.GetHierarchyItems();
            var allRows            = new List <TreeTableDataItem>();

            try {
                groupsCollection.ForEach(groupItem => {
                    int level = groupItem.ParentIds?.Length ?? 0;
                    HierarchySettingItem hierarchyItem = sheetHierarchyList.FirstOrDefault(item => item.Level == level);
                    if (hierarchyItem == null)
                    {
                        string message = $"Could not get hierarchy item by level {level}. ForecastId: {forecastId}";
                        _log.Error(message);
                        throw new Exception(message);
                    }
                    IEnumerable <HierarchyFilterItem> hierarchyFilterItems =
                        sheet.FormHierarchyFilter(groupItem.ParentIds);
                    var cells = ForecastSummaryProvider.GetGroupsSummary(sheet, new FilterConfig()
                    {
                        PeriodIds       = periods,
                        RecordIds       = groupItem.RecordIds,
                        Hierarchy       = hierarchyFilterItems,
                        GroupColumnPath = hierarchyItem?.ColumnPath
                    });
                    var rows = ForecastDataMapper.GetMapTreeTableDataItems(cells, groupItem.ParentIds);
                    rows.ForEach(row => row.IsGroup = true);
                    allRows.AddRange(rows);
                });
                response.DataSource = allRows;
                if (UserConnection.GetIsFeatureEnabled("ForecastSummaryFormula"))
                {
                    SummaryColumnCalculator.ApplySummaryData(UserConnection, forecastId, response.DataSource);
                }
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ForecastDataResponse GetCellValuesByRecords(Guid forecastId, Guid[] periods, Guid[] records)
        {
            var response = new ForecastDataResponse();

            if (!records.Any())
            {
                response.DataSource = new TreeTableDataItem[0];
                return(response);
            }
            var data = ForecastProvider.GetData(forecastId, new FilterConfig {
                PeriodIds = periods,
                RecordIds = records
            });
            var columns = ForecastDataMapper.GetMapTableColumns(data);

            response.DataSource = ForecastDataMapper.GetMapTreeTableDataItems(data, columns);
            if (UserConnection.GetIsFeatureEnabled("ForecastSummaryFormula"))
            {
                SummaryColumnCalculator.ApplySummaryData(UserConnection, forecastId, response.DataSource);
            }
            return(response);
        }