61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
using Oracle.DataAccess.Client;
|
|
|
|
namespace Endpoint
|
|
{
|
|
public class OracleEndpoint : IServiceEndpoint
|
|
{
|
|
private readonly OracleEndpointConfiguration _serviceEndpointConfiguration;
|
|
|
|
public IServiceEndpointConfiguration ServiceEndpointConfiguration
|
|
{
|
|
get { return _serviceEndpointConfiguration; }
|
|
}
|
|
|
|
public string ServiceName
|
|
{
|
|
get { return _serviceEndpointConfiguration.Name; }
|
|
}
|
|
|
|
public string StatusDescription { get; private set; }
|
|
|
|
public Status GetStatus()
|
|
{
|
|
using (OracleConnection oracleConnection = new OracleConnection(_serviceEndpointConfiguration.ConnectionString))
|
|
using (OracleCommand oracleCommand = new OracleCommand(_serviceEndpointConfiguration.ScalarQueryString, oracleConnection))
|
|
{
|
|
try
|
|
{
|
|
oracleConnection.Open();
|
|
object result = oracleCommand.ExecuteScalar();
|
|
string resultString = result.ToString();
|
|
if (resultString != _serviceEndpointConfiguration.ExpectedQueryResult)
|
|
{
|
|
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", resultString,
|
|
_serviceEndpointConfiguration.ExpectedQueryResult);
|
|
return Status.Error;
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
StatusDescription = ex.Message;
|
|
return Status.Error;
|
|
}
|
|
}
|
|
StatusDescription = "OK";
|
|
return Status.Up;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="OracleEndpoint"/> class.
|
|
/// </summary>
|
|
/// <param name="config">The config.</param>
|
|
public OracleEndpoint(OracleEndpointConfiguration config)
|
|
{
|
|
_serviceEndpointConfiguration = config;
|
|
StatusDescription = "";
|
|
}
|
|
}
|
|
}
|