public static SReportTemplateTable GetTemplateVariants(String AReportType, String AAuthor, Boolean ADefaultOnly = false) { SReportTemplateTable Tbl = new SReportTemplateTable(); SReportTemplateTable Ret = new SReportTemplateTable(); TDBTransaction Transaction = null; TDataBase dbConnection = new TDataBase(); try { dbConnection = TReportingDbAdapter.EstablishDBConnection(true, "GetTemplateVariants"); LoadTemplatesFromBackupFile(AReportType, dbConnection); dbConnection.BeginAutoReadTransaction( ref Transaction, delegate { SReportTemplateRow TemplateRow = Tbl.NewRowTyped(false); TemplateRow.ReportType = AReportType; Tbl = SReportTemplateAccess.LoadUsingTemplate(TemplateRow, Transaction); }); String filter = String.Format("(s_author_c ='{0}' OR s_private_l=false)", AAuthor); if (ADefaultOnly) { filter += " AND (s_default_l=true OR s_private_default_l=true)"; } Tbl.DefaultView.RowFilter = filter; if (Tbl.DefaultView.Count > 0) { Tbl.DefaultView.Sort = (ADefaultOnly) ? "s_private_default_l DESC, s_default_l DESC" : "s_readonly_l DESC, s_default_l DESC, s_private_default_l DESC"; } else // Something went wrong, but I'll try not to return empty-handed. { Tbl.DefaultView.RowFilter = ""; } Ret.Merge(Tbl.DefaultView.ToTable()); Ret.AcceptChanges(); } finally { dbConnection.CloseDBConnection(); } return(Ret); }
public static SReportTemplateTable GetTemplateById(int TemplateId) { TDataBase dbConnection = null; TDBTransaction Transaction = null; SReportTemplateTable TemplateTable = null; try { dbConnection = TReportingDbAdapter.EstablishDBConnection(true, "GetTemplateById"); dbConnection.BeginAutoReadTransaction( ref Transaction, delegate { TemplateTable = SReportTemplateAccess.LoadByPrimaryKey(TemplateId, Transaction); }); } finally { dbConnection.CloseDBConnection(); } return(TemplateTable); }