aggiunta stampa di un json alla creazione del report
This commit is contained in:
parent
62a6f238f0
commit
6effeecf35
@ -56,6 +56,9 @@
|
|||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\GestoreTrimestrale\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath>
|
<HintPath>..\GestoreTrimestrale\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
|
using Amib.Threading;
|
||||||
|
using DataAccessLayer;
|
||||||
|
using PDFGenerator;
|
||||||
|
using PDFGenerator.BusinessLayer;
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.Collections.Specialized;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Amib.Threading;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using PDFGenerator.BusinessLayer;
|
|
||||||
using PDFGenerator;
|
|
||||||
|
|
||||||
|
|
||||||
using DataAccessLayer;
|
|
||||||
|
|
||||||
namespace GestorePDF.Logic
|
namespace GestorePDF.Logic
|
||||||
{
|
{
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
public class GestoreThread
|
public class GestoreThread
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||||
<package id="NLog" version="4.2.3" targetFramework="net45" />
|
<package id="NLog" version="4.2.3" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
@ -0,0 +1,55 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PDFGenerator.BusinessLayer.Json
|
||||||
|
{
|
||||||
|
public class JsonExporter
|
||||||
|
{
|
||||||
|
private static string ExecutionTimestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
|
public static void ExportForJasperReport(DataThread dataThread, string codice)
|
||||||
|
{
|
||||||
|
string fileName = $"{codice}.json";
|
||||||
|
string directory = Path.Combine(CACHE.SavePDFtoDISK_Folder, ExecutionTimestamp);
|
||||||
|
|
||||||
|
// Crea la directory se non esiste
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
|
||||||
|
string fullPath = Path.Combine(directory, fileName);
|
||||||
|
ExportToJson(dataThread, fullPath);
|
||||||
|
|
||||||
|
Console.WriteLine($"Data source per Jasper creato: {fileName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ExportToJson(DataThread dataThread, string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Serializza l'oggetto in JSON con formattazione
|
||||||
|
string json = JsonConvert.SerializeObject(dataThread, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
// Gestisce le referenze circolari se presenti
|
||||||
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||||
|
// Include proprietà null
|
||||||
|
NullValueHandling = NullValueHandling.Include,
|
||||||
|
// Formato data personalizzato
|
||||||
|
DateFormatString = "yyyy-MM-dd HH:mm:ss"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scrive il JSON nel file
|
||||||
|
File.WriteAllText(filePath, json);
|
||||||
|
|
||||||
|
Console.WriteLine($"DataThread esportato con successo in: {filePath}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Errore durante l'esportazione: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using PDFGenerator.Presentation.Section;
|
|||||||
using PDFGenerator.BusinessLayer.DataSection;
|
using PDFGenerator.BusinessLayer.DataSection;
|
||||||
|
|
||||||
using PDFGenerator.Presentation.TemplateGenerator;
|
using PDFGenerator.Presentation.TemplateGenerator;
|
||||||
|
using PDFGenerator.BusinessLayer.Json;
|
||||||
|
|
||||||
|
|
||||||
namespace PDFGenerator.BusinessLayer
|
namespace PDFGenerator.BusinessLayer
|
||||||
@ -449,6 +450,8 @@ namespace PDFGenerator.BusinessLayer
|
|||||||
if (notsez.Equals(_codice)) data.Esito = 0;
|
if (notsez.Equals(_codice)) data.Esito = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//QUI
|
||||||
|
JsonExporter.ExportForJasperReport(_dataThread, this.Codice);
|
||||||
|
|
||||||
if (data!=null && data.Esito > 0)
|
if (data!=null && data.Esito > 0)
|
||||||
{
|
{
|
||||||
|
@ -796,7 +796,7 @@ namespace PDFGenerator
|
|||||||
if (string.IsNullOrWhiteSpace(_dataThread.NomeFilePdf))
|
if (string.IsNullOrWhiteSpace(_dataThread.NomeFilePdf))
|
||||||
{
|
{
|
||||||
logger.Info("_dataThread.NomeFilePdf è vuoto");
|
logger.Info("_dataThread.NomeFilePdf è vuoto");
|
||||||
_dataThread.NomeFilePdf = "Test";
|
_dataThread.NomeFilePdf = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Percorso completo della cartella
|
// Percorso completo della cartella
|
||||||
|
@ -96,6 +96,9 @@
|
|||||||
<Reference Include="Microsoft.Practices.ObjectBuilder">
|
<Reference Include="Microsoft.Practices.ObjectBuilder">
|
||||||
<HintPath>..\DLLesterne\Microsoft.Practices.ObjectBuilder.dll</HintPath>
|
<HintPath>..\DLLesterne\Microsoft.Practices.ObjectBuilder.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\GestoreTrimestrale\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
|
<HintPath>..\GestoreTrimestrale\packages\NLog.4.2.3\lib\net40\NLog.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -857,6 +860,7 @@
|
|||||||
<Compile Include="BusinessLayer\DataSection\StructColor.cs" />
|
<Compile Include="BusinessLayer\DataSection\StructColor.cs" />
|
||||||
<Compile Include="BusinessLayer\DataThread.cs" />
|
<Compile Include="BusinessLayer\DataThread.cs" />
|
||||||
<Compile Include="BusinessLayer\DataThreadModel.cs" />
|
<Compile Include="BusinessLayer\DataThreadModel.cs" />
|
||||||
|
<Compile Include="BusinessLayer\Json\JsonExporter.cs" />
|
||||||
<Compile Include="BusinessLayer\LibFunction.cs" />
|
<Compile Include="BusinessLayer\LibFunction.cs" />
|
||||||
<Compile Include="BusinessLayer\ParagrafoReport.cs" />
|
<Compile Include="BusinessLayer\ParagrafoReport.cs" />
|
||||||
<Compile Include="BusinessLayer\ParametriReport.cs" />
|
<Compile Include="BusinessLayer\ParametriReport.cs" />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||||
<package id="NLog" version="4.2.3" targetFramework="net40" />
|
<package id="NLog" version="4.2.3" targetFramework="net40" />
|
||||||
</packages>
|
</packages>
|
Loading…
x
Reference in New Issue
Block a user