Click or drag to resize

DirectCommandsSendJsonCommandAsync Method

Linkar Framework for .NET and Core


Allows a variety of direct operations using standard JSON templates, asynchronously only.

Namespace: Linkar.Commands
Assembly: Linkar.Commands (in Linkar.Commands.dll) Version: 2.3.1
Syntax
public static Task<string> SendJsonCommandAsync(
	CredentialOptions credentialOptions,
	string command,
	int receiveTimeout = 0
)

Parameters

credentialOptions  CredentialOptions
Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.
command  String
Content of the operation you want to send.
receiveTimeout  Int32  (Optional)
Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.

Return Value

TaskString
The results of the operation.
Example
using Linkar;
using Linkar.Commands.Direct;

class Test
    {
        public string MySendCommand()
        {
            string result = "";
            try
            {
                CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
                string command =
                    "{" +
                    "    \"NAME\" : \"READ\"," +
                    "    \"COMMAND\" :" + 
                    "    {" +
                    "        \"CALCULATED\" : \"True\" ," +
                    "        \"OUTPUT_FORMAT\" : \"JSON_DICT\" ," +
                    "        \"FILE_NAME\" : \"LK.CUSTOMERS\" ," +
                    "        \"RECORDS\" : [" +
                    "            { \"LKITEMID\" : \"2\" }" +
                    "        ]" +
                    "    }" +
                    "}";
                result = DirectCommands.SendJsonCommandAsync(credentials, command).Result;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                // Do something
            }
            return result;
        }
    }
See Also