Controllers

The Server and client interact with each other via several main controllers with the following methods and parameters.

Responses from the controller methods are wrapped in an additional object. Below is an example of a successful completion of an operation:

{
    item: {...some response object ...},
    success: true
}

or

{
    message: "Some operation complete",
    success: true
}

An example of an error response

{
    message: "Some exception",
    details: "Stack trace",
    success: false
}

UserInterfaceController

The GetForm (route ui/form/{name}) method

Input parameters:

  • name - name of a form
  • wrapResult - if true, the JSON forms will be wrapped in an object of a {item:{form},success:true} type.
  • enableSecurity - if true, a form will included information about the permissions for the current authorized user, connected to the form.

Returns a form description object serialized in JSON, which contains the following important fields:

 public class Form : IMetadataItem
    {
        ...
        public string Name;
        public string Source;
        public List<FormPermissions> Permissions;
        public FormDataMapping Mapping;
        ...
    }
  • Source - a form layout stored and visualized in the Form Builder.
  • Permissions - the permission connected to a form with the indication of Permitted, Forbidden or Inherited.
  • Mapping - the name of a form controller - name of a data attribute relation and vice versa. Used automatically for modal child forms.

The GetFormsBusinesscode (route ui/login) method

Returns a Javascript file with the code of all client user-defined actions.

The Login (route ui/form/{name}) method

Returns a login form.

ConfigAPIController

The API (route ConfigAPI) method

A system method for saving/loading metadata from the admin to the server. The request parameters are the following:

  • operation - a type of request that influences what parameters will be accepted by the server and what will be returned.
    • operation = load - returns all system metadata, except for forms
    • operation = loadform - loads and saves forms
    • operation = change - saves metadata
    • operation = compile - test compilation of server user-defined actions
    • operation = resetappcache - clears metadata cache in the application
    • operation = uploadlicense - uploads a license file to the server
    • operation = analysedb - calculates delta between the state of the database and metadata
    • operation = workflow - workflow operations (a list of schemes, change of the state and status of a process, etc.)

DataController

The GetData (route data/get) method

Input parameters:

  • name - name of a form
  • control - name of a form control, which is specified in case you request not the data for the entire form, but a page of data for a grid with server pagination.
  • urlFilter - part of the url, responsible for the filter. It can be represented in the following formats:
    • hostname/form/FormName/FilterActionName/ - name of a server user-defined action - filter
    • or hostname/form/FormName/90fb3531-808f-43d9-be92-d3c5e8b70ebd/ - value of the primary key of an opened record
    • or hostname/form/FormName/[{term:"Like",column:"Name",value:"Document1"},{term:"EqGt",column:"Amount",value:10}] - value of a filter by columns, serialized in JSON. This expression means Name LIKE ('%Document1%') AND Amount >= 10.
  • options - a serialized object-parameter transmitted to the server user-defined action - filter
  • filter - a filter serialized in JSON, sent by a grid with server pagination, for example, [{term:"Like",column:"Name",value:"Document1"},{term:"EqGt",column:"Amount",value:10}]
  • paging - a request of a data page, serialized in JSON, sent by a grid with server pagination, for example, {startIndex:20,pageSize:10}
  • sort - sorting serialized in JSON, sent by a grid with server pagination, for example, [{Column:"Name",Order:"ASC"},{Column:"Amount",Order:"DESC"]

Returns the data to be displayed in the form or the data for a grid with server pagination. Grids with server pagination request data apart from the rest of the form. As far as grids with server pagination are independent from each other, each grid requests data only for itself. Let's consider a form in the following example. This form does not contain grids with server pagination, that's why one request is enough to get the data it needs.

{
...
    amount: 111,
    comment: null,
    Id: '90fb3531-808f-43d9-be92-d3c5e8b70ebd',
    __id: '90fb3531-808f-43d9-be92-d3c5e8b70ebd',
    gridHistory: [
        {
        ...
            command: 'Approve',
            to: 'Accounting review',
            Id: 'cd8ebe54-2a33-4b3a-b318-0bbc1d13af87',
            from: 'BigBoss signing',
            __id: 'cd8ebe54-2a33-4b3a-b318-0bbc1d13af87'
        ...
        },
        {
        ...
            command: 'SetState',
            to: 'Manager signing',
            Id: 'f47d6f0e-81a2-4fbd-b6e2-8083b518e547',
            from: 'Vacation request created',
            __id: 'f47d6f0e-81a2-4fbd-b6e2-8083b518e547'
        ...
        },
    ]
...
}

This form contains only one grid with server pagination, that's why responses to its requests will look like this:

{
    __grid_totalcount: 2,
    grid: [
        {
            amount: 100,
            comment: null,
            Id: "90fb3531-808f-43d9-be92-d3c5e8b70ebd",
            name: "Name1",
            State: "RequestApproved",
            __id: "90fb3531-808f-43d9-be92-d3c5e8b70ebd"
        ...
        },
        {
            amount: 200,
            comment: "Test comment",
            Id: "cd8ebe54-2a33-4b3a-b318-0bbc1d13af87",
            name: "Name2",
            State: "AccountingReview",
            __id: "cd8ebe54-2a33-4b3a-b318-0bbc1d13af87"
        ...
        }
    ]
}        

The ChangeData (route data/change) method

Changes the form data. Input parameters are:

  • name - name of a form
  • data - the changed form data. The data format is identical to the data retutned by the GetData method

Returns a success or error response.

The DeleteData (route data/delete) method

Used to delete data from the entire form or lines from the grid with server pagination. Input parameters are:

  • name - name of a form
  • control - control - name of a form control, specified in case you delete not the data from the entire form, but the lines from the grid with server pagination
  • data - a list of IDs of deleted records, serialized in JSON

Returns a success or error response.

The GetDictionary (route data/dictionary) method

Returns the data for the control of the Dictionary type. Input parameters are:

  • name - name of the Data model specified in the settings of the Dictionary control
  • sort - sorting serialized in JSON, for example [{Column:"Name",Order:"ASC"},{Column:"Amount",Order:"DESC"]
  • columns - a serialized list of columns, from which an output value is formed, for example ["Name","Amount"]

Returns a dictionary of values.

[
    {key:"cd8ebe54-2a33-4b3a-b318-0bbc1d13af87", value: "Name1 100" },
    {key:"90fb3531-808f-43d9-be92-d3c5e8b70ebd", value: "Name2 200" }
]

WorkflowController

The DesignerAPI (workflow/designerapi) method

Enables proper functioning of the Workflow Designer.

The GetData (workflow/get) method

Returns a list of commands and states available for a document. Input parameters are:

  • name - name of a form
  • urlFilter - part of the url, responsible for the filter. It can be represented in the following formats:
    • hostname/form/FormName/FilterActionName/ - name of a server user-defined action - filter
    • or hostname/form/FormName/90fb3531-808f-43d9-be92-d3c5e8b70ebd/ - value of the primary key of an opened record

DWKit finds a requested document, finds a corresponding WFE Process and returns a list of commands and states available for setting.

{
    commands : [{Value:"CommandSystemName", Text:"Command name", Scheme:"WorkflowSchemeName",Type:1},{...}],
    states : [{Value:"StateSystemName", Text:"State name"},{...}]
}

For more details, refer to the sections on commands and states.

The ExecuteCommand (workflow/execute) method

Executes a command. Input parameters are:

  • name - name of a form
  • id - id of a document
  • command - name of the command to be executed

Returns a success or error response.

The SetState (workflow/set) method

Sets a state. Input parameters are:

  • name - name of a form
  • id - id of a document
  • state - name of the state to be set

Returns a success or error response.