TracingDB : Cleaned-up and upgraded to current version, TBF : Workplace registered for approx. 2 weeks.

This commit is contained in:
Milan Hanajik 2019-03-01 14:16:04 +01:00
parent 02f6c9264a
commit 13eb7138a3
29 changed files with 741 additions and 825 deletions

View File

@ -92,7 +92,7 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
"1.2.3.4", "1.2.3.4",
"<multiple>", "<multiple>",
WorkstepName, WorkstepName,
DateTime.Now + new TimeSpan(8, 0, 0)); DateTime.Now + new TimeSpan(15, 0, 0, 0)); /// Test Bench registered for approx. 2. weeks
session.Flush(); session.Flush();
} }
} }

View File

@ -5,9 +5,9 @@ using TracingDB.Entities;
namespace TracingDB namespace TracingDB
{ {
public class BatteryInfo public class BatteryAndFlowtubeInfo
{ {
static readonly ILog log = LogManager.GetLogger(typeof(BatteryInfo)); static readonly ILog log = LogManager.GetLogger(typeof(BatteryAndFlowtubeInfo));
/// Constants /// Constants
public const string VitzrocellBatteryPartNr = "68118221"; public const string VitzrocellBatteryPartNr = "68118221";
@ -18,16 +18,18 @@ namespace TracingDB
public int BattBatchNr; /// Batch number (purchase order) public int BattBatchNr; /// Batch number (purchase order)
public string BattMMYY; /// Production date public string BattMMYY; /// Production date
public string BattSupplier; /// Supplier public string BattSupplier; /// Supplier
public string PrintedBatteryInfo; /// 'T', 'Vi' or '-' public string FlowtubeSapPartNr; /// Flowtube SAP part number
public bool IsPorexFlowtube; ///
public string PrintedInfo; /// 'T', 'Vi', '-', 'T/P', 'Vi/P' or '-/P'
public DateTime TimeStamp; /// Record creation time public DateTime TimeStamp; /// Record creation time
bool complete { get { return (PcbNumber != null) && (BattSapPartNr != null) && (BattBatchNr != 0) && (BattMMYY != null) && (BattSupplier != null); } } bool complete { get { return (PcbNumber != null) && (BattSapPartNr != null) && (BattBatchNr != 0) && (BattMMYY != null) && (BattSupplier != null); } }
public BatteryInfo() public BatteryAndFlowtubeInfo()
{ {
TimeStamp = DateTime.Now; TimeStamp = DateTime.Now;
PrintedBatteryInfo = "-"; PrintedInfo = "-";
} }
@ -35,7 +37,7 @@ namespace TracingDB
/// Search MySQL DB and get battery info, add it into the record. /// Search MySQL DB and get battery info, add it into the record.
/// </summary> /// </summary>
/// <returns>true when successful</returns> /// <returns>true when successful</returns>
public static BatteryInfo GetBatteryInfo(string pcbNumber, IList<Record> records) public static BatteryAndFlowtubeInfo GetBatteryAndFlowtubeInfo(string pcbNumber, IList<WMPart> parts, string porexSapNumbers)
{ {
if (string.IsNullOrEmpty(pcbNumber)) if (string.IsNullOrEmpty(pcbNumber))
{ {
@ -43,38 +45,43 @@ namespace TracingDB
return null; return null;
} }
BatteryInfo info = new BatteryInfo() { PcbNumber = pcbNumber }; BatteryAndFlowtubeInfo info = new BatteryAndFlowtubeInfo() { PcbNumber = pcbNumber };
try try
{ {
bool error = false; bool error = false;
foreach (var rec in records) foreach (var part in parts)
{ {
if (rec.Part.CodeLocation == CodeLocation.OnPallet) if (part.CodeLocation == CodeLocation.OnPart)
{ {
if (rec.Part.Name == VitzrocellBatteryPartNr) if (porexSapNumbers.Contains(part.Name))
{ {
if (info.BattSapPartNr != null) { error = true; break; } info.IsPorexFlowtube = true;
info.BattSapPartNr = VitzrocellBatteryPartNr; info.FlowtubeSapPartNr = part.Name;
int battBatchNr;
info.BattBatchNr = int.TryParse(rec.Code, out battBatchNr) ? battBatchNr : 1;
info.BattSupplier = "VITZROCELL";
}
else if (rec.Part.Name == TadiranBatteryPartNr)
{
if (info.BattSapPartNr != null) { error = true; break; }
info.BattSapPartNr = TadiranBatteryPartNr;
int battBatchNr;
info.BattBatchNr = int.TryParse(rec.Code, out battBatchNr) ? battBatchNr : 1;
info.BattSupplier = "TADIRAN";
} }
} }
if (rec.Part.CodeType == CodeType.DateMMYY) if (!string.IsNullOrEmpty(part.OraDBType))
{
string[] oraItems = part.OraDBType.Split(new char[] { ' ' });
string oraType = oraItems[0];
string oraDescr = (oraItems.Length > 1) ? oraItems[1] : string.Empty;
if ((oraType == "Batt") || (oraType == "Batt1") || (oraType == "Batt2"))
{
if (info.BattSapPartNr != null) { error = true; break; }
info.BattSapPartNr = part.Name;
int battBatchNr;
info.BattBatchNr = int.TryParse(part.Code, out battBatchNr) ? battBatchNr : 1;
info.BattSupplier = oraDescr; /// Should be "TADIRAN" or "VITZROCELL"
}
}
if (part.CodeType == CodeType.DateMMYY)
{ {
if (info.BattMMYY != null) { error = true; break; } if (info.BattMMYY != null) { error = true; break; }
info.BattMMYY = rec.Code; info.BattMMYY = part.Code;
} }
} }
@ -89,13 +96,18 @@ namespace TracingDB
/// ///
if (info.BattSupplier == "VITZROCELL") if (info.BattSupplier == "VITZROCELL")
{ {
info.PrintedBatteryInfo = "Vi"; info.PrintedInfo = "Vi";
} }
else if (info.BattSupplier == "TADIRAN") else if (info.BattSupplier == "TADIRAN")
{ {
info.PrintedBatteryInfo = "T"; info.PrintedInfo = "T";
} }
///
/// Append Porex flowtube info in case of a Porex flowtube
///
if (info.IsPorexFlowtube) { info.PrintedInfo += "/P"; }
return info; return info;
} }
catch (Exception exc) catch (Exception exc)
@ -109,7 +121,7 @@ namespace TracingDB
public override string ToString() public override string ToString()
{ {
return string.Format("PcbNr={0}, Battery={1}/{2}/{3}, Time={4}", PcbNumber, BattBatchNr, BattMMYY, BattSupplier, TimeStamp); return string.Format("PcbNr={0}, Battery={1}/{2}/{3} {4}, Time={5}", PcbNumber, BattBatchNr, BattMMYY, BattSupplier, (IsPorexFlowtube ? "porex" : ""), TimeStamp);
} }
} }
} }

View File

@ -6,6 +6,7 @@ using NHibernate;
using NHibernate.Cfg; using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl; using NHibernate.Tool.hbm2ddl;
using log4net; using log4net;
using TracingDB.Entities;
namespace TracingDB namespace TracingDB
{ {
@ -55,7 +56,7 @@ namespace TracingDB
FluentConfiguration cfg = Fluently FluentConfiguration cfg = Fluently
.Configure() .Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString)) .Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entities.Process>()); .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Process>());
if (createDB) if (createDB)
{ {
@ -114,7 +115,7 @@ namespace TracingDB
{ {
//using (var transaction = session.BeginTransaction()) //using (var transaction = session.BeginTransaction())
//{ //{
// var part1 = new TracingDB.Entities.Part("flow tube", CodeType.UniqueNr, CodeForm.QRCode, 0); // var part1 = new Part("flow tube", CodeType.UniqueNr, CodeForm.QRCode, 0);
// session.SaveOrUpdate(part1); // session.SaveOrUpdate(part1);
// transaction.Commit(); // transaction.Commit();
//} //}

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
namespace TracingDB.Entities
{
public class Option1 : Interfaces.IOption
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OraDBType { get; set; }
public virtual string Description { get; set; }
public virtual CodeType CodeType { get; set; }
public virtual CodeForm CodeForm { get; set; }
public virtual CodeLocation CodeLocation { get; set; }
public virtual LifetimeManagement LifetimeManagement { get; set; }
public virtual bool Enabled { get; set; }
public Option1()
{
Name = string.Empty;
Description = string.Empty;
}
/// <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 GetPart(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 = 0;
rslt.Process = owningProcess;
rslt.Workstep = null;
return rslt;
}
public override string ToString()
{
return string.Format("{0}. {1} ({2})", ItemNr, Name, Description);
}
}
}

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
namespace TracingDB.Entities
{
public class Option2 : Interfaces.IOption
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OraDBType { get; set; }
public virtual string Description { get; set; }
public virtual CodeType CodeType { get; set; }
public virtual CodeForm CodeForm { get; set; }
public virtual CodeLocation CodeLocation { get; set; }
public virtual LifetimeManagement LifetimeManagement { get; set; }
public virtual bool Enabled { get; set; }
public Option2()
{
Name = string.Empty;
Description = string.Empty;
}
/// <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 GetPart(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 = 0;
rslt.Process = owningProcess;
rslt.Workstep = null;
return rslt;
}
public override string ToString()
{
return string.Format("{0}. {1} ({2})", ItemNr, Name, Description);
}
}
}

