Skip to content

Commit 8d1049e

Browse files
authored
Merge pull request #824 from FastReports/sync_branch_2026.2.1
FastReport.OpenSource 2026.2.1
2 parents 8ef9cde + 54af4bd commit 8d1049e

29 files changed

Lines changed: 2454 additions & 50 deletions

Extras/Core/FastReport.Data/FastReport.Data.MySql/MySqlDataConnection.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ public override DbDataAdapter GetAdapter(string selectCommand, DbConnection conn
133133
}
134134
return adapter;
135135
}
136-
136+
137137
/// <inheritdoc/>
138138
public override Type GetParameterType()
139139
{
140140
return typeof(MySqlDbType);
141141
}
142-
142+
143143
private static object VariantToClrType(Variant value, MySqlDbType type)
144144
{
145145
if (value.ToString() == "" && type != MySqlDbType.Null)
@@ -333,7 +333,7 @@ public override TableDataSource CreateProcedure(string tableName)
333333
{
334334
Name = parameterName,
335335
Direction = direction,
336-
DataType = (int)Enum.Parse(typeof(MySqlDbType), parameterType, true)
336+
DataType = (int)MapMySqlType(parameterType)
337337
});
338338

339339
}
@@ -390,7 +390,7 @@ public override async Task<TableDataSource> CreateProcedureAsync(string tableNam
390390
{
391391
Name = parameterName,
392392
Direction = direction,
393-
DataType = (int)Enum.Parse(typeof(MySqlDbType), parameterType, true)
393+
DataType = (int)MapMySqlType(parameterType)
394394
});
395395

396396
}
@@ -404,6 +404,33 @@ public override async Task<TableDataSource> CreateProcedureAsync(string tableNam
404404
return table;
405405
}
406406

