Skip to content

Commit 412093d

Browse files
authored
Merge pull request #664 from FastReports/sync_branch_2024.1.3
FastReport.OpenSource 2024.1.3
2 parents e9dfb47 + be5d09b commit 412093d

File tree

11 files changed

+164
-36
lines changed

11 files changed

+164
-36
lines changed

Extras/Core/FastReport.Data/FastReport.Data.Postgres/PostgresDataConnection.cs

Lines changed: 144 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Data.Common;
51
using Npgsql;
62
using NpgsqlTypes;
3+
using System;
4+
using System.Collections.Generic;
75
using System.Data;
6+
using System.Data.Common;
87

98
namespace FastReport.Data
109
{
@@ -22,7 +21,7 @@ private void GetDBObjectNames(string name, List<string> list)
2221
try
2322
{
2423
OpenConnection(connection);
25-
schema = connection.GetSchema("Tables", new string[] { null, "", null, name }); //not only public
24+
schema = connection.GetSchema(name);
2625
}
2726
finally
2827
{
@@ -34,16 +33,39 @@ private void GetDBObjectNames(string name, List<string> list)
3433
string schemaName = row["TABLE_SCHEMA"].ToString();
3534
if (!EnableSystemSchemas && (schemaName == "pg_catalog" || schemaName == "information_schema"))
3635
continue;
37-
list.Add(schemaName + "." + "\"" + row["TABLE_NAME"].ToString() + "\"");
36+
list.Add(schemaName + ".\"" + row["TABLE_NAME"].ToString() + "\"");
3837
}
3938
}
4039

40+
private DataTable GetSchema(string selectCommand)
41+
{
42+
var connection = GetConnection();
43+
try
44+
{
45+
OpenConnection(connection);
46+
47+
var dataset = new DataSet();
48+
var adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection);
49+
adapter.Fill(dataset);
50+
51+
if (dataset.Tables.Count > 0)
52+
return dataset.Tables[0];
53+
}
54+
finally
55+
{
56+
DisposeConnection(connection);
57+
}
58+
59+
return null;
60+
}
61+
4162
/// <inheritdoc/>
4263
public override string[] GetTableNames()
4364
{
4465
List<string> list = new List<string>();
45-
GetDBObjectNames("BASE TABLE", list);
46-
GetDBObjectNames("VIEW", list);
66+
GetDBObjectNames("Tables", list);
67+
GetDBObjectNames("Views", list);
68+
4769
if (list.Count == 0)
4870
{
4971
string selectCommand =
@@ -60,30 +82,122 @@ public override string[] GetTableNames()
6082
"AND pg_catalog.pg_table_is_visible(c.oid) " +
6183
"ORDER BY 1,2; ";
6284

63-
DataSet dataset = new DataSet();
64-
65-
DbConnection connection = GetConnection();
66-
try
85+
var schema = GetSchema(selectCommand);
86+
if (schema != null)
6787
{
68-
OpenConnection(connection);
69-
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection);
70-
adapter.Fill(dataset);
71-
72-
if (dataset.Tables.Count > 0)
73-
foreach (DataRow row in dataset.Tables[0].Rows)
74-
{
75-
list.Add(row["Name"].ToString());
76-
}
88+
foreach (DataRow row in schema.Rows)
89+
{
90+
list.Add(row["Name"].ToString());
91+
}
7792
}
78-
finally
93+
}
94+
95+
return list.ToArray();
96+
}
97+
98+
///<inheritdoc/>
99+
public override string[] GetProcedureNames()
100+
{
101+
List<string> list = new List<string>();
102+
103+
string selectCommand =
104+
"SELECT routine_schema As schema_name,\r\n" +
105+
"routine_name As procedure_name\r\n" +
106+
"FROM information_schema.routines\r\n" +
107+
"WHERE routine_type = 'FUNCTION'";
108+
109+
var schema = GetSchema(selectCommand);
110+
if (schema != null)
111+
{
112+
foreach (DataRow row in schema.Rows)
79113
{
80-
DisposeConnection(connection);
114+
string schemaName = row["schema_name"].ToString();
115+
if (!EnableSystemSchemas && (schemaName == "pg_catalog" || schemaName == "information_schema"))
116+
continue;
117+
list.Add(schemaName + ".\"" + row["procedure_name"].ToString() + "\"");
81118
}
82-
83119
}
120+
84121
return list.ToArray();
85122
}
86123

