The following example creates a graph and assigns it to a report.
privatebool CreateReportGraph() { // Get report object by report code name ReportInfo report = ReportInfoProvider.GetReportInfo("MyNewReport"); // If report exists if (report != null) { // Create new report graph object ReportGraphInfo newGraph = newReportGraphInfo(); // Set the properties newGraph.GraphDisplayName = "My new graph"; newGraph.GraphName = "MyNewGraph";
newGraph.GraphQuery = "SELECT TOP 10 DocumentName, DocumentID FROM CMS_Document";
newGraph.GraphReportID = report.ReportID; newGraph.GraphQueryIsStoredProcedure = false; newGraph.GraphType = "bar"; // Save the report graph ReportGraphInfoProvider.SetReportGraphInfo(newGraph); returntrue; } returnfalse; }
The following example gets and updates a report graph.
privatebool GetAndUpdateReportGraph() {
// Get the report graph ReportGraphInfo updateGraph = ReportGraphInfoProvider.GetReportGraphInfo("MyNewGraph");
if (updateGraph != null) { // Update the properties updateGraph.GraphDisplayName = updateGraph.GraphDisplayName.ToLower(); // Save the changes ReportGraphInfoProvider.SetReportGraphInfo(updateGraph); returntrue; } returnfalse; }
The following example gets and bulk updates report graphs.
privatebool GetAndBulkUpdateReportGraphs() { // Prepare the parameters string where = "GraphName LIKE N'MyNewGraph%'"; // Get the data DataSet graphs = ReportGraphInfoProvider.GetGraphs(where, null); if (!DataHelper.DataSourceIsEmpty(graphs)) { // Loop through the individual items foreach (DataRow graphDr in graphs.Tables[0].Rows) { // Create object from DataRow ReportGraphInfo modifyGraph = newReportGraphInfo(graphDr); // Update the properties modifyGraph.GraphDisplayName = modifyGraph.GraphDisplayName.ToUpper(); // Save the changes ReportGraphInfoProvider.SetReportGraphInfo(modifyGraph); } returntrue; } returnfalse; }
The following example deletes a report graph.
privatebool DeleteReportGraph() {
// Get the report graph ReportGraphInfo deleteGraph = ReportGraphInfoProvider.GetReportGraphInfo("MyNewGraph");