Cleaning up with Rider
This commit is contained in:
parent
69758735de
commit
91da89a4e8
22 changed files with 574 additions and 386 deletions
35
Core/Sql/DatabaseScope.cs
Normal file
35
Core/Sql/DatabaseScope.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System.Data;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
|
||||
namespace PlanTempus.Core.Sql;
|
||||
|
||||
public class DatabaseScope : IDisposable
|
||||
{
|
||||
private readonly IOperationHolder<DependencyTelemetry> _operation;
|
||||
|
||||
public DatabaseScope(IDbConnection connection, IOperationHolder<DependencyTelemetry> operation)
|
||||
{
|
||||
Connection = connection;
|
||||
_operation = operation;
|
||||
}
|
||||
|
||||
public IDbConnection Connection { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_operation.Dispose();
|
||||
Connection.Dispose();
|
||||
}
|
||||
|
||||
public void Success()
|
||||
{
|
||||
_operation.Telemetry.Success = true;
|
||||
}
|
||||
|
||||
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