Skip to content

Instantly share code, notes, and snippets.

DECLARE @FILE_PATH VARBINARY(MAX), @TIMESTAMP VARCHAR(MAX), @ObjectToken INT
DECLARE FILEPATH CURSOR FAST_FORWARD FOR SELECT [DATA_DOCUMENT] FROM [DOC].[DOCUMENT] WHERE ID IN(370550, 743574, 370551,370549)
OPEN FILEPATH
FETCH NEXT FROM FILEPATH INTO @FILE_PATH
WHILE @@FETCH_STATUS = 0
BEGIN
SET @TIMESTAMP = 'C:\temp\' + REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 121), '-', ''), ':', ''), '.', ''), ' ', '') + '.lnk'
PRINT @TIMESTAMP
EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
EXEC sp_OASetProperty @ObjectToken, 'Type', 1
public class RequestResponseLoggingMiddleware: IMiddleware
{
private readonly IApiLoggingService _apiLoggingService;
public RequestResponseLoggingMiddleware(IApiLoggingService apiLoggingService)
{
_apiLoggingService=apiLoggingService;
}
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
public class RequestResponseLoggingMiddleware: IMiddleware
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
// Call the next delegate/middleware in the pipeline.
await next(context);
}
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<RequestResponseLoggingMiddleware>();
public class RequestResponseLoggingMiddleware
{
private readonly RequestDelegate _next;
public RequestResponseLoggingMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext httpContext, IApiLoggingService apiLoggingService)
services.TryAddTransient<IApiLoggingService, ApiLoggingService>();
services.AddScoped<IInterceptor, AuditInterceptor>();
public class ApiLoggingService : IApiLoggingService
{
private readonly IUnitOfWorkFactory _unitOfWorkFactory;
private readonly IInterceptor _interceptor;
public ApiLoggingService( IUnitOfWorkFactory unitOfWorkFactory, IInterceptor interceptor)
{
_interceptor = interceptor;
_unitOfWorkFactory = unitOfWorkFactory;
}
public class RequestResponseLoggingMiddleware
{
private readonly RequestDelegate _next;
private IApiLoggingService _apiLoggingService;
public RequestResponseLoggingMiddleware(RequestDelegate next, IApiLoggingService apiLoggingService)
{
_next = next;
_apiLoggingService = apiLoggingService;
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IMyDependency, MyDependency>();
builder.Services.AddScoped<IMyDependency2, MyDependency2>();
var app = builder.Build();
Log.Logger = new LoggerConfiguration()
.WriteTo.Seq("http://localhost:5341", eventBodyLimitBytes:500000)
.CreateLogger();