Hi,
Situation :
We have a list of cheques where a user can select (more that one) and using reportviewer to print it by pressing a print button (please refer to attach image)
Problem :
On first print activitiy, printing is success, but if the user need to re-print or select another cheques from the list and press the print button, an error "Report instance with ID 'null' not found" will occur.
Need some advise to fixed or a workaround.
Thanks in advance.
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.
While developing an endpoint (.NET 6 API) to export a PDF from a TRDX file ( no problems here ) I decided to publish to the test environment.
I keep getting this error :
2024-02-19T06:04:14.564687177Z at Telerik.Reporting.XmlSerialization.ReportXmlSerializer.Deserialize(Stream stream)
Is this error related to the Trial version or is there anything else?
Hi,
We are looking for a way to display the following data in a crosstab. The data comes from a webservice datasource.
Each row represents an object of the following JobDto class with some pre-defined properties and an array of metadata.
public class JobDto
{
public string Id { get; set; }
public string Name { get; set; }
public int Number { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public MetadataDto[] Metadata { get; set; } = Array.Empty<MetadataDto>();
}
public class MetadataDto
{
public string Name { get; set; }
public string Value { get; set; }
}
How can we display first the fixed properties as pre-defined columns, followed by each metadata item from the array as auto-generated columns? We are primarily using the Web report designer.
Kind regards,
Lennert
I created a report using Telerik Report Designer Standalone with sqlDataSource1 setup with the following ReportParameters like this:
C# coded that read that send the parameter as Int32
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
// set any deviceInfo settings if necessary
var deviceInfo = new System.Collections.Hashtable();
var reportSource = new Telerik.Reporting.UriReportSource();
var directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
var value = Convert.ToInt32(numericExportarPdf.Value);
reportSource.Uri = "Report.trdp";
reportSource.Parameters.Add("NRO_TICKET", value);
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
if (result.HasErrors) return;
string fileName = result.DocumentName + "." + result.Extension;
string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string filePath = Path.Combine(path, fileName);
using FileStream fs = new FileStream(filePath, FileMode.Create);
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
Telerik.Reporting.Processing.CancelProcessingException: An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.
---> System.Exception: Invalid value of report parameter 'NRO_TICKET'.
--- End of inner exception stack trace ---
at Telerik.Reporting.Processing.Report.ValidateParameters()
at Telerik.Reporting.Processing.Report.ProcessItem()
at Telerik.Reporting.Processing.ReportItemBase.ProcessElement()
at Telerik.Reporting.Processing.Report.ProcessElement()
at Telerik.Reporting.Processing.ProcessingElement.Process(IDataMember dataContext)
at Telerik.Reporting.Processing.Report.Process(Boolean processItemActions, Boolean documentMapEnabled)
at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(Report report, IPathResolver pathResolver, IProcessingContext parentContext, IEnumerable`1 parameters, Key rootKey, Boolean interactivityEnabled, Boolean documentMapEnabled, PageLayoutInfo pageSettings, ErrorEventHandler errorHandler, List`1 documentNodes, Boolean& documentMapAvailable)
at Telerik.Reporting.Processing.ReportProcessor.ProcessResolvedReports(ResolvedReportDocument resolvedReportDocument, IList`1 parameters, IProcessingContext contextPerDocument, Boolean interactivityEnabled, Boolean documentMapEnabled, PageLayoutInfo pageSettings, List`1 processedReports, ErrorEventHandler errorHandler, List`1 documentNodes, Boolean& documentMapAvailable, ListSlice& tocReportsSlice)
at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, IRenderingContext context)
at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, Hashtable deviceInfo, IRenderingContext context)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.<>c__DisplayClass47_0.<RenderReport>b__0(SingleStreamManager sm)
at Telerik.Reporting.Processing.ReportProcessor.RenderReportSafe(Func`2 renderCallback, String format, IRenderingContext renderingContext)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo, CancellationToken cancellationToken)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)
Greetings!
I'm trying to run the DatabaseCacheConfigurator.exe, select a PostgreSQL target backend, and create schema. I first ran into an issue where the Npgsql database provider was "not installed properly". I seem to have resolved that by installing what appears to be the last version of the Npgsql MSI (GAC) provider version 4.1.8.
This gets me past the not "installed properly" message, but now I receive the following:
Database driver installation problem: Cannot use factory for PostgreSql. Could not load type 'NpgsqlTypes.NpgsqlTimeZone' from assembly 'Npgsql, version=4.1.8.0.....
The full stack trace is in the attached screenshot.
Any suggestions?
Many Thanks!
Bryan
Hello Telerik,
I'm currently developing an application using Blazor Server along with the balzor Report Designer/Viewer.
We are a multitenant application that has multiples dbs per tenant. I'm facing the challenge of ensuring that connection strings are safe and flexible. I need each tenant to be able to create and print reports without interacting with the connection string at any time. So want to use Shared Data Sources.
Storing them in the report with the embedded in the report definition option is not safe nor flexible enough and the shared connection with alias and read it from appsettings file doesn't provide the level of security I require security nor flexibility.
I have a custom implementation of the ISettingsStorage. That works well in the designer, it allows me to provide a shared connection string from custom sources (stored and encrypted in a db). But I can't seem to make the ISettingsStorage work with the ReportViewer, it seems like it allways tries to find the shared data sources from appsetings, wich is not desired. I'm using blazor designer and viewer in the same server.
TLDR: I need to use ISettingsStorage instead of appsettings in the ReportViewer with shared SQL Server data source.
Can you help me please?
hi everybody,
I would like to know if it is possible to have the asp.net mvc generic layout (the one we have when creating a web app) with report, so far I just have report layout.
any suggestion, thanks
Ray
Hi,
Is there a supported or recommended way to mark/tag a report definition with a version number?
Currently, we use:
It will be very useful to be able to automate the report import process on a deployment of the application so that it will only overwrite an existing report in the storage when it is a newer version.
Thanks.