Hello Supports,
I want to try and install Nuget packages Telerik.Reporting.Services.AspNetCore for my Asp.net Core project but it isn't found.
when I go to the option "Manage Nuget packages", these are no available the packages to download (see the attached file).
Is it missing from the private nuget feed ?
Thank You.
Hi,
Maybe you want me refer Assign connection string dynamically using report parameter and bindings - Telerik Reporting .I followed the solution, it didn't work . And then I set the 'ConnectionString' to '@ReportParameters.PFDSConnectionString', it also didn't work, even if I add the '.Value'.Pls refer the error.png
But when I set the connection string to the property 'ConnectionString' , it worked. And I tested the parameter rendering, it's also OK. Pls refer the success.png.
I think the C# code is OK. Because when I use the appsetting.json file to injec the connection string.
Set ConnectionString to 'AcosReportsConnection', It's OK too. Pls refer the appsettings.png.
Because now the connection string come from database depending on different input parameters, I need to set the connection string dynamically.
Now I am very confused.
Do you have any suggestiones? Thanks.
Hi everyone.
We have an extremely frustrating problem we are attempting to solve.
We have a .NET 7 Web Application using a Blazor Server hosting model for reporting. The application is containerized and runs as part of a service via AWS Fargate. We have a series of legacy reports that we have converted to '.trdp' format, several of these reports use a named connection string to interact with RDS (AWS SQL DB).
We are using the 'Blazor' reporting solution that is merely a wrapper over the HTML5 reporting. The assembly versions are as follows:
Telerik.Drawing.Skia, 17.2.23.1114 Telerik.Reporting, 17.2.23.1114 Telerik.Reporting.OpenXmlRendering, 17.2.23.1114 Telerik.Reporting.Services.AspNetCore, 17.2.23.1114 Telerik.ReportViewer.Blazor, 17.2.23.1114
As part of our build process - we inject a secrets file into the container definition with the credentials for accessing the db. This is modified during launch to include the correct environment db and db credentials:
if (ConnectionUtility.IsRunningInFargate())
{
// Create new copy of string in memory so we can modify it
var connectionString = connectionStrings[Constants.ReportingSqlConnectionKey];
var databaseUriForEnvironment = ConnectionUtility.GetDatabaseUriForEnvironment();
var databaseForEnvironment = ConnectionUtility.GetDatabaseForEnvironment();
// Replace placeholders with values
var protoConnectionString =
connectionString!
.Replace("{0}", databaseUriForEnvironment)
.Replace("{1}", databaseForEnvironment);
// Important! - This replaces the 'in-memory' connection string that reports use to interact with the primary db
connectionStrings[Constants.ReportingSqlConnectionKey] = protoConnectionString.TransformSecret(Constants.SettingClass.ConnectionString);
}
The connection string key isn't important here, but it is used to provide the connection key for each report.;
The Telerik services are injected:
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp => new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "X.Reporting",
Storage = new FileStorage(),
ExceptionsVerbosity = "detailed",
ReportSourceResolver =
new CustomReportSourceResolverWithFallBack(
new TypeReportSourceResolver()
.AddFallbackResolver(
new UriReportSourceResolver(
Path.Combine(
GetReportsDir(sp))))),
});
The resolver is less important, but for the sake of completion:
using Telerik.Reporting;
using Telerik.Reporting.Services;
namespace X.Reporting.Services
{
public class CustomReportSourceResolverWithFallBack : IReportSourceResolver
{
private readonly IReportSourceResolver? _parentResolver;
public CustomReportSourceResolverWithFallBack(IReportSourceResolver? parentResolver)
{
_parentResolver = parentResolver;
}
public ReportSource Resolve(string report, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
{
var reportDocument = ResolveCustomReportSource(report, operationOrigin, currentParameterValues);
if (null == reportDocument && null != _parentResolver)
{
reportDocument = _parentResolver.Resolve(report, operationOrigin, currentParameterValues);
}
return reportDocument;
}
private ReportSource ResolveCustomReportSource(string reportId, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
{
var reportBook = new ReportBook();
var splitString = reportId.Split(',').ToList();
foreach (var report in splitString)
{
var uriReportSource = new UriReportSource
{
Uri = $"Reports/{report}.trdp"
};
reportBook.ReportSources.Add(uriReportSource);
if (operationOrigin == OperationOrigin.ResolveReportParameters)
{
reportBook.ReportSources.Add(GetReportParameters(report, currentParameterValues));
}
}
return new InstanceReportSource { ReportDocument = reportBook };
}
private ReportSource GetReportParameters(string reportId, IDictionary<string, object> currentParameterValues)
{
UriReportSource report = new UriReportSource();
foreach (var parameterValue in currentParameterValues)
{
if (parameterValue.Value is not null and not (string)"standardReport")
{
var par = new Parameter
{
Name = parameterValue.Key,
Value = parameterValue.Value.ToString()
};
report.Parameters.Add(par);
report.Uri = $"Reports/{reportId}.trdp";
}
}
return report;
}
}
}
90 % of the time, we can render reports without issue. However, there are times where any report that uses a SQL connection seems to be unable to reach our primary database. EF Core (which interacts with the same DB prior to and after rendering reports) seems to never have this issue - even when Telerik does. Both share the exact same connection string. Rendering a report with an included SQL query returns something like the following:
On occasion, this issue seems to resolve itself after ~5 minutes. Most of time, we need to kill the container instance and restart it a number of times before reports render without issue. I'm confounded why this happens - it 'feels' like the underlying SQL connection is reused.
Any help is appreciated - this has been a critical issue to our clients, we can't keep using this reporting solution without a fix.
Hi All,
I am using the telerik reporting trial version in blazor. On the development machine everything works fine and report display.
But when i deploy to iis for testing, the report does not show.
Attached is an error from the console.
Kindly help.
Thank you
Good morning.
I wanted to address an issue we're running into while trying to post a .Net Core / Angular app with a folder of standalone reports. For some unknown reason these will work fine on my machine, I have a couple dozen built from the Telerik Reporting standalone designer, but it won't work on an Azure VM.
The need to set up an Azure VM occurred to me when I realized that I couldn't update a SQL connection for a report unless the connection returns as valid, which in this case it's a private SQL resource so they set us up with a VM to momentarily upload the reports and edit them from the same internal domain as the SQL server. The problem I'm running into now is that we get the following error, seemingly unconditoinally, from the Azure VM environment:
Connection unsuccessful. Check the connection string and try again. Details: Expecting a non-empty string for 'providerInvariantName' parameter.
That error comes back even if we add providerInvariantName to the string. Something else is clearly going on, I don't exactly know what but it seems like it's an environment issue with the Azure VM if no changes to the sql string either cause a different error or succeed.
What I'd like to ask for is more insight into what kinds of things can cause this error so we understand the problem space a bit better. Please let us know your thoughts on what we need to look at in order to troubleshoot this.
Alright, this might be a long post, but I am quite confused with something. So, I have a Blazor WASM app. In here I get a list of reports using the following code:
Reports = await Http.GetFromJsonAsync<List<string>>($"{BaseAddress}/getreports") ?? new List<string>();
When I select one (because that code is in my NavMenu, I build up a list of the reports there), I then do an OnInitializedAsync and set the ReportSourceOption:
Report Viewer Code:
<div style="padding-top:10px;">
<ReportViewer @ref ="_reportViewer1"
ViewerId="rv1"
ServiceUrl="http://localhost:59655/api/reports"
ReportSource="@(new ReportSourceOptions()
{
Report = ReportName
})"
Parameters="@(new ParametersOptions { Editors = new EditorsOptions { MultiSelect = EditorType.ListView, SingleSelect = EditorType.ComboBox }})"
ScaleMode="@(ScaleMode.Specific)"
Scale="1.0"
EnableAccessibility="false" />
</div>
OnInitializedAsync Code:
protected override async Task OnInitializedAsync()
{
await _reportViewer1.SetReportSourceAsync(new ReportSourceOptions
{
Report = ReportName
});
}
Now, in my Blazor App I set default headers. This is important, because these headers will determine which connection string to use, as we have a Multi-Tenant system:
"DefaultHeaders": [ { "Name": "TenantName", "Value": "TenantId" } ]
When I render the Report Viewer page, it hits the Reports REST service (as expected), but here is the first question I have. Why does my CustomReportSourceResolver get hit up to 6 times? Reason I am asking, is because when my CustomReportSourceResolver constructor gets hit the first time, the header with the TenantId is there. But, the second time the constructor gets hit, it is as if Telerik creates a new Http Context, which in turn clears the headers and then I do not have access to the TenantId.
Here is my CustomReportSourceResolver constructor:
private static string _tenantId;
public CustomReportSourceResolver(IConfiguration configuration, IHttpContextAccessor context)
{
_configuration = configuration;
_contextAccessor = context;
if (!string.IsNullOrEmpty(_contextAccessor.HttpContext.Request.Headers["TenantId"]))
{
_tenantId = _contextAccessor.HttpContext.Request.Headers["TenantId"];
}
}
I had to add the if (!string.IsNullOrEmpty) and set the static string, because the headers kept clearing, but this could cause problems if there are too many users using the report service at the same time. Well, if I am thinking quickly, because I feel like the Custom Resolver will get confused with the _tenantId. If I am wrong, please do let me know.
And then my Resolve method:
public ReportSource Resolve(string report, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
{
var tenantId = _contextAccessor.HttpContext.Request.Headers["TenantId"].ToString();
var json = System.IO.File.ReadAllText($"{configurationsDirectory}\\database.json");
Settings databaseSettings = JsonSerializer.Deserialize<Settings>(json);
foreach (var tenant in databaseSettings.DatabaseSettings.TenantSettings)
{
if (tenant.TenantId == _tenantId)
{
_connectionString = tenant.ConnectionString;
}
}
using (var conn = new NpgsqlConnection(_connectionString))
{
conn.Open();
var sourceReportSource = new UriReportSource { Uri = $"{report}.trdp" };
var reportSource = UpdateReportSource(sourceReportSource);
return reportSource;
}
}
So, as you can see, I have a var tenantId at the top, but that will ALWAYS be null, due to the headers being cleared.
Here is my Program.cs where I inject the CustomReportSourceResolver, as well as my HttpContextAccessor:
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<IReportSourceResolver, CustomReportSourceResolver>();
builder.Services.TryAddScoped<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "MyHostAppId",
Storage = new FileStorage(),
ReportSourceResolver = sp.GetService<IReportSourceResolver>()
});
If I cannot work around the header being cleared, because I am not sure what Telerik does in the background, so I cannot confirm if they create a new Http Context each time the constructor gets hit, is there a different way I can pass through the TenantId to my CustomReportSourceResolver? I have tried using the report parameters, but that is obviously (at least I think so) used for parameters that is present in the .trdp file, so I am unable to use that. Any help would be appreciated.
I would also like to add that I am using PostgreSQL, not sure if that info is needed. And then this project is being built in .NET 7, but I am planning on upgrading to .NET 8.
I would also like to apologise if the question I posted is stupid, as I am new to Blazor and to Telerik.