diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/AssemblyInitializer.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/AssemblyInitializer.cs
new file mode 100644
index 00000000..aed747ba
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/AssemblyInitializer.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using FastReport.Utils;
+
+namespace FastReport.Data.ElasticSearch
+{
+ public class ElasticSearchAssemblyInitializer : AssemblyInitializerBase
+ {
+ public ElasticSearchAssemblyInitializer()
+ {
+ RegisteredObjects.AddConnection(typeof(ESDataSourceConnection));
+ }
+ }
+}
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/Directory.Build.targets b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/Directory.Build.targets
new file mode 100644
index 00000000..18cedec9
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/Directory.Build.targets
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.Designer.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.Designer.cs
new file mode 100644
index 00000000..fc20750f
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.Designer.cs
@@ -0,0 +1,132 @@
+
+using FastReport.Controls;
+
+namespace FastReport.Data.ConnectionEditors
+{
+ partial class ESConnectionEditor
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.gbConnection = new System.Windows.Forms.GroupBox();
+ this.lbHeaders = new System.Windows.Forms.Label();
+ this.dgvHeaders = new System.Windows.Forms.DataGridView();
+ this.colHeader = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colContent = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.lbEndPoint = new System.Windows.Forms.Label();
+ this.tbEndPoint = new System.Windows.Forms.TextBox();
+ this.gbConnection.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dgvHeaders)).BeginInit();
+ this.SuspendLayout();
+ //
+ // gbConnection
+ //
+ this.gbConnection.Controls.Add(this.lbHeaders);
+ this.gbConnection.Controls.Add(this.dgvHeaders);
+ this.gbConnection.Controls.Add(this.lbEndPoint);
+ this.gbConnection.Controls.Add(this.tbEndPoint);
+ this.gbConnection.Location = new System.Drawing.Point(8, 4);
+ this.gbConnection.Margin = new System.Windows.Forms.Padding(8, 4, 8, 4);
+ this.gbConnection.Name = "gbConnection";
+ this.gbConnection.Size = new System.Drawing.Size(320, 233);
+ this.gbConnection.TabIndex = 0;
+ this.gbConnection.TabStop = false;
+ this.gbConnection.Text = "Connection settings";
+ //
+ // lbHeaders
+ //
+ this.lbHeaders.AutoSize = true;
+ this.lbHeaders.Location = new System.Drawing.Point(11, 70);
+ this.lbHeaders.Name = "lbHeaders";
+ this.lbHeaders.Size = new System.Drawing.Size(47, 13);
+ this.lbHeaders.TabIndex = 12;
+ this.lbHeaders.Text = "Headers";
+ //
+ // dgvHeaders
+ //
+ this.dgvHeaders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dgvHeaders.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.colHeader,
+ this.colContent});
+ this.dgvHeaders.Location = new System.Drawing.Point(11, 90);
+ this.dgvHeaders.Name = "dgvHeaders";
+ this.dgvHeaders.RowHeadersVisible = false;
+ this.dgvHeaders.Size = new System.Drawing.Size(303, 131);
+ this.dgvHeaders.TabIndex = 11;
+ //
+ // colHeader
+ //
+ this.colHeader.HeaderText = "Header";
+ this.colHeader.Name = "colHeader";
+ this.colHeader.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ //
+ // colContent
+ //
+ this.colContent.HeaderText = "Content";
+ this.colContent.Name = "colContent";
+ this.colContent.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ //
+ // lbJson
+ //
+ this.lbEndPoint.AutoSize = true;
+ this.lbEndPoint.Location = new System.Drawing.Point(8, 24);
+ this.lbEndPoint.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
+ this.lbEndPoint.Name = "lbESEndPoint";
+ this.lbEndPoint.Size = new System.Drawing.Size(32, 13);
+ this.lbEndPoint.TabIndex = 2;
+ this.lbEndPoint.Text = "ElasticSearch EndPoint";
+ //
+ // tbJson
+ //
+ this.tbEndPoint.Location = new System.Drawing.Point(11, 44);
+ this.tbEndPoint.Margin = new System.Windows.Forms.Padding(8, 3, 0, 5);
+ this.tbEndPoint.Name = "tbESEndPoint";
+ this.tbEndPoint.Size = new System.Drawing.Size(303, 20);
+ this.tbEndPoint.TabIndex = 0;
+ //
+ // JsonDataSourceConnectionEditor
+ //
+ this.Controls.Add(this.gbConnection);
+ this.Name = "ESDataSourceConnectionEditor";
+ this.Size = new System.Drawing.Size(336, 241);
+ this.gbConnection.ResumeLayout(false);
+ this.gbConnection.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dgvHeaders)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox gbConnection;
+ private System.Windows.Forms.TextBox tbEndPoint;
+ private System.Windows.Forms.Label lbEndPoint;
+ private System.Windows.Forms.Label lbHeaders;
+ private System.Windows.Forms.DataGridView dgvHeaders;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colHeader;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colContent;
+ }
+}
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.cs
new file mode 100644
index 00000000..c678011b
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.cs
@@ -0,0 +1,52 @@
+using FastReport.Data.ElasticSearch;
+using FastReport.Data.JsonConnection;
+using FastReport.Utils;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace FastReport.Data.ConnectionEditors
+{
+ public partial class ESConnectionEditor : ConnectionEditorBase
+ {
+
+ public ESConnectionEditor()
+ {
+ InitializeComponent();
+ }
+
+ protected override string GetConnectionString()
+ {
+ ESDataSourceConnectionStringBuilder builder = new ESDataSourceConnectionStringBuilder();
+ builder.EndPoint = tbEndPoint.Text;
+ for (int i = 0; i < dgvHeaders.Rows.Count; i++)
+ {
+ DataGridViewRow row = dgvHeaders.Rows[i];
+ if (row.Cells[0].Value != null && row.Cells[1].Value != null)
+ {
+ var headerName = row.Cells[0].Value.ToString();
+ var headerData = row.Cells[1].Value.ToString();
+ builder.Headers.Add(headerName, headerData);
+ }
+ }
+
+ return builder.ToString();
+ }
+
+ protected override void SetConnectionString(string value)
+ {
+ ESDataSourceConnectionStringBuilder builder = new ESDataSourceConnectionStringBuilder(value);
+ tbEndPoint.Text = builder.EndPoint;
+
+ foreach (KeyValuePair header in builder.Headers)
+ {
+ dgvHeaders.Rows.Add(header.Key, header.Value);
+ }
+ }
+ }
+}
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.resx b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESConnectionEditor.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.DesignExt.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.DesignExt.cs
new file mode 100644
index 00000000..0813bc9e
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.DesignExt.cs
@@ -0,0 +1,37 @@
+using FastReport.Data.ConnectionEditors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FastReport.Data.ElasticSearch
+{
+ partial class ESDataSourceConnection
+ {
+ #region Properties
+ public ESConnectionEditor Editor { get; set; }
+ #endregion
+
+ #region Public Methods
+
+ ///
+ public override ConnectionEditorBase GetEditor()
+ {
+ return Editor = new ESConnectionEditor();
+ }
+ ///
+ public override void TestConnection()
+ {
+ InitConnection();
+ }
+
+ public override string GetConnectionId()
+ {
+ ESDataSourceConnectionStringBuilder connectionStringBuilder = new ESDataSourceConnectionStringBuilder(ConnectionString);
+ if (connectionStringBuilder.EndPoint.Length > 1)
+ return "ElasticSearch: " + connectionStringBuilder.EndPoint;
+ else return "ElasticSearch: ";
+ }
+ #endregion
+ }
+}
diff --git a/FastReport.Base/Data/Elasticsearch/ESDataSourceConnection.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.cs
similarity index 98%
rename from FastReport.Base/Data/Elasticsearch/ESDataSourceConnection.cs
rename to Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.cs
index 6e524b52..f99848b3 100644
--- a/FastReport.Base/Data/Elasticsearch/ESDataSourceConnection.cs
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnection.cs
@@ -114,9 +114,10 @@ public override string[] GetTableNames()
respoce = reader.ReadToEnd();
}
List Names = new List();
- object s = JsonBase.FromString(respoce).Keys;
+
foreach (string name in JsonBase.FromString(respoce).Keys)
Names.Add(name);
+
return Names.ToArray();
}
@@ -184,15 +185,19 @@ public JsonBase GetJson(TableDataSource tableDataSource)
if (tableNames == null)
tableNames = GetTableNames();
+
if (tableNames == null || !tableNames.Contains(tableDataSource.Name))
return null;
int countRec = GetRecCount(tableDataSource.Name);
JsonDataSourceConnectionStringBuilder connectionStringBuilder = new JsonDataSourceConnectionStringBuilder();
+
connectionStringBuilder.ConnectionString =
$"Json={sourceConnectionStringBuilder.EndPoint}/{tableDataSource.Name}/_search?size={countRec};JsonShema=;Encoding=utf-8;";
+
connectionStringBuilder.Headers = sourceConnectionStringBuilder.Headers;
- return (new JsonDataSourceConnection() { ConnectionString = connectionStringBuilder.ToString() }).Json;
+
+ return (new JsonDataSourceConnection() { ConnectionString = connectionStringBuilder.ToString() }).GetJson(tableDataSource);
}
#endregion
}
diff --git a/FastReport.Base/Data/Elasticsearch/ESDataSourceConnectionStringBuilder.cs b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnectionStringBuilder.cs
similarity index 100%
rename from FastReport.Base/Data/Elasticsearch/ESDataSourceConnectionStringBuilder.cs
rename to Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/ESDataSourceConnectionStringBuilder.cs
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/FastReport.OpenSource.Data.ElasticSearch.csproj b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/FastReport.OpenSource.Data.ElasticSearch.csproj
new file mode 100644
index 00000000..823f438b
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/FastReport.OpenSource.Data.ElasticSearch.csproj
@@ -0,0 +1,43 @@
+
+
+ netstandard2.1;net461;netcoreapp3.1
+ true
+ ../../../FastReport.Plugins.snk
+ true
+ Fast Reports Inc.
+ Fast Reports Inc.
+ https://www.fast-report.com/en/product/fast-report-net/license
+ https://www.fast-report.com/en/product/fast-report-net
+ Fast Reports Inc.
+ FastReport.Data.ElasticSearch
+ FastReport.OpenSource.Data.ElasticSearch
+ https://www.fast-report.com/download/images/frlogo-big.png
+ reporting, elasticsearch, connection, reports, core
+ 1.0.0
+ Debug;Release;
+ FastReport.Data.ElasticSearch
+ FastReport.Data
+ Represents a connection to ElasticSearch database for FastReport.OpenSource
+
+This package will not be updated. The $(AssemblyName) package now includes a connector for all versions of the FastReport product: FastReport .NET, FastReport.Core, FastReport.OpenSource, FastReport.CoreWin (.Net Core 3.1 and .Net 5 Windows).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/readme.txt b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/readme.txt
new file mode 100644
index 00000000..59dc4647
--- /dev/null
+++ b/Extras/Core/FastReport.Data/FastReport.Data.ElasticSearch/readme.txt
@@ -0,0 +1,11 @@
+How to use it:
+- execute the following code once at the application start:
+FastReport.Utils.RegisteredObjects.AddConnection(typeof(ESDataSourceConnection));
+- now you should be able to create a new ElasticSearch data source from Designer (.Net 4) or from code:
+Report report = new Report();
+report.Load(@"YourReport.frx");
+//...
+ESDataSourceConnection conn = new ESDataSourceConnection();
+conn.ConnectionString = "your connection string";
+conn.CreateAllTables();
+report.Dictionary.Connections.Add(conn);
\ No newline at end of file
diff --git a/FastReport.Base/AssemblyInitializer.cs b/FastReport.Base/AssemblyInitializer.cs
index caf03eb4..bbc7e8c3 100644
--- a/FastReport.Base/AssemblyInitializer.cs
+++ b/FastReport.Base/AssemblyInitializer.cs
@@ -50,7 +50,6 @@ public AssemblyInitializer()
//RegisteredObjects.Add(typeof(Data.JsonConnection.JsonObjectDataSource), "", 0);
//RegisteredObjects.Add(typeof(Data.JsonConnection.JsonArrayDataSource), "", 0);
RegisteredObjects.InternalAddConnection(typeof(Data.JsonConnection.JsonDataSourceConnection));
- RegisteredObjects.InternalAddConnection(typeof(Data.ElasticSearch.ESDataSourceConnection));
// formats
RegisteredObjects.InternalAdd(typeof(BooleanFormat), "", 0);
RegisteredObjects.InternalAdd(typeof(CurrencyFormat), "", 0);
diff --git a/FastReport.Base/Report.cs b/FastReport.Base/Report.cs
index cc742a36..80b35315 100644
--- a/FastReport.Base/Report.cs
+++ b/FastReport.Base/Report.cs
@@ -1362,7 +1362,7 @@ public object Calc(string expression, Variant value)
DataSourceBase data = cachedItem.dataSource;
Column column = cachedItem.column;
- object val = ConvertToColumnDataType(column.Value, column.DataType, false);
+ object val = ConvertToColumnDataType(column.Value, column.DataType, ConvertNulls);
if (CustomCalc != null)
{
@@ -1396,7 +1396,7 @@ private object ConvertToColumnDataType(object val, Type dataType, bool convertNu
{
if (val == null || val is DBNull)
{
- if (ConvertNulls || convertNulls)
+ if (convertNulls)
val = Converter.ConvertNull(dataType);
}
else
diff --git a/FastReport/Resources/en.xml b/FastReport/Resources/en.xml
index 8d257e66..d6166064 100644
--- a/FastReport/Resources/en.xml
+++ b/FastReport/Resources/en.xml
@@ -280,6 +280,7 @@
+
@@ -302,6 +303,7 @@
+
diff --git a/Localization/Russian.frl b/Localization/Russian.frl
index 60f11386..6f08fe52 100644
--- a/Localization/Russian.frl
+++ b/Localization/Russian.frl
@@ -278,6 +278,7 @@
+
@@ -299,6 +300,7 @@
+