Telerik Forums
Reporting Forum
1 answer
84 views

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.

Momchil
Telerik team
 answered on 20 Feb 2024
2 answers
265 views

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.

Christiaan
Top achievements
Rank 1
Iron
 answered on 20 Feb 2024
2 answers
842 views

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.518155356Z System.MissingMethodException: Type: Telerik.Reporting.ReportSerialization.Current.ReportSerializable`1[Telerik.Reporting.Report]
2024-02-19T06:04:14.518227356Z ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
2024-02-19T06:04:14.525815894Z ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
2024-02-19T06:04:14.525839694Z ---> System.TypeInitializationException: The type initializer for 'Telerik.Reporting.Drawing.Unit' threw an exception.
2024-02-19T06:04:14.525845694Z ---> Telerik.Drawing.Contract.DrawingFactoryUnavailableException: Cannot load assembly Telerik.Drawing.Skia. Make sure it is accessible in the current application domain.
2024-02-19T06:04:14.525850094Z at Telerik.Drawing.Contract.DrawingFactory.GetFactoryBase(String factoryTypeName, String factoryAssemblyName, Boolean assemblyLoaded)
2024-02-19T06:04:14.525854594Z at Telerik.Drawing.Contract.DrawingFactory.GetSkiaInstance()
2024-02-19T06:04:14.525858494Z at Telerik.Drawing.Contract.DrawingFactory.TryResolveFromRuntime()
2024-02-19T06:04:14.525862394Z at Telerik.Drawing.Contract.DrawingFactory.ResolveDrawingFactory()
2024-02-19T06:04:14.525866094Z at Telerik.Drawing.Contract.DrawingFactory.CreateDrawingFactory()
2024-02-19T06:04:14.525869694Z at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
2024-02-19T06:04:14.525873394Z at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
2024-02-19T06:04:14.525877094Z at System.Lazy`1.CreateValue()
2024-02-19T06:04:14.525880593Z at System.Lazy`1.get_Value()
2024-02-19T06:04:14.525884293Z at Telerik.Drawing.Contract.DrawingFactory.get_Instance()
2024-02-19T06:04:14.525887893Z at Telerik.Reporting.Drawing.Unit.GetDotsPerInch()
2024-02-19T06:04:14.525891493Z at Telerik.Reporting.Drawing.Unit.ResetDpiSettings()
2024-02-19T06:04:14.525895093Z at Telerik.Reporting.Drawing.Unit..cctor()
2024-02-19T06:04:14.525898593Z --- End of inner exception stack trace ---
2024-02-19T06:04:14.525902093Z at Telerik.Reporting.Drawing.Unit.Cm(Int32 value)
2024-02-19T06:04:14.525924393Z at Telerik.Reporting.Report..ctor()
2024-02-19T06:04:14.525929493Z at System.RuntimeType.CreateInstanceOfT()
2024-02-19T06:04:14.525933093Z --- End of inner exception stack trace ---
2024-02-19T06:04:14.525936593Z at System.RuntimeType.CreateInstanceOfT()
2024-02-19T06:04:14.525940093Z at System.Activator.CreateInstance[T]()
2024-02-19T06:04:14.525943593Z at Telerik.Reporting.ReportSerialization.Current.ReportSerializable`1..ctor(IConvertersContainer converters)
2024-02-19T06:04:14.525947293Z --- End of inner exception stack trace ---
2024-02-19T06:04:14.525950893Z at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2024-02-19T06:04:14.525954893Z at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2024-02-19T06:04:14.525959993Z at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
2024-02-19T06:04:14.525963993Z at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
2024-02-19T06:04:14.564619278Z at System.Activator.CreateInstance(Type type, Object[] args)
2024-02-19T06:04:14.564649677Z at Telerik.Reporting.Serialization.ObjectReader.CreateInstance(Type type, String name)
2024-02-19T06:04:14.564655577Z --- End of inner exception stack trace ---
2024-02-19T06:04:14.564659977Z at Telerik.Reporting.Serialization.ObjectReader.CreateInstance(Type type, String name)
2024-02-19T06:04:14.564663977Z at Telerik.Reporting.Serialization.ObjectReader.CreateInstance(Type type)
2024-02-19T06:04:14.564668077Z at Telerik.Reporting.Serialization.ObjectReader.ReadObject(Type type)
2024-02-19T06:04:14.564672077Z at Telerik.Reporting.Serialization.ObjectReader.ReadXmlElement(String name)
2024-02-19T06:04:14.564675877Z at Telerik.Reporting.Serialization.ObjectReader.Deserialize(IResourceHandler handler)
2024-02-19T06:04:14.564679577Z at Telerik.Reporting.XmlSerialization.XmlSerializerBase.Deserialize(XmlReader reader, IResourceHandler resourceHandler)
2024-02-19T06:04:14.564683477Z at Telerik.Reporting.XmlSerialization.XmlSerializerBase.Deserialize(Stream stream, IResourceHandler resourceHandler)

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?

Dimitar
Telerik team
 answered on 20 Feb 2024
1 answer
86 views

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

1 answer
150 views

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);

I get the following error:

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)

If I remove the parameter the report works fine, I added changing to Decimal Type value as my DB engine is MS-SQL 2022 Express. I added filters and get same error. I don't know what to do anymore What I am missing

1 answer
87 views

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

 

Dimitar
Telerik team
 answered on 14 Feb 2024
1 answer
324 views
how to use AM PM date format in textbox
n/a
Top achievements
Rank 1
Iron
 answered on 13 Feb 2024
1 answer
118 views

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?

Dimitar
Telerik team
 answered on 13 Feb 2024
1 answer
164 views

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

Dimitar
Telerik team
 answered on 09 Feb 2024
1 answer
120 views

Hi,

Is there a supported or recommended way to mark/tag a report definition with a version number?

Currently, we use:

  • reports created in the standalone designer, saved to *.trdp
  • ASP.NET Core .NET 6 application, that:
    • hosts the reporting REST service
    • uses EFCore IDefinitionStorage based report storage
    • has functionality to import *.trdp files into the database storage

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.

Dimitar
Telerik team
 answered on 09 Feb 2024
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?