Early loading of the 1st component implementing IBenchInfo to ProcessData.BenchInfo.

This commit is contained in:
Milan Hanajik 2022-06-07 11:58:53 +02:00
parent 38b8184dfb
commit 3dc6f291bb

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.IO;
@ -11,6 +11,7 @@ using Config.Entities;
using Users;
using Users.Entities;
using TBF.Resources;
using TBF.Rig.Sequences;
using TBF.UI.Shared;
using NHibernate;
@ -40,6 +41,8 @@ namespace TBF
public const string LocalSettingsBackupName = "config.backup.xml";
public static System.Globalization.CultureInfo AltCulture;
static IList<Procedure> listOfProcedures;
/// <summary>
/// Selected procedure data
@ -52,12 +55,12 @@ namespace TBF
/// of procedure data and uses them for the test. Changes of 'SelectedProcedure'
/// done during the test do not have any influence on the currently running test.
/// </summary>
public static Config.Entities.Procedure SelectedProcedure = null;
public static Procedure SelectedProcedure = null;
/// <summary>
/// Main window object.
/// </summary>
public static UI.MainWnd MainWnd;
public static TBF.UI.MainWnd MainWnd;
/// <summary>
@ -360,12 +363,44 @@ namespace TBF
///
/// Connect to Config database.
/// This triggers an exception in case user is a power user and there is no Config database.
///
IList<Procedure> listOfProcedures = TBF.DB.CreateSession(Common.DBKind.Config)
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == Common.ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
///
ISession session = TBF.DB.CreateSession(DBKind.Config);
if (!string.IsNullOrEmpty(LocalSettings.LastProcedureName))
{
listOfProcedures = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
}
/// Search for 'BenchInfo' component
var components = session.QueryOver<Config.Entities.Component>()
.Where(x => x.ClassName == "BenchInfoEx")
.List();
if (components.Count > 0)
{
var factory = new TBF.Rig.DataContainers.BenchInfo.Extended.ComponentFactory();
var cfg = factory.CmpntCfgFromCmpntEntity(components[0])
as TBF.Rig.DataContainers.BenchInfo.Extended.ComponentCfg;
ProcessData.BenchInfo = new TBF.Rig.DataContainers.BenchInfo.Extended.Component(cfg);
}
else
{
/// Search for 'iPerlBenchInfo' component
components = session.QueryOver<Config.Entities.Component>()
.Where(x => x.ClassName == "BenchInfo.iPerl")
.List();
if (components.Count > 0)
{
var factory = new TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentFactory();
var cfg = factory.CmpntCfgFromCmpntEntity(components[0])
as TBF.Rig.DataContainers.BenchInfo.iPerl.ComponentCfg;
ProcessData.BenchInfo = new TBF.Rig.DataContainers.BenchInfo.iPerl.Component(cfg);
}
}
session.Close();
///
/// Connect to Results database and determine the last saved batch number.
@ -448,10 +483,10 @@ namespace TBF
if (LocalSettings.LastProcedureName != null)
{
IList<Procedure> listOfProcedures = TBF.DB.CreateSession(Common.DBKind.Config)
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == Common.ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == Common.ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
if (listOfProcedures.Count == 1)
{