# Applications In a powerJobs Processor context, entities that support a specific set of operations e.g. opening or exporting a file, are referred to as Applications.\ These Applications are used by the powerJobs Processor {doc}`Cmdlets ` to perform their actions on documents. Available Applications can be accessed in the {doc}`$host.applications ` variable in a {doc}`/jobprocessor/jobs/setup_job`.\ The product also provides an option to {ref}`extend or implement new ` and existing Applications. ## Supported Applications The following Applications can be used in {doc}`/jobprocessor/jobs` out of the box: | Application | Note | | :--------------------------------------------------------------------------- | :---------------------------------------------------- | | Inventor | [Autodesk Inventor](https://www.autodesk.com/products/inventor/overview) supports opening, manipulating and converting 3D mechanical designs.
A software license is required and a Single-User or Multi-User **License must be activated on the Job Processor** in order to prevent [license issues](https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/Inventor-cannot-access-your-license.html)| | InventorServer | Inventor Server is a headless version of [Autodesk Inventor](https://www.autodesk.com/products/inventor/overview) and is noticeably faster in starting and processing jobs, but there are no GUI features available.
No additional license must be purchased for the Job Processor environment and no full Inventor installation is required.| | DWG TrueView | [DWGTrue View](https://knowledge.autodesk.com/support/dwg-trueview/learn-explore/caas/simplecontent/content/using-autodesk-dwg-trueview-to-convert-dwg-file-version.html) is a CAD file viewer which, in contrast to AutoCAD, only supports conversions to PDF and DWF formats.
No additional license is required and no full version of [AutoCAD](https://www.autodesk.com/products/autocad/overview) must be installed.
[AutoCAD](https://www.autodesk.com/products/autocad/overview) is currently not supported.| More details on the supported conversions for each Application can be found on the {doc}`/jobprocessor/file_conversion` page. ## Custom Applications Custom applications can be used to extend the products export capabilities. To implement the exposed .NET interfaces you first need to {doc}`install ` powerJobs Processor on your development machine.\ Afterwards the implemented application must be registered and can therefore be used by all {doc}`document related cmdlets
`.\ The .Net library requires your project to target **.NET Framework 4.7** ! ### IApplication Interface The API for Applications is designed around the *IApplication* interface and also includes types like IDocument, IExport, ect. and is designed as follows: ```{image} /jobprocessor/img/application_uml.png :width: 1800px ``` ### Visual Studio Project setup for Custom Applications ```{dropdown} 1. Create a new Solution in VisualStudio Choose a new project of type **Class Library** with the name of your application. The new project should have the following settings: * Output Type: Class Library * Target .Net framework: 4.7 * Platform Target: Any CPU ``` ```{dropdown} 2. Reference the powerJobs.Common assembly In Visual Studio right-click on *References* and click *“Add References”*.\ Search for the assembly *powerJobs.Common”* in Assemblies-tab and add it to your project. The assembly will be referenced from the **GAC**, therefore set *“Copy Local”* to *“false”* (when using Visual Studio 2012 this should be done automatically). ``` ````{dropdown} 3. Create an IApplication implementation In order to gain access to the IApplicaiton interace, the following **namespace** should be imported: ```csharp using powerJobs.Common.Applications; ``` Now we can define our Application class which implements the `IApplication` interface and handles the start and stop functionality.\ In order to prevent troubles with long running applications, we recommend to derive your class from `powerjobs.Common.Applications.ApplicationBase` and implement the functionality IsRunning properly.\ This will allow powerJobs Processor to automatically restart this application whenever required.\ Note that the Application will only open documents configured in the IsSupportedFile (or `SupportedFileTypes`) functionality! ```` ```{dropdown} 4. Create an IDocument implementation The closing functionality should be implemented properly, in order to have no unmanaged resources lying around in memory later.\ The constuctor can use the ``OpenDocumentSettings`` parameter for opening the correct file.\ Additional all the options passed from the [](/jobprocessor/code_reference/cmdlets/open-document) cmldet can be consumed.\ We recommend to derive your Document class from the `powerjobs.Common.Applications.DocumentBase` class.\ The function `OpenDocument` of the custom application class (Step 3) must be extended to return an instance of this Type.\ If the application is derived from `powerjobs.Common.Applications.ApplicationBase`, you just need to return a new instance of your class in ``OpenDocument_Internal(OpenDocumentSettings openSettings)``.\ Now the cmdlets [](/jobprocessor/code_reference/cmdlets/open-document) and [](/jobprocessor/code_reference/cmdlets/close-document) should already work. ``` ```{dropdown} 5. Create an IDocumentExport implementation The exporter takes care about different export formats and decides which export should be used from [](/jobprocessor/code_reference/cmdlets/export-document).\ The Application property ``IDocumentExporter Exporter`` has to be set to an instance of this IDocumentExporter. We recommend to derive your DocumentExporter class from `powerjobs.Common.Applications.DocumentExporterBase` class which handles multiple DocumentExports depending on the file format.\ Even multiple exports can be registered in this class later. For the moment a single IDocumentExport implementation can be provided.\ Based on the name of this export (e.g. "PDF"), the DocumentExporter can decide to take this export when required.\ We recommend to derive your DocumentExport class from the `powerjobs.Common.Applications.DocumentExportBase` class. After deriving from the class implement all the abstract functions.\ By specifying the ``SupportedDocumentTypes`` your export will be called only for the specified formats.\ The real export logic has to be implemented in the ``Execute`` function.\ You can use the ``ExportSettings`` to gain access to the options passed to the [](/jobprocessor/code_reference/cmdlets/export-document) cmdlet. ``` ```{dropdown} 6. Deploy to Modules directory Next copy your application assembly into a new folder under the Modules directory. ``` ````{dropdown} 7. Create Module to register the application Create a new module in the modules directory and register your application in there, similar to the [default application](jobprocessor/code_reference/objects/host:registration): ```powerShell Add-Type -Path "$($Env:POWERJOBS_MODULESDIR)\\.dll" Register-Application ([]) ``` Now you can [create your own job](/jobprocessor/jobs/creating_job_scripts) and pass to the [](/jobprocessor/code_reference/cmdlets/open-document) the application name of your new application: ```powerShell Open-Document -Application -LocalFile $file.LocalPath ``` ```` ```{dropdown} 8. Best practice: Set the PowerShell Console as Start Programm The Visual Studio project can now be configured to automatically load your assembly in the PowerShell Console.\ In the [Project Debug settings](https://docs.microsoft.com/en-us/visualstudio/debugger/project-settings-for-csharp-debug-configurations?#debug-tab) you have to configure the following settings:\    *Start external program:* ``C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe``\    *Command line arguments:* ``-noexit -command "Import-Module powerJobs"`` ``` ```{dropdown} 9. Launch the PowerShell Console or Job Processor Press F5 to start the PowerShell Console and the powerJobs module imports and registers your application.\ You can now execute the commandlets `Open-Document`, `Export-Document` and `Close-Document` in order to debug your implementations.\ At the same time the application can now be used and tested in your job. ``` ### Visual Studio Template The Visual Studio Template creates a basic project similar to following the {ref}`steps above `. ```{panels} :body: text-justify :column: col-lg-12 **Visual Studio 2012**\ Download: {download}`C# Template ` Installation:\ *Copy the zip file* to your VisualStudio Templates directory *%userprofile%\\Documents\\Visual Studio 2012\\Templates\\ProjectTemplates\\coolOrange*. ``` Start VisualStudio and *create a new project* by using the project template **powerJobs Processor Application** and give your application a meaningful name (without characters like spaces or dots). The assembly which contains your application and the according registration module will be deployed to the *Modules* directory, with the name of your project.\ It is already configured to automatically launch the PowerShell Console and import the {code}`powerJobs` module when **pressing F5**.