omni projects clean up
This commit is contained in:
+168
-17
@@ -1,35 +1,186 @@
|
||||
namespace CommonConsole
|
||||
{
|
||||
using Stichproben.Cordonel;
|
||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||
using Common.Hardware.WaterMeter.eRegister.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var assemblyLocation = typeof(Program).Assembly.Location;
|
||||
var stichproben = new Stichproben(assemblyLocation);
|
||||
var features = new List<EregisterFeature>();
|
||||
|
||||
for (var pono = 1; pono <= 10; pono++)
|
||||
foreach (var featureInfo in typeof(EregisterFeatures).GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
for (var sn = 1; sn <= 10; sn++)
|
||||
var featurePamAttribute = featureInfo.GetCustomAttribute<PamAttribute>();
|
||||
|
||||
if (featurePamAttribute is null)
|
||||
{
|
||||
for (var pcb = 1; pcb <= 10; pcb++)
|
||||
continue;
|
||||
}
|
||||
|
||||
var featureType = featureInfo.PropertyType;
|
||||
|
||||
if (typeof(Pam).IsAssignableFrom(featureType))
|
||||
{
|
||||
var featurePam = Activator.CreateInstance(featureType) as Pam;
|
||||
var feature = new EregisterFeature
|
||||
{
|
||||
stichproben.ShouldBePressureTested(pono, sn, pcb);
|
||||
FeatureType = featureType,
|
||||
Cmd = featurePam.CmdHex,
|
||||
IsSingleCmd = featurePamAttribute.IsSingleCmd,
|
||||
OnlyProductionMode = featurePamAttribute.OnlyProductionMode,
|
||||
AuthLevel = featurePamAttribute.AuthLevel,
|
||||
};
|
||||
|
||||
foreach (var featurePropertyInfo in feature.FeatureType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
if (!featurePropertyInfo.CanRead || !featureInfo.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
feature.Add(new EregisterFeatureProperty
|
||||
{
|
||||
Name = featurePropertyInfo.Name,
|
||||
Type = featurePropertyInfo.PropertyType,
|
||||
Getter = featurePropertyInfo.GetValue,
|
||||
Setter = featurePropertyInfo.SetValue,
|
||||
});
|
||||
}
|
||||
|
||||
features.Add(feature);
|
||||
}
|
||||
else if (featureType == typeof(EregisterDebugFeatures))
|
||||
{
|
||||
var feature = new EregisterDebugFeature
|
||||
{
|
||||
AuthLevel = AuthLevel.III,
|
||||
Cmd = "F1",
|
||||
FeatureType = featureType,
|
||||
IsSingleCmd = true
|
||||
};
|
||||
|
||||
foreach (var debugFeatureFeatureInfo in typeof(EregisterDebugFeatures).GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
var debugFeaturePamAttribute = debugFeatureFeatureInfo.GetCustomAttribute<PamAttribute>();
|
||||
|
||||
if (debugFeaturePamAttribute is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var debugFeatureType = debugFeatureFeatureInfo.PropertyType;
|
||||
var debugFeaturePam = Activator.CreateInstance(debugFeatureType) as Pam;
|
||||
var debugFeature = new EregisterDebugFeature
|
||||
{
|
||||
FeatureType = featureType,
|
||||
Cmd = debugFeaturePam.CmdHex,
|
||||
IsSingleCmd = featurePamAttribute.IsSingleCmd,
|
||||
OnlyProductionMode = featurePamAttribute.OnlyProductionMode,
|
||||
AuthLevel = featurePamAttribute.AuthLevel,
|
||||
};
|
||||
|
||||
foreach (var debugFeaturePropertyInfo in debugFeatureType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
if (!debugFeaturePropertyInfo.CanRead || !featureInfo.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
debugFeature.Add(new EregisterFeatureProperty
|
||||
{
|
||||
Name = debugFeaturePropertyInfo.Name,
|
||||
Type = debugFeaturePropertyInfo.PropertyType,
|
||||
Getter = debugFeaturePropertyInfo.GetValue,
|
||||
Setter = debugFeaturePropertyInfo.SetValue,
|
||||
});
|
||||
}
|
||||
|
||||
feature.Add(debugFeature);
|
||||
}
|
||||
|
||||
features.Add(feature);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var feature in features)
|
||||
{
|
||||
foreach (var items in feature.GetItems())
|
||||
{
|
||||
Console.Write($"{items[0],40}");
|
||||
Console.Write($"{items[1],5}");
|
||||
Console.Write($"{items[2],5}");
|
||||
Console.Write($"{items[3],5}");
|
||||
Console.Write($"{items[4],5}");
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//IF OBJECT_ID(N'Stichproben') IS NOT NULL BEGIN DROP TABLE Stichproben END
|
||||
public class EregisterFeature
|
||||
{
|
||||
private readonly ICollection<EregisterFeatureProperty> properties
|
||||
= new List<EregisterFeatureProperty>();
|
||||
|
||||
//CREATE TABLE Stichproben
|
||||
// (Id INT PRIMARY KEY IDENTITY(1, 1) NOT NULL
|
||||
// , FertigungsauftragNr INT NOT NULL
|
||||
// , SerienNr INT NOT NULL
|
||||
// , PcbId INT NOT NULL
|
||||
// , Nummer INT NOT NULL
|
||||
// , Prozentsatz INT NOT NULL
|
||||
// , IstStichprobe BIT DEFAULT(0))
|
||||
public Type FeatureType { get; set; }
|
||||
|
||||
public string Cmd { get; set; }
|
||||
|
||||
public bool IsSingleCmd { get; set; }
|
||||
|
||||
public bool OnlyProductionMode { get; set; }
|
||||
|
||||
public AuthLevel AuthLevel { get; set; }
|
||||
|
||||
public virtual void Add(EregisterFeatureProperty eregisterFeatureProperty)
|
||||
=> this.properties.Add(eregisterFeatureProperty);
|
||||
|
||||
public virtual IEnumerable<string[]> GetItems()
|
||||
{
|
||||
yield return new[]
|
||||
{
|
||||
this.FeatureType.Name,
|
||||
this.Cmd,
|
||||
$"{this.AuthLevel}",
|
||||
this.IsSingleCmd ? "v" : " ",
|
||||
this.OnlyProductionMode ? "v" : " "
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class EregisterDebugFeature : EregisterFeature
|
||||
{
|
||||
private readonly ICollection<EregisterFeature> features
|
||||
= new List<EregisterFeature>();
|
||||
|
||||
public virtual void Add(EregisterFeature feature)
|
||||
=> this.features.Add(feature);
|
||||
|
||||
public override IEnumerable<string[]> GetItems()
|
||||
{
|
||||
foreach (var feature in this.features)
|
||||
{
|
||||
foreach (var items in feature.GetItems())
|
||||
{
|
||||
yield return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EregisterFeatureProperty
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public Type Type { get; set; }
|
||||
|
||||
public Func<object, object> Getter { get; set; }
|
||||
|
||||
public Action<object, object> Setter { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user