Aggiunta documentazione su GestorePDF

This commit is contained in:
Gaetano Savo 2025-04-15 14:44:49 +02:00
parent b82676c402
commit ff0a25775f

162
arm_GestorePDF.md Normal file
View File

@ -0,0 +1,162 @@
# GestorePDF System Documentation
## Overview
GestorePDF is a multi-threaded PDF generation system composed of two main components:
- **GestorePDF** (v4.0.0.0) - Main executable project
- **GestorePDF.Logic** (v2016.207.1342.27) - Core business logic library
## Architecture
### Component Structure
1. **GestorePDF (Main Application)**
- Entry point for the PDF management system
- Contains ThreadManager for process initialization
2. **GestorePDF.Logic (Business Logic)**
- Core processing engine
- Handles PDF generation workflow
- Manages thread queuing and execution
- Implements error handling and logging
### Key Components
#### ThreadManager (GestorePDF)
- Main entry point class
- Initializes the PDF processing system
- Starts the processing logic
#### MasterThread (GestorePDF.Logic)
- Manages work queue using `ConcurrentQueue<DataThread>`
- Processes data threads sequentially
- Creates GestoreThread instances for PDF generation
- Implements thread-safe processing
#### GestoreThread (GestorePDF.Logic)
- Core PDF generation worker
- Handles both "DIAGNOSI" and "MONITORAGGIO" report types
- Features:
- PDF generation via PDFGenerator
- Error logging and database status updates
- Configurable PDF storage options
- Document status management
- Exception handling and error reporting
#### Worker (GestorePDF.Logic)
- Task-based processing unit
- Manages processing context via PipelineContext
- Handles network (Rete) and fiscal code (CodiceFiscale) data
## Process Flow
1. ThreadManager initializes the system
2. MasterThread manages the work queue
3. GestoreThread performs PDF generation:
- Processes DIAGNOSI reports
- Processes MONITORAGGIO reports
- Updates document status
- Handles error conditions
## Integration Points
- **Database**: SQL Server (DBProvider.SqlServerStampeC6)
- **Logging**: NLog system
- **PDF Generation**: PDFGenerator component
- **Utilities**: ContrattoSei.Utilities
## Configuration
- PDF storage options controlled via "SavePDFtoDISK" setting
- Supports multiple storage modes:
- File system storage
- Database storage
- Configurable target folders
## Error Handling
- Comprehensive exception handling
- Error logging to database
- Document status recovery
- Fault customer tracking
## Performance Considerations
- Thread-safe queue implementation
- Sequential processing of data threads
- Configurable processing delays
- Status monitoring and recovery mechanisms
## Template System
The system uses `TemplateGenerator.xml` as a configuration file that defines the structure and content of generated PDF reports:
1. **Section Definitions**
- Contains detailed definitions of all possible sections (e.g., AreediBisogno, AssetClass, etc.)
- Each section defines:
- Title
- Body content
- Detailed descriptions and explanations
2. **Report Templates**
- Defines two main report types:
- "MONITORAGGIO"
- "DIAGNOSI"
3. **Client Customization**
- Differentiates templates by:
- Contract type: "OLD" vs "PRIVATE"
- Client type: "NONPROFFESIONAL" vs "PROFFESIONAL"
4. **Page Layout**
- Specifies sections per page
- Defines section order
- Includes various components (AreediBisogno, AssetClass, etc.)
## Data Sources
1. **SQL Server Database (DBProvider.SqlServerStampeC6)**:
- Key Stored Procedures:
- `c6martPeriodico.UpdateStatoReport` - report status updates
- `[C6MartPeriodico].[GESTIONE_INSERT_CUSTOMER_ERROR]` - error handling
- `test.GESTIONE_PDF_PREPARE_TEST_SAMPLE` - data preparation
- `[C6Mart].[UT_INSERT_ERROR]` - error logging
- `SP_GESTIONE_UPDATE_ELABORAZIONE_PDF` - processing updates
2. **DataThread Structure**:
Contains core report generation data:
- CodiceFiscale
- Rete
- TipoContratto
- ReportsType
- TipoReport ("DIAGNOSI" or "MONITORAGGIO")
- NomeFileReport
3. **Data Access Layer**:
- Uses `DataAccessLayer` for database access
- `DataAccessDE` for specific database operations
4. **Configuration**:
- Uses `ConfigurationManager.AppSettings` for parameters:
- "SavePDFtoDISK"
- "SavePDFtoDISK_Folder"
- "SP_GESTIONE_UPDATE_ELABORAZIONE_PDF"
## Data Flow
1. System receives PDF generation request via `DataThread`
2. Retrieves necessary data from database using stored procedures
3. Applies data to template defined in TemplateGenerator.xml
4. Generates final PDF using PDFGenerator component
## Future Enhancements
- Support for additional report types
- Enhanced error handling and logging
- Improved performance optimization
- Expanded integration points