407+
private MySqlDbType MapMySqlType(string type)
408+
{
409+
MySqlDbType dbType;
410+
if (Enum.TryParse(type, true, out dbType))
411+
return dbType;
412+
413+
switch (type.ToLower())
414+
{
415+
case "tinyint":
416+
return MySqlDbType.Byte;
417+
case "smallint":
418+
return MySqlDbType.Int16;
419+
case "int":
420+
case "integer":
421+
return MySqlDbType.Int32;
422+
case "bigint":
423+
return MySqlDbType.Int64;
424+
case "mediumint":
425+
return MySqlDbType.Int24;
426+
case "numeric":
427+
return MySqlDbType.NewDecimal;
428+
case "char":
429+
return MySqlDbType.String;
430+
}
431+
throw new Exception(string.Format("Unsupported procedure type: ", type));
432+
}
433+
407434
public MySqlDataConnection() : base()
408435
{
409436
CanContainProcedures = true;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" />
4+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{17CE85B1-B182-4BEA-90A8-F8D110B1CFCE}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>FastReport.ReportBuilder.UnitTest</RootNamespace>
12+
<AssemblyName>FastReport.ReportBuilder.UnitTest</AssemblyName>
13+
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
17+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
18+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
19+
<IsCodedUITest>False</IsCodedUITest>
20+
<TestProjectType>UnitTest</TestProjectType>
21+
<NuGetPackageImportStamp>
22+
</NuGetPackageImportStamp>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25+
<DebugSymbols>true</DebugSymbols>
26+
<DebugType>full</DebugType>
27+
<Optimize>false</Optimize>
28+
<OutputPath>bin\Debug\</OutputPath>
29+
<DefineConstants>DEBUG;TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
34+
<DebugType>pdbonly</DebugType>
35+
<Optimize>true</Optimize>
36+
<OutputPath>bin\Release\</OutputPath>
37+
<DefineConstants>TRACE</DefineConstants>
38+
<ErrorReport>prompt</ErrorReport>
39+
<WarningLevel>4</WarningLevel>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="Accessibility" />
43+
<Reference Include="FastReport, Version=2021.1.0.0, Culture=neutral, PublicKeyToken=5ceb240df42bf6e8, processorArchitecture=MSIL">
44+
<HintPath>..\..\..\packages\FastReport.OpenSource.2021.1.0\lib\net40\FastReport.dll</HintPath>
45+
</Reference>
46+
<Reference Include="FastReport.Compat, Version=2020.4.2.0, Culture=neutral, PublicKeyToken=406e1f4c3c8ef97e, processorArchitecture=MSIL">
47+
<HintPath>..\..\..\packages\FastReport.Compat.2020.4.2\lib\net40\FastReport.Compat.dll</HintPath>
48+
</Reference>
49+
<Reference Include="FastReport.OpenSource.Export.PdfSimple, Version=2021.1.2.0, Culture=neutral, PublicKeyToken=b33a9a06fcc00c4c, processorArchitecture=MSIL">
50+
<HintPath>..\..\..\packages\FastReport.OpenSource.Export.PdfSimple.2021.1.2\lib\net40\FastReport.OpenSource.Export.PdfSimple.dll</HintPath>
51+
</Reference>
52+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
53+
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
54+
</Reference>
55+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
56+
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
57+
</Reference>
58+
<Reference Include="System" />
59+
<Reference Include="System.ComponentModel.Annotations, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
60+
<HintPath>..\..\..\packages\System.ComponentModel.Annotations.4.1.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
61+
</Reference>
62+
<Reference Include="System.ComponentModel.DataAnnotations" />
63+
<Reference Include="System.Core" />
64+
<Reference Include="System.Data" />
65+
<Reference Include="System.Drawing" />
66+
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
67+
<HintPath>..\..\..\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll</HintPath>
68+
</Reference>
69+
<Reference Include="System.Security" />
70+
<Reference Include="System.Windows.Forms" />
71+
<Reference Include="System.Xml" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<Compile Include="Person.cs" />
75+
<Compile Include="ReportTest.cs" />
76+
<Compile Include="Properties\AssemblyInfo.cs" />
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="packages.config" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<ProjectReference Include="..\FastReport.ReportBuilder\FastReport.ReportBuilder.csproj">
83+
<Project>{abfbdac5-ac9e-44b4-9201-fe8bfbd5db0a}</Project>
84+
<Name>FastReport.ReportBuilder</Name>
85+
</ProjectReference>
86+
</ItemGroup>
87+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
88+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
89+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
90+
<PropertyGroup>
91+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
92+
</PropertyGroup>
93+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props'))" />
94+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets'))" />
95+
<Error Condition="!Exists('..\..\..\packages\FastReport.Compat.2020.4.2\build\FastReport.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\FastReport.Compat.2020.4.2\build\FastReport.Compat.targets'))" />
96+
</Target>
97+
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" />
98+
<Import Project="..\..\..\packages\FastReport.Compat.2020.4.2\build\FastReport.Compat.targets" Condition="Exists('..\..\..\packages\FastReport.Compat.2020.4.2\build\FastReport.Compat.targets')" />
99+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
5+
namespace FastReport.ReportBuilder.UnitTest
6+
{
7+
public class Person
8+
{
9+
[Display(Name = "First Name")]
10+
public string FirstName { get; set; }
11+
public string LastName { get; set; }
12+
public DateTime BirthDate { get; set; }
13+
public bool IsActive { get; set; }
14+
15+
[DisplayFormat(DataFormatString = "P")]
16+
public int Level { get; set; }
17+
18+
public List<Person> GetData()
19+
{
20+
return new List<Person> {
21+
new Person { FirstName = "Jon", LastName = "Snow", BirthDate = new DateTime(1987, 1, 15), IsActive = true, Level = 25 },
22+
new Person { FirstName = "Arya", LastName = "Stark", BirthDate = new DateTime(1987, 1, 15), Level = 10},
23+
new Person { FirstName = "Sansa", LastName = "Stark", BirthDate = new DateTime(1987, 1, 15), Level = 10},
24+
new Person { FirstName = "Oberyn", LastName = "Martell", BirthDate = new DateTime(1987, 1, 15) },
25+
};
26+
}
27+
28+
}
29+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
[assembly: AssemblyTitle("FastReport.ReportBuilder.UnitTest")]
6+
[assembly: AssemblyDescription("")]
7+
[assembly: AssemblyConfiguration("")]
8+
[assembly: AssemblyCompany("")]
9+
[assembly: AssemblyProduct("FastReport.ReportBuilder.UnitTest")]
10+
[assembly: AssemblyCopyright("Copyright © 2020")]
11+
[assembly: AssemblyTrademark("")]
12+
[assembly: AssemblyCulture("")]
13+
14+
[assembly: ComVisible(false)]
15+
16+
[assembly: Guid("17ce85b1-b182-4bea-90a8-f8d110b1cfce")]
17+
18+
// [assembly: AssemblyVersion("1.0.*")]
19+
[assembly: AssemblyVersion("1.0.0.0")]
20+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using FastReport.Export.PdfSimple;
3+
using System.Drawing;
4+
using System.Collections.Generic;
5+
6+
namespace FastReport.ReportBuilder.UnitTest
7+
{
8+
[TestClass]
9+
public class ReportTest
10+
{
11+
List<Person> list;
12+
ReportBuilder builder;
13+
public ReportTest()
14+
{
15+
list = new Person().GetData();
16+
builder = new ReportBuilder();
17+
// there are no assertions on test method, test it on created file at \bin\Debug\Empleyee.pdf path
18+
}
19+
20+
[TestMethod]
21+
public void export_basic_report_pdf()
22+
{
23+
var report = builder.Report(list)
24+
.ReportTitle(title => title
25+
.Text("Employee List")
26+
.HorzAlign(HorzAlign.Center)
27+
)
28+
.Data(data =>
29+
{
30+
data.Column(col => col.FirstName); // this column get title with data annotation
31+
data.Column(col => col.LastName).Title("Last Name");
32+
data.Column(col => col.BirthDate);
33+
data.Column(col => col.IsActive);
34+
data.Column(col => col.Level);
35+
})
36+
.Prepare();
37+
38+
PDFSimpleExport pdfExport = new PDFSimpleExport();
39+
pdfExport.Export(report, "Employees.pdf");
40+
}
41+
42+
[TestMethod]
43+
public void export_report_resized_columns_by_percentage_pdf()
44+
{
45+
var report = builder.Report(list)
46+
.ReportTitle(title => title
47+
.Text("Employee List")
48+
.HorzAlign(HorzAlign.Center)
49+
)
50+
.Data(data =>
51+
{
52+
data.Column(col => col.FirstName).Width(25); // 25%
53+
data.Column(col => col.LastName).Width(20); // 20%
54+
data.Column(col => col.BirthDate); // other three columns are equal - (55/3)%
55+
data.Column(col => col.IsActive);
56+
data.Column(col => col.Level);
57+
})
58+
.Prepare();
59+
60+
PDFSimpleExport pdfExport = new PDFSimpleExport();
61+
pdfExport.Export(report, "Employees.pdf");
62+
}
63+
64+
[TestMethod]
65+
public void export_report_using_column_format_pdf()
66+
{
67+
var report = builder.Report(list)
68+
.ReportTitle(title => title
69+
.Text("Employee List")
70+
.HorzAlign(HorzAlign.Center)
71+
)
72+
.Data(data =>
73+
{
74+
data.Column(col => col.FirstName);
75+
data.Column(col => col.LastName);
76+
data.Column(col => col.BirthDate).Format("MM/dd/yyyy");
77+
data.Column(col => col.IsActive);
78+
data.Column(col => col.Level); // this column formatted with data annotation
79+
})
80+
.Prepare();
81+
82+
PDFSimpleExport pdfExport = new PDFSimpleExport();
83+
pdfExport.Export(report, "Employees.pdf");
84+
}
85+
86+
[TestMethod]
87+
public void export_report_using_expression_pdf()
88+
{
89+
var report = builder.Report(list)
90+
.ReportTitle(title => title
91+
.Text("Employee List - [MonthName(Month([Date]))]")
92+
.HorzAlign(HorzAlign.Center)
93+
)
94+
.Data(data =>
95+
{
96+
data.Column(col => col.FirstName);
97+
data.Column(col => col.LastName).Expression("UpperCase({0})");
98+
data.Column(col => col.BirthDate);
99+
data.Column(col => col.IsActive);
100+
data.Column(col => col.Level);
101+
})
102+
.Prepare();
103+
104+
PDFSimpleExport pdfExport = new PDFSimpleExport();
105+
pdfExport.Export(report, "Employees.pdf");
106+
}
107+
108+
[TestMethod]
109+
public void export_group_report_pdf()
110+
{
111+
var report = builder.Report(list)
112+
.ReportTitle(title => title
113+
.Text("Employee List - [MonthName(Month([Date]))]")
114+
.HorzAlign(HorzAlign.Center)
115+
)
116+
.GroupHeader(header => header
117+
.Condition(con => con.LastName)
118+
.SortOrder(SortOrder.Descending)
119+
.Expression("Substring({0},0,1)")
120+
)
121+
.DataHeader(header => header
122+
.TextColor(Color.Brown)
123+
.Font("Helvetica")
124+
)
125+
.Data(data =>
126+
{
127+
data.Column(col => col.FirstName).Width(20);
128+
data.Column(col => col.LastName).Expression("UpperCase({0})");
129+
data.Column(col => col.BirthDate).Format("MM/dd/yyyy");
130+
data.Column(col => col.IsActive).Title("Active").Width(10);
131+
data.Column(col => col.Level).HorzAlign(HorzAlign.Center);
132+
})
133+
.Prepare();
134+
135+
PDFSimpleExport pdfExport = new PDFSimpleExport();
136+
pdfExport.Export(report, "Employees.pdf");
137+
}
138+
}
139+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="FastReport.Compat" version="2020.4.2" targetFramework="net471" />
4+
<package id="FastReport.OpenSource" version="2021.1.0" targetFramework="net471" />
5+
<package id="FastReport.OpenSource.Export.PdfSimple" version="2021.1.2" targetFramework="net471" />
6+
<package id="MSTest.TestAdapter" version="2.1.1" targetFramework="net471" />
7+
<package id="MSTest.TestFramework" version="2.1.1" targetFramework="net471" />
8+
<package id="System.ComponentModel.Annotations" version="4.1.0" targetFramework="net471" />
9+
<package id="System.Drawing.Common" version="4.7.2" targetFramework="net471" />
10+
</packages>

0 commit comments

Comments
 (0)