public override void Execute()
        {
            DataSet   dataSet   = (DataSet)Model;
            DataRow   countRow  = dataSet.GetRow("Count");
            string    tableName = ViewBag.MetaData.Table.TableName;
            DataTable dataTable = dataSet.Tables[tableName];
            string    url       = dataSet.GetFieldValue <string>("URL", "DSelfURL");
            string    condition = dataSet.GetFieldValue <string>("Sort", "SqlCon");
            IEnumerable <IFieldInfoEx> fields   = ViewBag.MetaData.Table.TableList;
            NormalListData             pageData = (NormalListData)ViewBag.PageData;
            DataRow sortRow   = dataSet.GetRow("Sort");
            int     sortField = sortRow.GetValue <int>("SortField");

            WriteLiteral("\r\n");

            DefineSection("DefaultListHeader", () => {
                WriteLiteral("\r\n    <tr>\r\n");


                if (pageData.OperatorPosition == OperatorPosition.Left)
                {
                    WriteLiteral("            <th");

                    WriteLiteral(" class=\"text-center text-nowrap\"");

                    WriteLiteral(">\r\n                <div>");

                    Write(pageData.OperationCaption);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("        ");


                int index = 0;

                WriteLiteral("\r\n");


                foreach (IFieldInfoEx field in fields)
                {
                    WriteLiteral("            <th ");

                    Write(CreateHeadAttrs(field, index++, sortField, sortRow));

                    WriteLiteral(">\r\n                <div>");

                    Write(field.DisplayName);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("        ");

                if (pageData.OperatorPosition == OperatorPosition.Right)
                {
                    WriteLiteral("            <th");

                    WriteLiteral(" class=\"text-center text-nowrap\"");

                    WriteLiteral(">\r\n                <div>");

                    Write(pageData.OperationCaption);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("    </tr>\r\n");
            });

            DefineSection("DefaultListWidth", () => {
                WriteLiteral("\r\n");


                if (pageData.OperatorPosition == OperatorPosition.Left)
                {
                    WriteLiteral("        <col ");

                    Write(OperatorWidth(pageData.OperatorWidth));

                    WriteLiteral(" />\r\n");
                }

                WriteLiteral("    ");


                int index = 0;

                WriteLiteral("\r\n");


                foreach (IFieldInfoEx field in fields)
                {
                    WriteLiteral("        <col ");

                    Write(CreateColAttrs(field, index++, sortField));

                    WriteLiteral(" />\r\n");
                }

                WriteLiteral("    ");

                if (pageData.OperatorPosition == OperatorPosition.Right)
                {
                    WriteLiteral("        <col ");

                    Write(OperatorWidth(pageData.OperatorWidth));

                    WriteLiteral(" />\r\n");
                }
            });

            DefineSection("DefaultTabSheet", () => {
                WriteLiteral("\r\n");


                if (BootcssUtil.HasTabSheet(dataSet))
                {
                    WriteLiteral("        <ul");

                    WriteAttribute("class", Tuple.Create(" class=\"", 3750), Tuple.Create("\"", 3835)
                                   , Tuple.Create(Tuple.Create("", 3758), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("nav", BootcssUtil.GetTabClass(pageData.TabDisplayType))
                                                                                                                     , 3758), false)
                                   );

                    WriteLiteral(" role=\"tablist\"");

                    WriteLiteral(">\r\n");

                    WriteLiteral("            ");

                    Write(BootcssUtil.CreateTabSheets(dataSet));

                    WriteLiteral("\r\n        </ul>\r\n");
                }
            });

            Write(RenderSectionOrDefault("TabSheet", "DefaultTabSheet"));

            WriteLiteral("\r\n<table");

            WriteAttribute("class", Tuple.Create(" class=\"", 3992), Tuple.Create("\"", 4078)
                           , Tuple.Create(Tuple.Create("", 4000), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("list-table table", pageData.Display.TableDisplayClass())
                                                                                                             , 4000), false)
                           );

            WriteLiteral(">\r\n    <colgroup>\r\n");

            WriteLiteral("        ");

            Write(RenderSectionOrDefault("ListWidth", "DefaultListWidth"));

            WriteLiteral("\r\n    </colgroup>\r\n");


            if (pageData.ShowListHeader)
            {
                WriteLiteral("        <thead>\r\n");

                WriteLiteral("            ");

                Write(RenderSectionOrDefault("ListHeader", "DefaultListHeader"));

                WriteLiteral("\r\n        </thead>\r\n");
            }

            WriteLiteral("    <tbody");

            WriteLiteral(" id=\"pageList\"");

            WriteLiteral(" data-totalcount=\"");

            Write(countRow.GetString("TotalCount"));

            WriteLiteral("\"");

            WriteLiteral(" data-totalpage=\"");

            Write(countRow.GetString("TotalPage"));

            WriteLiteral("\"");

            WriteLiteral(" data-sort=\"");

            Write(sortField);

            WriteLiteral("\"");

            WriteLiteral(" data-order=\"");

            Write(sortRow.GetString("Order"));

            WriteLiteral("\"");

            WriteLiteral(" data-page=\"");

            Write(countRow.GetString("CurrentPage"));

            WriteLiteral("\"");

            WriteLiteral(" data-url=\"");

            Write(url);

            WriteLiteral("\"");

            WriteLiteral(" data-condition=\"");

            Write(condition);

            WriteLiteral("\"");

            WriteLiteral(" data-tab=\"");

            Write(HtmlUtil.GetSelectedTab(dataSet));

            WriteLiteral("\"");

            WriteLiteral(" data-source=\"");

            Write(dataSet.GetFieldValue <string>("Info", "Source"));

            WriteLiteral("\"");

            WriteLiteral(">\r\n");


            if (dataTable != null)
            {
                foreach (DataRow row in dataTable.Rows)
                {
                    string rowString = @RenderRow(row);


                    if (rowString != null)
                    {
                        Write(rowString);
                    }
                    else
                    {
                        WriteLiteral("                    <tr>\r\n");


                        if (pageData.OperatorPosition == OperatorPosition.Left)
                        {
                            WriteLiteral("                            <td");

                            WriteLiteral(" class=\"text-nowrap text-center\"");

                            WriteLiteral(">");

                            Write(BootcssUtil.CreateRowOperators(dataSet, row));

                            WriteLiteral("</td>\r\n");
                        }
                        WriteLiteral("\r\n");


                        foreach (IFieldInfoEx field in fields)
                        {
                            Tk5FieldInfoEx fieldInfo   = field.Convert <Tk5FieldInfoEx>();
                            string         fieldString = @RenderFieldItem(row, fieldInfo);


                            if (fieldString == null)
                            {
                                WriteLiteral("                                <td>");

                                Write(fieldInfo.DisplayValue(row));

                                WriteLiteral("</td>\r\n");
                            }
                            else
                            {
                                Write(fieldString);
                            }
                        }
                        WriteLiteral("\r\n");


                        if (pageData.OperatorPosition == OperatorPosition.Right)
                        {
                            WriteLiteral("                            <td");

                            WriteLiteral(" class=\"text-nowrap text-center\"");

                            WriteLiteral(">");

                            Write(BootcssUtil.CreateRowOperators(dataSet, row));

                            WriteLiteral("</td>\r\n");
                        }
                        WriteLiteral("\r\n                    </tr>\r\n");
                    }
                }
            }

            WriteLiteral("    </tbody>\r\n</table>\r\n");

            if (countRow.GetValue <int>("TotalCount") == 0)
            {
                WriteLiteral("    <div");

                WriteLiteral(" class=\"p30\"");

                WriteLiteral(">");

                Write(pageData.NoDataCaption);

                WriteLiteral("</div>\r\n");
            }
            else
            {
                if (@pageData.ShowPage)
                {
                    Write(RenderLayoutPartial("pagenumber.cshtml", Model));
                }
            }
        }
Esempio n. 2
0
        public override void Execute()
        {
            ObjectListModel model     = (ObjectListModel)Model;
            CountInfo       countRow  = model.Count;
            ListSortInfo    sortRow   = model.Sort;
            int             sortField = sortRow.SortField;
            string          tableName = ViewBag.MetaData.Table.TableName;

            IEnumerable <ObjectContainer> dataTable = model.List;
            UrlInfo  urlInfo  = model.CallerInfo.URL;
            string   url      = urlInfo.DSelfUrl;
            PageInfo pageInfo = model.CallerInfo.Info;

            string condition = sortRow.SqlCon;
            IEnumerable <IFieldInfoEx> fields   = ViewBag.MetaData.Table.TableList;
            NormalListData             pageData = (NormalListData)ViewBag.PageData;

            WriteLiteral("\r\n");

            DefineSection("DefaultListHeader", () => {
                WriteLiteral("\r\n    <tr>\r\n");


                if (pageData.OperatorPosition == OperatorPosition.Left)
                {
                    WriteLiteral("            <th");

                    WriteLiteral(" class=\"text-center text-nowrap\"");

                    WriteLiteral(">\r\n                <div>");

                    Write(pageData.OperationCaption);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("        ");


                int index = 0;

                WriteLiteral("\r\n");


                foreach (IFieldInfoEx field in fields)
                {
                    WriteLiteral("            <th ");

                    Write(CreateHeadAttrs(field, index++, sortField, sortRow));

                    WriteLiteral(">\r\n                <div>");

                    Write(field.DisplayName);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("        ");

                if (pageData.OperatorPosition == OperatorPosition.Right)
                {
                    WriteLiteral("            <th");

                    WriteLiteral(" class=\"text-center text-nowrap\"");

                    WriteLiteral(">\r\n                <div>");

                    Write(pageData.OperationCaption);

                    WriteLiteral("</div>\r\n            </th>\r\n");
                }

                WriteLiteral("    </tr>\r\n");
            });

            DefineSection("DefaultListWidth", () => {
                WriteLiteral("\r\n");


                if (pageData.OperatorPosition == OperatorPosition.Left)
                {
                    WriteLiteral("        <col ");

                    Write(OperatorWidth(pageData.OperatorWidth));

                    WriteLiteral(" />\r\n");
                }

                WriteLiteral("    ");


                int index = 0;

                WriteLiteral("\r\n");


                foreach (IFieldInfoEx field in fields)
                {
                    WriteLiteral("        <col ");

                    Write(CreateColAttrs(field, index++, sortField));

                    WriteLiteral(" />\r\n");
                }

                WriteLiteral("    ");

                if (pageData.OperatorPosition == OperatorPosition.Right)
                {
                    WriteLiteral("        <col ");

                    Write(OperatorWidth(pageData.OperatorWidth));

                    WriteLiteral(" />\r\n");
                }
            });

            DefineSection("DefaultTabSheet", () => {
                WriteLiteral("\r\n    ");

                WriteLiteral("\r\n");
            });

            Write(RenderSectionOrDefault("TabSheet", "DefaultTabSheet"));

            WriteLiteral("\r\n<table");

            WriteAttribute("class", Tuple.Create(" class=\"", 4099), Tuple.Create("\"", 4185)
                           , Tuple.Create(Tuple.Create("", 4107), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("list-table table", pageData.Display.TableDisplayClass())
                                                                                                             , 4107), false)
                           );

            WriteLiteral(">\r\n    <colgroup>\r\n");

            WriteLiteral("        ");

            Write(RenderSectionOrDefault("ListWidth", "DefaultListWidth"));

            WriteLiteral("\r\n    </colgroup>\r\n");


            if (pageData.ShowListHeader)
            {
                WriteLiteral("        <thead>\r\n");

                WriteLiteral("            ");

                Write(RenderSectionOrDefault("ListHeader", "DefaultListHeader"));

                WriteLiteral("\r\n        </thead>\r\n");
            }

            WriteLiteral("    <tbody");

            WriteLiteral(" id=\"pageList\"");

            WriteLiteral(" data-totalcount=\"");

            Write(countRow.TotalCount);

            WriteLiteral("\"");

            WriteLiteral(" data-totalpage=\"");

            Write(countRow.TotalPage);

            WriteLiteral("\"");

            WriteLiteral(" data-sort=\"");

            Write(sortField);

            WriteLiteral("\"");

            WriteLiteral(" data-order=\"");

            Write(sortRow.Order);

            WriteLiteral("\"");

            WriteLiteral(" data-page=\"");

            Write(countRow.CurrentPage);

            WriteLiteral("\"");

            WriteLiteral(" data-url=\"");

            Write(url);

            WriteLiteral("\"");

            WriteLiteral(" data-condition=\"");

            Write(condition);

            WriteLiteral("\"");

            WriteLiteral(" data-source=\"");

            Write(pageInfo.Source);

            WriteLiteral("\"");

            WriteLiteral(" ");

            WriteLiteral(">\r\n");


            if (dataTable != null)
            {
                foreach (ObjectContainer row in dataTable)
                {
                    string rowString = @RenderRow(row);


                    if (rowString != null)
                    {
                        Write(rowString);
                    }
                    else
                    {
                        WriteLiteral("            <tr>\r\n");


                        if (pageData.OperatorPosition == OperatorPosition.Left)
                        {
                            WriteLiteral("                    <td");

                            WriteLiteral(" class=\"text-nowrap text-center\"");

                            WriteLiteral(">");

                            Write(BootcssUtil.CreateRowOperators(model.RowOperators, row));

                            WriteLiteral("</td>\r\n");
                        }
                        WriteLiteral("\r\n");


                        foreach (IFieldInfoEx field in fields)
                        {
                            Tk5FieldInfoEx fieldInfo   = field.Convert <Tk5FieldInfoEx>();
                            string         fieldString = @RenderFieldItem(row, fieldInfo);


                            if (fieldString == null)
                            {
                                WriteLiteral("                    <td>");

                                Write(fieldInfo.DisplayValue(row));

                                WriteLiteral("</td>\r\n");
                            }
                            else
                            {
                                Write(fieldString);
                            }
                        }
                        WriteLiteral("\r\n");


                        if (pageData.OperatorPosition == OperatorPosition.Right)
                        {
                            WriteLiteral("                    <td");

                            WriteLiteral(" class=\"text-nowrap text-center\"");

                            WriteLiteral(">");

                            Write(BootcssUtil.CreateRowOperators(model.RowOperators, row));

                            WriteLiteral("</td>\r\n");
                        }
                        WriteLiteral("\r\n            </tr>\r\n");
                    }
                }
            }

            WriteLiteral("    </tbody>\r\n</table>\r\n");

            if (countRow.TotalCount == 0)
            {
                WriteLiteral("    <div");

                WriteLiteral(" class=\"p30\"");

                WriteLiteral(">");

                Write(pageData.NoDataCaption);

                WriteLiteral("</div>\r\n");
            }
            else
            {
                if (@pageData.ShowPage)
                {
                }
            }
        }