コード例 #1
0
ファイル: table.aspx.cs プロジェクト: nelsonjma/ntec
    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...
        }
    }