Skip to content

The Customer Monitoring Application is a desktop application built on the .NET 6 framework using Windows Presentation Foundation (WPF) and Entity Framework Core. This application is designed to facilitate the management of user data and permissions within an organization, providing a user-friendly interface for administrators.

Notifications You must be signed in to change notification settings

Opselon/TelegramMonitoringApp

Repository files navigation

Customer Monitoring Application

Description

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.

Key Features

  • 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.

Best Practices and Technologies Used

  • 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.

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Installation

  1. Clone the repository:

    git clone https://github.com/YourUsername/CustomerMonitoringApp.git
  2. Navigate to the project directory:

    cd CustomerMonitoringApp
  3. Open the solution file in Visual Studio:

    Open CustomerMonitoringApp.sln in Visual Studio.

  4. Restore NuGet packages:

    In Visual Studio, right-click on the solution in the Solution Explorer and select Restore NuGet Packages.

  5. 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"
    }
  6. Configure Telegram Bot:

    • Add your Telegram bot token to appsettings.json:
    "TelegramBot": {
        "Token": "YOUR_TELEGRAM_BOT_TOKEN"
    }
  7. Apply migrations to create the database schema:

    Open the Package Manager Console in Visual Studio and run the following command:

    Update-Database

Secure and Efficient Data Handling with Polly

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.

Polly Configuration Example

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.


Database Security Enhancements

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.

Example of Secure Database Connection

"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;"
}

Handling Large Data Efficiently

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.

Example of Asynchronous File Processing

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
        }
    }
}

Usage

  • 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.

License

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.

About

The Customer Monitoring Application is a desktop application built on the .NET 6 framework using Windows Presentation Foundation (WPF) and Entity Framework Core. This application is designed to facilitate the management of user data and permissions within an organization, providing a user-friendly interface for administrators.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published