internal string AddParametersForSql(string parameter, string sql, DynamicParameters p, dynamic ViewBag) { if (sql.Contains("@qtagid", ignoreCase: true)) { var id = Db.FetchLastQuery().Id; var tag = Db.PopulateSpecialTag(id, DbUtil.TagTypeId_Query); int?qtagid = tag.Id; p.Add("@qtagid", qtagid); ViewBag.Type = "SqlReport"; } if (sql.Contains("@BlueToolbarTagId", ignoreCase: true)) { var id = Db.FetchLastQuery().Id; var tag = Db.PopulateSpecialTag(id, DbUtil.TagTypeId_Query); int?qtagid = tag.Id; p.Add("@BlueToolbarTagId", qtagid); ViewBag.Type = "SqlReport"; } else if (sql.Contains("@CurrentOrgId", ignoreCase: true)) { var oid = Db.CurrentSessionOrgId; p.Add("@CurrentOrgId", oid); if (oid > 0) { var name = Db.LoadOrganizationById(oid).FullName2; ViewBag.Name2 = name; ViewBag.Type = "SqlReport"; } } else if (sql.Contains("@OrgIds", ignoreCase: true)) { var oid = Db.CurrentSessionOrgId; if (oid != 0 || !p.Contains("@OrgIds")) { p.Add("@OrgIds", oid.ToString()); } ViewBag.Type = "OrgSearchSqlReport"; if (sql.Contains("--class=StartEndReport")) { p.Add("@MeetingDate1", DateTime.Now.AddDays(-90)); p.Add("@MeetingDate2", DateTime.Now); } } else if (sql.Contains("--class=TotalsByFund")) { ViewBag.Type = "TotalsByFundSqlReport"; p.Add("@StartDate", dbType: DbType.DateTime); p.Add("@EndDate", dbType: DbType.DateTime); p.Add("@CampusId", dbType: DbType.Int32); p.Add("@Online", dbType: DbType.Boolean); p.Add("@TaxNonTax", dbType: DbType.Boolean); p.Add("@FundSet", dbType: DbType.String); p.Add("@IncludeUnclosedBundles", dbType: DbType.Boolean); p.Add("@ActiveTagFilter", dbType: DbType.Int64); } else { ViewBag.Type = "SqlReport"; } if (sql.Contains("@StartDt")) { p.Add("@StartDt", new DateTime(DateTime.Now.Year, 1, 1)); } if (sql.Contains("@EndDt")) { p.Add("@EndDt", DateTime.Today); } if (sql.Contains("@userid", ignoreCase: true)) { p.Add("@userid", Util.UserId); } #if DEBUG foreach (var name in p.ParameterNames) { sql = QueryFunctions.RemoveDeclaration(name, sql); } #endif sql = QueryFunctions.AddP1Parameter(sql, parameter, p); return(sql); }