Flexmonster Software License Agreement (“Agreement”) has been significantly revised and is effective as of September 30, 2024.
The following modifications were made:
The modified version of Flexmonster Software License Agreement is available here.
Downloading, installing, and/or continuing to use Flexmonster Software after September 30, 2024, constitutes Licensee’s acceptance of the terms and conditions of the modified version of Flexmonster Software License Agreement. If Licensee does not agree to any of these terms and conditions, they must cease using Flexmonster Software and must not download, install, use, access, or continue to access Flexmonster Software. By continuing to use Flexmonster Software or renewing the license under License Model or Maintenance after the effective date of any modifications to Agreement, Licensee accepts and agrees to be bound by the terms and conditions of the modified Agreement.
This guide describes the available configurations for Flexmonster.DataServer.Core.dll
. For the Data Server DLL, it is possible to configure data sources and set the data refresh time.
The Data Server supports the following configuration properties:
{
DataSources: DataSourceConfigObject[],
DataStorageOptions: DataStorageOptionsObject,
ReportSharingOptions: ReportSharingOptionsObject
}
Property/Type | Description |
---|---|
DataSources DataSourceConfigObject[] | Options for configuring the data sources. |
DataStorageOptions DataStorageOptionsObject | optional Allows configuring options for data storage. |
ReportSharingOptions ReportSharingOptionsObject | optional Allows configuring the report-sharing functionality. |
This object allows configuring a data source. It has the following properties:
{
Type: string,
DatabaseType: string,
ConnectionString: string,
Indexes: object
}
Property/Type | Description |
---|---|
Type String | The type of the data source: "json" , "csv" , "database" , or your custom type (for the custom parser). |
DatabaseType String | optional The type of the database: "mysql" , "mariadb" , "mssql" , "postgresql" , or "oracle" . Only for the "database" data source type. |
ConnectionString String | optional A connection string for the database. Only for the "database" data source type.Setting passwords with special characters in the connection string. The Data Server parses passwords with special characters correctly unless the password contains ; or " . These symbols are treated as delimiters, so they should be escaped:
|
Indexes Object | Contains a list of datasets. Each dataset is represented by a "key": "value" pair, where "key" is a dataset name. The "value" can either be null (only for the custom data source type) or be an IndexObject. |
This object describes a specific dataset. It has the following properties:
{
Path: string,
Query: string,
Mapping: ServerSideMappingObject,
Delimiter: string,
DecimalSeparator: string,
ThousandsSeparator: string,
Status: string,
RefreshTime: number
}
Property/Type | Description |
---|---|
Path String | optional The path to the file with data. Only for "json" and "csv" data source types. |
Query String | optional The query to execute (e.g., "SELECT * FROM tablename" ). It can contain a stored procedure. Only for the "database" data source type. |
Mapping ServerSideMappingObject | optional Defines how the Data Server should process fields from the dataset. Only for "json" and "csv" data source types. |
Delimiter String | optional Defines the specific fields separator to split each CSV row. There is no need to define it if the CSV fields are separated by , . This property is required only if another character separates fields.Default value: "," . |
DecimalSeparator String | optional Defines the specific character used to separate decimal parts of numbers. For example, to import CSV data with commas used to separate decimal parts of numbers (e.g., 3,14 ), set the DecimalSeparator property to "," .Default value: "." . |
ThousandsSeparator String | optional Defines the specific character used to separate groups of digits in numbers. For example, to import CSV data with periods used to separate groups of digits in numbers (e.g., 1.000 for one thousand), set the ThousandsSeparator property to "." .Default value: "," . |
Status String | optional The index status. It can be either "enabled" or "disabled" . Disabled indexes are not available from the client.The Status property is available starting from version 2.9 of the Data Server.Default value: "enabled" . |
RefreshTime Number | optional Defines how often the Data Server reloads the data for the index. The refresh time is specified in minutes and is measured from the moment the Data Server starts up. If the RefreshTime is specified, it overrides the DataStorageOptions.DataRefreshTime property.When the RefreshTime is set to 0 , the Data Server will not reload the data. If the RefreshTime is not specified, the Data Server will use the value set in the DataStorageOptions.DataRefreshTime property.The RefreshTime property is available starting from version 2.9 of the Data Server. |
This object defines how the Data Server should process fields from the dataset. It has the following properties:
Mapping: {
<uniqueName>: {
Type: string
}
}
This object allows configuring options for data storage. It has the following properties:
DataStorageOptions: {
DataRefreshTime: number,
CacheSizeLimit: number,
KeepDataOnRefresh: boolean,
CommandTimeout: number
}
Property/Type | Description |
---|---|
DataRefreshTime Number | optional Defines how often the Data Server reloads the data from the data source. The refresh time is specified in minutes and is measured from the moment the Data Server starts up. The Indexes.<indexName>.RefreshTime property overrides the DataRefreshTime .By default, the DataRefreshTime is 0 , which means the Data Server will not reload the data. |
CacheSizeLimit Number | optional The maximum number of cached server responses for every index defined in the DataSources property. When set to 0 , the Data Server does not cache the responses.Default value: 100 . |
KeepDataOnRefresh Boolean | optional When set to true , the Data Server keeps a copy of index data while the index is being refreshed. As a result, the index is available to Flexmonster Pivot even during index reload. Note that this feature requires more RAM. As soon as the index is refreshed, the Data Server deletes its copy.If KeepDataOnRefresh is set to false , the index will be unavailable while refreshing.Default value: true . |
CommandTimeout Number | optional Defines the wait time before canceling the attempt to execute the Query and generating an error. The wait time is set in seconds. When set to 0 , the wait time is unlimited.If CommandTimeout is not specified, the Data Server will use the timeout value from the SQL driver. Only for the "database" data source type. |
This object allows configuring the report-sharing functionality. It contains the following properties:
ReportSharingOptions: {
PathToFolder: string
}
Property/Type | Description |
---|---|
PathToFolder String | optional Defines the folder to which the Data Server saves reports. This property overrides the default folder set in the AddReportSharing service configuration. |
You can configure the Data Server through:
Flexmonster.DataServer.Core.dll
can be configured via the ASP.NET configuration file (e.g., appsettings.json
). In addition to the Data Server's configuration, this file can contain any other settings needed for the project, as long as they do not conflict with each other.
To configure the Data Server via appsettings.json
, follow the steps below:
Step 1. Define the needed configurations in appsettings.json
. Here is an example of a configured appsettings.json
file with the custom parser:
{ "DataSources": [ { "Type": "custom-parser", "Indexes": { "custom-index": null } }, { "Type": "json", "Indexes": { "first-json-index": { "Path": "data/data.json" }, "second-json-index": { "Path": "data/another-data.json" } } }, { "Type": "csv", "Indexes": { "csv-index": { "Path": "data/data.csv", "Delimiter": ";", "DecimalSeparator": "." } } } ], "DataStorageOptions": { "DataRefreshTime": 60, "CacheSizeLimit": 150 } }
Step 2. To apply configs from appsettings.json
, add the following line of code to the Program.cs
file:
using Flexmonster.DataServer.Core; var builder = WebApplication.CreateBuilder(args); builder.Services.ConfigureFlexmonsterOptions(builder.Configuration); // Other configurations
You can configure the Data Server through code using the Program.cs
file. See how to:
Step 1. In the Program.cs
file, call the builder.Services.Configure<DatasourceOptions>
method:
var builder = WebApplication.CreateBuilder(args); // Other configurations builder.Services.Configure<DatasourceOptions>((options) => { }); // Other configurations
Step 2. In the builder.Services.Configure<DatasourceOptions>
, create a dictionary to store your indexes:
// Other configurations builder.Services.Configure<DatasourceOptions>((options) => { options.Indexes = new Dictionary<string, IndexOptions>(); }); // Other configurations
As you can see, each index consists of two fields:
IndexOptions
field, which contains configurations needed to load the index’s data. IndexOptions
is an abstract class.Step 3. Add your index to the Indexes
dictionary. For example, let’s create a new JSON index:
// Other configurations builder.Services.Configure<DatasourceOptions>((options) => { options.Indexes = new Dictionary<string, IndexOptions>(); options.Indexes.Add("json-index", new JsonIndexOptions("path-to-your-file.json")); }); // Other configurations
JsonIndexOptions
is a class that allows configuring JSON indexes. It is based on the IndexOptions
class.
CSV and database indexes are configured through similar classes. See a list of these classes and their constructors:
public JsonIndexOptions(string path)
public CsvIndexOptions(string path)
public CsvIndexOptions(string path, char delimiter, char decimalSeparator, char thousandsSeparator)
public DatabaseIndexOptions(databaseType, connectionString, query)
See the full list of configurations for indexes.
Step 1. In the Program.cs
file, add the following lines of code:
using Flexmonster.DataServer.Core.DataStorages; var builder = WebApplication.CreateBuilder(args); // Other configurations builder.Services.Configure<DataStorageOptions>((options) => { }); // Other configurations
Step 2. Set the needed data storage options using the options
object:
// Other configurations builder.Services.Configure<DataStorageOptions>((options) => { options.CacheSizeLimit = 100; options.DataRefreshTime = 60; }); // Other configurations
See the full list of available data storage options.
If needed, you can load configs from appsettings.json
and then continue configuring the Data Server through code. It can be done by importing configs from appsettings.json
before adding configs through code:
using Flexmonster.DataServer.Core; var builder = WebApplication.CreateBuilder(args); builder.Services.ConfigureFlexmonsterOptions(builder.Configuration); /* Note: importing configs from the file overrides configs set through code. That’s why you should always add your configs after the builder.Services.ConfigureFlexmonsterOptions(builder.Configuration) line */ builder.Services.Configure<DatasourceOptions>((options) => { options.Indexes = new Dictionary<string, IndexOptions>(); options.Indexes.Add("json-index", new JsonIndexOptions("path-to-your-file.json")); }); // Other configurations
You may be interested in the following articles: