SelectedProcedure stored in ProcessData, used in DataEntry.iPERL and S620, S640Comm cleaned, IOrderInfo, I640Cfg, OrderManagement v.3.0.6, etc.

This commit is contained in:
Milan Hanajik
2021-12-09 17:12:52 +01:00
parent ff28d507cf
commit 68c3ccbef6
32 changed files with 2453 additions and 944 deletions
+71 -7
View File
@@ -75,7 +75,8 @@ namespace TBF.Rig.Output.DB.ProductionTracing
Results.Entities.Batch batch;
ISessionFactory sessionFactory; /// Factory to create database sessions that is initialized in the constructor
public ISessionFactory SessionFactory; /// Factory to create database sessions that is initialized in the constructor
IList<SharedDatabase.Entities.Process> processes;
Dictionary<int, SharedDatabase.Entities.Process> processDictionary;
Dictionary<int, IList<SharedDatabase.Entities.Workstep>> workstepsDictionary;
@@ -125,7 +126,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
/// Session factory is used to create database sessions
///
sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
SessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Process>())
.ExposeConfiguration(SharedDatabase.TracingDB.BuildSchema)
@@ -146,7 +147,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
/// Register this test bench in the tracing DB for approx. 2 weeks
///
ISession session = sessionFactory.OpenSession();
ISession session = SessionFactory.OpenSession();
#if !DEBUG
/// Only a release version registers a workplace
@@ -160,7 +161,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
#endif
session.Flush();
session.Close();
SharedDatabase.TracingDB.SessionFactory = sessionFactory;
SharedDatabase.TracingDB.SessionFactory = SessionFactory;
if (session != null) session.Dispose();
currentWorkflow = null;
@@ -178,7 +179,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
if (tracingCfg.DebugLevel == DebugMode.Simulate) return;
using (ISession session = sessionFactory.OpenSession())
using (ISession session = SessionFactory.OpenSession())
{
SharedDatabase.TracingDB.UnregisterWorkplaceObsolete(session, workplace);
session.Flush();
@@ -187,6 +188,69 @@ namespace TBF.Rig.Output.DB.ProductionTracing
public void StopDevice2() {}
public IList<OrderInfo> ReadOrders(ISession session)
{
try
{
session = SessionFactory.OpenSession();
var result = session.QueryOver<OrderInfo>()
.Where(x => (x.POState == (sbyte)OrderState.New || x.POState == (sbyte)OrderState.Active))
.List<OrderInfo>();
return result;
}
catch (Exception exc)
{
log.ErrorFormat("Cannot read orders from the tracing DB: {0}", exc.Message);
return new List<OrderInfo>();
}
}
/// <summary>
/// Read reference records belonging to specified order
/// </summary>
/// <param name="session">DB sesson</param>
/// <param name="order">Order</param>
/// <returns>List of reference records-s</returns>
public IList<ReferenceRecord> ReadRefRecords(ISession session, OrderInfo order)
{
try
{
return session.QueryOver<ReferenceRecord>()
.Where(x => (x.POrder == order))
.List();
}
catch (Exception exc)
{
log.ErrorFormat("Cannot read orders from the tracing DB: {0}", exc.Message);
return new List<ReferenceRecord>();
}
}
/// <summary>
/// Read records belonging to specified order
/// </summary>
/// <param name="session">DB sesson</param>
/// <param name="order">Order</param>
/// <returns>List of records</returns>
public IList<Record> ReadRecords(ISession session, OrderInfo order)
{
try
{
return session.QueryOver<Record>()
.JoinQueryOver<ReferenceRecord>(rec => rec.ReferenceRecord)
.Where(rr => rr.POrder.Id == order.Id)
.List<Record>();
}
catch (Exception exc)
{
log.ErrorFormat("Cannot read orders from the tracing DB: {0}", exc.Message);
return new List<Record>();
}
}
/// <summary>
/// Reads information on start of a cycle, Events: Event.InfoRead
/// </summary>
@@ -349,7 +413,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
if (sampleWM != null)
{
bool isAtLeastOneNOK = false;
using (ISession session = sessionFactory.OpenSession())
using (ISession session = SessionFactory.OpenSession())
{
var cOrders = session.QueryOver<OrderInfo>()
.Where(x => x.POName == sampleWM.PurchaseOrder)
@@ -518,7 +582,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
try
{
session = sessionFactory.OpenSession();
session = SessionFactory.OpenSession();
transaction = session.BeginTransaction();
var cOrders = session.QueryOver<OrderInfo>()