/********* 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); }
private void Startup(Frame frame) { // replace log file so that is one frame to one log ReplaceLogFile(frame.IDPage, frame.ID); OptionItems oi = new OptionItems(frame.Options); // ------ Frame css ------ ChangeCss(oi.GetSingle("css")); // ------ Title ------ headerTitle.Text = frame.Title; if (!oi.GetSingle("title_is_hidden").Equals("true")) // hide title if value is true, else will always show the title { lbTitle.InnerText = frame.Title; TitleStyle(oi.GetList("title_style")); // title style // ------ Load Javascript ------ SetTitlePosition(); // loads javascript that controls title position } else { lbTitleContainer.Style.Add("display", "none"); } // ------ Border ------ // Border is defined in draw_frames class, sets the border of the panel outside de iframe. // ------ Table ------ int rowsCount = -1; // file name is here to be used outside the try catch string filePath = string.Empty; try { /* * default filter => * * default filter from XML is this way: * default_filter = "select SUBESTADO, count as qtd group by SUBESTADO"; * * default filder from sqlite is a query * default_filder = "select * from xpto" * */ LoadData ld = new LoadData { PageId = frame.IDPage, Datafile = oi.GetSingle("datafile"), Datatable = oi.GetList("datatable"), DefaultFilter = oi.GetSingle("default_filter"), FileName = oi.GetSingle("xml_file"), MasterFilterId = oi.GetSingle("master_filter").Trim() }; // set virtual folder lbDownload.HRef = ld.GetVirtualFilePath(); // set real folder filePath = ld.GetFilePath(); mGridView.DataSource = ld.GetData(); rowsCount = ((DataView)mGridView.DataSource).Count; } catch (Exception ex) { loging.Error("table", "load data", ex.Message, ViewState["log_file"].ToString()); /** Hide when error **/ LabelCountVisible(true); LabelDownloadVisible(true); FiltersVisibility(true); } if (rowsCount >= 0) { try { /********** Css Style **********/ mGridView.CssClass = "gridview"; mGridView.AlternatingRowStyle.CssClass = "alt"; mGridView.PagerStyle.CssClass = "pgr"; /********** Sort **********/ GridView_Sort(oi.GetSingle("table_sort").Trim().ToLower().Equals("false")); /********** Paging **********/ GridView_Paging(oi.GetSingle("table_paging"), rowsCount); /********** GridviewHeader **********/ GridView_Header(oi.GetSingle("table_show_header").Trim().ToLower().Equals("false")); /********** GridView Width **********/ GridView_Width(oi.GetSingle("table_width")); /********** Filter **********/ FiltersVisibility(oi.GetSingle("filters_visible").Trim().ToLower().Equals("false")); /********** Color Markers **********/ AddColorMarkers(oi.GetList("color_markers")); //AddColorMarkers(new List<string> { }); /********** Rows Count **********/ LoadLabelCount(rowsCount); LabelCountVisible(oi.GetSingle("label_count_visible").Trim().ToLower().Equals("false")); /********** Show Xml File lastupd **********/ LabelFileLastUpdVisible(oi.GetSingle("show_xml_file_lastupd").Trim().ToLower().Equals("true")); LoadLabelFileLastUpd(filePath); /********** Downloads **********/ LabelDownloadVisible(oi.GetSingle("label_download_visible").Trim().ToLower().Equals("false")); /********** Table Color Alarms **********/ TableColorAlarms(oi.GetList("warning_text"), oi.GetList("critical_text"), oi.GetSingle("warning_color"), oi.GetSingle("critical_color")); /********** Hyperlinks **********/ CreateHyperlink(frame.IDPage, oi.GetList("hyperlinks"), oi.GetSingle("hyperlink_color")); } catch (Exception ex) { loging.Error("table", "load options", ex.Message, ViewState["log_file"].ToString()); } mGridView.DataBind(); // no fim de correr todas as opções faz o databind... } }