// Get the report category ReportCategoryInfo category = ReportCategoryInfoProvider.GetReportCategoryInfo("MyNewCategory");
if (category != null) { // Create new report object ReportInfo newReport = newReportInfo(); // Set the properties newReport.ReportDisplayName = "My new report"; newReport.ReportName = "MyNewReport"; newReport.ReportCategoryID = category.CategoryID; newReport.ReportAccess = ReportAccessEnum.All; newReport.ReportLayout = ""; newReport.ReportParameters = ""; // Save the report ReportInfoProvider.SetReportInfo(newReport); returntrue; } returnfalse; }
The following example gets and updates a report.
privatebool GetAndUpdateReport() { // Get the report ReportInfo updateReport = ReportInfoProvider.GetReportInfo("MyNewReport"); if (updateReport != null) {
// Update the properties updateReport.ReportDisplayName = updateReport.ReportDisplayName.ToLower();
// Save the changes ReportInfoProvider.SetReportInfo(updateReport); returntrue; } returnfalse; }
The following example gets and bulk updates reports.
privatebool GetAndBulkUpdateReports() { // Prepare the parameters string where = "ReportName LIKE N'MyNewReport%'"; string orderby = ""; int topN = 0; string columns = ""; // Get the data DataSet reports = ReportInfoProvider.GetReports(where, orderby, topN, columns);
if (!DataHelper.DataSourceIsEmpty(reports)) { // Loop through the individual items foreach (DataRow reportDr in reports.Tables[0].Rows) { // Create object from DataRow ReportInfo modifyReport = newReportInfo(reportDr);
// Update the properties modifyReport.ReportDisplayName = modifyReport.ReportDisplayName.ToUpper();
// Save the changes ReportInfoProvider.SetReportInfo(modifyReport); } returntrue; } returnfalse; }
The following example deletes a report.
privatebool DeleteReport() { // Get the report ReportInfo deleteReport = ReportInfoProvider.GetReportInfo("MyNewReport"); // Delete the report ReportInfoProvider.DeleteReportInfo(deleteReport); return (deleteReport != null); }