wip
This commit is contained in:
parent
f3ab94eff1
commit
31666b4ba0
34 changed files with 140 additions and 83 deletions
31
Core/Database/DatabaseScope.cs
Normal file
31
Core/Database/DatabaseScope.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System.Data;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
|
||||
namespace PlanTempus.Core.Database;
|
||||
|
||||
public class DatabaseScope : IDisposable
|
||||
{
|
||||
private readonly IOperationHolder<DependencyTelemetry> _operation;
|
||||
|
||||
public DatabaseScope(IDbConnection connection, IOperationHolder<DependencyTelemetry> operation)
|
||||
{
|
||||
Connection = connection;
|
||||
_operation = operation;
|
||||
_operation.Telemetry.Success = true;
|
||||
}
|
||||
|
||||
public IDbConnection Connection { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_operation.Dispose();
|
||||
Connection.Dispose();
|
||||
}
|
||||
|
||||
public void Error(Exception ex)
|
||||
{
|
||||
_operation.Telemetry.Success = false;
|
||||
_operation.Telemetry.Properties["Error"] = ex.Message;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue