Audit Trail Component , .net standard 2.1 + Full Source Code icon

Audit Trail Component , .net standard 2.1 + Full Source Code

Audit Trail Component , .net standard 2.1 + Full Source Code

Description

Audit Trail Component + Full Source Code

Version v1.0

Introduction

Audit trail component stores database actions (Add, Update, Delete), business actions (you can specify them), sends notifications and logs its own errors, also it’s dynamic as it gives user the ability to specify , , [Notification’s subject] and [Notification’s Message], also you can search for all the data has been stored by the component by predefined methods.

Framework: .net standard 2.1

Packages :

  • Microsoft.EntityFrameworkCore.SqlServer 3.1.3
  • Newtonsoft.Json  12.0.3

Hangfire Packages :

  • Hangfire.AspNetCore
  • Hangfire.SqlServer

Features :

  • Store database actions and business actions.
  • Send notifications.
  • Log send notification process, and retry if it’s failed.
  • Log errors.
  • Dynamic: User can specify actions and emails and specify if the component should send notification when a specific action happened.

Recommendation :

use background job to execute component methods, to ensure that the original request time will not be increased.

Database Tables

Audit.Action 

to store actions lookup data

Audit.ActionUserGroup

to make relation between , and emails, so if this action happened then the component will   send notification to the related emails with the specified message.

Audit.AuditTrail

to store the audit data

Audit.ErrorLog

to log the component errors

Audit.Notification

to store the notifications that the component will send to emails

Audit.NotificationLog

to log the send notification process, component will store every (send email) retry and store if it’s done successfully or not with error message

How to Register

  • In your project, you need to install Hangfire nugetpackages [Hangfire.AspNetCore, Hangfire.SqlServer] ,or any package to perform background processing.
  • Also you need to implement[ IEmailService ] interface to send notification emails .

Startup class

  • In method

        #region hangfire

            // Add Hangfire services.

            services.AddHangfire(configuration => configuration

                .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)

                .UseSimpleAssemblyNameTypeSerializer()

                .UseRecommendedSerializerSettings()

                .UseSqlServerStorage(Configuration.GetConnectionString(“DefaultConnection”), new SqlServerStorageOptions

                {

                    CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),

                    SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),

                    QueuePollInterval = TimeSpan.Zero,

                    UseRecommendedIsolationLevel = true,

                    UsePageLocksOnDequeue = true,

                    DisableGlobalLocks = true

                }));

            // Add the processing server as IHostedService

            services.AddHangfireServer();

            #endregion

            #region Audit

            services.AddScoped<IEmailService, EmailService>();

            //AddAuditTrail classes

            services.AddAuditTrail(Configuration.GetConnectionString(“DefaultConnection”),

                 new List<AuditActionDto> {

                    new AuditActionDto() { ActionCode =”CreateOrder”,SendNotification=true,NotificationFromEmail=”admin@gmail.com“

                                        ,NotificationEmails=”ahmed@yahoo.com,ali@hotmail.com”,NotificationSubject=”subject “

                                        ,NotificationMessage=”sample message”},

                    new AuditActionDto() { ActionCode = “DeleteOrder”,SendNotification=true,NotificationFromEmail=”admin@gmail.com”,

  NotificationEmails=”ahmed2@yahoo.com,ali2@hotmail.com”,NotificationSubject=”subject “  ,

   NotificationMessage=”sample message2” },

                    new AuditActionDto() { ActionCode = “UpdateOrder” ,SendNotification=true},

                   new AuditActionDto() { ActionCode = “NewUpdateOrder” ,SendNotification=false}});

            //register background job to Check Notifications to send emails

            var sp = services.BuildServiceProvider().CreateScope().ServiceProvider;

            var notificationService = sp.GetService<INotificationPublicService>();

                 JobStorage.Current = new SqlServerStorage(Configuration.GetConnectionString(“DefaultConnection”),

                 new SqlServerStorageOptions

            {

                CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),

                SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),

                QueuePollInterval = TimeSpan.Zero,

                UseRecommendedIsolationLevel = true,

                UsePageLocksOnDequeue = true,

                DisableGlobalLocks = true

            });

            RecurringJob.AddOrUpdate(() => notificationService.CheckNotificationsAndSend(), Cron.Daily);

            #endregion

How to create tables

  • Open and in the list .. select project
  • Write the below commands
    • add-migration InitiatAudit -context AuditDbContext
    • update-database -context AuditDbContext

How to use

  • Inject this interface to your class
  • To store business action

BackgroundJob.Enqueue(() => AuditTrailService.SaveCustomActionsAuditTrailAsync(“DeleteOrder”, “sample data by hangfire”, “username1”));

  • To store database action ,use the below code before Entity framework save changes method

BackgroundJob.Enqueue(() =>AuditTrailService.SaveDbActionsAuditTrailAsync(ApplicationDbContext.ChangeTracker.Entries()

            .Select(a =>

            new DatabaseChangesDto

            {

                Entity = a.Entity,

                OriginalValues = a.OriginalValues.ToObject(),

                CurrentValues = a.CurrentValues.ToObject()

            }).ToList()));

  • To search for audit data