View File

@ -25,6 +25,14 @@ namespace TracingDB.Entities
Description = string.Empty; Description = string.Empty;
} }
public Part(string name, Process process, string description)
{
Name = name;
Description = description;
Process = process;
Workstep = null;
}
/// <summary> /// <summary>
/// Constructor used when the part is added to a process /// Constructor used when the part is added to a process
/// </summary> /// </summary>
@ -51,9 +59,9 @@ namespace TracingDB.Entities
/// </summary> /// </summary>
/// <param name="process">Process owning the cloned part</param> /// <param name="process">Process owning the cloned part</param>
/// <returns>Cloned part</returns> /// <returns>Cloned part</returns>
public virtual Part Clone(Process owningProcess) public virtual Part Clone(Process owningProcess)
{ {
Part rslt = new Part(); Part rslt = new Part();
rslt.Name = Name; rslt.Name = Name;
rslt.OraDBType = OraDBType; rslt.OraDBType = OraDBType;
@ -61,18 +69,18 @@ namespace TracingDB.Entities
rslt.CodeType = CodeType; rslt.CodeType = CodeType;
rslt.CodeForm = CodeForm; rslt.CodeForm = CodeForm;
rslt.CodeLocation = CodeLocation; rslt.CodeLocation = CodeLocation;
rslt.LifetimeManagement = LifetimeManagement; rslt.LifetimeManagement = LifetimeManagement;
rslt.StepNumber = StepNumber;
rslt.StepNumber = 0;
rslt.Process = owningProcess; rslt.Process = owningProcess;
rslt.Workstep = null; rslt.Workstep = null;
return rslt; return rslt;
} }
public override string ToString() public override string ToString()
{ {
return string.Format("{0} step={1} ({2})", Name, StepNumber, Description); return string.Format("{0} ({1}: {2})", Name, StepNumber, Description);
} }
} }
} }

View File

@ -20,13 +20,43 @@ namespace TracingDB.Entities
public virtual IList<Part> Parts { get; set; } public virtual IList<Part> Parts { get; set; }
public virtual IList<Workstep> Worksteps { get; set; } public virtual IList<Workstep> Worksteps { get; set; }
#region SubClass utilities
/// Wrappers /// Wrappers
public virtual SubClass GetSubClass() { return (SubClass)SubClass; } public virtual SubClass GetSubClass() { return (SubClass)SubClass; }
public virtual void SetSubClass(SubClass subClass) { SubClass = (int)subClass; } public virtual void SetSubClass(SubClass subClass) { SubClass = (int)subClass; }
/// Convert SubClass to string
public static string SubClass2Str(SubClass subClass)
{
return subClass.ToDescription();
}
/// <summary> /// Convert string to SubClass
public static SubClass Str2SubClass(string str)
{
foreach (SubClass sc in Enum.GetValues(typeof(SubClass)))
{
if ((str == sc.ToDescription()) && (sc != TracingDB.SubClass.Invalid)) return sc;
}
return TracingDB.SubClass.Invalid;
}
/// Determine whether string is a valid SubClass name
public static bool IsValidSubClassStr(string str)
{
foreach (SubClass sc in Enum.GetValues(typeof(SubClass)))
{
if ((str == sc.ToDescription()) && (sc != TracingDB.SubClass.Invalid)) return true;
}
return false;
}
#endregion SubClass utilities
/// <summary>
/// Default (private) constructor inicializing lists /// Default (private) constructor inicializing lists
/// </summary> /// </summary>
protected Process() protected Process()
@ -54,21 +84,30 @@ namespace TracingDB.Entities
} }
/// <summary> /// <summary>
/// Create a copy of a process with a new name /// Create a copy of a process with a new name and original 'Created by' user.
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public virtual Process Clone(string name) public virtual Process Clone(string name)
{
return Clone(name, CreatedBy);
}
/// <summary>
/// Create a copy of a process with a new name.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public virtual Process Clone(string name, string userName)
{ {
Process rslt = new Process(name); Process rslt = new Process(name);
rslt.SubClass = SubClass; rslt.SubClass = SubClass;
rslt.Description = Description; rslt.Description = Description;
rslt.ReleaseNotes = ReleaseNotes; rslt.ReleaseNotes = ReleaseNotes;
CreatedBy = "admin"; rslt.CreatedBy = userName;
TimeStamp = DateTime.Now; rslt.TimeStamp = DateTime.Now;
ApprovedBy = string.Empty; rslt.ApprovedBy = string.Empty;
TimeStamp2 = DateTime.Now; rslt.ReleaseStatus = ReleaseStatus.In_preparation;
ReleaseStatus = ReleaseStatus.In_preparation;
foreach (var part in Parts) rslt.Parts.Add(part.Clone(rslt)); foreach (var part in Parts) rslt.Parts.Add(part.Clone(rslt));
foreach (var workstep in Worksteps) rslt.Worksteps.Add(workstep.Clone(rslt)); foreach (var workstep in Worksteps) rslt.Worksteps.Add(workstep.Clone(rslt));
@ -76,9 +115,25 @@ namespace TracingDB.Entities
return rslt; return rslt;
} }
/// <summary>
/// Gets a process with a specified name from a list of processes.
/// </summary>
/// <param name="processes">List of processes (ReleasedActive processs)</param>
/// <param name="processName">Process name</param>
/// <returns>Process or null if not found</returns>
public static Process GetProcessFromName(IList<Process> processes, string processName)
{
foreach (var proc in processes)
{
if (proc.Name == processName) return proc;
}
return null;
}
public override string ToString() public override string ToString()
{ {
return string.IsNullOrEmpty(Name) ? string.Empty : Name; return string.IsNullOrEmpty(Name) ? string.Empty : ((Id != 0) ? Name : string.Format("{0} ({1})", Name, TracingDB.Resources.Strings.unsaved));
} }
} }
} }

