本文整理汇总了C#中AdoDataConnection.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# AdoDataConnection.ExecuteReader方法的具体用法?C# AdoDataConnection.ExecuteReader怎么用?C# AdoDataConnection.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdoDataConnection
的用法示例。
在下文中一共展示了AdoDataConnection.ExecuteReader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// Loads configuration from the database and configures adapter to run with that configuration
/// </summary>
public override void Initialize()
{
base.Initialize();
HashSet<IMeasurement> outputMeasurements = new HashSet<IMeasurement>();
m_configuredCalculations = new List<PowerCalculation>();
m_averageCalculationsPerFrame = new RunningAverage();
m_averageCalculationTime = new RunningAverage();
m_averageTotalCalculationTime = new RunningAverage();
m_lastActivePowerCalculations = new ConcurrentQueue<IMeasurement>();
m_lastReactivePowerCalculations = new ConcurrentQueue<IMeasurement>();
m_lastApparentPowerCalculations = new ConcurrentQueue<IMeasurement>();
string query = "SELECT " +
// 1 2 3 4 5
"ID, CircuitDescription, VoltageAngleSignalID, VoltageMagSignalID, CurrentAngleSignalID, CurrentMagSignalID, " +
// 6 7 8
"ActivePowerOutputSignalID, ReactivePowerOutputSignalID, ApparentPowerOutputSignalID FROM PowerCalculation " +
"WHERE NodeId = {0} AND Enabled <> 0 ";
using (AdoDataConnection database = new AdoDataConnection("systemSettings"))
using (IDataReader rdr = database.ExecuteReader(query, ConfigurationFile.Current.Settings["systemSettings"]["NodeID"].ValueAs<Guid>()))
{
while (rdr.Read())
{
m_configuredCalculations.Add(new PowerCalculation
{
PowerCalculationID = rdr.GetInt32(0),
CircuitDescription = rdr.GetString(1),
VoltageAngleSignalID = MeasurementKey.LookUpBySignalID(Guid.Parse(rdr[2].ToString())),
VoltageMagnitudeSignalID = MeasurementKey.LookUpBySignalID(Guid.Parse(rdr[3].ToString())),
CurrentAngleSignalID = MeasurementKey.LookUpBySignalID(Guid.Parse(rdr[4].ToString())),
CurrentMagnitudeSignalID = MeasurementKey.LookUpBySignalID(Guid.Parse(rdr[5].ToString())),
ActivePowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(rdr[6].ToString()), outputMeasurements),
ReactivePowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(rdr[7].ToString()), outputMeasurements),
ApparentPowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(rdr[8].ToString()), outputMeasurements)
});
}
}
if (m_configuredCalculations.Any())
InputMeasurementKeys = m_configuredCalculations.SelectMany(pc => new[] {pc.CurrentAngleSignalID, pc.CurrentMagnitudeSignalID, pc.VoltageAngleSignalID, pc.VoltageMagnitudeSignalID}).ToArray();
else
throw new InvalidOperationException("Skipped initialization of power calculator: no defined power calculations...");
if (outputMeasurements.Any())
OutputMeasurements = outputMeasurements.ToArray();
Dictionary<string, string> settings = Settings;
string setting;
if (settings.TryGetValue("AlwaysProduceResult", out setting))
AlwaysProduceResult = setting.ParseBoolean();
if (settings.TryGetValue("ApplySqrt3Adjustment", out setting))
ApplySqrt3Adjustment = setting.ParseBoolean();
if (settings.TryGetValue("RemoveSqrt3Adjustment", out setting))
RemoveSqrt3Adjustment = setting.ParseBoolean();
if (settings.TryGetValue("EnableTemporalProcessing", out setting))
EnableTemporalProcessing = setting.ParseBoolean();
}