Project Overview: Ticket Analysis & Reporting Application
This project is a Windows Forms Application (WinForms) built with C# (.NET 8). Its primary purpose is to manage, analyze, and report on IT Helpdesk tickets. The application connects to a MySQL database to fetch ticket data, provides a user-friendly interface for filtering and searching, visualizes data using charts, and allows exporting reports to Word and Excel formats.
- Technology Stack & External Libraries
The project relies on several key libraries to handle specific tasks:
- MySQL.Data: For connecting to and interacting with the MySQL database.
- ScottPlot & ScottPlot.WinForms: Used for generating graphical analysis charts (Bar and Scatter plots).
- ClosedXML: Used for exporting data to Excel (.xlsx) files.
- DocumentFormat.OpenXml: Used for generating Word (.docx) reports.
- CsvHelper: Used for parsing and importing CSV files into the database.
- Architecture & Key Components
The project is structured into Data Access, Business Models, Services, and User Interface (UI) layers.
A. Domain Model Ticket Class (Tickets.cs):
- Represents a single helpdesk ticket.
- Properties: Id, Name (Title), Category, OpenDate, SolveDate, TicketContent (Problem description), and SolutionContent. All string properties are initialized with default values to comply with nullable reference type safety.
- Calculated Properties:
- ResolutionTime: Calculates the duration between opening and solving the ticket.
- MonthName: Formats the opening date to show the month and year in Turkish (e.g., "Ocak 2024").
B. Data Access Layer (DAL) MySQLConnectionHelper:
- Manages the single shared connection string to the local MySQL database (destek_analizleri).
- All components (TicketRepository, ImportService) use this helper — credentials are defined in one place only.
TicketRepository:
- Contains the GetAllTickets() method.
- Executes a raw SQL SELECT query with LEFT JOIN operations to combine data from the tickets, categories, and solutions tables.
- Handles DBNull values safely to prevent crashes when fields (like category or solution date) are empty.
C. Services (Import & Export) ImportService:
- Handles importing data from CSV files into the MySQL database.
- Dynamic Table Creation: Checks if the required tables (tickets, categories, solutions) exist and creates them if they don't.
- Transaction Management: Uses SQL transactions to insert data in batches (every 1000 rows) for performance and data integrity. Rolls back on failure.
- Returns the count of skipped rows (due to errors) so the UI can inform the user.
ExcelExporter:
- Creates an Excel sheet with columns for ID, Title, Category, Dates, and Resolution Time.
- Header row is bold with a blue background for clear visual separation.
- Automatically adjusts column widths for better readability.
WordExporter:
- Generates a formatted Word document.
- Content Cleaning: Uses Regex and WebUtility.HtmlDecode to strip HTML tags from the ticket content and solution text before writing to the Word file, ensuring clean text output.
- Dates are explicitly formatted using Turkish culture (tr-TR) to ensure correct month names on all systems.
D. User Interface (UI) Form1 (Main Window):
- Load button fetches all tickets, excluding "Problem:" and "test" entries.
- Month dropdown is sorted chronologically (not alphabetically).
- Search controls (title, ID, category, date range) are laid out without overlapping.
- Date pickers default to a one-year range (last year → today) for immediate usability.
- "Detaylı Ara" applies the same exclusion filters as the main filter.
- Word and Excel export use a SaveFileDialog so the user can choose the save location.
- DataGridView shows Turkish column headers (ID, Başlık, Kategori, Açılış Tarihi, Çözüm Tarihi, Çözüm Süresi).
Form2 (Chart Analysis):
- Tab 1: Monthly ticket count (bar chart).
- Tab 2: Category summary table with percentages.
- Tab 3: Average resolution time by month (scatter plot). Shows an informative message if no resolved tickets exist in the selected range.
- Configuration
Database connection is configured in MySQLConnectionHelper.cs:
Server=localhost;Database=destek_analizleri;User ID=root;Password=<your_password>;
Update the Password field before running the application.