124+
///<inheritdoc/>
125+
public override TableDataSource CreateProcedure(string tableName)
126+
{
127+
string schemaName = "public";
128+
string procName = tableName;
129+
130+
string[] parts = tableName.Split('.');
131+
if (parts.Length == 2)
132+
{
133+
schemaName = parts[0];
134+
procName = parts[1];
135+
}
136+
137+
procName = procName.Replace("\"", "");
138+
139+
var table = new ProcedureDataSource()
140+
{
141+
Enabled = true,
142+
SelectCommand = tableName
143+
};
144+
145+
string selectCommand =
146+
"select proc.specific_schema as procedure_schema,\r\n" +
147+
" proc.specific_name,\r\n" +
148+
" proc.routine_name as procedure_name,\r\n" +
149+
" proc.external_language,\r\n" +
150+
" args.parameter_name,\r\n" +
151+
" args.parameter_mode,\r\n" +
152+
" args.data_type\r\n" +
153+
"from information_schema.routines proc\r\n" +
154+
"left join information_schema.parameters args\r\n" +
155+
" on proc.specific_schema = args.specific_schema\r\n" +
156+
" and proc.specific_name = args.specific_name\r\n" +
157+
"where proc.routine_schema not in ('pg_catalog', 'information_schema')\r\n" +
158+
" and proc.routine_type = 'FUNCTION'\r\n" +
159+
" and proc.specific_schema = '" + schemaName + "'\r\n" +
160+
" and proc.routine_name = '" + procName + "'\r\n" +
161+
"order by procedure_schema,\r\n" +
162+
" specific_name,\r\n" +
163+
" procedure_name,\r\n" +
164+
" args.ordinal_position;";
165+
166+
var schema = GetSchema(selectCommand);
167+
if (schema != null)
168+
{
169+
foreach (DataRow row in schema.Rows)
170+
{
171+
var direction = ParameterDirection.Input;
172+
switch (row["parameter_mode"].ToString())
173+
{
174+
case "IN":
175+
direction = ParameterDirection.Input;
176+
table.Enabled = false;
177+
break;
178+
179+
case "INOUT":
180+
direction = ParameterDirection.InputOutput;
181+
table.Enabled = false;
182+
break;
183+
184+
case "OUT":
185+
// skip completely: it's a result table's column
186+
continue;
187+
}
188+
189+
table.Parameters.Add(new ProcedureParameter()
190+
{
191+
Name = row["parameter_name"].ToString(),
192+
DataType = (int)(NpgsqlDbType)Enum.Parse(typeof(NpgsqlDbType), row["data_type"].ToString(), true),
193+
Direction = direction
194+
});
195+
}
196+
}
197+
198+
return table;
199+
}
200+
87201
/// <inheritdoc/>
88202
public override string QuoteIdentifier(string value, DbConnection connection)
89203
{
@@ -115,7 +229,7 @@ public override Type GetParameterType()
115229

116230
/// <inheritdoc/>
117231
public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
118-
CommandParameterCollection parameters)
232+
CommandParameterCollection parameters)
119233
{
120234
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(selectCommand, connection as NpgsqlConnection);
121235
foreach (CommandParameter p in parameters)
@@ -125,5 +239,10 @@ public override DbDataAdapter GetAdapter(string selectCommand, DbConnection conn
125239
}
126240
return adapter;
127241
}
242+
243+
public PostgresDataConnection()
244+
{
245+
CanContainProcedures = true;
246+
}
128247
}
129248
}

FastReport.Base/Format/CustomFormat.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public override string FormatValue(object value)
5858
{
5959
if (value is Variant)
6060
value = ((Variant)value).Value;
61+
62+
//If value is "00:00:00"() and it can be converted to DateTime
63+
if (value is TimeSpan && DateTime.TryParse(value.ToString(), out DateTime dateTime))
64+
return String.Format("{0:" + Format + "}", dateTime);
65+
6166
return String.Format("{0:" + Format + "}", value);
6267
}
6368

