Skip to content

Commit

Permalink
OutputStreamDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
collins-self committed Dec 18, 2024
1 parent fd42477 commit 6deaf6b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ public static ObservableCollection<OutputStreamDevice> Load(AdoDataConnection da
{
string commaSeparatedKeys = keys.Select(key => key.ToString()).Aggregate((str1, str2) => $"{str1},{str2}");

string query = $"SELECT NodeID, AdapterID, ID, IDCode, Acronym, BpaAcronym, Name, PhasorDataFormat, FrequencyDataFormat, AnalogDataFormat, CoordinateFormat, LoadOrder, Enabled, Virtual FROM OutputStreamDeviceDetail WHERE ID IN ({commaSeparatedKeys})";
string query = "SELECT NodeID, AdapterID, ID, IDCode, Acronym, BpaAcronym, Name, PhasorDataFormat, FrequencyDataFormat, AnalogDataFormat, CoordinateFormat, LoadOrder, Enabled, Virtual FROM OutputStreamDeviceDetail WHERE ID IN ({0})";

if (database.IsMySQL)
query = $"SELECT NodeID, AdapterID, ID, IDCode, Acronym, BpaAcronym, Name, PhasorDataFormat, FrequencyDataFormat, AnalogDataFormat, CoordinateFormat, LoadOrder, Enabled, `Virtual` FROM OutputStreamDeviceDetail WHERE ID IN ({commaSeparatedKeys})";
query = "SELECT NodeID, AdapterID, ID, IDCode, Acronym, BpaAcronym, Name, PhasorDataFormat, FrequencyDataFormat, AnalogDataFormat, CoordinateFormat, LoadOrder, Enabled, `Virtual` FROM OutputStreamDeviceDetail WHERE ID IN ({0})";

DataTable outputStreamDeviceTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout);
DataTable outputStreamDeviceTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout, commaSeparatedKeys);
outputStreamDeviceList = new OutputStreamDevice[outputStreamDeviceTable.Rows.Count];

