public void InsertEndpointStatistics(Guid endpointId, EndpointHealth stats) { using (var conn = _db.OpenConnection()) using (var tx = conn.BeginTransaction()) { conn.Execute( "insert into EndpointStats (EndpointId, CheckTimeUtc, ResponseTime, Status) values (@endpointId, @checkTimeUtc, @responseTime, @status)", new { endpointId, stats.CheckTimeUtc, responseTime = stats.ResponseTime.Ticks, stats.Status }, tx); tx.Commit(); } }
public void SaveEndpoint(Endpoint endpoint) { using (var conn = _db.OpenConnection()) using (var tx = conn.BeginTransaction()) { if (conn.Execute("update EndpointConfig set MonitorType=@MonitorType, Address=@Address, GroupName=@Group, Name=@Name where Id=@Id", new { endpoint.MonitorType, endpoint.Address, endpoint.Group, endpoint.Name, endpoint.Id }, tx) == 0) { conn.Execute("insert into EndpointConfig (MonitorType, Address, GroupName, Name, Id) values(@MonitorType,@Address,@Group,@Name,@Id)", new { endpoint.MonitorType, endpoint.Address, endpoint.Group, endpoint.Name, endpoint.Id }, tx); } tx.Commit(); } }