From be5d09ba24008500f89f3b25f3f9e449a2ba1f35 Mon Sep 17 00:00:00 2001 From: FastReports-bot Date: Fri, 29 Dec 2023 15:20:36 +0300 Subject: [PATCH] * sync 12/29/2023 version: 2024.1.3 --- .../PostgresDataConnection.cs | 169 +++++++++++++++--- FastReport.Base/Format/CustomFormat.cs | 5 + FastReport.Base/TextObject.cs | 2 +- FastReport.Compat/LICENSE.md | 2 +- FastReport.Compat/UsedPackages.version | 2 +- .../Implementation/ReportDesignerService.cs | 4 +- FastReport/Resources/en.xml | 3 +- Localization/Russian.frl | 3 +- Pack/BuildScripts/Tools/Startup.cs | 2 +- Pack/FastReport MIT license.md | 2 +- UsedPackages.version | 6 +- 11 files changed, 164 insertions(+), 36 deletions(-) diff --git a/Extras/Core/FastReport.Data/FastReport.Data.Postgres/PostgresDataConnection.cs b/Extras/Core/FastReport.Data/FastReport.Data.Postgres/PostgresDataConnection.cs index f343b8f9..ff351a04 100644 --- a/Extras/Core/FastReport.Data/FastReport.Data.Postgres/PostgresDataConnection.cs +++ b/Extras/Core/FastReport.Data/FastReport.Data.Postgres/PostgresDataConnection.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Data.Common; using Npgsql; using NpgsqlTypes; +using System; +using System.Collections.Generic; using System.Data; +using System.Data.Common; namespace FastReport.Data { @@ -22,7 +21,7 @@ private void GetDBObjectNames(string name, List list) try { OpenConnection(connection); - schema = connection.GetSchema("Tables", new string[] { null, "", null, name }); //not only public + schema = connection.GetSchema(name); } finally { @@ -34,16 +33,39 @@ private void GetDBObjectNames(string name, List list) string schemaName = row["TABLE_SCHEMA"].ToString(); if (!EnableSystemSchemas && (schemaName == "pg_catalog" || schemaName == "information_schema")) continue; - list.Add(schemaName + "." + "\"" + row["TABLE_NAME"].ToString() + "\""); + list.Add(schemaName + ".\"" + row["TABLE_NAME"].ToString() + "\""); } } + private DataTable GetSchema(string selectCommand) + { + var connection = GetConnection(); + try + { + OpenConnection(connection); + + var dataset = new DataSet(); + var adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection); + adapter.Fill(dataset); + + if (dataset.Tables.Count > 0) + return dataset.Tables[0]; + } + finally + { + DisposeConnection(connection); + } + + return null; + } + /// public override string[] GetTableNames() { List list = new List(); - GetDBObjectNames("BASE TABLE", list); - GetDBObjectNames("VIEW", list); + GetDBObjectNames("Tables", list); + GetDBObjectNames("Views", list); + if (list.Count == 0) { string selectCommand = @@ -60,30 +82,122 @@ public override string[] GetTableNames() "AND pg_catalog.pg_table_is_visible(c.oid) " + "ORDER BY 1,2; "; - DataSet dataset = new DataSet(); - - DbConnection connection = GetConnection(); - try + var schema = GetSchema(selectCommand); + if (schema != null) { - OpenConnection(connection); - NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection); - adapter.Fill(dataset); - - if (dataset.Tables.Count > 0) - foreach (DataRow row in dataset.Tables[0].Rows) - { - list.Add(row["Name"].ToString()); - } + foreach (DataRow row in schema.Rows) + { + list.Add(row["Name"].ToString()); + } } - finally + } + + return list.ToArray(); + } + + /// + public override string[] GetProcedureNames() + { + List list = new List(); + + string selectCommand = + "SELECT routine_schema As schema_name,\r\n" + + "routine_name As procedure_name\r\n" + + "FROM information_schema.routines\r\n" + + "WHERE routine_type = 'FUNCTION'"; + + var schema = GetSchema(selectCommand); + if (schema != null) + { + foreach (DataRow row in schema.Rows) { - DisposeConnection(connection); + string schemaName = row["schema_name"].ToString(); + if (!EnableSystemSchemas && (schemaName == "pg_catalog" || schemaName == "information_schema")) + continue; + list.Add(schemaName + ".\"" + row["procedure_name"].ToString() + "\""); } - } + return list.ToArray(); } + /// + public override TableDataSource CreateProcedure(string tableName) + { + string schemaName = "public"; + string procName = tableName; + + string[] parts = tableName.Split('.'); + if (parts.Length == 2) + { + schemaName = parts[0]; + procName = parts[1]; + } + + procName = procName.Replace("\"", ""); + + var table = new ProcedureDataSource() + { + Enabled = true, + SelectCommand = tableName + }; + + string selectCommand = + "select proc.specific_schema as procedure_schema,\r\n" + + " proc.specific_name,\r\n" + + " proc.routine_name as procedure_name,\r\n" + + " proc.external_language,\r\n" + + " args.parameter_name,\r\n" + + " args.parameter_mode,\r\n" + + " args.data_type\r\n" + + "from information_schema.routines proc\r\n" + + "left join information_schema.parameters args\r\n" + + " on proc.specific_schema = args.specific_schema\r\n" + + " and proc.specific_name = args.specific_name\r\n" + + "where proc.routine_schema not in ('pg_catalog', 'information_schema')\r\n" + + " and proc.routine_type = 'FUNCTION'\r\n" + + " and proc.specific_schema = '" + schemaName + "'\r\n" + + " and proc.routine_name = '" + procName + "'\r\n" + + "order by procedure_schema,\r\n" + + " specific_name,\r\n" + + " procedure_name,\r\n" + + " args.ordinal_position;"; + + var schema = GetSchema(selectCommand); + if (schema != null) + { + foreach (DataRow row in schema.Rows) + { + var direction = ParameterDirection.Input; + switch (row["parameter_mode"].ToString()) + { + case "IN": + direction = ParameterDirection.Input; + table.Enabled = false; + break; + + case "INOUT": + direction = ParameterDirection.InputOutput; + table.Enabled = false; + break; + + case "OUT": + // skip completely: it's a result table's column + continue; + } + + table.Parameters.Add(new ProcedureParameter() + { + Name = row["parameter_name"].ToString(), + DataType = (int)(NpgsqlDbType)Enum.Parse(typeof(NpgsqlDbType), row["data_type"].ToString(), true), + Direction = direction + }); + } + } + + return table; + } + /// public override string QuoteIdentifier(string value, DbConnection connection) { @@ -115,7 +229,7 @@ public override Type GetParameterType() /// public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection, - CommandParameterCollection parameters) + CommandParameterCollection parameters) { NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection); foreach (CommandParameter p in parameters) @@ -125,5 +239,10 @@ public override DbDataAdapter GetAdapter(string selectCommand, DbConnection conn } return adapter; } + + public PostgresDataConnection() + { + CanContainProcedures = true; + } } } diff --git a/FastReport.Base/Format/CustomFormat.cs b/FastReport.Base/Format/CustomFormat.cs index abfe8fa9..24ef19ab 100644 --- a/FastReport.Base/Format/CustomFormat.cs +++ b/FastReport.Base/Format/CustomFormat.cs @@ -58,6 +58,11 @@ public override string FormatValue(object value) { if (value is Variant) value = ((Variant)value).Value; + + //If value is "00:00:00"() and it can be converted to DateTime + if (value is TimeSpan && DateTime.TryParse(value.ToString(), out DateTime dateTime)) + return String.Format("{0:" + Format + "}", dateTime); + return String.Format("{0:" + Format + "}", value); } diff --git a/FastReport.Base/TextObject.cs b/FastReport.Base/TextObject.cs index 4eacddd3..84b0f455 100644 --- a/FastReport.Base/TextObject.cs +++ b/FastReport.Base/TextObject.cs @@ -832,7 +832,7 @@ private SizeF CalcSize() width = renderer.CalcWidth(); width += Padding.Horizontal + 1; - if (LineHeight == 0) + //if (LineHeight == 0) height += Padding.Vertical + 1; return new SizeF(width, height); } diff --git a/FastReport.Compat/LICENSE.md b/FastReport.Compat/LICENSE.md index 2af2d487..a2173613 100644 --- a/FastReport.Compat/LICENSE.md +++ b/FastReport.Compat/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fast Reports Inc +Copyright (c) 2018-2024 Fast Reports Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/FastReport.Compat/UsedPackages.version b/FastReport.Compat/UsedPackages.version index 3a5d3392..179a2d26 100644 --- a/FastReport.Compat/UsedPackages.version +++ b/FastReport.Compat/UsedPackages.version @@ -6,7 +6,7 @@ 2024.1.0 - [4.7.0,) + [4.7.3,) [3.3.1,) diff --git a/FastReport.Core.Web/Services/Implementation/ReportDesignerService.cs b/FastReport.Core.Web/Services/Implementation/ReportDesignerService.cs index 0094c63d..d99f55f3 100644 --- a/FastReport.Core.Web/Services/Implementation/ReportDesignerService.cs +++ b/FastReport.Core.Web/Services/Implementation/ReportDesignerService.cs @@ -443,7 +443,9 @@ string PasteRestricted(WebReport webReport, string xmlString) if (!String.IsNullOrEmpty(connectionString)) { var item2 = dictionary2.FindItem(item1.Name); - if (item2 != null) + var newConnectionString = item2.GetProp("ConnectionString"); + + if (item2 != null && newConnectionString.IsNullOrEmpty()) { item2.SetProp("ConnectionString", connectionString); } diff --git a/FastReport/Resources/en.xml b/FastReport/Resources/en.xml index 98d43c2a..1bafb595 100644 --- a/FastReport/Resources/en.xml +++ b/FastReport/Resources/en.xml @@ -2011,7 +2011,7 @@ - + @@ -2889,6 +2889,7 @@ + diff --git a/Localization/Russian.frl b/Localization/Russian.frl index a0c7a29f..b7a6e541 100644 --- a/Localization/Russian.frl +++ b/Localization/Russian.frl @@ -1826,7 +1826,7 @@ - + @@ -2656,6 +2656,7 @@ + diff --git a/Pack/BuildScripts/Tools/Startup.cs b/Pack/BuildScripts/Tools/Startup.cs index 2de9ea2b..4896a07c 100644 --- a/Pack/BuildScripts/Tools/Startup.cs +++ b/Pack/BuildScripts/Tools/Startup.cs @@ -81,7 +81,7 @@ private static void ParseArgs(string[] args) { foreach (var argument in args) { - if (string.IsNullOrEmpty(argument)) + if (string.IsNullOrEmpty(argument) || !argument.StartsWith("--")) continue; if (argument == "--tree") diff --git a/Pack/FastReport MIT license.md b/Pack/FastReport MIT license.md index f72eaea4..9be87c66 100644 --- a/Pack/FastReport MIT license.md +++ b/Pack/FastReport MIT license.md @@ -1,4 +1,4 @@ -Copyright (c) 2023 Fast Reports Inc +Copyright (c) 2024 Fast Reports Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/UsedPackages.version b/UsedPackages.version index bec6bee4..c9b3500d 100644 --- a/UsedPackages.version +++ b/UsedPackages.version @@ -12,9 +12,9 @@ [2024.1.0] - 2024.1.0 - 2024.1.0 - 2024.1.0 + 2024.1.2 + 2024.1.2 + 2024.1.2 2024.1.0 2024.1.0