/********* Filter *********/ //private void BuildFilters(string xmlFile, List<string> listColummns, string pageId, string filterTitle, bool isVertical) private void BuildFilters(LoadData ld, List<string> listColummns, string filterTitle, bool isVertical) { Table t = new Table(); TableRow tr = new TableRow(); string pageId = ld.PageId.ToString(); // transform the ids into hash ids to send the column to memory or to get them from memory string filterTitleHash = Generic.GetHash(filterTitle); string pageIdHash = Generic.GetHash(pageId); bool isDataFileChanged = IsDataFileChanged(ld.GetFilePath(), pageIdHash, filterTitleHash); bool areFiltersNull = AreFiltersNull(listColummns, pageIdHash, filterTitleHash); if (isDataFileChanged || areFiltersNull) // if first time that the page loads or xml file has changed { DataView dv = new DataView(); try { dv = ld.GetData(); } catch (Exception ex) { loging.Error("filter", "load xml file", ex.Message, ViewState["log_file"].ToString()); } if (dv.Count > 0) { foreach (string column in listColummns) { try { string columnHash = Generic.GetHash(column); // ---------------------------- combobox_filter cbf = new combobox_filter(pageId, filterTitle, column, dv); // generate combobox filter_sessions.SetFilterItem(pageIdHash, filterTitleHash, columnHash, cbf); // send the columns to memory tr.Cells.Add(cbf.GetComboBox()); // set vertical filter alignment if (isVertical) { t.Rows.Add(tr); tr = new TableRow(); } } catch (Exception ex) { loging.Error("filter", "create column", ex.Message, ViewState["log_file"].ToString()); } } } } else // else will load the data from session variables to have faster access. { foreach (string column in listColummns) { try { string columnHash = Generic.GetHash(column); // ---------------------------- combobox_filter cbf = (combobox_filter)filter_sessions.GetFilterItem(pageIdHash, filterTitleHash, columnHash); // get the columns from memory tr.Cells.Add(cbf.GetComboBox()); // set vertical filter alignment if (isVertical) { t.Rows.Add(tr); tr = new TableRow(); } } catch (Exception ex) { loging.Error("filter", "load column", ex.Message, ViewState["log_file"].ToString()); } } } // by default is horizontal if (!isVertical) { t.Rows.Add(tr); } filterPanel.Controls.Add(t); }
public static void SetFilterItem(string pageIdHash, string filterTitleHash, string titleHash, combobox_filter cbf) { HttpContext.Current.Session["filter_item_" + pageIdHash + "_" + filterTitleHash + "_" + titleHash] = cbf; }