...
- Create a new project of type "Class Library"
- Choose .NET Framework 4 or higher
- Add References:
- Add Reference
com.sos-berlin.engine.engine-job-api-dotnet.dll
- Add Reference
jni4net.n-0.8.8.0.dll
- Create a Class to implement a JobScheduler job or a JobScheduler monitor
...
Code Block |
---|
language | xml |
---|
title | SampleJob |
---|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<job title="CSharp SampleJob" order="no" process_class="/agent-1.11.x">
<params>
<param name="test" value="12345" />
</params>
<script language="dotnet" dotnet_class="JobSchedulerSamples.SampleJob" dll="<path to dll>\dlls/JobSchedulerSamples.dll" />
<run_time />
</job> |
Monitor API
...
Code Block |
---|
language | c# |
---|
title | SampleMonitor |
---|
|
namespace JobSchedulerSamples
{
using sos.spooler;
public class SampleMonitor : Monitor_impl
{
#region Public Methods
public override bool spooler_process_after(bool spoolerProcessResult)
{
this.spooler_log.info(".NET spooler_process_after");
return spoolerProcessResult;
}
public override bool spooler_process_before()
{
this.spooler_log.info(".NET spooler_process_before");
return true;
}
public override void spooler_task_after()
{
this.spooler_log.info(".NET spooler_task_after");
}
public override bool spooler_task_before()
{
this.spooler_log.info(".NET spooler_task_before");
return true;
}
#endregion
}
}
|
Running the monitor
In JobScheduler the monitor for the above example is configured as follows:
Code Block |
---|
language | xml |
---|
title | SampleMonitor |
---|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<job title="CSharp SampleMonitor" order="no" process_class="agent">
<params>
</params>
<script language="shell"><![CDATA[echo Hello, World]]></script>
<monitor name="csharp_monitor" ordering="1">
<script language="dotnet" dotnet_class="JobSchedulerSamples.SampleMonitor" dll="dlls/JobSchedulerSamples.dll" />
</monitor>
<run_time />
</job> |
C# compiling on Windows without Visual Studio
For the both JobScheduler versions (x86 and x64) both .NET Framework x86 and .NET Framework x64 (see WINDOWS_NET_SDK_HOME
below) can be used for compilation.
Code Block |
---|
language | bash |
---|
title | csharp_compilation.cmd |
---|
|
@echo off
rem --- Compiler Folder Location: x86 Windows ---
rem set WINDOWS_NET_SDK_HOME=C:\Windows\Microsoft.NET\Framework\v4.0.30319
rem --- Compiler Folder Location: x64 Windows ---
set WINDOWS_NET_SDK_HOME=C:\Windows\Microsoft.NET\Framework64\v4.0.30319
rem --- Compilation Dependencies: directory with the JobScheduler .NET API dlls (com.sos-berlin.engine.engine-job-api-dotnet.dll, jni4net.n-0.8.8.0.dll)
set REFERENCE_DIRECTORY=C:\Temp\samples\dependencies
rem --- Compilation Folder Location: directory with the .NET sources to compile
set SOURCE_DIRECTORY=C:\Temp\samples\sources
rem --- Compilation Output file
set OUTPUT_DLL=C:\Temp\samples\out\MySample.dll
%WINDOWS_NET_SDK_HOME%\csc.exe /nologo /t:library /out:"%OUTPUT_DLL%" /recurse:"%SOURCE_DIRECTORY%\*.*" /reference:"%REFERENCE_DIRECTORY%\com.sos-berlin.engine.engine-job-api-dotnet.dll";"%REFERENCE_DIRECTORY%\jni4net.n-0.8.8.0.dll"
echo %OUTPUT_DLL% |
Samples
Download and extract JobSchedulerSamples.NET.zip
- Copy
dlls
folder to the agent working directory (agent_home)- Unblock if necessary a downloaded
dlls/JobSchedulerSamples.dll
file to avoid security warnings. To unblock
a file:- right-click it in Windows Explorer
- choose
Properties
from the context menu - click the
Unblock
button in the lower right-hand corner of the resulting dialog - hit
OK
or Apply
- Copy
dotnet_samples
folder to the master live directory (config/live)
- Configure agent url in the
agent.process_class.xml
- Run samples