Kentico CMS 7.0 Developer's Guide

Managing reports

Managing reports

Previous topic Next topic Mail us feedback on this topic!  

Managing reports

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a report.

 

private bool CreateReport()
{

  // Get the report category
  ReportCategoryInfo category = ReportCategoryInfoProvider.GetReportCategoryInfo("MyNewCategory");

    if (category != null)
    {
        // Create new report object
        ReportInfo newReport = new ReportInfo();
 
        // 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);
 
        return true;
    }
 
    return false;
}

 

The following example gets and updates a report.

 

private bool 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);
 
        return true;
    }
 
    return false;
}

 

The following example gets and bulk updates reports.

 

private bool 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 = new ReportInfo(reportDr);

 

          // Update the properties
           modifyReport.ReportDisplayName = modifyReport.ReportDisplayName.ToUpper();

 
            // Save the changes
            ReportInfoProvider.SetReportInfo(modifyReport);
        }
 
        return true;
    }
 
    return false;
}

 

The following example deletes a report.

 

private bool DeleteReport()
{
    // Get the report
    ReportInfo deleteReport = ReportInfoProvider.GetReportInfo("MyNewReport");
 
    // Delete the report
    ReportInfoProvider.DeleteReportInfo(deleteReport);
 
    return (deleteReport != null);
}