using System; using System.Collections.Generic; namespace TracingDB.Entities { public class Record { public virtual int Id { get; protected set; } public virtual string Code { get; set; } public virtual DateTime TimeStamp { get; set; } public virtual Part Part { get; set; } public virtual ReferenceRecord ReferenceRecord { get; set; } protected Record() { } /// /// Constructor used when a part barcode is scanned /// /// Part /// Reference record /// Scanned barcode public Record(Part part, ReferenceRecord referenceRecord, string code) { Part = part; ReferenceRecord = referenceRecord; Code = code; TimeStamp = DateTime.Now; } /// /// Create a copy of a process with a new name /// /// /// public virtual Record Clone(Process newProcess, ReferenceRecord newRR) { Part newPart = null; foreach (var pt in newProcess.Parts) { if (Part.Name == pt.Name) { newPart = pt; break; } } Record rslt = new Record(newPart, newRR, Code); rslt.TimeStamp = TimeStamp; return rslt; } public override string ToString() { return string.Format("code={0} part={1}{2} description={3}", Code, Part.Name, string.IsNullOrEmpty(Part.OraDBType) ? string.Empty : string.Format(" ORACLE='{0}'", Part.OraDBType), Part.Description); } } }