63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
///
|
|
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using MySql.Data.MySqlClient;
|
|
using TracingDB;
|
|
|
|
namespace TBF.BenchControl.Output.DB.ProductionTracing
|
|
{
|
|
public class WMPart
|
|
{
|
|
public string Name;
|
|
public int ProcessId;
|
|
public string OraDBType;
|
|
public string Description;
|
|
public string Code;
|
|
public DateTime TimeStamp;
|
|
public TracingDB.CodeType CodeType;
|
|
public TracingDB.CodeForm CodeForm;
|
|
public TracingDB.CodeLocation CodeLocation;
|
|
public string UserName;
|
|
public string Workplace;
|
|
|
|
public WMPart() {}
|
|
|
|
public static IList<WMPart> FindWMParts(MySqlConnection dbConn, string pcbNumber)
|
|
{
|
|
IList<WMPart> foundParts = new List<WMPart>(); /// initially empty
|
|
|
|
if (string.IsNullOrEmpty(pcbNumber)) return foundParts; /// return an empty list
|
|
|
|
try
|
|
{
|
|
dbConn.Open();
|
|
|
|
//IList<Entities.ReferenceRecord> referenceRecords = session
|
|
// .QueryOver<Entities.ReferenceRecord>()
|
|
// .Where(x => (x.Code == pcbNumber))
|
|
// .OrderBy(x => x.TimeStamp).Desc
|
|
// .List<Entities.ReferenceRecord>();
|
|
|
|
MySqlCommand cmd = dbConn.CreateCommand();
|
|
cmd.CommandText = string.Format("SELECT Id, TimeStamp, UserName, Workplace, Result, Process_id, Workstep_id FROM ReferenceRecord WHERE Code = {0}", pcbNumber);
|
|
cmd.ExecuteNonQuery();
|
|
|
|
MySqlDataReader dr = cmd.ExecuteReader();
|
|
while (dr.Read())
|
|
{
|
|
foundParts.Add( new WMPart() { Code = pcbNumber, ProcessId = dr.GetInt32(5), /* etc */ } );
|
|
}
|
|
dr.Close();
|
|
cmd.Dispose();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
return foundParts;
|
|
}
|
|
}
|
|
}
|