View File

@ -55,7 +55,11 @@ namespace TracingDB.Entities
public override string ToString() public override string ToString()
{ {
return string.Format("code={0} part={1} description='{2}'", Code, Part.Name, Part.Description); 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);
} }
} }
} }

View File

@ -33,6 +33,7 @@ namespace TracingDB.Entities
/// <param name="code">Scanned barcode</param> /// <param name="code">Scanned barcode</param>
public ReferenceRecord(Process process, Workstep workstep, string code, public ReferenceRecord(Process process, Workstep workstep, string code,
string userName, string workplace, int result) string userName, string workplace, int result)
: this()
{ {
Process = process; Process = process;
Workstep = workstep; Workstep = workstep;

View File

@ -47,5 +47,10 @@ namespace TracingDB.Entities
this.ProcessName = processName; this.ProcessName = processName;
this.WorkstepName = workstepName; this.WorkstepName = workstepName;
} }
public override string ToString()
{
return string.Format("Name={0} User={1}", Workplace, UserName);
}
} }
} }

View File

@ -9,13 +9,47 @@ namespace TracingDB.Entities
public virtual int WorkstepNr { get; set; } public virtual int WorkstepNr { get; set; }
public virtual string Name { get; set; } public virtual string Name { get; set; }
public virtual string Description { get; set; } public virtual string Description { get; set; }
public virtual int CheckPartNr { get; set; } public virtual int CheckPartNr { get; set; } /// 0 == No previous part checked
public virtual bool AllowRepairs { get; set; } public virtual bool AllowRepairs { get; set; }
public virtual Process Process { get; set; } public virtual Process Process { get; set; }
public virtual Part ReferencePart { get; set; } public virtual Part ReferencePart { get; set; }
public virtual IList<Part> Parts { get; set; } public virtual IList<Part> Parts { get; set; }
public virtual Workstep Clone(Process owningProcess)
{
Workstep rslt = new Workstep(WorkstepNr, Name, owningProcess);
rslt.Description = Description;
rslt.CheckPartNr = CheckPartNr;
rslt.AllowRepairs = AllowRepairs;
if (ReferencePart != null)
{
foreach (var p in owningProcess.Parts)
{
if (p.Name == ReferencePart.Name)
{
rslt.ReferencePart = p;
break;
}
}
}
foreach (var srcP in Parts)
{
foreach (var p in owningProcess.Parts)
{
if ((p.Name == srcP.Name) && (p.StepNumber == srcP.StepNumber))
{
rslt.Parts.Add(p);
p.Workstep = rslt;
}
}
}
return rslt;
}
/// <summary> /// <summary>
/// Default (private) constructor inicializing a list /// Default (private) constructor inicializing a list
@ -42,41 +76,9 @@ namespace TracingDB.Entities
ReferencePart = null; ReferencePart = null;
} }
public virtual Workstep Clone(Process owningProcess)
{
Workstep rslt = new Workstep(WorkstepNr, Name, owningProcess);
rslt.Description = Description;
rslt.CheckPartNr = CheckPartNr;
rslt.AllowRepairs = AllowRepairs;
if (ReferencePart != null)
{
foreach (var p in owningProcess.Parts)
{
if (p.Name == ReferencePart.Name) rslt.ReferencePart = p;
}
}
foreach (var srcP in Parts)
{
foreach (var p in owningProcess.Parts)
{
if (p.Name == srcP.Name)
{
rslt.Parts.Add(p);
p.StepNumber = srcP.StepNumber;
p.Workstep = rslt;
}
}
}
return rslt;
}
public override string ToString() public override string ToString()
{ {
//return string.Format("{0} {1} ({2}) Ref: {3}", WorkstepNr, Name, Description, (ReferencePart != null) ? ReferencePart.Name : "none"); return Name; /// Displayed in Pracovisko.WorkstepDlg.workstepComboBox, Items are Workstep objects
return string.Format("{0}: {1}", WorkstepNr, Name);
} }
} }
} }

View File

@ -38,13 +38,13 @@ namespace TracingDB
public enum CodeType public enum CodeType
{ {
[Description("-")] [Description("")]
UniqueNr, UniqueNr,
[Description("PCB")] [Description("Sap6-8")]
FlowtubeNr, /// prvé 3 znaky sa zhodujú s poslednými 3 znakmi názvu FlowtubeNr, /// prvé 3 znaky sa zhodujú s poslednými 3 znakmi názvu
[Description("Flowt.")] [Description("FT-20")]
FlowtubeNrLU, /// začiatok kódu sa zhoduje s názvom FlowtubeNrLU, /// začiatok kódu sa zhoduje s názvom
[Description("1")] [Description("1")]
@ -143,7 +143,9 @@ namespace TracingDB
Workplace, Workplace,
UserName, UserName,
Barcode, Barcode,
RefPartName,
PartBarcode, PartBarcode,
PartName,
TimeStamp2, TimeStamp2,
Workstep2, Workstep2,
@ -156,6 +158,8 @@ namespace TracingDB
PurchaseOrder, PurchaseOrder,
TestResult, TestResult,
MaxPruefindex, MaxPruefindex,
MaxTestindexEx,
TestBenchId,
Process, Process,
} }

View File

@ -61,6 +61,10 @@ namespace TracingDB.Forms
private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20); private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
#endregion #endregion
public SortOrder SortOrder = SortOrder.None;
public int SortColumn = -1;
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
@ -394,12 +398,18 @@ namespace TracingDB.Forms
OnSubItemEndEditing(e); OnSubItemEndEditing(e);
_editItem.SubItems[_editSubItem].Text = e.DisplayText; if (_editSubItem >= 0 && _editSubItem < _editItem.SubItems.Count)
{
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
}
_editingControl.Leave -= new EventHandler(_editControl_Leave); if (_editingControl != null)
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress); {
_editingControl.Leave -= new EventHandler(_editControl_Leave);
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
_editingControl.Visible = false; _editingControl.Visible = false;
}
_editingControl = null; _editingControl = null;
_editItem = null; _editItem = null;

