Skip to content

Commit

Permalink
Merge pull request #664 from FastReports/sync_branch_2024.1.3
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2024.1.3
  • Loading branch information
0legK authored Jan 9, 2024
2 parents e9dfb47 + be5d09b commit 412093d
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -22,7 +21,7 @@ private void GetDBObjectNames(string name, List<string> list)
try
{
OpenConnection(connection);
schema = connection.GetSchema("Tables", new string[] { null, "", null, name }); //not only public
schema = connection.GetSchema(name);
}
finally
{
Expand All @@ -34,16 +33,39 @@ private void GetDBObjectNames(string name, List<string> 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;
}

/// <inheritdoc/>
public override string[] GetTableNames()
{
List<string> list = new List<string>();
GetDBObjectNames("BASE TABLE", list);
GetDBObjectNames("VIEW", list);
GetDBObjectNames("Tables", list);
GetDBObjectNames("Views", list);

if (list.Count == 0)
{
string selectCommand =
Expand All @@ -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();
}

///<inheritdoc/>
public override string[] GetProcedureNames()
{
List<string> list = new List<string>();

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();
}

///<inheritdoc/>
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;
}

/// <inheritdoc/>
public override string QuoteIdentifier(string value, DbConnection connection)
{
Expand Down Expand Up @@ -115,7 +229,7 @@ public override Type GetParameterType()

/// <inheritdoc/>
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)
Expand All @@ -125,5 +239,10 @@ public override DbDataAdapter GetAdapter(string selectCommand, DbConnection conn
}
return adapter;
}

public PostgresDataConnection()
{
CanContainProcedures = true;
}
}
}
5 changes: 5 additions & 0 deletions FastReport.Base/Format/CustomFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion FastReport.Base/TextObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion FastReport.Compat/LICENSE.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
2 changes: 1 addition & 1 deletion FastReport.Compat/UsedPackages.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<FRFormsWPFVersion Condition="$(FRFormsWPFVersion) == ''">2024.1.0</FRFormsWPFVersion>

<SystemDrawingCommonVersion>[4.7.0,)</SystemDrawingCommonVersion>
<SystemDrawingCommonVersion>[4.7.3,)</SystemDrawingCommonVersion>

<CodeAnalysisCSharpVersion>[3.3.1,)</CodeAnalysisCSharpVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion FastReport/Resources/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@
<Superscript Text="Superscript"/>
<Bullets Text="Bullets"/>
<ConfirmChanges Text="Text has been modified. Save changes?"/>
<Invoke Text="Doubleclick to edit RichText"/>
<Invoke Text="Double click to select an RTF file"/>
</RichTextEditor>
<SearchReplace Text="Find and Replace">
<Find Text="Find what:"/>
Expand Down Expand Up @@ -2889,6 +2889,7 @@
<Docx Text="Export to Microsoft Word 2007">
<File Text="Microsoft Word 2007 file"/>
<RowHeight Text="Row height is"/>
<SaveRowHeight Text="Save row height"/>
<Exactly Text="Exactly"/>
<Minimum Text="Minimum"/>
<DoNotExpandShiftReturn Text="Do not expand shift return"/>
Expand Down
3 changes: 2 additions & 1 deletion Localization/Russian.frl
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@
<Superscript Text="Верхний индекс"/>
<Bullets Text="Список"/>
<ConfirmChanges Text="Текст был изменен. Сохранить изменения?"/>
<Invoke Text="Сделайте двойной щелчок для редактирования текста"/>
<Invoke Text="Сделайте двойной щелчок для выбора файла RTF"/>
</RichTextEditor>
<SearchReplace Text="Поиск и замена">
<Find Text="Найти:"/>
Expand Down Expand Up @@ -2656,6 +2656,7 @@
<Docx Text="Экспорт в Microsoft Word 2007">
<File Text="Microsoft Word 2007 формат"/>
<RowHeight Text="Высота строк таблицы"/>
<SaveRowHeight Text="Сохранить высоту строки"/>
<Exactly Text="Точно"/>
<Minimum Text="Минимум"/>
<DoNotExpandShiftReturn Text="Не расширять мягкий перенос"/>
Expand Down
2 changes: 1 addition & 1 deletion Pack/BuildScripts/Tools/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion Pack/FastReport MIT license.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
6 changes: 3 additions & 3 deletions UsedPackages.version
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<FRDataVisualizationSkiaVersion>[2024.1.0]</FRDataVisualizationSkiaVersion>

<!-- WPF -->
<FRWPFVersion>2024.1.0</FRWPFVersion>
<FRWPFRoslynPadVersion>2024.1.0</FRWPFRoslynPadVersion>
<FRFormsWPFVersion>2024.1.0</FRFormsWPFVersion>
<FRWPFVersion>2024.1.2</FRWPFVersion>
<FRWPFRoslynPadVersion>2024.1.2</FRWPFRoslynPadVersion>
<FRFormsWPFVersion>2024.1.2</FRFormsWPFVersion>
<FRCompatWPFVersion>2024.1.0</FRCompatWPFVersion>
<FRDataVisualizationWPFVersion>2024.1.0</FRDataVisualizationWPFVersion>

Expand Down

0 comments on commit 412093d

Please sign in to comment.