FastReport.Base/TextObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ private SizeF CalcSize()
832832
width = renderer.CalcWidth();
833833

834834
width += Padding.Horizontal + 1;
835-
if (LineHeight == 0)
835+
//if (LineHeight == 0)
836836
height += Padding.Vertical + 1;
837837
return new SizeF(width, height);
838838
}

FastReport.Compat/LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2018-2023 Fast Reports Inc
1+
Copyright (c) 2018-2024 Fast Reports Inc
22

33
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:
44

FastReport.Compat/UsedPackages.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
<SystemDrawingCommonVersion>[4.7.0,)</SystemDrawingCommonVersion>
9+
<SystemDrawingCommonVersion>[4.7.3,)</SystemDrawingCommonVersion>
1010

1111
<CodeAnalysisCSharpVersion>[3.3.1,)</CodeAnalysisCSharpVersion>
1212

FastReport.Core.Web/Services/Implementation/ReportDesignerService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,9 @@ string PasteRestricted(WebReport webReport, string xmlString)
443443
if (!String.IsNullOrEmpty(connectionString))
444444
{
445445
var item2 = dictionary2.FindItem(item1.Name);
446-
if (item2 != null)
446+
var newConnectionString = item2.GetProp("ConnectionString");
447+
448+
if (item2 != null && newConnectionString.IsNullOrEmpty())
447449
{
448450
item2.SetProp("ConnectionString", connectionString);
449451
}

FastReport/Resources/en.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@
20112011
<Superscript Text="Superscript"/>
20122012
<Bullets Text="Bullets"/>
20132013
<ConfirmChanges Text="Text has been modified. Save changes?"/>
2014-
<Invoke Text="Doubleclick to edit RichText"/>
2014+
<Invoke Text="Double click to select an RTF file"/>
20152015
</RichTextEditor>
20162016
<SearchReplace Text="Find and Replace">
20172017
<Find Text="Find what:"/>
@@ -2889,6 +2889,7 @@
28892889
<Docx Text="Export to Microsoft Word 2007">
28902890
<File Text="Microsoft Word 2007 file"/>
28912891
<RowHeight Text="Row height is"/>
2892+
<SaveRowHeight Text="Save row height"/>
28922893
<Exactly Text="Exactly"/>
28932894
<Minimum Text="Minimum"/>
28942895
<DoNotExpandShiftReturn Text="Do not expand shift return"/>

Localization/Russian.frl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@
18261826
<Superscript Text="Верхний индекс"/>
18271827
<Bullets Text="Список"/>
18281828
<ConfirmChanges Text="Текст был изменен. Сохранить изменения?"/>
1829-
<Invoke Text="Сделайте двойной щелчок для редактирования текста"/>
1829+
<Invoke Text="Сделайте двойной щелчок для выбора файла RTF"/>
18301830
</RichTextEditor>
18311831
<SearchReplace Text="Поиск и замена">
18321832
<Find Text="Найти:"/>
@@ -2656,6 +2656,7 @@
26562656
<Docx Text="Экспорт в Microsoft Word 2007">
26572657
<File Text="Microsoft Word 2007 формат"/>
26582658
<RowHeight Text="Высота строк таблицы"/>
2659+
<SaveRowHeight Text="Сохранить высоту строки"/>
26592660
<Exactly Text="Точно"/>
26602661
<Minimum Text="Минимум"/>
26612662
<DoNotExpandShiftReturn Text="Не расширять мягкий перенос"/>

Pack/BuildScripts/Tools/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static void ParseArgs(string[] args)
8181
{
8282
foreach (var argument in args)
8383
{
84-
if (string.IsNullOrEmpty(argument))
84+
if (string.IsNullOrEmpty(argument) || !argument.StartsWith("--"))
8585
continue;
8686

8787
if (argument == "--tree")

Pack/FastReport MIT license.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2023 Fast Reports Inc
1+
Copyright (c) 2024 Fast Reports Inc
22

33
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:
44

0 commit comments

Comments
 (0)