Skip to main content

Plugin API

The server installation of the SCCM Manager provides an interface for self-development of plugins. This requires an IDE (e.g. Visual Studio) for the development of C-Sharp applications with the graphics framework WPF. Furthermore, .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 class library ActionPanel.PluginBase.dll. In addition, the class library ActionPanel.Common.dll is also supplied. It contains some useful helper classes.

api-folder_thumb_480_0.png

To integrate the newly developed plugin, simply copy the corresponding DLL file into the plugin directory of the SCCM Manager:

{installation path}\Web\SCCMManager\Resources\Assemblies\

After that the start menu shortcut "Update Plugin Versions" has to be executed, so that the new plugin is available for configuration in the administration interface of the SCCM Manager.

Interface IActionPlugin

The following is the interface IActionPlugin explains.

Features
Name Type Description Automatically Set
Title string Title according to action configuration Yes
Argument string Argument according to action configuration Yes
SelectedComputers ObservableCollection<IComputerItem> All computers selected at runtime are listed here Yes
IsSingleton bool Singleton according to action configuration Yes
ApplicationVariables IApplicationVariables Plugin variables from the database, values can also be modified here Yes
ActionPanelControl IActionPanel Access to various functions of the SCCM Manager and to the WebService Yes
LanguageTranslater ILanguageTranslater Access to the language translations of the plugin 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) Type of plugin. Possible values: No
ContentControl UserControl UserControl to be displayed as interface in SCCM Manager if the plugin type is a UserControl plugin No
Methods
Name Return Type Transfer Parameter Description
Initialize bool
Initialization of the plugin.
OnApplicationExit void
Event when the SCCM Manager is terminated.
UpdateArgument void string argument  If a plugin was started a second time as a singleton, this method is called.
InvokeFunction bool string function, string[] parameters  Transfer of the configured function and parameters.
Implementation
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; }
    }
}