Skip to content

Commit

Permalink
* sync 1/31/2024 version: 2024.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
FastReports-bot committed Jan 31, 2024
1 parent 09d0d97 commit 4746ad4
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
1 change: 1 addition & 0 deletions FastReport.Base/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,7 @@ private async Task<bool> PrepareAsync(bool append, CancellationToken token = def
try
{
await CompileAsync(token).ConfigureAwait(false);
isParameterChanged = false;
return Engine.Run(true, append, true);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public sealed class ConnectionTablesRequestModel
}

[HttpGet("/designer.getConnectionTypes")]
public static IResult GetConnectionTypes(IConnectionsService connectionsService)
public static IResult GetConnectionTypes([FromQuery] string needSqlSupportInfo, IConnectionsService connectionsService)
{
var response = connectionsService.GetConnectionTypes();
var isNeedSqlSupport = bool.TryParse(needSqlSupportInfo, out var parsedBool) && parsedBool;

var response = connectionsService.GetConnectionTypes(isNeedSqlSupport);
var content = "{" + string.Join(",", response.ToArray()) + "}";

return Results.Content(content, "application/json");
Expand Down
4 changes: 2 additions & 2 deletions FastReport.Core.Web/Controllers/Designer/UtilsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public static IResult GetComponentProperties(string name, IDesignerUtilsService
}

[HttpGet("/designer.getConfig")]
public static IResult GetConfig(string reportId, IReportService reportService)
public static IResult GetConfig(string reportId, IReportService reportService, IDesignerUtilsService designerUtilsService)
{
if (!reportService.TryFindWebReport(reportId, out var webReport))
return Results.NotFound();

var content = webReport.Designer.Config.IsNullOrWhiteSpace() ? "{}" : webReport.Designer.Config;
var content = designerUtilsService.GetConfig(webReport);

return Results.Content(content, "application/json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public interface IConnectionsService
/// <summary>
/// Returns the list of connection types
/// </summary>
List<string> GetConnectionTypes();
List<string> GetConnectionTypes(bool needSqlSupportInfo = false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public interface IDesignerUtilsService
/// <returns>Returns a string with the report functions</returns>
string GetFunctions(Report report);

/// <summary>
/// Returns the Online Designer configuration
/// </summary>
/// <param name="webReport">WebReport configuration of which is to be returned</param>
/// <returns>String in JSON format with configuration for Online Designer</returns>
string GetConfig(WebReport webReport);

string DesignerObjectPreview(WebReport webReport, string reportObj);
}
}
30 changes: 24 additions & 6 deletions FastReport.Core.Web/Services/Implementation/ConnectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.Encodings.Web;
Expand Down Expand Up @@ -198,6 +199,7 @@ public string GetConnectionTables(string connectionType, string connectionString
{
Table = new DataTable(),
TableName = view.TableName,
Name = view.TableName,
SelectCommand = view.SqlQuery
};

Expand Down Expand Up @@ -245,17 +247,33 @@ private static bool IsConnectionStringValid(string connectionString, out string
return true;
}

public List<string> GetConnectionTypes()
public List<string> GetConnectionTypes(bool needSqlSupportInfo = false)
{
var names = new List<string>();
var result = new List<string>();
var objects = new List<DataConnectionInfo>();
RegisteredObjects.DataConnections.EnumItems(objects);

foreach (var info in objects)
if (info.Object != null)
names.Add($@"""{info.Object.FullName}"":""{Res.TryGetBuiltin(info.Text)}""");
foreach (var info in objects.Where(info => info.Object != null))
{
string connection;

if (needSqlSupportInfo)
{
using var conn = (DataConnectionBase)Activator.CreateInstance(info.Object);
connection = $"\"{info.Object.FullName}\": {GetConnectionJson(info.Text, conn.IsSqlBased)}";
}
else connection = $"\"{info.Object.FullName}\": \"{Res.TryGetBuiltin(info.Text)}\"";

return names;
result.Add(connection);
}

return result;
}

private static string GetConnectionJson(string text, bool isSqlBased)
{
return $"{{\"connectionType\": \"{Res.TryGetBuiltin(text)}\", \"sqlSupport\": {isSqlBased.ToString().ToLowerInvariant()}}}";
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FastReport.Utils;
using FastReport.Utils.Json;

using FastReport.Web.Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
Expand All @@ -17,6 +17,7 @@ namespace FastReport.Web.Services
{
internal sealed class DesignerUtilsService : IDesignerUtilsService
{
private const string IsCustomSqlAllowedKey = "custom-sql-allowed";

public string GetMSChartTemplateXML(string templateName)
{
Expand Down Expand Up @@ -149,6 +150,25 @@ public string DesignerObjectPreview(WebReport webReport, string reportObj)

return sb.ToString();
}

public string GetConfig(WebReport webReport)
{
JsonBase config;

try
{
config = JsonBase.FromString(webReport.Designer.Config);
}
catch
{
config = new JsonObject();
}

config[IsCustomSqlAllowedKey] = FastReportGlobal.AllowCustomSqlQueries;

return config.ToString();
}

}

static class ComponentInformationCache
Expand Down

0 comments on commit 4746ad4

Please sign in to comment.