Sharing procedures from a remote DB, ver. 2.18.928

This commit is contained in:
Milan Hanajik
2018-06-15 14:31:40 +02:00
parent 619c06a511
commit cf5dd8cb71
8 changed files with 84 additions and 34 deletions
+6 -1
View File
@@ -39,7 +39,11 @@ namespace Config
dbType = Data.CurrentBench.WaterMetersDBSettings.DbType;
connectionString = Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
break;
}
case Users.Entities.DBKind.RemoteConfig:
dbType = Data.CurrentBench.UsersDBSettings.DbType;
connectionString = Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
break;
}
return CreateSessionFactory(database, dbType, connectionString, false);
}
@@ -69,6 +73,7 @@ namespace Config
{
default:
case Users.Entities.DBKind.Config:
case Users.Entities.DBKind.RemoteConfig:
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
break;
case Users.Entities.DBKind.Results:
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.893.0")]
[assembly: AssemblyFileVersion("2.18.893.0")]
[assembly: AssemblyVersion("2.18.928.0")]
[assembly: AssemblyFileVersion("2.18.928.0")]
+57 -15
View File
@@ -3,6 +3,7 @@
///
using System;
using System.Collections.Generic;
using System.Diagnostics;
using log4net;
using NHibernate;
using Config;
@@ -109,8 +110,8 @@ namespace TBF.BenchControl.Sequences
Selection selection;
string selectedTestName;
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
StateMachine.LoadPathsAndTransitions(session); // TODO: Implement as an operation so that the worker thread is not blocked
ISession sessn = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
StateMachine.LoadPathsAndTransitions(sessn); // TODO: Implement as an operation so that the worker thread is not blocked
Bridge.OnActivity(this, Strings.Starting_system);
State.Create("MainSeq : Press OK to start the system")
@@ -313,24 +314,57 @@ namespace TBF.BenchControl.Sequences
default: selectedTestName = Bridge.SelectedTestName; break;
}
try
{
using (ISession localSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
{
StateMachine.LoadPathsAndTransitions(localSession);
}
}
catch (Exception) { continue; }
#if (TURA_IPERL || TURA_SPECIAL)
///
/// Load all parameters for this procedure from DB
/// Try to load all parameters for this procedure from a remote DB
///
try
{
ISession sesn = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
StateMachine.LoadPathsAndTransitions(sesn);
StateMachine.LoadProcedure(sesn);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
testParamsForCurrentProcedure = new List<ComponentTest>();
foreach (var test in StateMachine.Tests)
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.RemoteConfig))
{
IList<ComponentTest> testParams = sesn.QueryOver<ComponentTest>()
.Where(x => (x.Test == test))
.List();
foreach (var tp in testParams) testParamsForCurrentProcedure.Add(tp);
StateMachine.LoadProcedure(remoteOrLocalSession);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
/// This is to load Procedure.Tests and tets.MoreParams for each test
int a = 0;
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
}
}
catch (Exception)
{
StateMachine.Procedure = null;
}
if (StateMachine.Procedure != null) break;
#endif
///
/// Try to load all parameters for this procedure from the local DB
///
try
{
using (ISession localSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
{
StateMachine.LoadPathsAndTransitions(localSession);
}
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
{
StateMachine.LoadProcedure(remoteOrLocalSession);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
/// This is to load Procedure.Tests and tets.MoreParams for each test
int a = 0;
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
}
}
catch (Exception)
@@ -340,6 +374,14 @@ namespace TBF.BenchControl.Sequences
}
while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected
Debug.WriteLine(string.Empty);
Debug.WriteLine(string.Format("TransitionSequences {0}", NHibernateUtil.IsInitialized(StateMachine.TransitionSequences) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("TransitionSteps {0}", NHibernateUtil.IsInitialized(StateMachine.TransitionSteps) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure.MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.MoreParams) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure.Tests {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests) ? "initialized" : "NOT initialized"));
Debug.WriteLine(string.Format("Procedure.Tests[0].MoreParams {0}", NHibernateUtil.IsInitialized(StateMachine.Procedure.Tests[0].MoreParams) ? "initialized" : "NOT initialized"));
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
///
+9 -5
View File
@@ -372,12 +372,16 @@ namespace TBF.BenchControl.Sequences
else
{
///
/// Execute the transition sequence
/// Fetch and execute the transition sequence
///
IList<TransitionStep> transitionSteps = StateMachine.WtSession.QueryOver<TransitionStep>()
.Where(x => (x.TransitionSequence == transitionSequence))
.OrderBy(x => x.ItemNr).Asc
.List();
IList<TransitionStep> transitionSteps = new List<TransitionStep>();
if (StateMachine.TransitionSteps != null)
{
foreach (var step in StateMachine.TransitionSteps)
{
if (step.TransitionSequence.Id == transitionSequence.Id) transitionSteps.Add(step);
}
}
int stepsCount = transitionSteps.Count;
+5 -7
View File
@@ -1,12 +1,10 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using NHibernate;
using Config.Entities;
@@ -42,6 +40,7 @@ namespace TBF.BenchControl
static IList<Config.Entities.MetersPath> metersPaths;
static IList<Config.Entities.HeatMetersPath> heatMetersPaths;
public static IList<Config.Entities.TransitionSequence> TransitionSequences;
public static IList<Config.Entities.TransitionStep> TransitionSteps;
/// Public components
public static Elde.ControlBoardDev ControlBoard;
@@ -74,7 +73,6 @@ namespace TBF.BenchControl
/// Worker thread and database session
static Thread workerThread;
public static ISession WtSession;
static IList<State> states; /// list of states
@@ -390,13 +388,12 @@ namespace TBF.BenchControl
/// </summary>
public static void LoadPathsAndTransitions(ISession session)
{
WtSession = session; /// WtSession is used to read steps of transition sequences
feedingPaths = session.QueryOver<Config.Entities.FeedingPath>().OrderBy(x => x.ItemNr).Asc.List();
benchPaths = session.QueryOver<Config.Entities.BenchPath>().OrderBy(x => x.ItemNr).Asc.List();
outputPaths = session.QueryOver<Config.Entities.OutputPath>().OrderBy(x => x.ItemNr).Asc.List();
metersPaths = session.QueryOver<Config.Entities.MetersPath>().OrderBy(x => x.ItemNr).Asc.List();
TransitionSequences = session.QueryOver<TransitionSequence>().OrderBy(x => x.ItemNr).Asc.List();
TransitionSteps = session.QueryOver<TransitionStep>().OrderBy(x => x.ItemNr).Asc.List();
#if HEAT_METERS
heatMetersPaths = session.QueryOver<Config.Entities.HeatMetersPath>().OrderBy(x => x.ItemNr).Asc.List();
#endif
@@ -408,6 +405,8 @@ namespace TBF.BenchControl
/// </summary>
public static bool LoadProcedure(ISession session)
{
Procedure = null;
IList<Procedure> selectedProcs = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == TBF.UiBridge.Bridge.SelectedProcedureName))
@@ -417,7 +416,6 @@ namespace TBF.BenchControl
Procedure = selectedProcs[0];
Tests = selectedProcs[0].Tests;
return true;
}
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.927.0")]
[assembly: AssemblyFileVersion("2.18.927.0")]
[assembly: AssemblyVersion("2.18.928.0")]
[assembly: AssemblyFileVersion("2.18.928.0")]
+1
View File
@@ -18,6 +18,7 @@ namespace Users.Entities
{
Config,
Results,
RemoteConfig,
Count
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.901.0")]
[assembly: AssemblyFileVersion("2.18.901.0")]
[assembly: AssemblyVersion("2.18.928.0")]
[assembly: AssemblyFileVersion("2.18.928.0")]