Skip to main content

Step 5 – Writing the POST action

The system onboarding POST action can be used to verify and modify already-entered onboarding values. In the following example, you can write a POST action, which validates that the entered path to the XML file for the directory is correct, and therefore confirm that the file does exist.

  1. In Visual Studio, create an empty class library project targeting .NET 4.6.1.

  2. Add a reference to the Omada.OE.Solution.OIM.AppLogic.dll file. The assembly is installed as part of the SDK. You can find it here: C:\Program Files\Omada SDK\V14.0\libs.

  3. Add a new class named Postaction. The class is placed in the Acme.Foo.Postaction namespace. The name of the assembly is the same. For example:

    using Omada.OE.Solution.OIM.AppLogic.SystemOnboarding.Model;
    using Omada.OE.Solution.OIM.AppLogic.SystemOnboarding.PostActions;
    using System;
    using System.IO;
    namespace Acme.Foo.Postaction
    {
    public class Postaction : ISystemOnboardingPostActionHandler
    .
    .

    The assembly name is what you must enter in the registration file under <codeAssemblies\>. See the following code sample:

  4. The class must implement the ISystemOnboardingPostActionHandler interface. The interface has a single method, Validate, which you must implement. See the following code sample:

        public void Validate(ActionArgument arguments)
        {
          if (arguments.Scope == EnumScope.DataConnection && arguments.HasValuesForSection("ConnectionDetails"))
          {
            var isTestConnectionEnabled =
              arguments.GetParameterValue("ConnectionDetails", "testConnection") != null ?
                Convert.ToBoolean(arguments.GetParameterValue("ConnectionDetails", "testConnection").Value) : false;
            if (isTestConnectionEnabled)
            {
              string filePath = arguments.GetParameterValue("ConnectionDetails", "filePath", "");
              if (!File.Exists(filePath))
              {
                string errorMessage = String.Format("Connection test failed!\n\nFile '{0}' was not found", filePath);
                throw new ApplicationException(errorMessage);
              }
            }
          }
        }

In the code sample, the Validate method gets an ActionArgument object passed as a parameter. This object contains all the values entered from the System Onboarding page. The ActionArgument class contains a set of methods which can be used to read and write values.

Also, the code sample shows if there are any values present from the ConnectionDetails sections, and if the testConnection parameter was set. If so, you get the entered file path from the filePath parameter.

Using standard .NET methods, the code sample also checks if the file exists or not.

This code is performed on the server hosting the Enterprise Server, and it is performed by the application pool identity.

If the file does not exist, an exception is thrown. When this happens, the new values entered are not persisted.

For more details regarding the ISystemOnboardingPostActionHandler interface and the ActionArgument class, see the Omada.SDK.Reference.chm file located in the following path: C:\Program files\Omada SDK\V14.0\doc or see the Related documentation section.