View File

@ -0,0 +1,104 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TracingDB.Forms
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ListViewExtensions
{
[StructLayout(LayoutKind.Sequential)]
public struct HDITEM
{
public Mask mask;
public int cxy;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszText;
public IntPtr hbm;
public int cchTextMax;
public Format fmt;
public IntPtr lParam;
// _WIN32_IE >= 0x0300
public int iImage;
public int iOrder;
// _WIN32_IE >= 0x0500
public uint type;
public IntPtr pvFilter;
// _WIN32_WINNT >= 0x0600
public uint state;
[Flags]
public enum Mask
{
Format = 0x4, // HDI_FORMAT
};
[Flags]
public enum Format
{
SortDown = 0x200, // HDF_SORTDOWN
SortUp = 0x400, // HDF_SORTUP
};
};
public const int LVM_FIRST = 0x1000;
public const int LVM_GETHEADER = LVM_FIRST + 31;
public const int HDM_FIRST = 0x1200;
public const int HDM_GETITEM = HDM_FIRST + 11;
public const int HDM_SETITEM = HDM_FIRST + 12;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, SortOrder order)
{
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
{
var columnPtr = new IntPtr(columnNumber);
var item = new HDITEM
{
mask = HDITEM.Mask.Format
};
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
if (order != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
item.fmt &= ~HDITEM.Format.SortUp;
item.fmt |= HDITEM.Format.SortDown;
break;
default:
break;
}
}
else
{
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
}
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
}
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace TracingDB.Forms
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
return (order == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace TracingDB.Forms
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
string txtX = ((ListViewItem)x).SubItems[column].Text;
string txtY = ((ListViewItem)y).SubItems[column].Text;
return (order == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}

View File

@ -1,351 +0,0 @@
namespace TracingDB.Forms
{
partial class SettingsDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.connectionStringTextBox = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.workplaceNameTextBox = new System.Windows.Forms.TextBox();
this.saveButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.extraBatteryLifetimeTextBox = new System.Windows.Forms.TextBox();
this.oracleGroupBox = new System.Windows.Forms.GroupBox();
this.checkPcbIsInOracleCheckBox = new System.Windows.Forms.CheckBox();
this.oracleBatteryCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.usersDBConnStringTextBox = new System.Windows.Forms.TextBox();
this.timeGroupBox = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.timePicker3 = new System.Windows.Forms.DateTimePicker();
this.timePicker2 = new System.Windows.Forms.DateTimePicker();
this.timePicker1 = new System.Windows.Forms.DateTimePicker();
this.processFilterGroupBox = new System.Windows.Forms.GroupBox();
this.processFilterComboBox = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.oracleGroupBox.SuspendLayout();
this.groupBox5.SuspendLayout();
this.timeGroupBox.SuspendLayout();
this.processFilterGroupBox.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.connectionStringTextBox);
this.groupBox1.Location = new System.Drawing.Point(12, 69);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(622, 50);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection string pre záznamy z výroby";
//
// connectionStringTextBox
//
this.connectionStringTextBox.Location = new System.Drawing.Point(17, 18);
this.connectionStringTextBox.Name = "connectionStringTextBox";
this.connectionStringTextBox.Size = new System.Drawing.Size(586, 20);
this.connectionStringTextBox.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButton2);
this.groupBox2.Controls.Add(this.radioButton1);
this.groupBox2.Location = new System.Drawing.Point(12, 250);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(222, 70);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Režim činnosti";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(95, 41);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(58, 17);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Výroba";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(95, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(46, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Test";
this.radioButton1.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.workplaceNameTextBox);
this.groupBox3.Location = new System.Drawing.Point(12, 12);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(300, 50);
this.groupBox3.TabIndex = 0;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Meno pracoviska";
//
// workplaceNameTextBox
//
this.workplaceNameTextBox.Location = new System.Drawing.Point(17, 18);
this.workplaceNameTextBox.Name = "workplaceNameTextBox";
this.workplaceNameTextBox.Size = new System.Drawing.Size(265, 20);
this.workplaceNameTextBox.TabIndex = 0;
//
// saveButton
//
this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.saveButton.Location = new System.Drawing.Point(400, 270);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(104, 42);
this.saveButton.TabIndex = 6;
this.saveButton.Text = "Uložiť";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// cancelButton
//
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelButton.Location = new System.Drawing.Point(523, 270);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(104, 42);
this.cancelButton.TabIndex = 7;
this.cancelButton.Text = "Zrušiť";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.extraBatteryLifetimeTextBox);
this.groupBox4.Location = new System.Drawing.Point(12, 182);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(222, 62);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Predĺženie životnosti baterky v mesiacoch";
//
// extraBatteryLifetimeTextBox
//
this.extraBatteryLifetimeTextBox.Location = new System.Drawing.Point(17, 25);
this.extraBatteryLifetimeTextBox.Name = "extraBatteryLifetimeTextBox";
this.extraBatteryLifetimeTextBox.Size = new System.Drawing.Size(191, 20);
this.extraBatteryLifetimeTextBox.TabIndex = 0;
//
// oracleGroupBox
//
this.oracleGroupBox.Controls.Add(this.checkPcbIsInOracleCheckBox);
this.oracleGroupBox.Controls.Add(this.oracleBatteryCheckBox);
this.oracleGroupBox.Location = new System.Drawing.Point(384, 182);
this.oracleGroupBox.Name = "oracleGroupBox";
this.oracleGroupBox.Size = new System.Drawing.Size(249, 74);
this.oracleGroupBox.TabIndex = 5;
this.oracleGroupBox.TabStop = false;
this.oracleGroupBox.Text = "Oracle";
this.oracleGroupBox.Visible = false;
//
// checkPcbIsInOracleCheckBox
//
this.checkPcbIsInOracleCheckBox.AutoSize = true;
this.checkPcbIsInOracleCheckBox.Location = new System.Drawing.Point(18, 45);
this.checkPcbIsInOracleCheckBox.Name = "checkPcbIsInOracleCheckBox";
this.checkPcbIsInOracleCheckBox.Size = new System.Drawing.Size(213, 17);
this.checkPcbIsInOracleCheckBox.TabIndex = 0;
this.checkPcbIsInOracleCheckBox.Text = "Skontrolovať či PCB už bola overovaná";
this.checkPcbIsInOracleCheckBox.UseVisualStyleBackColor = true;
//
// oracleBatteryCheckBox
//
this.oracleBatteryCheckBox.AutoSize = true;
this.oracleBatteryCheckBox.Location = new System.Drawing.Point(18, 19);
this.oracleBatteryCheckBox.Name = "oracleBatteryCheckBox";
this.oracleBatteryCheckBox.Size = new System.Drawing.Size(193, 17);
this.oracleBatteryCheckBox.TabIndex = 0;
this.oracleBatteryCheckBox.Text = "Uložiť informácie o batérii do Oracle";
this.oracleBatteryCheckBox.UseVisualStyleBackColor = true;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.usersDBConnStringTextBox);
this.groupBox5.Location = new System.Drawing.Point(12, 125);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(622, 50);
this.groupBox5.TabIndex = 2;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Connection string pre centrálnu databázu používateľov";
//
// usersDBConnStringTextBox
//
this.usersDBConnStringTextBox.Location = new System.Drawing.Point(17, 18);
this.usersDBConnStringTextBox.Name = "usersDBConnStringTextBox";
this.usersDBConnStringTextBox.Size = new System.Drawing.Size(586, 20);
this.usersDBConnStringTextBox.TabIndex = 0;
//
// timeGroupBox
//
this.timeGroupBox.Controls.Add(this.label1);
this.timeGroupBox.Controls.Add(this.timePicker3);
this.timeGroupBox.Controls.Add(this.timePicker2);
this.timeGroupBox.Controls.Add(this.timePicker1);
this.timeGroupBox.Location = new System.Drawing.Point(240, 181);
this.timeGroupBox.Name = "timeGroupBox";
this.timeGroupBox.Size = new System.Drawing.Size(138, 140);
this.timeGroupBox.TabIndex = 8;
this.timeGroupBox.TabStop = false;
this.timeGroupBox.Text = "Čas odlogovania";
this.timeGroupBox.Visible = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(106, 13);
this.label1.TabIndex = 3;
this.label1.Text = "00:00 = neodlogovať";
//
// timePicker3
//
this.timePicker3.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.timePicker3.Location = new System.Drawing.Point(19, 98);
this.timePicker3.Name = "timePicker3";
this.timePicker3.Size = new System.Drawing.Size(98, 20);
this.timePicker3.TabIndex = 2;
//
// timePicker2
//
this.timePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.timePicker2.Location = new System.Drawing.Point(19, 72);
this.timePicker2.Name = "timePicker2";
this.timePicker2.Size = new System.Drawing.Size(98, 20);
this.timePicker2.TabIndex = 1;
//
// timePicker1
//
this.timePicker1.AllowDrop = true;
this.timePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.timePicker1.Location = new System.Drawing.Point(19, 46);
this.timePicker1.Name = "timePicker1";
this.timePicker1.Size = new System.Drawing.Size(98, 20);
this.timePicker1.TabIndex = 0;
//
// processFilterGroupBox
//
this.processFilterGroupBox.Controls.Add(this.processFilterComboBox);
this.processFilterGroupBox.Location = new System.Drawing.Point(334, 12);
this.processFilterGroupBox.Name = "processFilterGroupBox";
this.processFilterGroupBox.Size = new System.Drawing.Size(300, 50);
this.processFilterGroupBox.TabIndex = 9;
this.processFilterGroupBox.TabStop = false;
this.processFilterGroupBox.Text = "Filter procesov";
this.processFilterGroupBox.Visible = false;
//
// processFilterComboBox
//
this.processFilterComboBox.FormattingEnabled = true;
this.processFilterComboBox.Location = new System.Drawing.Point(20, 17);
this.processFilterComboBox.Name = "processFilterComboBox";
this.processFilterComboBox.Size = new System.Drawing.Size(261, 21);
this.processFilterComboBox.TabIndex = 0;
//
// SettingsDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(648, 333);
this.Controls.Add(this.processFilterGroupBox);
this.Controls.Add(this.timeGroupBox);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.oracleGroupBox);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "SettingsDlg";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "SettingsDlg";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.oracleGroupBox.ResumeLayout(false);
this.oracleGroupBox.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.timeGroupBox.ResumeLayout(false);
this.timeGroupBox.PerformLayout();
this.processFilterGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox connectionStringTextBox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox workplaceNameTextBox;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox extraBatteryLifetimeTextBox;
private System.Windows.Forms.GroupBox oracleGroupBox;
private System.Windows.Forms.CheckBox oracleBatteryCheckBox;
private System.Windows.Forms.CheckBox checkPcbIsInOracleCheckBox;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.TextBox usersDBConnStringTextBox;
private System.Windows.Forms.GroupBox timeGroupBox;
private System.Windows.Forms.DateTimePicker timePicker3;
private System.Windows.Forms.DateTimePicker timePicker2;
private System.Windows.Forms.DateTimePicker timePicker1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox processFilterGroupBox;
private System.Windows.Forms.ComboBox processFilterComboBox;
}
}