foreach (DataRow row in outputStreamDeviceTable.Rows)
Expand Down Expand Up @@ -698,7 +698,7 @@ public static OutputStreamDevice GetOutputStreamDevice(AdoDataConnection databas
try
{
createdConnection = CreateConnection(ref database);
DataTable deviceTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT * FROM OutputStreamDeviceDetail {whereClause}");
DataTable deviceTable = database.Connection.RetrieveData(database.AdapterType, "SELECT * FROM OutputStreamDeviceDetail {0}", whereClause);

if (deviceTable.Rows.Count == 0)
return null;
Expand Down Expand Up @@ -748,7 +748,7 @@ public static ObservableCollection<OutputStreamDevice> GetOutputStreamDevices(Ad
createdConnection = CreateConnection(ref database);

ObservableCollection<OutputStreamDevice> outputStreamDeviceList = new();
DataTable outputStreamDeviceTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT * FROM OutputStreamDeviceDetail {whereClause}");
DataTable outputStreamDeviceTable = database.Connection.RetrieveData(database.AdapterType, "SELECT * FROM OutputStreamDeviceDetail {0}", whereClause);

foreach (DataRow row in outputStreamDeviceTable.Rows)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static IList<int> LoadKeys(AdoDataConnection database, int outputStreamDe
if (!string.IsNullOrEmpty(sortMember))
sortClause = $"ORDER BY {sortMember} {sortDirection}";

DataTable outputStreamDeviceAnalogTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT ID FROM OutputStreamDeviceAnalog WHERE OutputStreamDeviceID = {outputStreamDeviceID} {sortClause}");
DataTable outputStreamDeviceAnalogTable = database.Connection.RetrieveData(database.AdapterType, "SELECT ID FROM OutputStreamDeviceAnalog WHERE OutputStreamDeviceID = {0} {1}", outputStreamDeviceID, sortClause);

foreach (DataRow row in outputStreamDeviceAnalogTable.Rows)
outputStreamDeviceAnalogList.Add((row.ConvertField<int>("ID")));
Expand Down Expand Up @@ -253,8 +253,7 @@ public static ObservableCollection<OutputStreamDeviceAnalog> Load(AdoDataConnect
if (keys is not null && keys.Count > 0)
{
string commaSeparatedKeys = keys.Select(key => $"{key}").Aggregate((str1, str2) => $"{str1},{str2}");
string query = database.ParameterizedQueryString($"SELECT NodeID, OutputStreamDeviceID, ID, Label, Type, ScalingValue, LoadOrder FROM OutputStreamDeviceAnalog WHERE ID IN ({commaSeparatedKeys})");
DataTable outputStreamDeviceAnalogTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout);
DataTable outputStreamDeviceAnalogTable = database.Connection.RetrieveData(database.AdapterType, "SELECT NodeID, OutputStreamDeviceID, ID, Label, Type, ScalingValue, LoadOrder FROM OutputStreamDeviceAnalog WHERE ID IN ({0})", DefaultTimeout, commaSeparatedKeys);
outputStreamDeviceAnalogList = new OutputStreamDeviceAnalog[outputStreamDeviceAnalogTable.Rows.Count];

foreach (DataRow row in outputStreamDeviceAnalogTable.Rows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static IList<int> LoadKeys(AdoDataConnection database, int outputStreamDe
if (!string.IsNullOrEmpty(sortMember))
sortClause = $"ORDER BY {sortMember} {sortDirection}";

DataTable outputStreamDeviceDigitalTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT ID From OutputStreamDeviceDigital WHERE OutputStreamDeviceID = {outputStreamDeviceID} {sortClause}");
DataTable outputStreamDeviceDigitalTable = database.Connection.RetrieveData(database.AdapterType, "SELECT ID From OutputStreamDeviceDigital WHERE OutputStreamDeviceID = {0} {1}", outputStreamDeviceID, sortClause);

foreach (DataRow row in outputStreamDeviceDigitalTable.Rows)
{
Expand Down Expand Up @@ -272,9 +272,10 @@ public static ObservableCollection<OutputStreamDeviceDigital> Load(AdoDataConnec
if (keys is not null && keys.Count > 0)
{
commaSeparatedKeys = keys.Select(key => $"{key}").Aggregate((str1, str2) => $"{str1},{str2}");
query = database.ParameterizedQueryString($"SELECT NodeID, OutputStreamDeviceID, ID, Label, MaskValue, LoadOrder FROM OutputStreamDeviceDigital WHERE ID IN ({commaSeparatedKeys})");

outputStreamDeviceDigitalTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout);
outputStreamDeviceDigitalTable = database.Connection.RetrieveData(database.AdapterType,
"SELECT NodeID, OutputStreamDeviceID, ID, Label, MaskValue, LoadOrder FROM OutputStreamDeviceDigital " +
"WHERE ID IN ({0})", DefaultTimeout, commaSeparatedKeys);
outputStreamDeviceDigitalList = new OutputStreamDeviceDigital[outputStreamDeviceDigitalTable.Rows.Count];

foreach (DataRow row in outputStreamDeviceDigitalTable.Rows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static IList<int> LoadKeys(AdoDataConnection database, int outputStreamDe
if (!string.IsNullOrEmpty(sortMember))
sortClause = $"ORDER BY {sortMember} {sortDirection}";

DataTable OutputStreamDevicePhasorTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT ID FROM OutputStreamDevicePhasor WHERE OutputStreamDeviceID = {outputStreamDeviceID} {sortClause}");
DataTable OutputStreamDevicePhasorTable = database.Connection.RetrieveData(database.AdapterType, "SELECT ID FROM OutputStreamDevicePhasor WHERE OutputStreamDeviceID = {0} {1}", outputStreamDeviceID, sortClause);

foreach (DataRow row in OutputStreamDevicePhasorTable.Rows)
outputStreamDevicePhasorList.Add((row.ConvertField<int>("ID")));
Expand Down Expand Up @@ -276,9 +276,8 @@ public static ObservableCollection<OutputStreamDevicePhasor> Load(AdoDataConnect
if (keys is not null && keys.Count > 0)
{
string commaSeparatedKeys = keys.Select(key => $"{key}").Aggregate((str1, str2) => $"{str1},{str2}");
string query = database.ParameterizedQueryString($"SELECT NodeID, OutputStreamDeviceID, ID, Label, Type, Phase, ScalingValue, LoadOrder FROM OutputStreamDevicePhasor WHERE ID IN ({commaSeparatedKeys})");

DataTable outputStreamDevicePhasorTable = database.Connection.RetrieveData(database.AdapterType, query);
DataTable outputStreamDevicePhasorTable = database.Connection.RetrieveData(database.AdapterType, "SELECT NodeID, OutputStreamDeviceID, ID, Label, Type, Phase, ScalingValue, LoadOrder FROM OutputStreamDevicePhasor WHERE ID IN ({0})", commaSeparatedKeys);
outputStreamDevicePhasorList = new OutputStreamDevicePhasor[outputStreamDevicePhasorTable.Rows.Count];

foreach (DataRow row in outputStreamDevicePhasorTable.Rows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ public static IList<int> LoadKeys(AdoDataConnection database, int outputStreamID

string sortClause = string.Empty;

DataTable outputStreamMeasurementTable;
if (!string.IsNullOrEmpty(sortMember))
sortClause = $"ORDER BY {sortMember} {sortDirection}";

DataTable outputStreamMeasurementTable = database.Connection.RetrieveData(database.AdapterType, $"SELECT ID From OutputStreamMeasurementDetail where AdapterID = {outputStreamID} {sortClause}");
outputStreamMeasurementTable = database.Connection.RetrieveData(database.AdapterType, "SELECT ID From OutputStreamMeasurementDetail where AdapterID = {0} ORDER BY {1} {2}", outputStreamID, sortMember, sortDirection);
else outputStreamMeasurementTable = database.Connection.RetrieveData(database.AdapterType, "SELECT ID From OutputStreamMeasurementDetail where AdapterID = {0}", outputStreamID);

foreach (DataRow row in outputStreamMeasurementTable.Rows)
{
Expand Down Expand Up @@ -261,9 +261,10 @@ public static ObservableCollection<OutputStreamMeasurement> Load(AdoDataConnecti
if (keys is not null && keys.Count > 0)
{
commaSeparatedKeys = keys.Select(key => $"{key}").Aggregate((str1, str2) => $"{str1},{str2}");
query = $"SELECT NodeID, AdapterID, ID, HistorianID, PointID, SignalReference, SourcePointTag, HistorianAcronym FROM OutputStreamMeasurementDetail WHERE ID IN ({commaSeparatedKeys})";

outputStreamMeasurementTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout);
outputStreamMeasurementTable = database.Connection.RetrieveData(database.AdapterType,
"SELECT NodeID, AdapterID, ID, HistorianID, PointID, SignalReference, SourcePointTag, HistorianAcronym " +
"FROM OutputStreamMeasurementDetail WHERE ID IN ({0})", DefaultTimeout, commaSeparatedKeys);
outputStreamMeasurementList = new OutputStreamMeasurement[outputStreamMeasurementTable.Rows.Count];

foreach (DataRow row in outputStreamMeasurementTable.Rows)
Expand Down

0 comments on commit 6deaf6b

Please sign in to comment.