(1) Multiple instances of SensusOracle.Database component possible, (2) Test.ItemNr updated properly, ver. 2.18.988
This commit is contained in:
parent
41959d863f
commit
0ff78b9d4c
@ -56,7 +56,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
|
||||
const int Anbid_StaraTura = 4;
|
||||
|
||||
public static DatabaseCfg DBCfg;
|
||||
public DatabaseCfg dbCfg;
|
||||
string separatorStr;
|
||||
|
||||
|
||||
@ -84,11 +84,11 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
public Database(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
DBCfg = cfg as DatabaseCfg;
|
||||
dbCfg = cfg as DatabaseCfg;
|
||||
|
||||
currentOp = CurrentOp.None;
|
||||
|
||||
switch (DBCfg.Separator)
|
||||
switch (dbCfg.Separator)
|
||||
{
|
||||
default:
|
||||
case Separator.None: separatorStr = string.Empty; break;
|
||||
@ -103,7 +103,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
switch (DBCfg.DBUsed)
|
||||
switch (dbCfg.DBUsed)
|
||||
{
|
||||
case DBUsed.Production:
|
||||
connection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
@ -119,7 +119,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
break;
|
||||
}
|
||||
|
||||
if (DBCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
if (dbCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
///
|
||||
/// Do something with the database to see if the connection works well
|
||||
@ -156,7 +156,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// <returns>Output string</returns>
|
||||
string ElSpaces(string item)
|
||||
{
|
||||
if (DBCfg.EliminateSpaces)
|
||||
if (dbCfg.EliminateSpaces)
|
||||
return item.Replace(" ", string.Empty);
|
||||
else
|
||||
return item;
|
||||
@ -171,22 +171,22 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// <returns>File name</returns>
|
||||
string GetFileName(DateTime time)
|
||||
{
|
||||
string directory = DBCfg.DestinationPath; /// Ends with "\\";
|
||||
string directory = dbCfg.DestinationPath; /// Ends with "\\";
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
if (DBCfg.YearFolders)
|
||||
if (dbCfg.YearFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Year.ToString());
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
if (DBCfg.MonthFolders)
|
||||
if (dbCfg.MonthFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Month.ToString("D2"));
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
if (DBCfg.DayFolders)
|
||||
if (dbCfg.DayFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Day.ToString("D2"));
|
||||
Directory.CreateDirectory(directory);
|
||||
@ -205,22 +205,22 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// <returns>File name</returns>
|
||||
string GetLogFileName(DateTime time)
|
||||
{
|
||||
string directory = DBCfg.LogFolderPath; /// Ends with "\\";
|
||||
string directory = dbCfg.LogFolderPath; /// Ends with "\\";
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
if (DBCfg.YearFolders)
|
||||
if (dbCfg.YearFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Year.ToString());
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
if (DBCfg.MonthFolders)
|
||||
if (dbCfg.MonthFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Month.ToString("D2"));
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
if (DBCfg.DayFolders)
|
||||
if (dbCfg.DayFolders)
|
||||
{
|
||||
directory = string.Format("{0}{1}\\", directory, time.Day.ToString("D2"));
|
||||
Directory.CreateDirectory(directory);
|
||||
@ -289,7 +289,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
{
|
||||
if (batch.WaterMeters.Count == 0) return Event.ResultsWritten;
|
||||
#if ORACLE_DB
|
||||
if (DBCfg.DebugLevel != DebugMode.Simulate && connection != null)
|
||||
if (dbCfg.DebugLevel != DebugMode.Simulate && connection != null)
|
||||
{
|
||||
if (WriteResultsToDatabase(connection, batch, false) == Retv.Error) anyError = true;
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
if (!opCompleted)
|
||||
{
|
||||
#if ORACLE_DB
|
||||
if (DBCfg.DebugLevel != DebugMode.Simulate && connection != null)
|
||||
if (dbCfg.DebugLevel != DebugMode.Simulate && connection != null)
|
||||
{
|
||||
if (CheckBarcodeScanning(connection, iperlHeads) == Retv.Error) anyError = true; ;
|
||||
}
|
||||
@ -335,7 +335,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
public static Retv WriteLogsToDisk(StreamWriter logger, Results.Entities.Batch batch)
|
||||
public Retv WriteLogsToDisk(StreamWriter logger, Results.Entities.Batch batch)
|
||||
{
|
||||
#if TURA_IPERL || TURA_SPECIAL
|
||||
if (logger == null) return Retv.Error;
|
||||
@ -684,7 +684,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
static void WriteOneToDisk(StreamWriter logger, int i, Results.Entities.TestRslt tr)
|
||||
void WriteOneToDisk(StreamWriter logger, int i, Results.Entities.TestRslt tr)
|
||||
{
|
||||
logger.WriteLine(string.Format("Prüfvolumen{0}={1}", i, Config.Units.ConvertTo(Unit.l, tr.TestData.TargetVolume).ToString(Program.AltCulture)));
|
||||
logger.WriteLine(string.Format("Prüfmasse{0}={1}", i, 0)); /// 3,72610
|
||||
@ -728,7 +728,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
|
||||
|
||||
#if ORACLE_DB
|
||||
public static Retv CheckBarcodeScanning(OracleConnection conn, GenericDevices.IRegisterReader[] iPerlHeads)
|
||||
public Retv CheckBarcodeScanning(OracleConnection conn, GenericDevices.IRegisterReader[] iPerlHeads)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -770,7 +770,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
public static Retv WriteResultsToDatabase(OracleConnection conn, Results.Entities.Batch batch, bool safeMode)
|
||||
public Retv WriteResultsToDatabase(OracleConnection conn, Results.Entities.Batch batch, bool safeMode)
|
||||
{
|
||||
OracleTransaction transaction = null;
|
||||
|
||||
@ -809,7 +809,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// </summary>
|
||||
/// <param name="wmNr">0-based water meter number</param>
|
||||
/// <param name="results">Sorted list of results to save</param>
|
||||
static void SaveSingleWM2DB(OracleConnection conn, Results.Entities.WaterMeter wm, bool safeMode)
|
||||
void SaveSingleWM2DB(OracleConnection conn, Results.Entities.WaterMeter wm, bool safeMode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(wm.SerialNr)) return; /// No database activity possible w/o PCB number
|
||||
|
||||
@ -852,7 +852,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
{
|
||||
if ((v % 100) > maxpruefindexLowPart) maxpruefindexLowPart = (v % 100);
|
||||
}
|
||||
int MAX_Pruefindex = 100 * DBCfg.TestBenchId + maxpruefindexLowPart + 1;
|
||||
int MAX_Pruefindex = 100 * dbCfg.TestBenchId + maxpruefindexLowPart + 1;
|
||||
|
||||
|
||||
int Hydr_Pruefung;
|
||||
@ -880,7 +880,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// Save common batch data
|
||||
/// </summary>
|
||||
/// <param name="b">Batch</param>
|
||||
static void SaveBatchData(OracleConnection conn, Results.Entities.Batch b)
|
||||
void SaveBatchData(OracleConnection conn, Results.Entities.Batch b)
|
||||
{
|
||||
OracleParameter parm;
|
||||
|
||||
@ -995,7 +995,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
static void SaveOrUpdateWM(OracleConnection conn, Results.Entities.WaterMeter wm, int max_Pruefindex, int hydr_Pruefung)
|
||||
void SaveOrUpdateWM(OracleConnection conn, Results.Entities.WaterMeter wm, int max_Pruefindex, int hydr_Pruefung)
|
||||
{
|
||||
int sekundaere_Adr = wm.Passed ? 1 : 0;
|
||||
int idBenutzer = 6; // = wm.Batch.UserNumber;
|
||||
@ -1014,7 +1014,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
parm = new OracleParameter("Hydr_Pruefung", OracleDbType.Int32); parm.Value = hydr_Pruefung; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("ID_Benutzer", OracleDbType.Int32); parm.Value = idBenutzer; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("ANBID", OracleDbType.Int32); parm.Value = Anbid_StaraTura; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("Baujahr", OracleDbType.Int32); parm.Value = DBCfg.Baujahr; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("Baujahr", OracleDbType.Int32); parm.Value = dbCfg.Baujahr; cmd.Parameters.Add(parm);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
log.InfoFormat("VT_ZAEHLER_PD inserted, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
@ -1029,7 +1029,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
parm = new OracleParameter("Max_Pruefindex", OracleDbType.Int32); parm.Value = max_Pruefindex; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("Hydr_Pruefung", OracleDbType.Int32); parm.Value = hydr_Pruefung; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("ID_Benutzer", OracleDbType.Int32); parm.Value = idBenutzer; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("Baujahr", OracleDbType.Int32); parm.Value = DBCfg.Baujahr; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("Baujahr", OracleDbType.Int32); parm.Value = dbCfg.Baujahr; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("VT_Fernum", OracleDbType.Varchar2); parm.Value = wm.SerialNr; cmd.Parameters.Add(parm);
|
||||
parm = new OracleParameter("ANBID", OracleDbType.Int32); parm.Value = Anbid_StaraTura; cmd.Parameters.Add(parm);
|
||||
|
||||
@ -1138,7 +1138,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
/// </summary>
|
||||
/// <param name="q">q = 0, 1, 2 or 3 (Adj., Q1, Q2, Q3)</param>
|
||||
/// <returns>Nr. of rows updated</returns>
|
||||
static int SaveMeterTestResult(OracleConnection conn, Results.Entities.MeterTestRslt mtr, int pruefungsNr, int max_Pruefindex) ///
|
||||
int SaveMeterTestResult(OracleConnection conn, Results.Entities.MeterTestRslt mtr, int pruefungsNr, int max_Pruefindex) ///
|
||||
{
|
||||
double Q_wm = 3600.0 * mtr.VolumeMeter / mtr.TestTime; /// in [l/hour]
|
||||
double Q_wm_with_upper_bound = Math.Min(2 * 1000 * mtr.TestRslt.FlowVolume, Math.Max(0.0, Q_wm));
|
||||
|
||||
@ -8,6 +8,7 @@ namespace TBF.BenchControl.Sequences
|
||||
{
|
||||
public static IBenchInfo BenchInfo;
|
||||
public static IErrorFlags ErrorFlagsComp;
|
||||
public static DB.SensusOracle.Database OracleDB;
|
||||
|
||||
public static FloatBox AmbTemp = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; /// [Celsius]
|
||||
public static FloatBox AmbPress = new FloatBox() { Name = "Ambient Pressure", Format = "F0", Factor = 1000 }; /// [bar], printed by ToString() in [mbar]
|
||||
|
||||
@ -221,6 +221,7 @@ namespace TBF.BenchControl
|
||||
if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev;
|
||||
if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo;
|
||||
if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags;
|
||||
if ((cmpnt is DB.SensusOracle.Database) && (ProcessData.OracleDB == null)) ProcessData.OracleDB = cmpnt as DB.SensusOracle.Database;
|
||||
if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter);
|
||||
if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
|
||||
@ -155,7 +155,8 @@ namespace TBF.Forms
|
||||
? new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;")
|
||||
: new OracleConnection("Data Source=STARA_TEST.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
|
||||
if (Database.WriteResultsToDatabase(conn, b, true) == Retv.OK)
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.OracleDB != null) &&
|
||||
(TBF.BenchControl.Sequences.ProcessData.OracleDB.WriteResultsToDatabase(conn, b, true) == Retv.OK))
|
||||
{
|
||||
b.RsltsSent = true; /// Result was successfully sent
|
||||
session.SaveOrUpdate(b); /// Update MySQL DB
|
||||
|
||||
@ -721,6 +721,7 @@ namespace TBF
|
||||
Test entity = (Test)lvi.Tag;
|
||||
|
||||
entity.Name = lvi.Text;
|
||||
entity.ItemNr = i;
|
||||
|
||||
int part = entity.Part;
|
||||
if (lvi.SubItems[(int)MtrlgyClmn.Part].Text.Equals("-"))
|
||||
@ -992,6 +993,7 @@ namespace TBF
|
||||
Test entity = (Test)lvi.Tag;
|
||||
|
||||
entity.Name = lvi.Text;
|
||||
entity.ItemNr = i;
|
||||
|
||||
int part = entity.Part;
|
||||
if (lvi.SubItems[(int)Mtrlgy2Clmn.Part].Text.Equals("-"))
|
||||
@ -1238,6 +1240,7 @@ namespace TBF
|
||||
Test entity = (Test)lvi.Tag;
|
||||
|
||||
entity.Name = lvi.Text;
|
||||
entity.ItemNr = i;
|
||||
|
||||
int part = entity.Part;
|
||||
if (lvi.SubItems[(int)ProcessClmn.Part].Text.Equals("-"))
|
||||
@ -1480,6 +1483,7 @@ namespace TBF
|
||||
Test entity = (Test)lvi.Tag;
|
||||
|
||||
entity.Name = lvi.Text;
|
||||
entity.ItemNr = i;
|
||||
|
||||
int part = entity.Part;
|
||||
if (lvi.SubItems[(int)ParametersClmn.Part].Text.Equals("-"))
|
||||
|
||||
@ -194,53 +194,5 @@ namespace TBF
|
||||
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpgradeAllTests()
|
||||
{
|
||||
NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
|
||||
IList<Config.Entities.Procedure> procedures = session.QueryOver<Config.Entities.Procedure>()
|
||||
.OrderBy(x => x.ItemNr).Asc
|
||||
.List();
|
||||
|
||||
///IList<TBF.BenchControl.Generic.IComponent> components = TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session);
|
||||
///
|
||||
int successful = 0;
|
||||
int failed = 0;
|
||||
string lastMsg = string.Empty;
|
||||
|
||||
int N = procedures.Count;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
Config.Entities.Procedure proc = procedures[i];
|
||||
Text = string.Format("{0} ({1}/{2})", proc.Name, i+1, N);
|
||||
|
||||
//TBF.BenchControl.Generic.IComponent component = TBF.BenchControl.TbfComponents.FindComponent()
|
||||
|
||||
NHibernate.ITransaction transaction = session.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
IList<Config.Entities.Test> tests = session.QueryOver<Config.Entities.Test>()
|
||||
.Where(x => (x.Procedure == proc))
|
||||
.OrderBy(x => x.ItemNr).Desc
|
||||
.List<Config.Entities.Test>();
|
||||
|
||||
|
||||
transaction.Commit();
|
||||
|
||||
successful++;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
transaction.Rollback();
|
||||
lastMsg = exc.Message;
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
MessageBox.Show(string.Format("Successful: {0}, Failed: {1}\r\nMessage: {2}", successful, failed, lastMsg), "Result",
|
||||
MessageBoxButtons.OK, (failed > 0) ? MessageBoxIcon.Error : MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.986.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.986.0")]
|
||||
[assembly: AssemblyVersion("2.18.988.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.988.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user