Plugin API
The SCCM Manager server installation includes an interface for developing custom plugins. This requires an IDE (e.g., Visual Studio) for developing C# applications using the WPF graphics framework. Additionally, .NET Framework 4.6.1 is required.
Development
A newly created plugin must be compiled as a class library (DLL file) and implement the IActionPlugin interface. The interface is located in the ActionPanel.PluginBase.dll class library. The ActionPanel.Common.dll class library is also included, which contains several useful helper classes.
To integrate the newly developed plugin, simply copy the corresponding DLL file to the SCCM Manager's plugin directory:
{Installation directory}\Web\SCCMManager\Resources\Assemblies\
Afterward, you must run the “Update Plugin Versions” shortcut in the Start menu so that the new plugin is available for configuration in the SCCM Manager administration interface.
Interface IActionPlugin
The IActionPlugin interface is described below.
Properties
| Name | Typ | Description | Set automatically |
| Title | string | Title according to action configuration | Yes |
| Argument | string | Argument based on action configuration | Yes |
| SelectedComputers | ObservableCollection<IComputerItem> | This lists all computers selected at runtime | Yes |
| IsSingleton | bool | Singleton based on action configuration | Yes |
| ApplicationVariables | IApplicationVariables | Plugin variables from the database; values can also be modified through this | Yes |
| ActionPanelControl | IActionPanel | Access to various features of SCCM Manager and the Web Service | Yes |
| LanguageTranslater | ILanguageTranslater | Access to the plugin's language translations | Yes |
| PluginContainer | IPluginContainer | Yes | |
| SelectedComputerType | SelectedComputerType (Enum) | No | |
| SingletonBehavior | SingletonBehavior (Enum) | Behavior when the plugin is started a second time and its singleton property is enabled | No |
| PluginType | PluginTypes (Enum) | Plugin type. Possible values: | No |
| ContentControl | UserControl | A UserControl that should be displayed as a user interface in SCCM Manager when the plugin type is a UserControl plugin | No |
| Name | Return type | Input parameters | Description |
| Initialize | bool | Initializing the plugin. | |
| OnApplicationExit | void | Event when the SCCM Manager is closed. | |
| UpdateArgument | void | string argument | If a plugin is started a second time as a singleton, this method is called. |
| InvokeFunction | bool | string function, string[] parameters | Transfer of the configured function and parameters. |
Implementierung
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls;
using ActionPanel.PluginBase;
using ActionPanel.PluginBase.Enums;
using ActionPanel.PluginBase.Interfaces;
using ClientActionsPlugin.View;
using FuncLib;
namespace ClientActionsPlugin
{
class ActionPanelPlugin : IActionPlugin
{
private ActionUserControl m_control;
public string Title { get; set; }
public bool IsSingleton { get; set; }
public string Argument { get; set; }
public ObservableCollection<IComputerItem> SelectedComputers { get; set; }
public SelectedComputersType SelectedComputerType { get; set; } = SelectedComputersType.Single;
public SingletonBehavior SingletonBehavior { get; } = SingletonBehavior.UpdateArgument;
public PluginTypes PluginType { get; } = PluginTypes.ExecuterUserControl;
public UserControl ContentControl => m_control;
public bool Initialize()
{
m_control = new ActionUserControl(this);
if (m_control != null)
{
m_control.Title = Title;
m_control.SelectedComputer = SelectedComputers?.FirstOrDefault()?.Name;
m_control.Init();
}
return true;
}
public void OnApplicationExit()
{
}
public void UpdateArgument(string argument)
{
Argument = argument;
m_control.SelectedComputer = SelectedComputers?.FirstOrDefault()?.Name;
m_control.Init();
}
public bool InvokeFunction(string function, string[] parameters)
{
bool force = (parameters != null && FLibCMD.CheckForCommandLineKey(parameters, "force", false));
if (function == Functions.SHUTDOWN)
{
return m_control.ShutdownComputer(force);
}
else if (function == Functions.RESTART)
{
return m_control.RestartComputer(force);
}
else if (function == Functions.WAKEUP)
{
return m_control.WakeUpComputer();
}
else
{
return false;
}
}
public IApplicationVariables ApplicationVariables { get; set; }
public IActionPanel ActionPanelControl { get; set; }
public ILanguageTranslater LanguageTranslater { get; set; }
public IPluginContainer PluginContainer { get; set; }
}
}