### Get Examples in C#
Source: https://docs-platform.datareon.ru/3.1.0/developer/dev_functions
Methods to retrieve examples from the ontology. You can get all examples, examples belonging to a specific class, or a single example by its unique identifier. TryGetExample provides a non-exception-throwing alternative for retrieving a single example.
```csharp
Ontology.GetExamples();
// Возвращает список объектов Example.
Ontology.GetExamplesByClass(Guid classId);
// Возвращает список объектов Example.
Example Ontology.GetExample(Guid exampleId);
// Возвращает объект Example, если пример существует. Если пример не существует, то срабатывает исключение NotExistsException.
bool Ontology.TryGetExample(Guid exampleId, out Example example)
```
--------------------------------
### Create Link for Data Types
Source: https://docs-platform.datareon.ru/developer/dev_functions
Methods to create links for specific data types. `CreateLink()` generates a link with a default identifier, while `CreateLink(Guid entityId)` allows specifying a particular entity's GUID for the link.
```csharp
using Metadata;
// Create a link with a default identifier
LinkType link1 = Metadata.DataTypes.SomeDataType.CreateLink();
// Create a link with a specific entity ID
Guid specificEntityId = Guid.NewGuid();
LinkType link2 = Metadata.DataTypes.SomeDataType.CreateLink(specificEntityId);
```
--------------------------------
### Get Handler Information
Source: https://docs-platform.datareon.ru/developer/dev_functions
Retrieves detailed information about a handler, including its ID, name, description, connector type, parameters, and response expectations. The `HandlerInfo` class encapsulates these details.
```csharp
using Metadata;
HandlerInfo info = Metadata.Handlers.SomeHandler.GetHandlerInfo();
Guid handlerId = info.Id;
string handlerName = info.Name;
string description = info.Description;
ConnectorType connectorType = info.ConnectorType;
PropertiesCollection parameters = info.Parameters;
bool waitResponse = info.WaitResponse;
bool waitArray = info.WaitArray;
Metadata.DataTypes waitDataType = info.WaitDataType;
Metadata.SM waitSystemDataType = info.WaitSystemDataType;
```
--------------------------------
### Role Management API
Source: https://docs-platform.datareon.ru/developer/dev_functions
Endpoints for managing roles, including retrieving lists of roles, getting roles by ID or name, and checking for role existence.
```APIDOC
## Credential API - Role Management
### Description
Provides methods for managing roles within the system. This includes retrieving all available roles, fetching a role by its unique identifier or name, and checking if a role exists.
### Methods
#### GetRoles
**Description**: Retrieves a list of all available roles.
**Method**: GET
**Endpoint**: `/api/credentials/roles`
#### GetRoleById
**Description**: Retrieves a specific role by its unique identifier.
**Method**: GET
**Endpoint**: `/api/credentials/roles/{roleId}`
**Path Parameters**:
- **roleId** (Guid) - Required - The unique identifier of the role.
#### GetRoleByName
**Description**: Retrieves a specific role by its name.
**Method**: GET
**Endpoint**: `/api/credentials/roles?name={roleName}`
**Query Parameters**:
- **roleName** (string) - Required - The name of the role.
#### RoleExists
**Description**: Checks if a role exists by its ID or name.
**Method**: GET
**Endpoint**:
- By ID: `/api/credentials/roles/exists/id/{roleId}`
- By Name: `/api/credentials/roles/exists/name/{roleName}`
**Path Parameters**:
- **roleId** (Guid) - Required - The unique identifier of the role.
- **roleName** (string) - Required - The name of the role.
```
--------------------------------
### Get Public Key for Password Encryption
Source: https://docs-platform.datareon.ru/developer/dev_functions
Retrieves a public key valid for 1 minute, used for encrypting passwords for external users.
```APIDOC
## Get Public Key for Password Encryption
### Description
Retrieves a public key that is valid for 1 minute, used for encrypting passwords for external users. After expiration, a new key must be requested.
### Method
GET
### Endpoint
`/api/credential/externalUsers/publicKey`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
### Request Example
(No request body or parameters needed)
### Response
#### Success Response (200)
- **publicKey** (string) - The public key for encryption.
#### Response Example
```json
{
"publicKey": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----"
}
```
```
--------------------------------
### Get Pipeline Operative Data Snapshot (C#)
Source: https://docs-platform.datareon.ru/developer/dev_functions
Fetches the current operative data snapshot for a specified conveyor pipeline. The result is an OwnList of ConveyorProcessData, providing real-time operational insights. This is an asynchronous operation.
```csharp
///
/// Текущие оперативные данные конвейера
///
///
///
public Task> GetOperativeDataSnapshot(Guid conveyorId);
```
--------------------------------
### Get External User by Name
Source: https://docs-platform.datareon.ru/developer/dev_functions
Retrieves external users by their name.
```APIDOC
## Get External User by Name
### Description
Retrieves a list of external users matching the provided name.
### Method
GET
### Endpoint
`/api/credential/externalUsers/users`
### Parameters
#### Path Parameters
None
#### Query Parameters
- **name** (string) - Required - The name of the external user to search for.
### Request Example
(Query parameter is appended to the URL)
`/api/credential/externalUsers/users?name=user01`
### Response
#### Success Response (200)
- **users** (array) - A list of external user objects matching the name.
- **userId** (string) - The ID of the external user.
- **name** (string) - The name of the external user.
- **login** (string) - The login name.
- **description** (string) - Description of the user.
- **comment** (string) - Comment about the user.
- **systemId** (string) - ID of the system.
- **internalUserId** (string) - ID of the internal user.
#### Response Example
```json
{
"users": [
{
"userId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"name": "user01",
"login": "user01",
"description": "user01test",
"comment": "comment111",
"systemId": "0abb2f56-30bf-4b4b-8049-2e8ae592892f",
"internalUserId": "90AD1E95-BA6F-4AE0-8E1B-1CF2D74FAAA4"
}
]
}
```
```
--------------------------------
### Get Message Body as Various Data Types (C#)
Source: https://docs-platform.datareon.ru/developer/dev_functions
Provides methods to retrieve the message body in different formats: as bytes, a string, a JSON object, or a strongly-typed object. It handles cases where the body might be a single element or an array.
```csharp
byte[] GetBodyAsBytes() //получить тело сообщения как массив байт
string ВхСообщ.GetBodyAsString() // получить тело в типе строка
JObject ВхСообщ.GetBodyAsObject() // получить тело сообщения как объект
// если в теле передан массив из одного элемента вернет этот элемент как объект типа
object ВхСообщ.GetBodyAsObject(Type t) // получить тело сообщения как объект
// если в теле передан массив из одного элемента вернет этот элемент как объект типа
T ВхСообщ.CastToDataType() //получить тело сообщения как объект типа.
// если в теле передан массив из одного элемента вернет этот элемент как объект типа
T ВхСообщ.CastToDataType(int index) //получить тело сообщения как объект типа.
// если в теле передан не массив и index == 0 вернет этот элемент как объект типа
// если в теле передан массив и index < длины массива вер нет элемент по индексу как
// объект типа
BaseClass ВхСообщ.GetBodyAsDataType() //получить сообщение как объект типа
// установленного в DataType
//Если DataType не задан - вернет null
BaseClass ВхСообщ.GetBodyAsSystemDataType() //получить сообщение как объект типа
// установленного в SystemDataType
//Если SystemDataTypeне задан - вернет null
```
--------------------------------
### Get GUID Property Example
Source: https://docs-platform.datareon.ru/3.0.53.1/administrator/external/restapi_system
Provides an example of how to obtain a GUID property, specifically 'MethodId', which identifies the called handler. This is useful for logging and debugging.
```pseudocode
GetGuidProperty("MethodId")
```
--------------------------------
### Manage Platform Services
Source: https://docs-platform.datareon.ru/3.2.0/installation/install_linux_Debian
Commands to start, stop, restart, and manage the Platform service and its components. Includes commands for initialization, environment setup, certificate management, and debugging.
```bash
platformmanager start
```
```bash
systemctl status platformmanager
```
```bash
platformmanager stop
```
```bash
platformmanager restart
```
```bash
platformmanager init
```
```bash
platformmanager initenvironment
```
```bash
platformmanager removeenvironment
```
```bash
platformmanager setCertificate
```
```bash
platformmanager startnode
```
```bash
platformmanager stopnode
```
```bash
platformmanager list
```
```bash
platformmanager show -t <тип_узла> -n <имя_узла>
```
```bash
platformmanager debug
```
```bash
platformmanager useSsl
```
```bash
platformmanager unUseSsl
```
--------------------------------
### Ontology Module Configuration Example (JSON)
Source: https://docs-platform.datareon.ru/3.0.53/administrator/services
This JSON snippet demonstrates a typical configuration for the Ontology module. It includes database connection settings, service parameters, and module identification details. This configuration is used to define how the Ontology module interacts with the database and the platform.
```json
{
"$type": "DT.ClusterConfiguration.NodeModule, DT_Core",
"config": {
"$type": "DT.ConfigurationRepository.Configuration.ModuleConfiguration.OntologyConfig, DT_ConfigurationRepository",
"databaseConfiguration": {
"$type": "DT.ClusterConfiguration.DBConnectionConfig, DT_Core",
"databaseType": "MsSql",
"useConnectionString": false,
"useUsernameAndPassword": true,
"serverAddress": "DTplatform31",
"serverPort": "1433",
"serverInstance": "sqlexpress",
"database": "MyDB",
"account": {
"$type": "DT.ClusterConfiguration.Account, DT_Core",
"userName": "Testing",
"passwordNew": "Testing",
"useCredential": false
},
"integratedSecurity": false,
"pooling": true,
"minimumPoolSize": 5,
"maximumPoolSize": 10,
"connectionLifetime": 0,
"properties": []
},
"sendingStrategy": ""
},
"isActive": true,
"folderId": null,
"entityId": "b5fecb0a-a516-449d-9533-8a262adc9df5",
"clusterId": "140e7996-8609-4ebd-a783-ca63855dbb9a",
"name": "Онтология",
"description": "Онтология",
"comment": "",
"version": 1,
"tagsCollection": [],
"className": "OntologyConfig",
"classNameStr": "Онтология"
}
}
```
--------------------------------
### Get GUID Property Example
Source: https://docs-platform.datareon.ru/3.1.1/administrator/external/restapi_system
Shows how to obtain a GUID property, specifically 'MethodId', which identifies the called handler. This method is part of the property collection. It returns the GUID value or null if the property is not found.
```javascript
const methodId = message.GetGuidProperty("MethodId");
```
--------------------------------
### External System Configuration Example (JSON)
Source: https://docs-platform.datareon.ru/3.2.0/administrator/external/restapi_system
This JSON snippet demonstrates the configuration structure for an external system within the Datareon platform. It includes details about the connector type, port, security settings, authentication, response error handling, and server information. This configuration is crucial for integrating external services.
```json
{
"$type": "DT.ClusterConfiguration.DtSystem, DT_Core",
"config": {
"$type": "DT.ConfigurationRepository.Configuration.Adapter.WebSystemConfig, DT_ConfigurationRepository",
"connectorType": "Web",
"port": 102,
"useHttps": true,
"replyStoreTime": 0,
"publishSwagger": true,
"authTypeRest": "Bearer",
"sslProtocols": [
"Tls",
"Tls11",
"Tls12"
],
"auth": {
"$type": "DT.ClusterConfiguration.AuthenticationConfig, DT_Core",
"enabled": true,
"usePasswordHash": false
},
"responseErrorSettings": {
"$type": "DT.ConfigurationRepository.Configuration.Adapter.ResponseErrorSettings, DT_ConfigurationRepository",
"bodyJsonTemplate": "{\n \"кодОтвета\": {errorCode},\n \"текстОшибкиРасширенный\": \"мой произвольный текст -{errorMessage}\",\n \"текстОшибкиКраткий\": \"{errorMessage}\",\n \"поляПлохие\": \"{notValidFields}\"\n}",
"validationErrorCode": 489
},
"handlersList": [],
"sendingStrategy": ""
},
"isActive": true,
"folderId": null,
"servers": [
""
],
"entityId": "1ee43391-769d-417b-a9d6-d9476632ea0d",
"clusterId": "2f070fd4-ccba-4c25-bfd9-334c4a5f64a6",
"name": "REST",
"description": "Test",
"version": 1,
"tagsCollection": [],
"className": "System",
"classNameStr": "Внешняя система"
}
```
--------------------------------
### Start and Check Platform Service
Source: https://docs-platform.datareon.ru/3.0.53/installation/install_linux_RHEL
Starts the Platform service using the 'platformmanager start' command and then checks its status using 'systemctl status platformmanager'. This verifies that the service has started successfully.
```bash
platformmanager start
systemctl status platformmanager
```
--------------------------------
### Retrieve Example by Content
Source: https://docs-platform.datareon.ru/3.0.53.1/developer/dev_functions
Searches for and returns an `Example` object based on its content string. Returns `null` if no matching example is found.
```csharp
Ontology.GetExampleByContent(string content);
```
--------------------------------
### Retrieve All Examples
Source: https://docs-platform.datareon.ru/3.0.53.1/developer/dev_functions
Fetches a list of all `Example` objects currently stored in the ontology.
```csharp
Ontology.GetExamples();
```
--------------------------------
### Get Message Property Example
Source: https://docs-platform.datareon.ru/3.1.2/administrator/external/restapi_system
These examples demonstrate how to retrieve specific boolean, string, or GUID properties from a message using provided methods. These are useful for accessing configuration details and identifiers within the system.
```csharp
GetBoolOrNullProperty("AnswerRequired")
GetStringOrNullProperty("AnswerRequired")
GetStringOrNullProperty("AnswerSystemDataType")
GetStringOrNullPropert("MethodType")
GetGuidProperty("MethodId")
```
--------------------------------
### Execute Business Processes and Algorithms
Source: https://docs-platform.datareon.ru/3.2.0/developer/dev_functions
Code examples demonstrating how to instantiate and execute business processes (BPs) and algorithms. This includes setting parameters for the BP and initiating execution with or without waiting for completion using the Executor class.
```csharp
var BP1 = new Вызываемый(); // Create an instance of the BP
// Set parameters
BP1.строка = "Здравствуй"; // String parameter
BP1.Сложное.число = 1; // Parameter within a complex type or group
// Execute the BP
Executor.Start(BP1); // Execute without waiting
Executor.Execute(BP1); // Execute and wait for completion
```