Page 1 of 1
Reopen data transformation datasource problem
Posted: Wed Dec 21, 2022 6:02 am
by Pavel K.
Hello. I have report, with data transformation datasource. I create report dynamic from my method, like this:
Code: Select all
public void MyMethod(TemplateDto template){
using (var report = new StiReport())
{
report.Load(template.Data);
SetConnectionStringToReport(report);
report.Compile();
SetParametersToReport(report);
// For test getting datasource and view data
StiDataTransformation dataTransformationSource = (StiDataTransformation)report.DataSources.Items.FirstOrDefault(x => x.Alias.Equals("MyDataTranform"));
if (dataTransformationSource != null)
{
// See data in my Data Transformation Source
var dataInSource = dataTransformationSource.RetrieveDataTable(Stimulsoft.Data.Engine.StiDataRequestOption.All);
}
report.Render();
}
}
When i call my method for the first time, my datasource open correctly and have correctly data (i see execute sql query in my database, from linked datasource). But next calls datasource not reopenning and datasource have data from first call. How i can update data manually in datasource?
Re: Reopen data transformation datasource problem
Posted: Wed Dec 21, 2022 9:36 am
by Max Shamanov
Hello,
Please send us the sample project that will let us trepoduces the issue.
Thank you.
Re: Reopen data transformation datasource problem
Posted: Wed Dec 21, 2022 6:37 pm
by Pavel K.
Max Shamanov wrote: ↑Wed Dec 21, 2022 9:36 am
Hello,
Please send us the sample project that will let us trepoduces the issue.
Thank you.
Hello Max.
I created simple report, it include JSONdataSource, DataTransformation and two dataBands:

- Снимок экрана 2022-12-21 210403.jpg (56.65 KiB) Viewed 1342 times

- Снимок экрана 2022-12-21 210323.jpg (24.53 KiB) Viewed 1342 times

- Снимок экрана 2022-12-21 210204.jpg (146.74 KiB) Viewed 1342 times
And simple .Net project. My project generate random data, attaches this data to dataset and render report.
This operation calling three time. First time, value in transformdataband is correct. Next times this value not changing.
I use StimulSoft dll version 2022.1.1.0
Code: Select all
using Newtonsoft.Json;
using Stimulsoft.Report;
using Stimulsoft.Report.Dictionary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace TestStimulSoftProject
{
public class DtoTestData
{
public int Ident { get; set; }
public string ParamName { get; set; }
public int value { get; set; }
}
class Program
{
static string CreateDataFile()
{
var FileName = Path.ChangeExtension(Path.GetRandomFileName(), ".json");
var DataList = new List<DtoTestData>();
var random = new Random();
for (var i = 0; i < 5; i++)
{
DataList.Add(new DtoTestData() { Ident = i, ParamName = $"Param #{i}", value = random.Next(0, 100) });
}
var json = JsonConvert.SerializeObject(DataList);
File.WriteAllText(FileName, json);
return FileName;
}
static void Main(string[] args)
{
CreateReport(1);
CreateReport(2);
CreateReport(3);
CreateReport(4);
}
private static void CreateReport(int v)
{
Stimulsoft.Base.StiLicense.Key = "enter key here";
var dataFile = CreateDataFile();
using (var report = new StiReport())
{
report.Load("Report.mrt");
var dataSource = (StiJsonDatabase)report.Dictionary.Databases.Items.FirstOrDefault(x => x.Name.Equals("JSONData"));
dataSource.PathData = dataFile;
report.Compile();
report.Render();
report.ExportDocument(StiExportFormat.ImageJpeg, $"report_{v}.jpeg");
}
}
}
}

- report_1.jpeg (30.52 KiB) Viewed 1342 times

- report_2.jpeg (30.53 KiB) Viewed 1342 times

- report_3.jpeg (30.53 KiB) Viewed 1342 times

- report_4.jpeg (30.54 KiB) Viewed 1342 times
Re: Reopen data transformation datasource problem
Posted: Thu Dec 22, 2022 7:17 am
by Pavel K.
I think i found resolve this problem. Need clearing cache after report render
Strange, I tried to disable caching but it didn't work.
Code: Select all
report.CacheAllData = false;
report.CacheTotals = false;
Re: Reopen data transformation datasource problem
Posted: Thu Dec 22, 2022 11:58 am
by Max Shamanov
Hello,
Yes, you should use the following code if you work with DataTransformation.