Skip to content

IAdmReportScheduledTask

The IAdmReportScheduledTask interface represents a Scheduled Task used to generate and deliver reports.

Inheritance: The IAdmReportScheduledTask interface inherits from the IAdmScheduledTask2 interface.

Methods

Properties

Details

CreateReportData()

Creates an instance of the IAdmScheduledReportData interface used to specify parameters for report generation and delivery on schedule.

IAdmScheduledReportData CreateReportData()

ScheduledReports

Gets a collection of reports scheduled by the task. Each report in the collection is represented by the IAdmScheduledReportItem interface.

Examples

The following code sample adds a report to a Scheduled Task.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to a Scheduled Task
$scheduledTaskDN = "CN=MyTask,CN=Report Schedule,CN=Reports Root,CN=Configuration Objects,"+
    "CN=Adaxes Configuration,CN=Adaxes"
$scheduledTask = $admService.OpenObject("Adaxes://$scheduledTaskDN", $Null, $Null, 0)

# Specify parameters for report generation and configure delivery options
$scheduledReportData = $scheduledTask.CreateReportData()
$reportDN = "CN=MyReport,CN=Reports,CN=Reports Root,CN=Configuration Objects,"+
    "CN=Adaxes Configuration,CN=Adaxes"
$report = $admService.OpenObject("Adaxes://$reportDN", $Null, $Null, 0)
$scheduledReportData.Report = $report
$reportDocument = $scheduledReportData.CreateDocument("ADM_REPORTDOCUMENTTYPE_PDF")
$reportDocument.Content = "ADM_REPORTDOCUMENTCONTENT_TABLE"
$scheduledReportData.Document = $reportDocument
$scheduledReportData.Delivery.EmailDelivery.Enabled = $True
$scheduledReportData.Delivery.EmailDelivery.AttachFile = $True

# Create Scheduled Task item
$scheduledTaskItem = $scheduledTask.ScheduledReports.Create()
$scheduledTaskItem.ReportData = $scheduledReportData
$scheduledTaskItem.SetInfo()

# Specify recipients
$userDN = "CN=John Smith,OU=Users,DC=company,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $Null, $Null, 0)
$recipient = $scheduledTaskItem.ActivityScopeItems.Create()
$recipient.BaseObject = $user
$recipient.Exclude = $false
$recipient.Inheritance = "ADS_SCOPE_BASE"
$recipient.Type = "ADM_SCOPEBASEOBJECTTYPE_CONTAINER"
$recipient.SetInfo()
$scheduledTaskItem.ActivityScopeItems.Add($recipient)

# Add the report to the Scheduled Task
$scheduledTask.ScheduledReports.Add($scheduledTaskItem)
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi.Reports;
using Softerra.Adaxes.Interop.Adsi.Reports.Document;
using Softerra.Adaxes.Interop.Adsi.Reports.Schedule;

class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to a Scheduled Task
        const string scheduledTaskPath = "Adaxes://CN=MyTask,CN=Report Schedule,CN=Reports Root," +
                                         "CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        IAdmReportScheduledTask scheduledTask = 
            (IAdmReportScheduledTask)admService.OpenObject(scheduledTaskPath, null, null, 0);

        // Specify parameters for report generation and configure delivery options
        IAdmScheduledReportData scheduledReportData = scheduledTask.CreateReportData();
        const string reportPath = "Adaxes://CN=MyReport,CN=Reports,CN=Reports Root," +
                                  "CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        IAdmReport report = (IAdmReport)admService.OpenObject(reportPath, null, null, 0);
        scheduledReportData.Report = report;
        IAdmReportDocumentExtended reportDocument = 
            (IAdmReportDocumentExtended)scheduledReportData.CreateDocument(
            ADM_REPORTDOCUMENTTYPE_ENUM.ADM_REPORTDOCUMENTTYPE_PDF);
        reportDocument.Content = ADM_REPORTDOCUMENTCONTENT_ENUM.ADM_REPORTDOCUMENTCONTENT_TABLE;
        scheduledReportData.Document = reportDocument;
        scheduledReportData.Delivery.EmailDelivery.Enabled = true;
        scheduledReportData.Delivery.EmailDelivery.AttachFile = true;

        // Create Scheduled Task item
        IAdmScheduledReportItem scheduledTaskItem = 
            (IAdmScheduledReportItem)scheduledTask.ScheduledReports.Create();
        scheduledTaskItem.ReportData = scheduledReportData;
        scheduledTaskItem.SetInfo();

        // Specify recipients
        const string userPath = "Adaxes://CN=John Smith,OU=Users,DC=company,DC=com";
        IAdmTop user = (IAdmTop)admService.OpenObject(userPath, null, null, 0);
        IAdmActivityScopeItem recipient = 
            (IAdmActivityScopeItem)scheduledTaskItem.ActivityScopeItems.Create();
        recipient.BaseObject = user;
        recipient.Exclude = false;
        recipient.Inheritance = ADS_SCOPEENUM.ADS_SCOPE_BASE;
        recipient.Type = ADM_SCOPEBASEOBJECTTYPE_ENUM.ADM_SCOPEBASEOBJECTTYPE_CONTAINER;
        recipient.SetInfo();
        scheduledTaskItem.ActivityScopeItems.Add(recipient);

        // Add the report to the Scheduled Task
        scheduledTask.ScheduledReports.Add(scheduledTaskItem);
    }
}

AllowForSelfScheduling

Gets or sets a value indicating whether users can schedule reports for themselves using the task.

  • Type:
  • Boolean
  • Access:
  • Read/Write

Requirements

Minimum required version: 2018.1

See also