Entwicklung/Sensormat/Sensormat/SQLExtensions.cs
2025-09-23 10:21:23 +02:00

57 lines
1.7 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Sensormat.SQLExtensions
// Assembly: Sensormat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 49795081-3467-4846-904D-9A360FB2FA3C
// Assembly location: \\192.168.178.26\Freigabe\Sensormat.dll
using MySqlConnector;
using Sensormat.Entities;
using System.Collections.Generic;
#nullable disable
namespace Sensormat
{
public static class SQLExtensions
{
public static IEnumerable<Sensoren> GetSensoren(this MySqlConnection connection)
{
using (MySqlCommand cmd = connection.CreateCommand())
{
cmd.CommandText = "SELECT * FROM tblSensoren WHERE Aktiv <> 0";
MySqlDataReader reader = cmd.ExecuteReader();
try
{
while (true)
{
if (reader.HasRows)
{
if (reader.Read())
yield return reader.ParseObject<Sensoren>();
else
break;
}
else
goto label_5;
}
}
finally
{
reader?.Dispose();
}
yield break;
label_5:
reader = (MySqlDataReader)null;
}
}
public static void CallCalculate(this MySqlConnection connection)
{
using (MySqlCommand command = connection.CreateCommand())
{
command.CommandText = "CALL spSensorCalculate; ";
command.ExecuteNonQuery();
}
}
}
}