The Customer Monitoring Application is a robust WPF-based application designed to manage and monitor users and their permissions. It provides powerful features for businesses to efficiently manage user data, permissions, and interact with a secure SQL Server database using modern techniques like Polly for resilience and enhanced error handling. The app also integrates a Telegram Bot, allowing seamless communication for file imports, exports, and data management on the go.
This application is optimized to handle large amounts of data securely, ensuring reliability even when working with large files.
- User Management: Manage customer profiles with full CRUD (Create, Read, Update, Delete) functionality.
- Permission Management: Assign, manage, and revoke user permissions to control access levels.
- Database Security: Uses secure database connections and advanced techniques like Polly for retry policies and handling transient faults.
- WPF User Interface: Offers a modern, intuitive user interface built with Windows Presentation Foundation (WPF).
- Telegram Bot Integration:
- Receive Files: Users can send Excel files directly to the bot for processing.
- Data Export: Export data in different formats (CSV, XLSX, JSON, XML) with fine-tuned configurations.
- Advanced Data Management: Users can filter, configure, and export data based on their needs.
- C# (.NET 8): The primary programming language and framework for the application, utilizing the latest version of .NET 8.
- WPF (Windows Presentation Foundation): Built using WPF to deliver a modern and responsive desktop UI.
- Entity Framework Core 8: An Object-Relational Mapper (ORM) for data access, supporting both SQL Server and large datasets efficiently.
- SQL Server: The relational database management system for secure data storage and retrieval.
- Polly: A resilience and transient fault-handling library, providing retry policies for managing failures, especially when working with large data.
- Secure Database Connections: Uses secure practices such as SQL Server Authentication, Encryption, and Connection String Management to safeguard sensitive data.
- Telegram Bot API: Facilitates seamless interaction with users, receiving and sending files and notifications directly in Telegram.
Before you begin, ensure you have the following installed:
- .NET 8 SDK
- SQL Server (local or remote)
- Visual Studio 2022 or later (with the .NET desktop development workload)
- A Telegram bot token (you can create a bot using the BotFather on Telegram).
-
Clone the repository:
git clone https://github.com/YourUsername/CustomerMonitoringApp.git
-
Navigate to the project directory:
cd CustomerMonitoringApp
-
Open the solution file in Visual Studio:
Open
CustomerMonitoringApp.sln
in Visual Studio. -
Restore NuGet packages:
In Visual Studio, right-click on the solution in the Solution Explorer and select Restore NuGet Packages.
-
Set up the SQL Server database:
- Ensure that SQL Server is running.
- Create a new database for the application.
- Update the connection string in
appsettings.json
to point to your SQL Server database.
Example connection string:
"ConnectionStrings": { "DefaultConnection": "Server=.;Database=YourDatabaseName;Integrated Security=True;Trust Server Certificate=True" }
-
Configure Telegram Bot:
- Add your Telegram bot token to
appsettings.json
:
"TelegramBot": { "Token": "YOUR_TELEGRAM_BOT_TOKEN" }
- Add your Telegram bot token to
-
Apply migrations to create the database schema:
Open the Package Manager Console in Visual Studio and run the following command:
Update-Database
Polly is integrated to ensure that the application can handle transient errors, like database timeouts or network issues, when working with large data sets. By using retry policies, you can ensure that the application remains resilient in the face of occasional failures, reducing the risk of disruptions during long-running tasks like data imports.
In the DatabaseService.cs
(or relevant service), you can configure Polly like so:
public class DatabaseService
{
private readonly IAsyncPolicy _retryPolicy;
public DatabaseService()
{
// Define a retry policy that retries up to 3 times with exponential backoff
_retryPolicy = Policy
.Handle<SqlException>()
.WaitAndRetryAsync(3, attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)));
}
public async Task ExecuteWithRetryAsync(Func<Task> action)
{
await _retryPolicy.ExecuteAsync(action);
}
}
This ensures that if the database connection fails due to transient faults (like temporary unavailability or timeouts), the application will automatically retry the operation, reducing the chances of failure.
The application implements secure database access to protect user data:
- Encryption: All sensitive data is encrypted using industry-standard encryption algorithms both at rest and in transit.
- SQL Server Authentication: Uses Windows Authentication and SQL Server Authentication methods to ensure only authorized users can access the database.
- Environment-Specific Configuration: Ensures that the connection strings and sensitive data are stored in a secure manner using Azure Key Vault or local secrets management.
"ConnectionStrings": {
"DefaultConnection": "Server=tcp:yourserver.database.windows.net,1433;Initial Catalog=YourDB;Persist Security Info=False;User ID=youruser;Password=yourpassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
To ensure that large files (e.g., Excel, CSV, etc.) can be processed without running into memory issues, the application uses chunking, asynchronous processing, and batching techniques.
- Chunking: Data is processed in smaller chunks, allowing the application to handle large datasets without consuming excessive memory.
- Asynchronous File Processing: Long-running tasks, such as importing or exporting large files, are performed asynchronously to prevent UI freezes and improve responsiveness.
public async Task ImportLargeFileAsync(string filePath, CancellationToken cancellationToken)
{
using (var reader = new StreamReader(filePath))
{
while (!reader.EndOfStream)
{
if (cancellationToken.IsCancellationRequested) break;
var line = await reader.ReadLineAsync();
// Process the line here
}
}
}
- Managing Users: Use the provided UI to create new users, view existing users, and update or delete users as needed.
- Managing Permissions: Assign and modify user permissions through the dedicated section in the application.
- Telegram Bot Features:
- Send and receive Excel files through the bot.
- Export data with custom configurations using commands in Telegram.
- Utilize special export settings to format data as required.
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments Special thanks to the contributors and the community for their support and feedback. This project wouldn't have been possible without the input and collaboration from the open-source community. A big thank you to the developers of Polly for making fault tolerance easier and more manageable. Thanks to Microsoft for providing the .NET ecosystem and Telegram for their Bot API, which enables smooth integration into this project.