init
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
using DbAPI.Connections;
|
||||
using DTS.Common.Interface.Database;
|
||||
using DTS.Common.Interface.Groups;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using DTS.Common.Interface.TestSetups.TestSetupsList;
|
||||
using System;
|
||||
|
||||
namespace DbAPI.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// defines functions to create, retrieve, update, delete test setups
|
||||
/// </summary>
|
||||
public interface ITestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// deletes matching test setup hardware record
|
||||
/// at least one parameter (id/dasid/testsetupid) must be specified
|
||||
/// </summary>
|
||||
/// <param name="user">user making request</param>
|
||||
/// <param name="connection">connection request is being made on</param>
|
||||
/// <param name="Id">id of test setup hardware record (null for all)</param>
|
||||
/// <param name="dasId">id of das (null for all)</param>
|
||||
/// <param name="testSetupId">id of test setup (null for all)</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupHardwareDelete(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int? Id,
|
||||
int? dasId,
|
||||
int? testSetupId
|
||||
);
|
||||
/// <summary>
|
||||
/// updates a test setup hardware record
|
||||
/// </summary>
|
||||
/// <param name="user">user committing update</param>
|
||||
/// <param name="connection">connection update is being made on</param>
|
||||
/// <param name="record">updated record</param>
|
||||
/// <returns>0 on success, all other values are error codes</returns>
|
||||
ulong TestSetupHardwareUpdate(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ITestSetupHardwareRecord record);
|
||||
/// <summary>
|
||||
/// inserts a new record
|
||||
/// </summary>
|
||||
/// <param name="user">user inserting record</param>
|
||||
/// <param name="connection">connection being inserted on</param>
|
||||
/// <param name="record">record being inserted</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupHardwareInsert(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ITestSetupHardwareRecord record);
|
||||
/// <summary>
|
||||
/// retrieves all hardware meta data associated with test
|
||||
/// [sample rate, aaf, etc]
|
||||
/// </summary>
|
||||
/// <param name="user">user retrieving hardware</param>
|
||||
/// <param name="connection">connecting hardware is retrieved on</param>
|
||||
/// <param name="testSetupId">id of test setup (use null for all)</param>
|
||||
/// <param name="records">all matching records</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupHardwareGet(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int clientDbVersion,
|
||||
int? testSetupId,
|
||||
out ITestSetupHardwareRecord[] records);
|
||||
/// <summary>
|
||||
/// inserts a new group/test setup association into db
|
||||
/// </summary>
|
||||
/// <param name="user">user making request</param>
|
||||
/// <param name="connection">connection request is being made on</param>
|
||||
/// <param name="record">record to insert</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupGroupsInsert(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ITestSetupGroupRecord record);
|
||||
/// <summary>
|
||||
/// updates a group/test setup association in db
|
||||
/// </summary>
|
||||
/// <param name="user">user making request</param>
|
||||
/// <param name="connection">connection is being made on</param>
|
||||
/// <param name="record">updated record</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupGroupsUpdate(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ITestSetupGroupRecord record);
|
||||
|
||||
/// <summary>
|
||||
/// retrieves all group records matching search criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user making request</param>
|
||||
/// <param name="connection">connection request is being made on</param>
|
||||
/// <param name="groupId">database id of group (use null for all)</param>
|
||||
/// <param name="testSetupId">database id of test setup (use null for all)</param>
|
||||
/// <param name="testSetupName">test setup name for test setup (use null for all)</param>
|
||||
/// <param name="groups">matching groups</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupGroupsGet(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int? groupId,
|
||||
int? testSetupId,
|
||||
string testSetupName,
|
||||
out ITestSetupGroupRecord[] groups
|
||||
);
|
||||
/// <summary>
|
||||
/// Commits a change to the IsDirty or IsComplete flags in the db for a test
|
||||
/// </summary>
|
||||
/// <param name="user">user committing change</param>
|
||||
/// <param name="connection">connection change is being committed on</param>
|
||||
/// <param name="name">name of test setup to modify</param>
|
||||
/// <param name="dirty">whether to set dirty flag or not. Dirty flag indicates
|
||||
/// whether the test setup has been checked for completeness and readiness to run</param>
|
||||
/// <param name="complete">whether the test setup is ready to run or not</param>
|
||||
/// <param name="error">error message(s) associated with test setup, if any</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupsMarkIsDirtyIsComplete(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
string name,
|
||||
bool dirty,
|
||||
bool complete,
|
||||
string error);
|
||||
/// <summary>
|
||||
/// deletes all test setups matching criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user deleting test setups</param>
|
||||
/// <param name="connection">connection tests are being deleted on</param>
|
||||
/// <param name="date">date of oldest allowed test setup</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success. All other values are error codes.</returns>
|
||||
ulong TestSetupsDeleteByDate(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
DateTime date);
|
||||
/// <summary>
|
||||
/// deletes all test setups and groups
|
||||
/// </summary>
|
||||
/// <param name="user">user requesting deletes</param>
|
||||
/// <param name="connection">connection to delete on</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success. All other values are error codes</returns>
|
||||
ulong TestSetupsAndGroupsDeleteAll(IUserDbRecord user,
|
||||
IConnectionDetails connection);
|
||||
/// <summary>
|
||||
/// Deletes all test setups that match the search criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user deleting test setups</param>
|
||||
/// <param name="connection">connection to delete test setups on</param>
|
||||
/// <param name="ids">ids of test setups to delete</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupsDeleteById(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// deletes all test setups that match the search criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user deleting test setups</param>
|
||||
/// <param name="connection">connection to delete test setups on</param>
|
||||
/// <param name="names">names of test setups to delete</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
ulong TestSetupsDeleteByName(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
string[] names);
|
||||
/// <summary>
|
||||
/// commits a test setup into the database
|
||||
/// </summary>
|
||||
/// <param name="user">user committing record</param>
|
||||
/// <param name="connection">connection record is being committed on</param>
|
||||
/// <param name="clientDbVersion">the database version of the client code</param>
|
||||
/// <param name="record">record being committed</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are errors</returns>
|
||||
ulong TestSetupsUpdateInsert(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int clientDbVersion,
|
||||
ref ITestSetupRecord record);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all test setups which match given search criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user making query</param>
|
||||
/// <param name="connection">connection over which query is to be made</param>
|
||||
/// <param name="clientDbVersion">the database version of the client code</param>
|
||||
/// <param name="testSetupId">database id of test setup (can be null)</param>
|
||||
/// <param name="testSetupName">name of test setup (can be null or empty)</param>
|
||||
/// <param name="defaultROIStart">start time for any ROIs that have to be generated
|
||||
/// some old test setups may not have ROIs specified for every event</param>
|
||||
/// <param name="defaultROIEnd">end time for any ROIs that have to be generated
|
||||
/// some old test setups may not have ROIs specified for every event</param>
|
||||
/// <param name="defaultIgnoreShortedStart">whether or not to ignore a shorted start
|
||||
/// since we may be using a Version 91 database that doesn't store this</param>
|
||||
/// <param name="defaultIgnoreShortedTrigger">whether or not to ignore a shorted trigger
|
||||
/// since we may be using a Version 91 database that doesn't store this</param>
|
||||
/// <param name="records">matching records</param>
|
||||
/// <param name="errors">any errors encountered while retrieving test setups</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are errors</returns>
|
||||
ulong TestSetupsGet(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int clientDbVersion,
|
||||
int? testSetupId,
|
||||
string testSetupName,
|
||||
double defaultROIStart,
|
||||
double defaultROIEnd,
|
||||
bool defaultIgnoreShortedStart,
|
||||
bool defaultIgnoreShortedTrigger,
|
||||
out ITestSetupRecord[] records,
|
||||
out string[] errors);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
using DbAPI.Connections;
|
||||
using DbAPI.Errors;
|
||||
using DbAPI.Logging;
|
||||
using DTS.Common.Classes;
|
||||
using DTS.Common.Classes.TestSetups;
|
||||
using DTS.Common.Interface.Database;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DbAPI.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles calculated channel functions
|
||||
/// <inheritdoc cref="ICalculatedChannels"/>
|
||||
/// </summary>
|
||||
internal class CalculatedChannels : ICalculatedChannels
|
||||
{
|
||||
/// <summary>
|
||||
/// removes calculated channel from database
|
||||
/// </summary>
|
||||
/// <param name="user">user committing delete</param>
|
||||
/// <param name="connection">connection over which to delete</param>
|
||||
/// <param name="calculatedChannelId">database id of calculated channel to delete</param>
|
||||
/// <returns></returns>
|
||||
public ulong CalculatedChannelsDelete(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int calculatedChannelId)
|
||||
{
|
||||
if (!DbAPI.Connections.IsUserLoggedIn(user, connection))
|
||||
{
|
||||
return ErrorCodes.ERROR_ACCESS_DENIED;
|
||||
}
|
||||
var ret = ConnectionManager.GetSqlCommand(connection, out var cmd, "sp_CalculatedChannelsDelete");
|
||||
if (ret != ErrorCodes.ERROR_SUCCESS) { return ret; }
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.Add(new SqlParameter("@CalculatedChannelsId", SqlDbType.Int) { Value = calculatedChannelId });
|
||||
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int)
|
||||
{ Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumber);
|
||||
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{ Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorMessage);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (!DBNull.Value.Equals(errorNumber.Value) && 0 != Convert.ToInt32(errorNumber.Value))
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsDelete failed: {errorNumber.Value} : {errorMessage.Value}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
return ErrorCodes.ERROR_SUCCESS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsDelete failed: {ex.Message}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// inserts a new calculated channel into the database
|
||||
/// original record is modified with database id after insert is complete
|
||||
/// </summary>
|
||||
/// <param name="user">user adding record</param>
|
||||
/// <param name="connection">connection record is being added on</param>
|
||||
/// <param name="record">record being added</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
public ulong CalculatedChannelsInsert(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ref ICalculatedChannelRecord record)
|
||||
{
|
||||
if (!DbAPI.Connections.IsUserLoggedIn(user, connection))
|
||||
{
|
||||
return ErrorCodes.ERROR_ACCESS_DENIED;
|
||||
}
|
||||
if (null == record)
|
||||
{
|
||||
return ErrorCodes.ERROR_MISSING_PARAMETER;
|
||||
}
|
||||
var ret = ConnectionManager.GetSqlCommand(connection, out var cmd, "sp_CalculatedChannelsInsert");
|
||||
if (ret != ErrorCodes.ERROR_SUCCESS) { return ret; }
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.Add(new SqlParameter("@Operation", SqlDbType.Int) { Value = (int)record.Operation });
|
||||
cmd.Parameters.Add(new SqlParameter("@CalculatedChannelValueCode", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.CalculatedValueCode });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@InputChannelIds", SqlDbType.VarBinary)
|
||||
{
|
||||
Value = Utility.GetBytesFromStringArray(record.InputChannelIds,
|
||||
CultureInfo.InvariantCulture.TextInfo.ListSeparator)
|
||||
});
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@CFCForInputChannels", SqlDbType.NVarChar, 255) { Value = record.CFCForInputChannels });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@CFCForOutput", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.ChannelFilterClassForOutput });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("TestSetupName", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.TestSetupName });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@CCName", SqlDbType.NVarChar, 255) { Value = record.Name });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ViewInRealtime", SqlDbType.Bit) { Value = record.ViewInRealtime });
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ClipLength", SqlDbType.Int) { Value = record.ClipLength });
|
||||
|
||||
var newId = new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newId);
|
||||
|
||||
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int)
|
||||
{ Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumber);
|
||||
|
||||
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{ Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorMessage);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (null != errorNumber.Value && 0 != Convert.ToInt32(errorNumber.Value))
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsInsert failed: {errorNumber.Value} : {errorMessage.Value}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
record.Id = Convert.ToInt32(newId.Value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsInsert failed: {ex.Message}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
return ErrorCodes.ERROR_SUCCESS;
|
||||
}
|
||||
/// <summary>
|
||||
/// updates calculated channel in the database
|
||||
/// </summary>
|
||||
/// <param name="user">user updating record</param>
|
||||
/// <param name="connection">connection record is being updated on</param>
|
||||
/// <param name="record">record to be updated</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
public ulong CalculatedChannelsUpdate(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
ICalculatedChannelRecord record)
|
||||
{
|
||||
if (!DbAPI.Connections.IsUserLoggedIn(user, connection))
|
||||
{
|
||||
return ErrorCodes.ERROR_ACCESS_DENIED;
|
||||
}
|
||||
if (null == record)
|
||||
{
|
||||
return ErrorCodes.ERROR_MISSING_PARAMETER;
|
||||
}
|
||||
var ret = ConnectionManager.GetSqlCommand(connection, out var cmd, "sp_CalculatedChannelsUpdate");
|
||||
if (ret != ErrorCodes.ERROR_SUCCESS) { return ret; }
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int) { Value = record.Id });
|
||||
cmd.Parameters.Add(new SqlParameter("@Operation", SqlDbType.Int) { Value = (int)record.Operation });
|
||||
cmd.Parameters.Add(new SqlParameter("@CalculatedChannelValueCode", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.CalculatedValueCode });
|
||||
cmd.Parameters.Add(new SqlParameter("@InputChannelIds", SqlDbType.VarBinary)
|
||||
{ Value = Utility.GetBytesFromStringArray(record.InputChannelIds, CultureInfo.InvariantCulture.TextInfo.ListSeparator) });
|
||||
cmd.Parameters.Add(new SqlParameter("@CFCForInputChannels", SqlDbType.NVarChar) { Value = record.CFCForInputChannels });
|
||||
cmd.Parameters.Add(new SqlParameter("@CFCForOutput", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.ChannelFilterClassForOutput });
|
||||
cmd.Parameters.Add(new SqlParameter("@TestSetupName", SqlDbType.NVarChar, 255)
|
||||
{ Value = record.TestSetupName });
|
||||
cmd.Parameters.Add(new SqlParameter("@CCName", SqlDbType.NVarChar, 255) { Value = record.Name });
|
||||
cmd.Parameters.Add(new SqlParameter("@ViewInRealtime", SqlDbType.Bit) { Value = record.ViewInRealtime });
|
||||
cmd.Parameters.Add(new SqlParameter("@ClipLength", SqlDbType.Int) { Value = record.ClipLength });
|
||||
var errorNumber = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumber);
|
||||
var errorMessage = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{ Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorMessage);
|
||||
cmd.ExecuteNonQuery();
|
||||
if (null != errorNumber.Value && 0 != Convert.ToInt32(errorNumber.Value))
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsUpdate failed: {errorNumber.Value} : {errorMessage.Value}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.CalculatedChannels, $"sp_CalculatedChannelsUpdate failed: {ex.Message}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
return ErrorCodes.ERROR_SUCCESS;
|
||||
}
|
||||
/// <summary>
|
||||
/// retrieves all CalculatedChannel records matching search criteria
|
||||
/// </summary>
|
||||
/// <param name="user">user making query</param>
|
||||
/// <param name="connection">connection query is being made on</param>
|
||||
/// <param name="calculatedChannelId">database id of calculated channel (can be null)</param>
|
||||
/// <param name="testSetupName">test setup calculated channel(s) belong to (can be empty)</param>
|
||||
/// <param name="records">all matching records found</param>
|
||||
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
|
||||
public ulong CalculatedChannelsGet(IUserDbRecord user,
|
||||
IConnectionDetails connection,
|
||||
int? calculatedChannelId,
|
||||
string testSetupName,
|
||||
out ICalculatedChannelRecord[] records)
|
||||
{
|
||||
records = new ICalculatedChannelRecord[0];
|
||||
if (!DbAPI.Connections.IsUserLoggedIn(user, connection))
|
||||
{
|
||||
return ErrorCodes.ERROR_ACCESS_DENIED;
|
||||
}
|
||||
var ret = ConnectionManager.GetSqlCommand(connection, out var cmd, "sp_CalculatedChannelsGet");
|
||||
if (ret != ErrorCodes.ERROR_SUCCESS) { return ret; }
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
if (null == calculatedChannelId)
|
||||
{
|
||||
cmd.Parameters.Add(new SqlParameter("@CalculatedChannelsId", SqlDbType.Int) { Value = null });
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.Add(new SqlParameter("@CalculatedChannelsId", SqlDbType.Int) { Value = (int)calculatedChannelId });
|
||||
}
|
||||
cmd.Parameters.Add(new SqlParameter("@TestSetupName", SqlDbType.NVarChar, 50) { Value = testSetupName });
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
var list = new List<ICalculatedChannelRecord>();
|
||||
while (reader.Read())
|
||||
{
|
||||
list.Add(new CalculatedChannelRecord(reader));
|
||||
}
|
||||
records = list.ToArray();
|
||||
|
||||
return ErrorCodes.ERROR_SUCCESS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Log(TraceEventType.Error, LogManager.LogEvents.Graphs, $"sp_CalculatedChannelsGet failed: {ex.Message}");
|
||||
return ErrorCodes.ERROR_UNKNOWN;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user