Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Mobile Operator Extensibility SDK On-Premises

Create a custom mobile action

  1. Create a new Visual C# Class Library Project which targets the .NET Framework 4.8 with Visual Studio 2017/2019.
    NOTE: The assembly created must include the file extension in its name for the AVEVA Mobile Operator Plug-In system to load it. The assembly created must also have the string "action" in the name (e.g. "CustomAction.dll").  
  2. Add references to SAT.Core.dll and AA.Core.Mobile.dll, located in the AVEVA Mobile Operator Client installation directory (by default, "\Program Files\AVEVA\Mobile Operator\Client") in the new project.
  3. Open AssemblyInfo.cs, located in the "Properties" section of the solution file, and add the following lines:

    [assembly: SAT.ComponentModel.Extensibility.AssemblyPlatform(SAT.ComponentModel.Extensibility.PlatformContext.Any)]   

     

    [assembly: SAT.ComponentModel.Services.CallingContext(SAT.ComponentModel.Services.CallingContextEnum.Default)] 

     

  4. Rename the solution, class library, and assembly to "MyCustomMobileAction" (as per the "namespace" section of step 5).
  5. Create a new class that inherits from AA.Core.Mobile.ComponentModel.SDK.Procedure.MobileSdkActionPlugin. 
    (NOTE: The GUID shown below in the line "[PluginInfo(typeof(MobileSdkActionPlugin), `GUID`)]" must match the ID created for the Custom Action.

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text;
    using SAT.ComponentModel.Extensibility;
    using AA.Core.Mobile.ComponentModel.SDK.Procedure;
    using System.IO;
    using AA.Core.Mobile.Procedure;
    using AA.Core.Mobile; 
    namespace MyCustomMobileAction


    {
       [PluginInfo(typeof(MobileSdkActionPlugin), "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
        public class MyCustomMobileAction : MobileSdkActionPlugin
        {
     
               private string fileName = "outputFileName.txt";
     
               public string UserName
               {
                  get
                  {
                      return base.GetPropertyBagAttributeValue("CustomTagHostName");
                  }
               }
     
     
               public MyCustomMobileAction(string propertyBag, IProcedureNode parentNode, Guid id)
                : base(propertyBag, parentNode, id)
               {
     
               }
     
               #region IMobileActionPlugin Members
     
               public override string Execute(IProcedureController procedureController)
               {
                  using (StreamWriter fileStream = new StreamWriter(fileName, true))
                  {
                     fileStream.Write("User {0} and node {1} had a value of {2}", UserName,
                        procedureController.CurrentNode.DisplayName,   procedureController.CurrentNode.Value);
                  }
     
                  return string.Format("MyCustomAction and wrote the file to {0}", fileName);
               }
     
            public override string StatusMessage(IProcedureController procedureController)
            {
                return string.Format("MyCustomAction data writer {0}", fileName);
            }
     
            public override MobileProcedureRunType ActionRunType
            {
                get { return MobileProcedurePluginRunType.FileIO; }
                
            }
     
            public override string DisplayName
            {
                get { return "MyCustomAction"; }
            }
     
            #endregion
         }
    }       

  6. Following are the uses of the methods within the code:

    1. public override string Execute()
      This function is called during execution and returns the result of the action based on the condition.
    2. public override string GetPropertyBagAttributeValue()
      This returns the value of the key or the value pair.
    3. public override string DisplayName()
      The display name in the Management Center.
    4. public override string StatusMessage()
      The status of the executed action.
    5. public override bool ActionRunType()
      This function denotes the type of action performed.
  7. Compile the DLL.
  8. To use the custom action in Procedure Builder, copy the compiled DLL (from the output directory specified by the build process) to the AVEVA Mobile Operator Client installation directory (by default: "\Program Files\AVEVA\Mobile Operator\Client").
TitleResults for “How to create a CRG?”Also Available in