public static string GetFiltersData() { var jss = new JavaScriptSerializer(); var fc = new FilterCollection(); AddRangeSafe(fc, AdHocContext.CurrentReportSet.Filters); var filtersData = new FiltersData(); filtersData.Initialize(fc, AdHocContext.CurrentReportSet); return(jss.Serialize(filtersData)); }
public static string GetActiveAdditionalFilters(List <string> wsArgs) { var reportName = wsArgs[0]; var reportSet = AdHocSettings.AdHocConfig.LoadFilteredReportSet(Utility.ReportWebNameToNormal(reportName)); var isDrillDown = false; string masterName = null; string ddValue = null; if (wsArgs != null) { if (wsArgs.Count > 2) { isDrillDown = true; masterName = wsArgs[1]; ddValue = wsArgs[2]; // not used yet, but reserved for future } } var jss = new JavaScriptSerializer(); var fc = new FilterCollection(); if (reportSet != null && reportSet.Filters.Count > 0) { AddRangeSafe(fc, reportSet.Filters); } // get stored additional filters var ownFilters = AdditionalFiltersStorage.GetAdditionalFiltersFromSession(reportName); AddRangeSafe(fc, ownFilters); // process drilldown data if (reportSet != null && isDrillDown) { var masterFilters = AdditionalFiltersStorage.GetAdditionalFiltersAllFromSession(masterName); foreach (Filter filter in masterFilters) { foreach (JoinedTable joinedTable in reportSet.JoinedTables) { var tableName = joinedTable.TableName; if (filter.dbColumn.Table.FullName == tableName) { AddFilterSafe(fc, filter); } // check linked columns if (!string.IsNullOrEmpty(filter.LinkedColumns)) { var linkedColumns = filter.LinkedColumns.Split(','); foreach (var linkedColumn in linkedColumns) { if (linkedColumn.IndexOf('.') >= 0) { var linkedColumnTable = linkedColumn.Substring(0, linkedColumn.LastIndexOf('.')); if (linkedColumnTable == tableName) { var newFilter = (Filter)filter.Clone(); newFilter.Column = linkedColumn; AddFilterSafe(fc, newFilter); } } } } } } if (ddValue != null && reportSet.DrillDownKey != null) { var ddKey = reportSet.DrillDownKey; var ddFilter = new AdditionalFilter { Operator = OperatorTypes.Equals, Value = ddValue, Column = ddKey }; AddFilterSafe(fc, ddFilter); } } foreach (Filter f in fc) { f.Parameter = true; } var filtersData = new FiltersData(); if (reportSet != null) { filtersData.Initialize(fc, reportSet); } return(jss.Serialize(filtersData)); }