//Inject this interface

AuditTrailFilterDto model = new AuditTrailFilterDto {Audit_ActionCode=”DeleteOrder” };

var result=await AuditTrailService.Search(model);

  • To search for Notifications

//Inject this interface

NotificationFilterDto model = new NotificationFilterDto { Audit_ActionCode=”DeleteOrder” };

var result=await NotificationPublicService.SearchNotifications(model);

  • to search for notification log

//Inject this interface

NotificationLogFilterDto model = new NotificationLogFilterDto { };

 var result = await NotificationService.SearchNotificationLogs(model);

  • to search for error logs

//Inject this interface

ErrorLogFilterDto model4 = new ErrorLogFilterDto();

var result = await ErrorLogPublicService.Search(model4);

External listing. code.market does not sell this product and does not process payment for it. Pricing, payment, delivery, licensing, refunds, and support are handled by the third-party merchant on its own website. We may earn an affiliate commission from a referral. Details.

Products of the Week.

Submit
codester.com

codester.com

SocialDesk+: Omnichannel Social Commerce & Business Management Platform This is stronger than simply “Social Commerce and Messaging” because it tells buyers this is a complete business platform, not just a messaging script. Turn Social Conversations Into Sales SocialDesk+ is a complete omnichannel social commerce and business management platform built for businesses that sell and communicate with customers through social media. Instead of switching between WhatsApp, Facebook, Instagram and TikTok, businesses can manage customer conversations, comments, products, leads, follow-ups, automation, teams and business reports from one professional workspace. And because the full source code is included, developers, agencies and entrepreneurs can customize, rebrand and launch SocialDesk+ as their own business solution or SaaS platform. 🚀 Build Your Own Social Commerce Business SocialDesk+ gives you the foundation to launch: - Your own SaaS platform - A white-label social CRM - A social-commerce management system - A customer communication platform - A business messaging solution - A custom solution for clients - A multi-business subscription platform 💬 Connect Your Customers Supported social channels include: WhatsApp • Facebook • Instagram • TikTok Bring supported conversations into one centralized workspace and help businesses respond faster without constantly switching between platforms. 🛍️ More Than a Messaging Platform SocialDesk+ combines communication with the tools businesses need to manage customer opportunities: Inbox Manage customer conversations from connected channels. Comments Monitor and respond to social-media comments. Customers & Leads Organize customer information and potential buyers. Products & Catalog Manage products and give your team quick access to product information. Follow-Ups Make sure potential customers don't get forgotten. Automation Automate repetitive customer questions and responses. AI Assistant Provide AI-assisted communication when configured. Team Management Give managers and staff access to the business workspace. Reports & Analytics Track activity using business reports and analytics. The current product listing already includes these capabilities. 🔥 Why Buyers Will Want It Launch Faster Start with an already-built business platform instead of developing the entire system from zero. Customize Everything The full source code is included, allowing developers to change branding, features, workflows and integrations. Build a SaaS Create multiple business workspaces and offer SocialDesk+ as a subscription-based service. Sell to Businesses Offer it to retailers, restaurants, service businesses, online sellers, agencies and other businesses that communicate with customers through social media. Mobile + Web + Backend This isn't just a mobile UI template. It includes: - Flutter mobile application - Python / FastAPI backend - Web interface - Administration tools - Database infrastructure - API-based architecture - SQLite / PostgreSQL support - Android and iOS project structure 💼 One Platform. Multiple Business Opportunities. For SaaS Entrepreneurs Launch your own subscription platform and allow multiple businesses to operate inside separate workspaces. For Software Agencies Customize and rebrand the platform for clients instead of building an omnichannel business system from scratch. For Developers Use the complete source code as a foundation for your own social-commerce or customer-management product. For Businesses Deploy a dedicated version for your own customer-service and social-commerce operations. 🧩 What's Included Mobile - Flutter / Dart - Android - iOS project Backend - Python - FastAPI - SQLAlchemy - Alembic Database - SQLite - PostgreSQL Web - HTML5 - CSS3 - JavaScript Deployment - Docker - Docker Compose - Production configuration Business Platform - Multi-workspace architecture - Authentication - Teams - Customers - Products - Messaging - Comments - Automation - Reports - Subscriptions - Administration The current listing also documents third-party integrations such as Meta, TikTok, Stripe, Firebase, SMTP and optional OpenAI configuration. ⚡ What Makes SocialDesk+ Different? You're not buying a simple: ❌ Chat UI ❌ WhatsApp clone ❌ Flutter template ❌ Admin dashboard ❌ Basic CRM You're getting a complete business platform foundation that can be customized, branded and commercialized. Connect. Automate. Manage. Grow. SocialDesk+ Omnichannel Social Commerce & Business Management Platform One important change I'd make to the current listing The current page starts with: “A simple guide to managing your social conversations, customers, products and business activity.”

Other · 3,112 views · 30 clicks

$2

Audit Trail Component , .net standard 2.1 + Full Source Code | Code Market