TracingDB synchronized with Production-Monitoring project, ver. 2.26.1562

This commit is contained in:
Milan Hanajik 2020-12-15 11:48:57 +01:00
parent 99cd84fb2a
commit d8ed144dee
15 changed files with 194 additions and 67 deletions

View File

@ -150,7 +150,7 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
ISession session = sessionFactory.OpenSession();
#if !DEBUG
/// Only release version registers a workplace
/// Only a release version registers a workplace
TracingDB.DB.RegisterWorkplace(session,
workplace,
Users.GlobalData.GetCurrentUserName(),
@ -181,7 +181,7 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
using (ISession session = sessionFactory.OpenSession())
{
TracingDB.DB.UnregisterWorkplace(session, workplace);
TracingDB.DB.UnregisterWorkplaceObsolete(session, workplace);
session.Flush();
}
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.26.1561.0")]
[assembly: AssemblyFileVersion("2.26.1561.0")]
[assembly: AssemblyVersion("2.26.1562.0")]
[assembly: AssemblyFileVersion("2.26.1562.0")]

View File

@ -179,7 +179,7 @@ namespace TracingDB
{
/// Read all already existing reference records with Code==pcbNumber, referenceRecords[0] will be the most recent one
var referenceRecords = session.QueryOver<ReferenceRecord>()
.Where(rr => (rr.Code == pcbNumber))
.Where(rr => (rr.Code == pcbNumber && rr.Result == 0))
.OrderBy(rr => rr.TimeStamp).Desc
.List();
@ -194,6 +194,60 @@ namespace TracingDB
}
/// <summary>
/// Updates processes, processDictionary and workstepsDictionary
/// </summary>
/// <param name="session">DB session</param>
public static IList<Process> ReadWorkflowsFromDB(ISession session,
string thisWorkstepName,
out Dictionary<int, Process> workflowDict,
out Dictionary<int, IList<Workstep>> workflowStepsDict,
out Dictionary<int, TracingDB.ScanVerificationInfo> verifInfos,
bool readDeactivatedWorkflows = false)
{
IList<Process> workflows;
if (readDeactivatedWorkflows)
{
workflows = session.QueryOver<Process>().Where(pr => ((pr.ReleaseStatus == ReleaseStatus.Released) ||
(pr.ReleaseStatus == ReleaseStatus.ReleasedActive) ||
(pr.ReleaseStatus == ReleaseStatus.ToBeApproved) ||
(pr.ReleaseStatus == ReleaseStatus.Deactivated)
)).List();
}
else
{
workflows = session.QueryOver<Process>().Where(pr => ((pr.ReleaseStatus == ReleaseStatus.Released) ||
(pr.ReleaseStatus == ReleaseStatus.ReleasedActive) ||
(pr.ReleaseStatus == ReleaseStatus.ToBeApproved)
)).List();
}
workflowDict = new Dictionary<int, Process>();
workflowStepsDict = new Dictionary<int, IList<Workstep>>();
verifInfos = new Dictionary<int, TracingDB.ScanVerificationInfo>();
foreach (var wf in workflows)
{
IList<Workstep> steps = session.QueryOver<Workstep>()
.Where(ws => ((ws.Process == wf) && (ws.Name == thisWorkstepName)))
.List();
workflowDict.Add(wf.Id, wf);
workflowStepsDict.Add(wf.Id, steps);
Workstep step;
bool verifyRefPart;
Part verifiedPart;
if (steps.Count == 1 && TracingDB.DB.AnalyzeProcess(session, wf, steps[0], out step, out verifyRefPart, out verifiedPart))
{
verifInfos.Add(wf.Id, new ScanVerificationInfo(step, verifyRefPart, verifiedPart));
log.WarnFormat("Workflow {0} :: Verified step={1} part={2} verify ref. part={3}", wf, step, verifiedPart, verifyRefPart);
}
}
return workflows;
}
/// <summary>
/// Finds a workstep and a part to be verified (typically a previous workstep and one of its parts).
/// Updates this.verifiedWorkstep, this.verifiedPart and this.verifyReferencePart.
@ -342,15 +396,13 @@ namespace TracingDB
/// <summary>
/// Obsolete, use WorkplaceRegistration class instead
/// </summary>
public static bool UnregisterWorkplace(ISession session, string workplace)
public static bool UnregisterWorkplaceObsolete(ISession session, string workplace)
{
try
{
IList<WorkplaceRegistration> wpRegs = session
.QueryOver<WorkplaceRegistration>()
.Where(x => (x.Workplace == workplace))
.List();
IList<WorkplaceRegistration> wpRegs = session.QueryOver<WorkplaceRegistration>()
.Where(x => (x.Workplace == workplace))
.List();
if (wpRegs.Count == 1)
{
WorkplaceRegistration wpReg = wpRegs[0];

View File

@ -12,12 +12,38 @@ namespace TracingDB.Entities
public virtual CodeType CodeType { get; set; }
public virtual CodeForm CodeForm { get; set; }
public virtual CodeLocation CodeLocation { get; set; }
public virtual string DefaultCode { get; set; }
public virtual LifetimeManagement LifetimeManagement { get; set; }
public virtual int StepNumber { get; set; }
public virtual Process Process { get; set; }
public virtual Workstep Workstep { get; set; }
/// <summary>
/// Create a copy of a part (1) belongig to another process, (2) not assigned to any workstep yet.
/// </summary>
/// <param name="process">Process owning the cloned part</param>
/// <returns>Cloned part</returns>
public virtual Part Clone(Process owningProcess)
{
Part rslt = new Part();
rslt.Name = Name;
rslt.OraDBType = OraDBType;
rslt.Description = Description;
rslt.CodeType = CodeType;
rslt.CodeForm = CodeForm;
rslt.CodeLocation = CodeLocation;
rslt.DefaultCode = DefaultCode;
rslt.LifetimeManagement = LifetimeManagement;
rslt.StepNumber = StepNumber;
rslt.Process = owningProcess;
rslt.Workstep = null;
return rslt;
}
public Part()
{
@ -48,36 +74,13 @@ namespace TracingDB.Entities
CodeType = codeType;
CodeForm = codeForm;
CodeLocation = codeLocation;
DefaultCode = string.Empty;
StepNumber = 0;
Process = process;
Workstep = null;
}
/// <summary>
/// Create a copy of a part (1) belongig to another process, (2) not assigned to any workstep yet.
/// </summary>
/// <param name="process">Process owning the cloned part</param>
/// <returns>Cloned part</returns>
public virtual Part Clone(Process owningProcess)
{
Part rslt = new Part();
rslt.Name = Name;
rslt.OraDBType = OraDBType;
rslt.Description = Description;
rslt.CodeType = CodeType;
rslt.CodeForm = CodeForm;
rslt.CodeLocation = CodeLocation;
rslt.LifetimeManagement = LifetimeManagement;
rslt.StepNumber = StepNumber;
rslt.Process = owningProcess;
rslt.Workstep = null;
return rslt;
}
public override string ToString()
{
return string.Format("{0} ({1}: {2})", Name, StepNumber, Description);

View File

@ -78,9 +78,9 @@ namespace TracingDB.Entities
{
return string.Format("code={0} part={1} description='{2}' step='{3}' workplace='{4}' user={5} time={6:dd.MM.yyyy HH:mm:ss}",
(Code != null) ? Code : "<none>",
Workstep.ReferencePart.Name,
Workstep.ReferencePart.Description,
Workstep.Name,
(Workstep != null) ? Workstep.ReferencePart.Name : string.Empty,
(Workstep != null) ? Workstep.ReferencePart.Description : string.Empty,
(Workstep != null) ? Workstep.Name : string.Empty,
Workplace,
UserName,
TimeStamp);

View File

@ -79,6 +79,9 @@ namespace TracingDB
QRCode, /// QR code
Keyboard, /// Data entered by a keyboard
OkNok, /// OK/NOK or Yes/No data entered by a keyboard or a mouse
SerialNr, /// Complete serial number of iPERL (follows PcbNumber which is a reference part)
Camera,
Scale,
Count
}

View File

@ -0,0 +1,10 @@
using System;
namespace TracingDB.Forms
{
public class MessageEventArgs : EventArgs
{
public string Message;
public MessageEventArgs(string message) { Message = message; }
}
}

View File

@ -6,6 +6,24 @@ namespace TracingDB.Forms
{
public partial class ModelessForm : Form
{
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public static void UpdateMessage(MessageEventArgs args)
{
if (UpdateMessageHandler == null) return;
try { UpdateMessageHandler(null, args); }
catch (Exception) { }
}
public static event EventHandler<MessageEventArgs> UpdateMessageHandler;
void OnUpdateMessage(object sender, MessageEventArgs args)
{
Message = args.Message;
if (Message != null) label1.Text = Message;
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
@ -44,6 +62,12 @@ namespace TracingDB.Forms
InitializeComponent();
ControlBox = false;
UpdateMessageHandler += delegate(object sender, MessageEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<MessageEventArgs>(OnUpdateMessage), sender, args); }
else OnUpdateMessage(sender, args);
};
CloseFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }

View File

@ -99,32 +99,33 @@ namespace TracingDB
{
AllItems = new List<ItemSpec>();
AllItems.Add(new ItemSpec(ItemSpecID.RefRecordID, Strings.RefRecordID, (x, f, p, w) => ((int)x).ToString(), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.TimeStamp, Strings.Time_stamp, (x, f, p, w) => string.IsNullOrEmpty(f) ? ((DateTime)x).ToString() : string.Format(f, (DateTime)x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workstep, Strings.Workstep, (x, f, p, w) => FormatStr(f, ((Workstep)x).Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workplace, Strings.Workplace, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.UserName, Strings.User_name, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Barcode, Strings.Ref_part_barcode, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.RefPartName, Strings.Ref_part_name, (x, f, p, w) => FormatStr(f, ((Workstep)x).ReferencePart.Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode, Strings.Part_barcode, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartName, Strings.Part_name, (x, f, p, w) => FormatStr(f, ((Part)x).Name), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.TimeStamp2, Strings.Time_stamp+"2", (x, f, p, w) => string.IsNullOrEmpty(f) ? ((DateTime)x).ToString() : string.Format(f, (DateTime)x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workstep2, Strings.Workstep + "2", (x, f, p, w) => FormatStr(f, ((Workstep)x).Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workplace2, Strings.Workplace + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.UserName2, Strings.User_name + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Barcode2, Strings.Barcode + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode2, Strings.Part_barcode+"2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.SerialNr, Strings.Serial_nr, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.PurchaseOrder, Strings.Purchase_order, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.TestResult, Strings.Test_result, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.MaxPruefindex, Strings.Tests_count, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.MaxTestindexEx,Strings.Tests_count_and_rslt,(x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.TestBenchId, Strings.Test_bench_Id, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.Process, Strings.Process, (x, f, p, w) => FormatStr(f, ((Process)x).Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.RefRecordID, Strings.RefRecordID, (x, f, p, w) => ((int)x).ToString(), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.TimeStamp, Strings.Time_stamp, (x, f, p, w) => string.IsNullOrEmpty(f) ? ((DateTime)x).ToString() : string.Format(f, (DateTime)x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workstep, Strings.Workstep, (x, f, p, w) => FormatStr(f, x is Workstep ? (x as Workstep).Name : "<null>"), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workplace, Strings.Workplace, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.UserName, Strings.User_name, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Barcode, Strings.Ref_part_barcode, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.RefPartName, Strings.Ref_part_name, (x, f, p, w) => FormatStr(f, ((Workstep)x).ReferencePart.Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode, Strings.Part_barcode, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartName, Strings.Part_name, (x, f, p, w) => FormatStr(f, ((Part)x).Name), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.TimeStamp2, Strings.Time_stamp+"2", (x, f, p, w) => string.IsNullOrEmpty(f) ? ((DateTime)x).ToString() : string.Format(f, (DateTime)x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workstep2, Strings.Workstep + "2", (x, f, p, w) => FormatStr(f, ((Workstep)x).Name), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Workplace2, Strings.Workplace + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.UserName2, Strings.User_name + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Barcode2, Strings.Barcode + "2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode2, Strings.Part_barcode+"2", (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord));
AllItems.Add(new ItemSpec(ItemSpecID.SerialNr, Strings.Serial_nr, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.PurchaseOrder, Strings.Purchase_order, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.TestResult, Strings.Test_result, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.MaxPruefindex, Strings.Tests_count, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.MaxTestindexEx,Strings.Tests_count_and_rslt, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.TestBenchId, Strings.Test_bench_Id, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.Process, Strings.Workflow, (x, f, p, w) => FormatStr(f, x is Process ? (x as Process).Name : "<null>"), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Result, Strings.Result, (x, f, p, w) => FormatStr(f, ((int)x).ToString()), ItemSpecCaps.ReferenceRecord));
}
@ -183,6 +184,7 @@ namespace TracingDB
case ItemSpecID.TestBenchId: return null;
case ItemSpecID.Process: return Projections.Property(() => refRecord.Process);
case ItemSpecID.Result: return Projections.Property(() => refRecord.Result);
default: return null;
}
@ -216,6 +218,7 @@ namespace TracingDB
case ItemSpecID.TestBenchId: return null;
case ItemSpecID.Process: return Projections.Property(() => refRecord2.Process);
case ItemSpecID.Result: return Projections.Property(() => refRecord2.Result);
default: return null;
}

View File

@ -13,7 +13,8 @@ namespace TracingDB.Mappings
Map(x => x.CodeType);
Map(x => x.CodeForm);
Map(x => x.CodeLocation);
Map(x => x.LifetimeManagement);
Map(x => x.DefaultCode);
Map(x => x.LifetimeManagement);
Map(x => x.StepNumber);
References(x => x.Process);

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.0.81.0")]
[assembly: AssemblyFileVersion("2.0.81.0")]
[assembly: AssemblyVersion("2.1.110.0")]
[assembly: AssemblyFileVersion("2.1.110.0")]

View File

@ -249,6 +249,15 @@ namespace TracingDB.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Result.
/// </summary>
internal static string Result {
get {
return ResourceManager.GetString("Result", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Selected results.
/// </summary>
@ -375,6 +384,15 @@ namespace TracingDB.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Workflow.
/// </summary>
internal static string Workflow {
get {
return ResourceManager.GetString("Workflow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Workplace.
/// </summary>

View File

@ -228,4 +228,10 @@
<data name="Test_bench_Id" xml:space="preserve">
<value>Test bench Id</value>
</data>
<data name="Result" xml:space="preserve">
<value>Result</value>
</data>
<data name="Workflow" xml:space="preserve">
<value>Workflow</value>
</data>
</root>

View File

@ -141,4 +141,10 @@
<data name="unsaved" xml:space="preserve">
<value>neuložený</value>
</data>
<data name="Result" xml:space="preserve">
<value>Výsledok</value>
</data>
<data name="Workflow" xml:space="preserve">
<value>Pozícia</value>
</data>
</root>

View File

@ -72,6 +72,7 @@
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\MessageEventArgs.cs" />
<Compile Include="Forms\ModelessForm.cs">
<SubType>Form</SubType>
</Compile>