Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • User might be interested to automatically receive a report about the daily plan.
    • The report includes the same information as available from the JOC Cockpit Daily Plan view.
    • The report is provided as an Excel file similar to what is available for export from the JOC Cockpit Daily Plan view.
  • The report can be scheduled on a daily basis or more frequently to provide ongoing information about completed tasks and outstanding tasks.

Use Cases

Report Daily Plan from a job

The PowerShell CLI can be is used by jobs to create reports. Two modules are in use applied for this purpose

  • the JobScheduler PowerShell Module
  • a reporting PowerShell Module. This example make use of ImportExcel that can be used to create Excel reports on Windows and Linux.

...

powershell
Code Block
languagepowershell
titleDaily Plan Report (Linux version)
linenumberstrue
collapsetrue
<?xml version="1.0" encoding="ISO-8859-1"?>
<job title="Report Daily Plan" process_class="agent_linux">
  <script language="shell"><![CDATA[pwsh -NoLogo -NonInteractive -Command '& {
    . $env:SCHEDULER_DATA/config/powershell/JobScheduler.PowerShell_profile.ps1
	Import-Module $env:SCHEDULER_DATA/config/powershell/Modules/ImportExcel
	Import-Module $env:SCHEDULER_DATA/config/powershell/Modules/JobScheduler

	Connect-JobScheduler -Url $JOCCockpitUrl -Credential $JOCCockpitCredential | Out-Null

	# start mode mapping
	$startModes = @{"0"="single start"; "1"="repeat start-start"; "2"="repeat end-start"}

	# Dates in local time zone, output includes local date format
	Get-JSDailyPlan -Timezone (Get-Timezone) `
                |  Select-Object -Property @{name="Job Chain/Job"; expression={ "$($_.jobChain)$($_.job)"}}, `
                                           @{name="Order ID"; expression={$_.orderId}}, `
                                           @{name="Status"; expression={$_.state._text}}, `
                                           @{name="Job Stream"; expression={$_.jobStream}}, `
                                           @{name="Late"; expression={$_.late}}, `
                                           @{name="Start Type"; expression={ $startModes[ "$($_.startMode)"] }}, `
                                           @{name="Repeat Interval"; expression={$_.period.repeat}}, `
                                           @{name="Planned Start Time"; expression={ Get-Date $_.plannedStartTime }}, `
                                           @{name="Expected End Time"; expression={ Get-Date $_.expectedEndTime }}, `
                                           @{name="Expected Duration (sec.)"; expression={ (New-Timespan -Start "$($_.plannedStartTime)" -End "$($_.expectedEndTime)").Seconds }}, `
                                           @{name="Start Time"; expression={ Get-Date $_.startTime }}, `
                                           @{name="End Time"; expression={ Get-Date $_.endTime }}, `
                                           @{name="Duration (sec.)"; expression={ (New-Timespan -Start "$($_.startTime)" -End "$($_.endTime)").Seconds }} `
                | Export-Excel -Path /tmp/jobscheduler_reporting.xlsx -WorksheetName "Daily-Plan" -ClearSheet
}'
]]></script>
  <run_time/>
</job>
Code Block
language


Explantions

  • The Add-JobSchedulerEvent cmdlet returns an event object that can be used for later pipelining
  • Event processing occurs asynchroneously, therefore newly created events might take some seconds to be available for retrieval..
  • The Get-JobSchedulerEvent cmdlet retrieves an array of event objects that are available with JobScheduler.
  • A previously created event object can be pipelined to the Remove-JobSchedulerEvent cmdlet.
  • In a more general sense all events as returned from Get-JobSchedulerEvent can be pipelined to the Remove-JobSchedulerEvent cmdlet.

...