diff --git a/TBF/Program.cs b/TBF/Program.cs index 78bb35f89..1b715c2ac 100644 --- a/TBF/Program.cs +++ b/TBF/Program.cs @@ -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 listOfProcedures; /// /// 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. /// - public static Config.Entities.Procedure SelectedProcedure = null; + public static Procedure SelectedProcedure = null; /// /// Main window object. /// - public static UI.MainWnd MainWnd; + public static TBF.UI.MainWnd MainWnd; /// @@ -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 listOfProcedures = TBF.DB.CreateSession(Common.DBKind.Config) - .QueryOver() - .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() + .Where(x => (x.ProcedureState == ProcedureState.Active)) + .And(x => (x.Name == LocalSettings.LastProcedureName)) + .List(); + } + + /// Search for 'BenchInfo' component + var components = session.QueryOver() + .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() + .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 listOfProcedures = TBF.DB.CreateSession(Common.DBKind.Config) - .QueryOver() - .Where(x => (x.ProcedureState == Common.ProcedureState.Active)) - .And(x => (x.Name == LocalSettings.LastProcedureName)) - .List(); + .QueryOver() + .Where(x => (x.ProcedureState == Common.ProcedureState.Active)) + .And(x => (x.Name == LocalSettings.LastProcedureName)) + .List(); if (listOfProcedures.Count == 1) {