diff --git a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs index 6b8564f66..6728a1c8b 100644 --- a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs +++ b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2018-2019 Sensus Slovensko a.s. +/// Copyright (c) 2018-2023 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -134,22 +134,21 @@ namespace TBF.Rig.Output.DB.ProductionTracing } /// Register this test bench in the tracing DB for approx. 2 weeks - ISession session = sessionFactory.OpenSession(); - + var session = sessionFactory.OpenSession(); #if !DEBUG - /// Only a release version registers a workplace - TracingDB.DB.RegisterWorkplace(session, - workplace, - Users.CurrentUser.UserName(), - (ipAddress != null) ? ipAddress.ToString() : "1.2.3.4", - "", - WorkstepName, - DateTime.Now + new TimeSpan(15, 0, 0, 0)); -#endif + /// Only a release version registers a workplace + TracingDB.DB.RegisterWorkplace(session, + workplace, + Users.CurrentUser.UserName(), + (ipAddress != null) ? ipAddress.ToString() : "1.2.3.4", + "", + WorkstepName, + DateTime.Now + new TimeSpan(15, 0, 0, 0)); session.Flush(); +#endif session.Close(); + TracingDB.DB.SessionFactory = sessionFactory; - if (session != null) session.Dispose(); log.FatalFormat("{0} initialized: {1}", Name, this); } else diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs index 85ba17588..19e229fff 100644 --- a/TBF/UI/MainWnd.cs +++ b/TBF/UI/MainWnd.cs @@ -289,10 +289,11 @@ namespace TBF.UI form.CloseForm(null, new EventArgs()); formThread.Join(); + string innerExcMsg = (exc.InnerException != null) ? Environment.NewLine + exc.InnerException.Message : string.Empty; string errMsg = string.Format(Strings.Failed_to_initialize_device_0_1_2, Rig.StateMachine.CurrentlyInitializedComponentName, - Environment.NewLine, - exc.Message); + Environment.NewLine + exc.Message, + innerExcMsg); log.Fatal(errMsg); MessageBox.Show(errMsg, Strings.Error, System.Windows.Forms.MessageBoxButtons.OK, diff --git a/TracingDB/DB.cs b/TracingDB/DB.cs index fe02ef979..77c78edfb 100644 --- a/TracingDB/DB.cs +++ b/TracingDB/DB.cs @@ -19,9 +19,6 @@ namespace TracingDB /// public static ISessionFactory SessionFactory; - public static ISession Session; - - /// /// Connection string for all sessions /// @@ -39,16 +36,6 @@ namespace TracingDB } } - - /// - /// NHibernate session factory (to create the database session 'SessionFactory') - /// - /// A database session - static ISessionFactory CreateSessionFactory() - { - return CreateSessionFactory(false); - } - /// /// NHibernate session factory (to create the database session 'SessionFactory') /// @@ -86,17 +73,6 @@ namespace TracingDB new SchemaExport(config).Create(true, true); } - /// Create a NHibernate session for the given database - public static ISession CreateSession(string connectionString) - { - ConnectionString = connectionString; /// Clears session factory on connction string change - - if (SessionFactory == null) - SessionFactory = CreateSessionFactory(); - - return SessionFactory.OpenSession(); - } - /// /// Create an empty database.