Utils Class :-
The Utils class is a helper utility that provides commonly used functions for various operations, including string manipulation,
data type conversion, configuration retrieval, encryption, and response mapping. It offers methods for quoting strings and dates,
checking for null or blank values, and converting strings to different data types such as integers, booleans, dates, decimals, floats,
and longs with default values. Additionally, it retrieves application settings from appsettings.json and the configuration manager, ensures
security through SHA-256 hashing and MD5,and formats data, such as currency values and date conversions. The class also standardizes response handling
by creating structured response objects with status, descriptions, and error messages.
RestExtension Class:-
The RestExtension class is a static utility that extends HttpClient, providing various asynchronous methods for making HTTP requests such as GET, POST, and PATCH.
It simplifies API calls by handling request creation, adding headers dynamically, and managing response deserialization. Each method includes a cancellation token
to prevent long-running requests from blocking execution. Error handling is built-in, returning a standardized ApiResponse object with status codes and messages.
The class supports different response formats, including JSON objects, lists, and binary data (e.g., PDFs).Potential improvements include using strongly typed models
for deserialization, better exception logging, and optimized header management with AuthenticationHeaderValue.
Logs Class:-
The Logs class is a utility for logging different types of events, such as security incidents (SIEMLogs), exceptions (ExceptionLogs), and API requests (APIRequestLogs).
Each method dynamically creates a log file based on the method name and date, ensuring the necessary directories exist before writing logs. It also sets access permissions for the
log files and records log entries with timestamps in a structured format. This class helps in monitoring, debugging, and auditing application activity by maintaining detailed logs.
DataServiceUtils Class :-
The DataServiceUtils class provides asynchronous utility methods for executing SQL queries using SqlConnection and SqlCommand.
It includes two variations of the GetScalarAsync method, which retrieve a single value from the database�one with SQL parameters
and one without. Similarly, the ExecuteNonQueryAsync method is available in two versions: one for executing non-query SQL statements
such as INSERT, UPDATE, and DELETE without parameters and another that supports SQL parameters. The class ensures proper usage of using
statements to manage SqlCommand resources efficiently. Additionally, exception handling uses throw; instead of throw ex; to preserve the
original stack trace. However, setting sqlCommand.CommandTimeout = 0; may cause indefinite waits, and it is advisable to define a reasonable
timeout to avoid performance issues.
MongoDataServiceUtils Class :-
The MongoDataServiceUtils class that provides asynchronous CRUD operations for MongoDB. It includes methods for inserting (InsertDocumentAsync), updating (UpdateDocumentAsync),
retrieving (GetDocumentsAsync), and deleting (DeleteDocumentAsync) documents based on filter criteria. Additionally, it offers a synchronous method (CountDocuments) to
count documents in a collection. This class simplifies MongoDB interactions by providing reusable and efficient database operations.