View File

@ -1,177 +0,0 @@
using System;
using System.Windows.Forms;
namespace TracingDB.Forms
{
public partial class SettingsDlg : Form
{
static readonly DateTime MinTime = new DateTime(1753, 1, 1, 0, 0, 0);
public string WorkplaceName
{
set { workplaceNameTextBox.Text = value; }
get { return workplaceNameTextBox.Text; }
}
public int ProcessFilter
{
set
{
if ((value & (int)SubClass.Normal) != 0 &&
(value & (int)SubClass.FlowTube) != 0 &&
(value & (int)SubClass.InheritsFlowTube) != 0)
{
processFilterComboBox.Text = "všetky";
}
else if ((value & (int)SubClass.FlowTube) != 0)
{
processFilterComboBox.Text = "flowtuby";
}
else if ((value & (int)SubClass.InheritsFlowTube) != 0)
{
processFilterComboBox.Text = "vodomery odvodene z flowtuby";
}
else /// if ((value & (int)SubClass.Normal) != 0)
{
processFilterComboBox.Text = "vodomery";
}
}
get
{
if (processFilterComboBox.Text == "všetky")
{
return (int)SubClass.Normal +
(int)SubClass.NormalWithoutPCB +
(int)SubClass.FlowTube +
(int)SubClass.InheritsFlowTube +
(int)SubClass.InheritsFlowTubeWithoutPCB;
}
else if (processFilterComboBox.Text == "flowtuby")
{
return (int)SubClass.FlowTube;
}
else if (processFilterComboBox.Text == "vodomery odvodene z flowtuby")
{
return (int)SubClass.InheritsFlowTube;
}
else /// if (processFilterComboBox.Text == "vodomery")
{
return (int)SubClass.Normal;
}
}
}
public string ConnectionString
{
set { connectionStringTextBox.Text = value; }
get { return connectionStringTextBox.Text; }
}
public string UsersDBConnString
{
set { usersDBConnStringTextBox.Text = value; }
get { return usersDBConnStringTextBox.Text; }
}
public bool OracleBattery
{
set { oracleBatteryCheckBox.Checked = value; }
get { return oracleBatteryCheckBox.Checked; }
}
public bool CheckPcbIsInOracle
{
set { checkPcbIsInOracleCheckBox.Checked = value; }
get { return checkPcbIsInOracleCheckBox.Checked; }
}
public int ExtraBatterLifetime
{
get
{
int extraLifetime;
if (int.TryParse(extraBatteryLifetimeTextBox.Text, out extraLifetime) && extraLifetime >= 0) return extraLifetime;
return 0;
}
}
public TracingDB.Mode Mode
{
set
{
radioButton1.Checked = (value == TracingDB.Mode.Test);
radioButton2.Checked = (value == TracingDB.Mode.Production);
}
get
{
return radioButton1.Checked ? TracingDB.Mode.Test : TracingDB.Mode.Production;
}
}
public DateTime LogoutTime1
{
get { return timePicker1.Value; }
set { timePicker1.Value = (value.CompareTo(MinTime) < 0) ? MinTime : value; }
}
public DateTime LogoutTime2
{
get { return timePicker2.Value; }
set { timePicker2.Value = (value.CompareTo(MinTime) < 0) ? MinTime : value; }
}
public DateTime LogoutTime3
{
get { return timePicker3.Value; }
set { timePicker3.Value = (value.CompareTo(MinTime) < 0) ? MinTime : value; }
}
/// <summary>
/// Basic configuration dialog
/// </summary>
/// <param name="isWorkplace">false = Konfiguracia pracovisk, true = Pracovisko</param>
public SettingsDlg(bool isWorkplace)
{
InitializeComponent();
if (isWorkplace)
{
oracleGroupBox.Visible = true;
timeGroupBox.Visible = true;
processFilterGroupBox.Visible = true;
processFilterComboBox.Items.Add("všetky");
processFilterComboBox.Items.Add("vodomery");
processFilterComboBox.Items.Add("vodomery odvodene z flowtuby");
processFilterComboBox.Items.Add("flowtuby");
}
extraBatteryLifetimeTextBox.Text = "0";
timePicker1.Format = DateTimePickerFormat.Custom;
timePicker1.CustomFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
timePicker2.Format = DateTimePickerFormat.Custom;
timePicker2.CustomFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
timePicker3.Format = DateTimePickerFormat.Custom;
timePicker3.CustomFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
}
private void saveButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
namespace TracingDB.Interfaces
{
public interface IOption
{
int Id { get; }
int ItemNr { get; set; }
string Name { get; set; }
string OraDBType { get; set; }
string Description { get; set; }
CodeType CodeType { get; set; }
CodeForm CodeForm { get; set; }
CodeLocation CodeLocation { get; set; }
LifetimeManagement LifetimeManagement { get; set; }
bool Enabled { get; set; }
Entities.Part GetPart(Entities.Process owningProcess);
}
}

View File

@ -50,6 +50,11 @@ namespace TracingDB
Width = 0; Width = 0;
} }
public override string ToString()
{
return string.Format("uid={0}, name={1}, caption={2}", Uid, Name, Caption);
}
/// <summary> Copy constructor </summary> /// <summary> Copy constructor </summary>
public ItemSpec Clone() public ItemSpec Clone()
{ {
@ -94,26 +99,30 @@ namespace TracingDB
{ {
AllItems = new List<ItemSpec>(); 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.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.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.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.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.UserName, Strings.User_name, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord));
AllItems.Add(new ItemSpec(ItemSpecID.Barcode, Strings.Barcode, (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.PartBarcode, Strings.Part_barcode, (x, f, p, w) => FormatStr(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord)); 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.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.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.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.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.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.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.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.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.TestResult, Strings.Test_result, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery));
AllItems.Add(new ItemSpec(ItemSpecID.MaxPruefindex, Strings.Max_pruefindex, (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.Process, Strings.Process, (x, f, p, w) => FormatStr(f, ((Process)x).Name), ItemSpecCaps.ReferenceRecord));
} }
@ -155,7 +164,9 @@ namespace TracingDB
case ItemSpecID.Workplace: return Projections.Property(() => refRecord.Workplace); case ItemSpecID.Workplace: return Projections.Property(() => refRecord.Workplace);
case ItemSpecID.UserName: return Projections.Property(() => refRecord.UserName); case ItemSpecID.UserName: return Projections.Property(() => refRecord.UserName);
case ItemSpecID.Barcode: return Projections.Property(() => refRecord.Code); case ItemSpecID.Barcode: return Projections.Property(() => refRecord.Code);
case ItemSpecID.RefPartName: return Projections.Property(() => refRecord.Workstep);
case ItemSpecID.PartBarcode: return Projections.Property(() => record.Code); case ItemSpecID.PartBarcode: return Projections.Property(() => record.Code);
case ItemSpecID.PartName: return Projections.Property(() => record.Part);
case ItemSpecID.TimeStamp2: return null; case ItemSpecID.TimeStamp2: return null;
case ItemSpecID.Workstep2: return null; case ItemSpecID.Workstep2: return null;
@ -168,6 +179,8 @@ namespace TracingDB
case ItemSpecID.PurchaseOrder: return null; case ItemSpecID.PurchaseOrder: return null;
case ItemSpecID.TestResult: return null; case ItemSpecID.TestResult: return null;
case ItemSpecID.MaxPruefindex: return null; case ItemSpecID.MaxPruefindex: return null;
case ItemSpecID.MaxTestindexEx: return null;
case ItemSpecID.TestBenchId: return null;
case ItemSpecID.Process: return Projections.Property(() => refRecord.Process); case ItemSpecID.Process: return Projections.Property(() => refRecord.Process);
@ -199,6 +212,8 @@ namespace TracingDB
case ItemSpecID.PurchaseOrder: return null; case ItemSpecID.PurchaseOrder: return null;
case ItemSpecID.TestResult: return null; case ItemSpecID.TestResult: return null;
case ItemSpecID.MaxPruefindex: return null; case ItemSpecID.MaxPruefindex: return null;
case ItemSpecID.MaxTestindexEx: return null;
case ItemSpecID.TestBenchId: return null;
case ItemSpecID.Process: return Projections.Property(() => refRecord2.Process); case ItemSpecID.Process: return Projections.Property(() => refRecord2.Process);

View File

@ -1,21 +0,0 @@
using FluentNHibernate.Mapping;
namespace TracingDB.Mappings
{
class Option1Map : ClassMap<Entities.Option1>
{
public Option1Map()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.OraDBType);
Map(x => x.Description);
Map(x => x.CodeType);
Map(x => x.CodeForm);
Map(x => x.CodeLocation);
Map(x => x.LifetimeManagement);
Map(x => x.Enabled);
}
}
}

