public virtual void SetFiltersByStorageValues(StorageValues storageValues, MainPageUrlBuilder urlBuilder) { var filterValues = GetFilterValues(); foreach (var item in storageValues.GetStorageNames()) { var columnFilterType = storageValues.GetStorageFilterType(item); if (columnFilterType == null || columnFilterType == ColumnFilterType.None) { continue; } var values = storageValues.GetStorageValues(item); if (!filterValues.ContainsKey(item)) { filterValues[item] = new List <FilterItem>(); } else { filterValues[item].Clear(); } if (columnFilterType == ColumnFilterType.In || columnFilterType == ColumnFilterType.OutOf) { filterValues[item].AddRange(values.Select(r => new FilterItem(item, columnFilterType, new[] { r }))); } else { var filterItem = new FilterItem(item, columnFilterType, values); filterValues[item].Add(filterItem); } } for (int i = 0; i < storageValues.CountListValues; i++) { foreach (var item in storageValues.GetCircleStorageNames(i)) { var columnFilterType = storageValues.GetCircleStorageFilterType(item, i); if (columnFilterType == null || columnFilterType == ColumnFilterType.None) { continue; } var values = storageValues.GetCircleStorageValues(item, i); var filterItem = new FilterItem(item, columnFilterType, values); if (!filterValues.ContainsKey(item)) { filterValues[item] = new List <FilterItem>(); } else if (i == 0) { filterValues[item].Clear(); } filterValues[item].Add(filterItem); } } urlBuilder.SetFilter(TableName, filterValues); }
private void LoadFiltersState() { var sid = GetSidBytes(); // Loading user dependend filters state settings // In case there is no user setting apply default settings StorageValues storageValues = StorageValues.GetStorageValues(string.Format("{0}_{1}", Page.AppRelativeVirtualPath, ClientID), sid); if (storageValues != null) { foreach (ColumnFilterStorage storage in ColumnFilterStorages) { storageValues.SetStorage(storage); } } else { WebInitializer.Initialize(); foreach (ColumnFilterStorage storage in ColumnFilterStorages) { ColumnFilterType columnFilterType = (ColumnFilterType)(DataSetResourceManager.GetColumnExtProperty( dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_CONDITION) ?? ColumnFilterType.None); if (columnFilterType != ColumnFilterType.None) { if (!dataTable.Columns.Contains(storage.Name)) { continue; } object[] values = new object[2]; values[0] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_1) ?? null; values[1] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_2) ?? null; string codeField = (String)DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_CODE_FIELD); if (storage.IsRefBound && !string.IsNullOrEmpty(codeField)) { for (int i = 0; i < values.Length; i++) { if (values[i] != null) { DataTable table = (DataTable)storage.RefDataSource; QueryConditionList queryConditionList = new QueryConditionList(); QueryCondition queryCondition = new QueryCondition(codeField, ColumnFilterType.Equal, values[i], null); queryConditionList.Add(queryCondition); Type tableAdapterType = TableAdapterTools.GetTableAdapterType(table.GetType()); QueryGenerator queryGenerator; if (table.Columns.IndexOf("dateEnd") != -1 && table.Columns.IndexOf("dateStart") != -1) { Component adapter = HistoricalData.GetTableAdapterToHistoricalData("dateEnd", "dateStart", DateTime.Now, tableAdapterType, 0); queryGenerator = new QueryGenerator(adapter); } else { queryGenerator = new QueryGenerator(table); } queryGenerator.TopCount = 1; queryGenerator.Fill(table, queryConditionList); if (table.Rows.Count != 0) { values[i] = table.Rows[0][storage.ValueColumn]; } } } } storage.FilterType = columnFilterType; try { for (int i = 0; i != 2; i++) { if (values[i] != null) { storage.SetValue(i, Convert.ChangeType(values[i], storage.DataType)); } } } catch (InvalidCastException) { } } } } }
private void SetCurrentPlugin(IReportPlugin plugin, bool isRedirect) { webReportManager.Plugin = plugin; plugin.InitializeReportCulture(plugin.SupportCulture[0]); IWebReportPlugin webPlugin = plugin as IWebReportPlugin; if (webPlugin != null) { webPlugin.Page = Page; } swReport.RefreshSessionWorker(); if (webReportManager.Plugin != null) { CurrentPlugin = webReportManager.Plugin.GetType().FullName; if (isRedirect) { ((IWebReportPlugin)webReportManager.Plugin).DefaultValue = Request.QueryString["idrec"]; } webReportManager.Plugin.OnReportOpening(); } else { CurrentPlugin = ""; } webReportManager.SessionWorker = swReport.SessionWorker; if (!isRedirect) { StorageValues values = null; IWebReportPlugin webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; if (webReportPlugin != null && webReportPlugin.AllowSaveValuesConditions) { byte[] sid = new byte[] { }; switch (this.Context.User.Identity.AuthenticationType) { case "Windows": var windowsIdentity = (WindowsIdentity)this.Context.User.Identity; sid = new byte[windowsIdentity.User.BinaryLength]; windowsIdentity.User.GetBinaryForm(sid, 0); break; case "Forms": // note: Получение сида при идентификации по формам. sid = Encoding.Default.GetBytes(User.GetSID()); break; } if (sid != null && sid.Length > 0) { values = StorageValues.GetStorageValues(webReportManager.Plugin.GetType().FullName, sid); } if (values != null && values.CountListValues > 0) { _countModelFillConditions = values.CountListValues; } } if (values != null) { webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); } } else if (IsSubscription) { IWebReportPlugin webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; if (webReportPlugin != null) { tdTreeView.Visible = false; TreeView1.Visible = false; btnCreateReportKz.Visible = false; btnCreateReportRu.Visible = false; ImageCheckBox.Visible = false; btnSubscriptionsSaveParams.Visible = true; StorageValues values = null; values = (StorageValues)Session[Request.QueryString["idStorageValues"]]; if (values != null && values.CountListValues > 0) { _countModelFillConditions = values.CountListValues; } if (values != null) { webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); } } } EnsureWebConditionControls(); }