The following sample code shows how you can create a new report category and add it to the system:
[C#]
using CMS.Reporting;
...
// Create new report category object ReportCategoryInfo rci = new ReportCategoryInfo();
// Set properties rci.CategoryDisplayName = "Test category"; rci.CategoryCodeName = "TestCategory";
// Save to database ReportCategoryInfoProvider.SetReportCategoryInfo(rci); |
The following sample code shows how you can create a new report under an existing report category and add it to the system:
[C#]
using CMS.Reporting;
...
// Get parent category for the new report ReportCategoryInfo parent = ReportCategoryInfoProvider.GetReportCategoryInfo("TestCategory");
// If parent exists if (parent != null) { // Create new report object ReportInfo ri = new ReportInfo();
// Set properties ri.ReportDisplayName = "Test report"; ri.ReportName = "TestReport"; ri.ReportCategoryID = parent.CategoryID; ri.ReportAccess = ReportAccessEnum.All; ri.ReportLayout = ""; ri.ReportParameters = "";
// Save to database ReportInfoProvider.SetReportInfo(ri); } |
The following sample code shows how you can delete an existing report:
[C#]
using CMS.Reporting;
...
// Get report object by report code name ReportInfo ri = ReportInfoProvider.GetReportInfo("TestReport");
// If report exists if (ri != null) { ReportInfoProvider.DeleteReportInfo(ri); } |