public void PreExecuteReportSet(ReportSet reportSet) { var reportName = Utility.GetWebReportName(reportSet); var additionalFilters = AdditionalFiltersStorage.GetAdditionalFiltersFromSession(reportName); RsDuncan.AddRangeSafe(reportSet.Filters, additionalFilters); PopulateFiltersDescription(reportSet); }
public static string ApplyFiltersFiltersNew(List <string> wsArgs) { var jss = new JavaScriptSerializer(); if (wsArgs.Count <= 0) { return(jss.Serialize(new ResultStatus("Data not passed"))); } var obj = jss.DeserializeObject(wsArgs[0]); if (obj != null) { var newFilters = WebServiceRequestProcessor.DeserializeFilters(obj); var reportName = wsArgs[1]; var reportSet = AdHocSettings.AdHocConfig.LoadFilteredReportSet(Utility.ReportWebNameToNormal(reportName)); try { if (reportSet.ReportName != AdHocContext.CurrentReportSet.ReportName) { AdHocContext.CurrentReportSet = AdHocSettings.AdHocConfig.LoadFilteredReportSet(Utility.ReportWebNameToNormal(reportName)); } } catch {} var newCollection = new FilterCollection(); var newAdditionalCollection = new FilterCollection(); foreach (DeserializedFilter deserializedFilter in newFilters) { var uid = deserializedFilter.Uid; var columnName = deserializedFilter.Column; if (columnName == null) { throw new NullReferenceException("Column property cannot be null"); } Filter selectedFilter = null; if (reportSet != null) { foreach (Filter filter in reportSet.Filters) { if (filter.Column == columnName) { selectedFilter = filter; } } } if (selectedFilter == null) { // additional filter selectedFilter = new AdditionalFilter(); selectedFilter.Column = columnName; selectedFilter.Description = deserializedFilter.Description; selectedFilter.Not = deserializedFilter.Not; selectedFilter.Operator = FilterData.GetOperatorType(deserializedFilter.Operator); selectedFilter.LinkedColumns = deserializedFilter.LinkedColumns; if (!string.IsNullOrEmpty(deserializedFilter.OperatorFriendlyName)) { string operatorFriendlyName = deserializedFilter.OperatorFriendlyName; if (selectedFilter.dbColumn != null) { var filterOperators = ResponseServer.GetOperatorList(selectedFilter.dbColumn.SqlType, selectedFilter.dbColumn.Table.Type == TableType.StoredProcedure, selectedFilter.dbColumn.FullName); foreach (ListItemCollection opGroup in filterOperators.Values) { foreach (ListItem li in opGroup) { OperatorTypes opType; if ((li.Text == operatorFriendlyName || li.Value == operatorFriendlyName) && OperatorTypes.TryParse(li.Value, true, out opType)) { selectedFilter.Operator = opType; } } } } if (operatorFriendlyName.ToLower() == "begins with") { selectedFilter.Operator = OperatorTypes.BeginsWith; } } } // set filter values var multipleValues = (deserializedFilter.Values.Length > 1 || FilterData.GetControlType(selectedFilter.Operator) == 2); if (!multipleValues) { selectedFilter.Value = deserializedFilter.Values[0]; if (selectedFilter.Value == null) { selectedFilter.Value = ""; } if (selectedFilter.Value is int) { selectedFilter.Operator = OperatorTypes.Equals; } } else { selectedFilter.Values = deserializedFilter.Values; } newAdditionalCollection.Add(selectedFilter); } if (reportSet != null) { reportSet.Filters.Clear(); reportSet.Filters = newCollection; RsDuncan.AddRangeSafe(reportSet.Filters, newAdditionalCollection); } RsDuncan.AddRangeSafe(AdHocContext.CurrentReportSet.Filters, newAdditionalCollection); AdditionalFiltersStorage.StoreAdditionalFiltersInSession(reportName, newAdditionalCollection); if (reportSet != null && reportSet.Summary != null) { string targetReportName = null; foreach (Field field in reportSet.Summary.Fields) { if (!string.IsNullOrEmpty(field.TargetReport)) { targetReportName = field.TargetReport; } } if (targetReportName != null) { reportSet.Summary.Filters.Clear(); reportSet.Summary.Filters = newCollection; RsDuncan.AddRangeSafe(reportSet.Summary.Filters, newAdditionalCollection); AdditionalFiltersStorage.StoreAdditionalFiltersInSession(targetReportName, newAdditionalCollection); } } } return(jss.Serialize(new ResultStatus("OK"))); }