Create an Action

Create an action class that inherits from ActionBase.

using ActionFramework.Base;
using System;

namespace DemoApp
{
    public class DemoAction1 : ActionBase
    {
        //define the runtime configuration properties
        public string MyProp { get; set; }

        //override the runtime "execute" function 
        public override object Execute()
        {
            try
            {
                //implement action logic, log my "MyProp" value
                Log.Info("Just make a log entry: " + MyProp);

                return HandleSuccess();
            }
            catch (Exception ex)
            {
                return HandleException(ex);
            }
        }
    }
}

Configure the action.

<?xml version="1.0" encoding="UTF-8"?>

<ActionFramework>
    <Settings>
        <Setting Value="true" Name="MyGlobalProperty"/>

        <!-- define a runtime function "GetExecutionParentRoot" -->
        <Setting Value="Invoke|GetExecutionParentRoot" Name="ExecutionRoot"/>

        <!-- using {variables} to define a custom log folder -->
        <Setting Value="{ExecutionRoot}log\custom\" Name="CustomLogFolder"/>
    </Settings>

    <Actions>
        <Action Id="1" Type="DemoAction1" BreakOnError="true" Description="A short description" ClientExecute="true" Enabled="true">
            <Property Name="MyProp" Value="{CustomLogFolder}"/>
        </Action>
    </Actions>

</ActionFramework>

Log output (xml).

<ActionLog Created="2015-12-02T14:00:55.5684275+01:00">
  <Log>

    <!-- action log results -->
    <Action ActionId="2" ActionType="DemoAction1" Created="2015-12-02T13:59:43.1744245+01:00" Assembly="DemoApp v.1.0.0.0 by Woxion AB">
      <Information>Just make a log entry: C:\actionframework\agents\12345\log\custom\</Information>
      <Information>Status: OK</Information>
    </Action>

    <!-- general agent information log -->
    <Agent Created="2015-12-02T13:58:03.2254255+01:00">
      <AssemblyLog>
        <Message>Assembly</Message>
        <Version>
          <Major>1</Major>
          <Minor>0</Minor>
          <Build>5814</Build>
          <Revision>25042</Revision>
          <MajorRevision>0</MajorRevision>
          <MinorRevision>25042</MinorRevision>
        </Version>
        <Title>ActionFramework</Title>
        <ProductName>ActionFramework</ProductName>
        <CopyrightHolder>Copyright © Woxion AB 2013</CopyrightHolder>
        <CompanyName>Woxion AB</CompanyName>
      </AssemblyLog>

      <!-- logging server instance url -->
      <Information>ActionList Initiated. Using http://localhost:12345 server url.</Information>

      <!-- general log results -->
      <ActionResultLog>
        <Message>Action Results</Message>
        <Total>1</Total>
        <AgentExecute>1</AgentExecute>
        <InternalActionExecute>0</InternalActionExecute>
        <Failed>0</Failed>
        <Runtime>00:01:12.39</Runtime>
      </ActionResultLog>
    </Agent>
  </Log>
</ActionLog>

On demand (REST) Actions

Build the Action class.

public class OnDemandDemo : ActionBase
{
    //GET (no parameters)
        public override object Execute()
        {
            try
            {
                XDocument result = XDocument.Parse("<xml>content</xml>");

                Log.Info("Parsed filecontent successfully");

                return result;
            }
            catch (Exception ex)
            {
                return HandleException(ex);
            }
        }

        //POST (object input parameter)
        public override object Execute(object input)
        {
            try
            {
                Log.Info("Object Input: " + input.ToString());

                return input;
            }
            catch (Exception ex)
            {
                return HandleException(ex);
            }
        }
}

Call the agent API endpoints (GET/POST). 

string uri = "http://localhost:1011/";

//GET:
var getclient = new RestClient(uri);
var getrequest = new RestRequest("api/agent/runaction/ondemanddemo", Method.GET);
var getresponse = getclient.Execute(getrequest);
Console.WriteLine(getresponse.Content);
Console.ReadLine();

//POST:
var postclient = new RestClient(uri);
var postrequest = new RestRequest("api/agent/runaction?name=ondemanddemo", Method.POST);
postrequest.RequestFormat = DataFormat.Json;
postrequest.AddBody(new TestModel()
{
    Id = 1,
    Name = "Test"
});

var postresponse = postclient.Execute(postrequest);
Console.WriteLine(postresponse.Content);
Console.ReadLine();

API endpoints

AGENT

GET http://{host}/api/agent/timer/info
GET http://{host}/api/agent/timer/stop
GET http://{host}/api/agent/timer/initialized
GET http://{host}/api/agent/timer/start/{interval}
GET http://{host}/api/agent/run
GET http://{host}/api/agent/run/{name}
POST http://{host}/api/agent/runaction?name={action}
GET http://{host}/api/agent/runaction/{action}

SERVER

ACTION

GET http://{host}/api/action/write/{text}
GET http://{host}/api/action/get/{id}
GET http://{host}/api/action/getbyagentid/{agentid}
GET http://{host}/api/action/available/{agentid}
GET http://{host}/api/action/create/{actionmodel}

AGENT

GET http://{host}/api/agent/list
GET http://{host}/api/agent/uri/{agentid}
GET http://{host}/api/agent/{agent}/{file}
GET http://{host}/api/run/{agent}
GET http://{host}/api/getserverinfo/{uri}
GET http://{host}/api/getagent/{id}
GET http://{host}/api/getagents
GET http://{host}/api/getapps/{agentid}
GET http://{host}/api/getagentschedule/{uri}

APP

GET http://{host}/api/app/getapps/{agentid}
GET http://{host}/api/app/install/{agentid}/{appid}/{uri}

LOG

GET http://{host}/api/log/detail/{id}
GET http://{host}/api/log/getlogswithpaging/{page}/{pagesize}
POST http://{host}/api/log/write
GET http://{host}/api/log/getlogcount