Example #1
0
        public static string PageBreakTables(CMSDataContext db, string sql, DynamicParameters p)
        {
            var cs = Util.ReadOnlyConnectionString(db.Host, db.CurrentRoles().Contains("Finance"));
            var cn = new SqlConnection(cs);

            cn.Open();
            var sb           = new StringBuilder();
            int pagebreakcol = 0;
            var pg           = 1;

            while (true)
            {
                var s   = sql.Replace("WHERE 1=1", $"WHERE pagebreak={pg}");
                var cmd = new SqlCommand(s, cn);
                foreach (var parm in p.ParameterNames)
                {
                    var value = p.Get <dynamic>(parm);
                    cmd.Parameters.AddWithValue(parm, value);
                }
                cmd.CommandTimeout = 1200;
                using (var rd = cmd.ExecuteReader())
                {
                    if (!rd.HasRows)
                    {
                        return(sb.ToString());
                    }
                    if (pg == 1)
                    {
                        var colnames = Enumerable.Range(0, rd.FieldCount).Select(rd.GetName).ToList();
                        pagebreakcol = colnames.FindIndex(vv => vv == "pagebreak");
                    }
                    var t = HtmlTable(rd, $"pagebreak={pagebreakcol}");
                    t.RenderControl(new HtmlTextWriter(new StringWriter(sb)));
                    sb.AppendLine("<div class='page-break'></div>");
                }
                pg++;
            }
        }
 public static IQueryable <ContributionFund> ScopedByRoleMembership(this IQueryable <ContributionFund> contributionFunds, CMSDataContext db)
 {
     return(contributionFunds.ScopedByRoleMembership(db, db.CurrentRoles()));
 }