Report samples

Methods

getReports

Description:

MethodReturn valuesDescription

getReports(boolean active)

List<Report>

Returns a list of reports.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);  
try {
ws.login(user, password); List<Report> reports = ws.getReports(true); foreach (Report rep in reports) { System.Console.WriteLine(rep.toString()); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getReport

Description:

MethodReturn valuesDescription

getReport(long rpId)

Report

Returns reports.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);  
try {
ws.login(user, password);
List<Report> reports = ws.getReports(true);
Report report = new Report();
foreach (var rep in reports)
{
if (rep.fileName.Equals("DocumentCheckout.rep"))
{
// Get report
report = ws.getReport(rep.id);
break;
}
}
System.Console.WriteLine(report.toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

executeReport

Description:

MethodReturn valuesDescription

executeReport(long rpId, Dictionary<String, String> params, String format)

Stream

Return a document result of executing a report.

Available formats:

  • Report.FORMAT_CSV
  • Report.FORMAT_DOCX
  • Report.FORMAT_HTML
  • Report.FORMAT_ODT
  • Report.FORMAT_PDF
  • Report.FORMAT_RTF
  • Report.FORMAT_TEXT

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.util;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host); 
try {
ws.login(user, password);
List<Report> reports = ws.getReports(true);
Report report = new Report();
foreach (var rep in reports)
{
if (rep.fileName.Equals("DocumentCheckout.rep"))
{
// Get report
report = ws.getReport(rep.id);
break;
}
}
Dictionary<String, String> param = new Dictionary<String, String>(); param.Add("from_date", "2016-01-01"); param.Add("to_date", "2016-12-23"); Stream stream = ws.executeReport(report.id, Report.FORMAT_PDF, param); BeanHelper beanHelper = new BeanHelper(); Byte[] data = beanHelper.ReadToEnd(stream); FileStream fileStream = new FileStream(@"C:\Desktop\out.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); foreach (byte b in data) { fileStream.WriteByte(b); } fileStream.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

saveReport

Description: 

MethodReturn valuesDescription

saveReport(long rpId, Dictionary<String, String> _params, String format, String dstId, String docName)

Document

Execute the report and save the resulting document.

Available formats:

  • Report.FORMAT_CSV
  • Report.FORMAT_DOCX
  • Report.FORMAT_HTML
  • Report.FORMAT_ODT
  • Report.FORMAT_PDF
  • Report.FORMAT_RTF
  • Report.FORMAT_TEXT

The values of the dstld parameter should be a folder or record UUID.

The parameter docName to put the name of the document saved.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);  
try {
ws.login(user, password);
long repId = 1;
Dictionary<String, String> param = new Dictionary<String, String>();
param.Add("from_date", "2018-01-01");
param.Add("to_date", "2019-12-30");
Document doc = ws.saveReport(repId, param, Report.FORMAT_PDF, "8599eab7-ae61-4628-8010-1103d6950c63", "REPORT-001.pdf");
System.Console.WriteLine(doc.toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

generateDownloadReportToken

Description:

MethodReturn valuesDescription

generateDownloadReportToken(long rpId)

String

Return the token for downloading the report.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);  
try {
ws.login(user, password);
long repId = 1;
String dwt = ws.generateDownloadReportToken(repId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }