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