View File

@ -1,21 +0,0 @@
using FluentNHibernate.Mapping;
namespace TracingDB.Mappings
{
class Option2Map : ClassMap<Entities.Option2>
{
public Option2Map()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.OraDBType);
Map(x => x.Description);
Map(x => x.CodeType);
Map(x => x.CodeForm);
Map(x => x.CodeLocation);
Map(x => x.LifetimeManagement);
Map(x => x.Enabled);
}
}
}

View File

@ -23,7 +23,7 @@ namespace TracingDB.Mappings
Map(x => x.ReleaseStatus); Map(x => x.ReleaseStatus);
HasMany(x => x.Parts) HasMany(x => x.Parts)
.OrderBy("Name") .OrderBy("StepNumber")
.Cascade.All(); .Cascade.All();
HasMany(x => x.Worksteps) HasMany(x => x.Worksteps)

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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.65.0")] [assembly: AssemblyVersion("2.0.81.0")]
[assembly: AssemblyFileVersion("2.0.65.0")] [assembly: AssemblyFileVersion("2.0.81.0")]

View File

@ -160,7 +160,7 @@ namespace TracingDB.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Another part barcode. /// Looks up a localized string similar to Another part barcode (s/n).
/// </summary> /// </summary>
internal static string Part_barcode { internal static string Part_barcode {
get { get {
@ -168,6 +168,15 @@ namespace TracingDB.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Another part name (SAP nr.).
/// </summary>
internal static string Part_name {
get {
return ResourceManager.GetString("Part_name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Precision. /// Looks up a localized string similar to Precision.
/// </summary> /// </summary>
@ -195,6 +204,24 @@ namespace TracingDB.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Ref. part barcode (s/n).
/// </summary>
internal static string Ref_part_barcode {
get {
return ResourceManager.GetString("Ref_part_barcode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Ref. part name (SAP nr.).
/// </summary>
internal static string Ref_part_name {
get {
return ResourceManager.GetString("Ref_part_name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Record ID. /// Looks up a localized string similar to Record ID.
/// </summary> /// </summary>
@ -258,6 +285,15 @@ namespace TracingDB.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Test bench Id.
/// </summary>
internal static string Test_bench_Id {
get {
return ResourceManager.GetString("Test_bench_Id", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Test result. /// Looks up a localized string similar to Test result.
/// </summary> /// </summary>
@ -267,6 +303,24 @@ namespace TracingDB.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Tests count.
/// </summary>
internal static string Tests_count {
get {
return ResourceManager.GetString("Tests_count", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Tests count (negative when NOK).
/// </summary>
internal static string Tests_count_and_rslt {
get {
return ResourceManager.GetString("Tests_count_and_rslt", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Text. /// Looks up a localized string similar to Text.
/// </summary> /// </summary>
@ -285,6 +339,15 @@ namespace TracingDB.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to unsaved.
/// </summary>
internal static string unsaved {
get {
return ResourceManager.GetString("unsaved", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Up. /// Looks up a localized string similar to Up.
/// </summary> /// </summary>

View File

@ -151,7 +151,7 @@
<value>OK</value> <value>OK</value>
</data> </data>
<data name="Part_barcode" xml:space="preserve"> <data name="Part_barcode" xml:space="preserve">
<value>Another part barcode</value> <value>Another part barcode (s/n)</value>
</data> </data>
<data name="Precision" xml:space="preserve"> <data name="Precision" xml:space="preserve">
<value>Precision</value> <value>Precision</value>
@ -192,6 +192,9 @@
<data name="Time_stamp" xml:space="preserve"> <data name="Time_stamp" xml:space="preserve">
<value>Time stamp</value> <value>Time stamp</value>
</data> </data>
<data name="unsaved" xml:space="preserve">
<value>unsaved</value>
</data>
<data name="UpBtnText" xml:space="preserve"> <data name="UpBtnText" xml:space="preserve">
<value>Up</value> <value>Up</value>
</data> </data>
@ -207,4 +210,22 @@
<data name="Workstep" xml:space="preserve"> <data name="Workstep" xml:space="preserve">
<value>Workstep</value> <value>Workstep</value>
</data> </data>
<data name="Ref_part_barcode" xml:space="preserve">
<value>Ref. part barcode (s/n)</value>
</data>
<data name="Ref_part_name" xml:space="preserve">
<value>Ref. part name (SAP nr.)</value>
</data>
<data name="Part_name" xml:space="preserve">
<value>Another part name (SAP nr.)</value>
</data>
<data name="Tests_count" xml:space="preserve">
<value>Tests count</value>
</data>
<data name="Tests_count_and_rslt" xml:space="preserve">
<value>Tests count (negative when NOK)</value>
</data>
<data name="Test_bench_Id" xml:space="preserve">
<value>Test bench Id</value>
</data>
</root> </root>

View File

@ -117,4 +117,28 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Part_barcode" xml:space="preserve">
<value>Kód inej súčiastky (s/n)</value>
</data>
<data name="Part_name" xml:space="preserve">
<value>Meno inej súčiastky (SAP č.)</value>
</data>
<data name="Ref_part_barcode" xml:space="preserve">
<value>Kód ref. súčiastky (s/n)</value>
</data>
<data name="Ref_part_name" xml:space="preserve">
<value>Meno ref. súčiastky (SAP č.)</value>
</data>
<data name="Tests_count" xml:space="preserve">
<value>Počet testovaní</value>
</data>
<data name="Tests_count_and_rslt" xml:space="preserve">
<value>Počet testovaní (záporný ak je NOK)</value>
</data>
<data name="Test_bench_Id" xml:space="preserve">
<value>ID overovacej stanice</value>
</data>
<data name="unsaved" xml:space="preserve">
<value>neuložený</value>
</data>
</root> </root>

View File

@ -61,13 +61,14 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BatteryInfo.cs" /> <Compile Include="BatteryAndFlowtubeInfo.cs" />
<Compile Include="Entities\Option1.cs" />
<Compile Include="Entities\Option2.cs" />
<Compile Include="Entities\WorkplaceRegistration.cs" /> <Compile Include="Entities\WorkplaceRegistration.cs" />
<Compile Include="Forms\ListViewEx.cs"> <Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\ModelessForm.cs"> <Compile Include="Forms\ModelessForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -80,16 +81,7 @@
<Compile Include="Forms\ResultsConfigDlg.designer.cs"> <Compile Include="Forms\ResultsConfigDlg.designer.cs">
<DependentUpon>ResultsConfigDlg.cs</DependentUpon> <DependentUpon>ResultsConfigDlg.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\SettingsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SettingsDlg.designer.cs">
<DependentUpon>SettingsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Interfaces\IOption.cs" />
<Compile Include="ItemSpec.cs" /> <Compile Include="ItemSpec.cs" />
<Compile Include="Mappings\Option1Map.cs" />
<Compile Include="Mappings\Option2Map.cs" />
<Compile Include="Mappings\WorkplaceRegistrationMap.cs" /> <Compile Include="Mappings\WorkplaceRegistrationMap.cs" />
<Compile Include="QuitAppException.cs" /> <Compile Include="QuitAppException.cs" />
<Compile Include="Resources\Strings.Designer.cs"> <Compile Include="Resources\Strings.Designer.cs">
@ -118,6 +110,7 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="WPlaceRegistrationMgmt.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Forms\ListViewEx.resx"> <EmbeddedResource Include="Forms\ListViewEx.resx">
@ -129,9 +122,6 @@
<EmbeddedResource Include="Forms\ResultsConfigDlg.resx"> <EmbeddedResource Include="Forms\ResultsConfigDlg.resx">
<DependentUpon>ResultsConfigDlg.cs</DependentUpon> <DependentUpon>ResultsConfigDlg.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\SettingsDlg.resx">
<DependentUpon>SettingsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -140,11 +130,18 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput> <LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Resources\Strings.sk.resx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RecordProcessing\RecordProcessing.csproj">
<Project>{67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}</Project>
<Name>RecordProcessing</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -0,0 +1,226 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using log4net;
namespace TracingDB
{
public class WPlaceRegistrationMgmt
{
static readonly ILog log = LogManager.GetLogger(typeof(WPlaceRegistrationMgmt));
string workplace; /// Workplace ID string
string user; /// User name
string ipAddress; /// IP address of the workplace (not implemented now)
string processName; /// Process name
string workstepName; /// Workstep name
DateTime valiUntil; /// End of validity of this registration
/// <summary>
/// Constructor without registering a workplace. Use UpdateRegistration() to register a workplace.
/// </summary>
public WPlaceRegistrationMgmt()
{
}
/// <summary>
/// Constructor that registers a workplace.
/// </summary>
/// <param name="session">MySQL DB session</param>
/// <param name="workplace">Workplace name</param>
/// <param name="user">User name</param>
/// <param name="ipAddress">IP address</param>
/// <param name="processName">Process name</param>
/// <param name="workstepName">Workstep name</param>
/// <param name="valiUntil">Registration is valid until this DateTime</param>
public WPlaceRegistrationMgmt(ISession session, string workplace, string user, string ipAddress, string processName, string workstepName, DateTime valiUntil)
{
if (RegisterWorkplace(session, workplace, user, ipAddress, processName, workstepName, valiUntil))
{
this.workplace = workplace;
this.user = user;
this.ipAddress = ipAddress;
this.processName = processName;
this.workstepName = workstepName;
this.valiUntil = valiUntil;
}
}
/// <summary>
/// Compares associated information and registers a workplace if anything changed.
/// </summary>
/// <param name="session">MySQL DB session</param>
/// <param name="workplace">Workplace name</param>
/// <param name="user">User name</param>
/// <param name="ipAddress">IP address</param>
/// <param name="processName">Process name</param>
/// <param name="workstepName">Workstep name</param>
/// <param name="valiUntil">Registration is valid until this DateTime</param>
/// <returns>true when successful</returns>
public bool UpdateRegistration(ISession session, string workplace, string user, string ipAddress, string processName, string workstepName, DateTime valiUntil)
{
if (this.workplace != workplace)
{
/// Workplace name changed -> Unregister and register with a new name
if (!UnregisterWorkplace(session, this.workplace)) return false;
if (RegisterWorkplace(session, workplace, user, ipAddress, processName, workstepName, valiUntil))
{
this.workplace = workplace;
this.user = user;
this.ipAddress = ipAddress;
this.processName = processName;
this.workstepName = workstepName;
this.valiUntil = valiUntil;
return true; /// Registration successful
}
else
{
return false; /// Registration failed
}
}
else if (this.user != user || this.ipAddress != ipAddress || this.processName != processName || this.workstepName != workstepName)
{
/// Anythig else changed -> Update registration
if (RegisterWorkplace(session, workplace, user, ipAddress, processName, workstepName, valiUntil))
{
this.workplace = workplace;
this.user = user;
this.ipAddress = ipAddress;
this.processName = processName;
this.workstepName = workstepName;
this.valiUntil = valiUntil;
return true; /// Registration successful
}
else
{
return false; /// Registration failed
}
}
else
{
return true; /// Already registered with identical associated info
}
}
/// <summary>
/// Unregisters a workplace.
/// </summary>
/// <param name="session">MySQL DB session</param>
/// <returns>true when successful</returns>
public bool UnregisterWorkplace(ISession session)
{
if (UnregisterWorkplace(session, this.workplace))
{
this.workplace = string.Empty;
return true;
}
else
{
return false;
}
}
/// <summary>
/// Register a workplace. Provide associated information.
/// </summary>
/// <param name="session">MySQL DB session</param>
/// <param name="workplace">Workplace name</param>
/// <param name="user">User name</param>
/// <param name="ipAddress">IP address</param>
/// <param name="processName">Process name</param>
/// <param name="workstepName">Workstep name</param>
/// <param name="valiUntil">Registration is valid until this DateTime</param>
/// <returns>true when successful</returns>
static bool RegisterWorkplace(ISession session, string workplace, string user, string ipAddress, string processName, string workstepName, DateTime valiUntil)
{
try
{
IList<Entities.WorkplaceRegistration> wpRegs = session
.QueryOver<Entities.WorkplaceRegistration>()
.Where(x => (x.Workplace == workplace))
.List();
if (wpRegs.Count == 0)
{
Entities.WorkplaceRegistration wpReg = new Entities.WorkplaceRegistration(workplace, user, ipAddress, processName, workstepName);
wpRegs.Add(wpReg);
session.SaveOrUpdate(wpReg);
log.InfoFormat("RegisterWorkplace(., {0}, {1}, ...) successful (new)", workplace, user);
return true;
}
else if (wpRegs.Count == 1)
{
Entities.WorkplaceRegistration wpReg = wpRegs[0];
wpReg.Active = true;
wpReg.TimeStamp = DateTime.Now;
wpReg.ValidUntil = DateTime.Now + new TimeSpan(8, 0, 0);
wpReg.UserName = user;
wpReg.IPAddress = ipAddress;
wpReg.ProcessName = processName;
wpReg.WorkstepName = workstepName;
session.SaveOrUpdate(wpReg);
session.Flush();
log.InfoFormat("RegisterWorkplace(., {0}, {1}, ...) successful", workplace, user);
return true;
}
else
{
log.ErrorFormat("RegisterWorkplace(., {0}, {1}, ...) failed", workplace, user);
return false;
}
}
catch (Exception e)
{
log.ErrorFormat("RegisterWorkplace(., {0}, {1}, ...) exception: {2}", workplace, user, e.Message);
return false;
}
}
/// <summary>
/// Unregister a workplace.
/// </summary>
/// <param name="session">MySQL DB session</param>
/// <param name="workplace">Workplace name</param>
/// <returns>true when successful</returns>
public static bool UnregisterWorkplace(ISession session, string workplace)
{
if (workplace == null) return true; /// no workplace => unregistration successful
try
{
IList<Entities.WorkplaceRegistration> wpRegs = session
.QueryOver<Entities.WorkplaceRegistration>()
.Where(x => (x.Workplace == workplace))
.List();
if (wpRegs.Count == 1)
{
Entities.WorkplaceRegistration wpReg = wpRegs[0];
wpReg.Active = false;
wpReg.TimeStamp = DateTime.Now;
session.SaveOrUpdate(wpReg);
session.Flush();
log.InfoFormat("UnregisterWorkplace(., {0}) successful", workplace);
return true;
}
else
{
log.ErrorFormat("UnregisterWorkplace(., {0}) failed", workplace);
return false;
}
}
catch (Exception e)
{
log.ErrorFormat("UnregisterWorkplace(., {0}) exception: {1}", workplace, e.Message);
return false;
}
}
}
}