Files
DP44/DataPRO/DbAPI/Channels/IChannels.cs
2026-04-17 14:55:32 -04:00

217 lines
11 KiB
C#

using DbAPI.Connections;
using DTS.Common.Interface.Database;
using DTS.Common.Interface.Channels;
using System;
using DTS.Common.Enums.Channels;
using DTS.Common.Interface.Channels.ChannelCodes;
using System.Collections.Generic;
namespace DbAPI.Channels
{
/// <summary>
/// Channel related functions (GetChannels, )
/// </summary>
public interface IChannels
{
/// <summary>
/// insert a new channel code, channel code is modified with a new id if successful
/// </summary>
/// <param name="user">user submitting request</param>
/// <param name="connection">connection being submitted on</param>
/// <param name="channelCode">channel code to insert</param>
/// <param name="lookup">mapping of code type string to code type integer</param>
/// <param name="id">id of newly inserted database record</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelCodesInsert(IUserDbRecord user, IConnectionDetails connection,
IReadOnlyDictionary<ChannelEnumsAndConstants.ChannelCodeType, short> lookup, IChannelCode channelCode,
out int id);
/// <summary>
/// Update a channel record in the database
/// </summary>
/// <param name="user">user committing change</param>
/// <param name="connection">connection change is committed on</param>
/// <param name="channelCode">channel code being record being updated</param>
/// <param name="lookup">mapping of code type string to code type integer</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelCodesUpdate(IUserDbRecord user, IConnectionDetails connection,
IReadOnlyDictionary<ChannelEnumsAndConstants.ChannelCodeType, short> lookup, IChannelCode channelCode);
/// <summary>
/// deletes matching channel codes
/// </summary>
/// <param name="user">user making deletes</param>
/// <param name="connection">connection to delete on</param>
/// <param name="id">id of channel code</param>
/// <param name="code">code of matching channel codes (can be null)</param>
/// <param name="name">name of matching channel codes (can be null)</param>
/// <param name="codeType">code type of matching channel codes (can be null)</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelCodesDelete(IUserDbRecord user,
IConnectionDetails connection,
int? id,
string code,
string name,
int? codeType);
/// <summary>
/// retrieves all matching channel code types (int identifier and string identifier)
/// </summary>
/// <param name="user">user making request</param>
/// <param name="codeType">code type (use null for all)</param>
/// <param name="id">id (use null for all)</param>
/// <param name="connection">connection request is being made on</param>
/// <param name="records">all matching records</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelCodeTypesGet(IUserDbRecord user,
IConnectionDetails connection,
short? id,
string codeType,
out Tuple<short, string>[] records);
/// <summary>
/// retrieves all matching channel codes
/// </summary>
/// <param name="user">user making request</param>
/// <param name="connection">connection query is being made on</param>
/// <param name="Id">id of channel code (use null for all)</param>
/// <param name="code">code of channel code (use null for all)</param>
/// <param name="name">name of channel code (use null for all)</param>
/// <param name="codeType">code type of channel code (use null for all)</param>
/// <param name="channelTypeLookup">matches a channel code type to a short id for that type</param>
/// <param name="records">matching records</param>
/// <returns>0 (ERROR SUCCESS) on success, all other values are error codes</returns>
ulong ChannelCodesGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string code,
string name,
ChannelEnumsAndConstants.ChannelCodeType? codeType,
IReadOnlyDictionary<short, string> channelTypeLookup,
out IChannelCode[] records
);
/// <summary>
/// updates the default value for a channel setting
/// </summary>
/// <param name="user">user making update</param>
/// <param name="connection">connection update is being made on</param>
/// <param name="settingId">setting id to update</param>
/// <param name="defaultValue">new value for setting</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelSettingsUpdate(IUserDbRecord user,
IConnectionDetails connection,
int settingId,
string defaultValue);
/// <summary>
/// retrieves all channel settings from the db for a given channel
/// </summary>
/// <param name="user">user making request</param>
/// <param name="connection">connection request is being made on</param>
/// <param name="settingId">channel id to match (allows null)</param>
/// <param name="settingName">setting name to match (allows null/empty)</param>
/// <param name="records">matching records</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelSettingsGet(IUserDbRecord user,
IConnectionDetails connection,
int? settingId,
string settingName,
out IChannelSettingRecord[] records);
/// <summary>
/// removes group channel settings from the db for a given channel
/// </summary>
/// <param name="user">user requesting changes</param>
/// <param name="connection">connection changes are being made on</param>
/// <param name="channelId">channel settings belong to</param>
/// <param name="settingId">setting which to delete (use null to delete all settings)</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong GroupChannelSettingsDelete(IUserDbRecord user,
IConnectionDetails connection,
long channelId,
int? settingId);
/// <summary>
/// Inserts a new channel setting record into db
/// </summary>
/// <param name="user">user inserting record</param>
/// <param name="connection">connection record is being inserted on</param>
/// <param name="channelId">channel setting belongs to</param>
/// <param name="record">record being inserted</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong GroupChannelSettingsInsert(IUserDbRecord user,
IConnectionDetails connection,
int clientDbVersion,
long channelId,
IGroupChannelSettingRecord record);
/// <summary>
/// returns all channel settings for a given channel
/// </summary>
/// <param name="user">user making request</param>
/// <param name="connection">connection request is being made on</param>
/// <param name="clientDbVersion">calling client's database version</param>
/// <param name="channelIdList">list of channels for the request</param>
/// <param name="records">all matching channel settings</param>
/// <param name="errors">any errors encountered while retrieving group channel settings</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong GroupChannelSettingsGet(IUserDbRecord user,
IConnectionDetails connection,
int clientDbVersion,
List<long> channelIdList,
out IGroupChannelSettingRecord[] records,
out string[] errors);
/// <summary>
/// Inserts a new record in the Channels table
/// </summary>
/// <param name="user"></param>
/// <param name="connection"></param>
/// <param name="channel">The new values for the record in the Channels table</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelsInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IChannelDbRecord channel);
/// <summary>
/// Updates an existing record in the Channels table
/// </summary>
/// <param name="user"></param>
/// <param name="connection"></param>
/// <param name="channel">The new values for the record in the Channels table</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelsUpdate(IUserDbRecord user,
IConnectionDetails connection,
IChannelDbRecord channel);
/// <summary>
/// retrieves all channels matching search criteria
/// </summary>
/// <param name="user"></param>
/// <param name="connection"></param>
/// <param name="channelId"></param>
/// <param name="groupId"></param>
/// <param name="dasId"></param>
/// <param name="sensorId"></param>
/// <param name="testSetupId"></param>
/// <param name="testSetupName"></param>
/// <param name="channels">null, or calibrations found</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelsGet(IUserDbRecord user,
IConnectionDetails connection,
int clientDbVersion,
long? channelId,
int? groupId,
int? dasId,
int? sensorId,
int? testSetupId,
string testSetupName,
out IChannelDbRecord[] channels);
/// <summary>
/// Deletes an entry in the Channels table
/// </summary>
/// <param name="user"></param>
/// <param name="connection"></param>
/// <param name="id">Id in the Channels table</param>
/// <param name="errorString">Error string returned, possibly from sp_ChannelsDelete</param>
/// <returns>0 (ERROR_SUCCESS) on success, all other values are error codes</returns>
ulong ChannelsDelete(IUserDbRecord user,
IConnectionDetails connection,
long id,
out string errorString);
}
}