From fa818c5cf85a8f0334870c2f087b7d6c00227679 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 28 Aug 2018 09:58:58 +0200 Subject: [PATCH] TracingDB : WorkplaceRegistration, etc. added, TrivialLoginDlg removed, ver. 1.5.61 --> 2.0.65 --- .../DB/ProductionMonitoring/Monitoring.cs | 2 +- TracingDB/{FluentNH.cs => DB.cs} | 87 ++++++++++++- TracingDB/Entities/Process.cs | 46 ++++--- TracingDB/Entities/WorkplaceRegistration.cs | 51 ++++++++ TracingDB/Enums.cs | 93 ++++++++++++-- TracingDB/Forms/SettingsDlg.Designer.cs | 46 +++++-- TracingDB/Forms/SettingsDlg.cs | 58 +++++++++ TracingDB/Forms/TrivialLoginDlg.cs | 49 ------- TracingDB/Forms/TrivialLoginDlg.designer.cs | 105 --------------- TracingDB/Forms/TrivialLoginDlg.resx | 120 ------------------ TracingDB/ItemSpec.cs | 50 ++++++-- TracingDB/Mappings/ProcessMap.cs | 17 ++- .../Mappings/WorkplaceRegistrationMap.cs | 20 +++ TracingDB/Properties/AssemblyInfo.cs | 4 +- TracingDB/TracingDB.csproj | 13 +- 15 files changed, 421 insertions(+), 340 deletions(-) rename TracingDB/{FluentNH.cs => DB.cs} (65%) create mode 100644 TracingDB/Entities/WorkplaceRegistration.cs delete mode 100644 TracingDB/Forms/TrivialLoginDlg.cs delete mode 100644 TracingDB/Forms/TrivialLoginDlg.designer.cs delete mode 100644 TracingDB/Forms/TrivialLoginDlg.resx create mode 100644 TracingDB/Mappings/WorkplaceRegistrationMap.cs diff --git a/TBF/BenchControl/Output/DB/ProductionMonitoring/Monitoring.cs b/TBF/BenchControl/Output/DB/ProductionMonitoring/Monitoring.cs index ac7ad8e50..3dca34a38 100644 --- a/TBF/BenchControl/Output/DB/ProductionMonitoring/Monitoring.cs +++ b/TBF/BenchControl/Output/DB/ProductionMonitoring/Monitoring.cs @@ -71,7 +71,7 @@ namespace TBF.BenchControl.Output.DB.ProductionMonitoring .Configure() .Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(monitoringCfg.ConnStr)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf()) - .ExposeConfiguration(TracingDB.FluentNH.BuildSchema) + .ExposeConfiguration(TracingDB.DB.BuildSchema) .BuildSessionFactory(); /// /// Read processes and worksteps from the database (this verifies DB connection as well) diff --git a/TracingDB/FluentNH.cs b/TracingDB/DB.cs similarity index 65% rename from TracingDB/FluentNH.cs rename to TracingDB/DB.cs index 2da67f650..eaeb9e3b0 100644 --- a/TracingDB/FluentNH.cs +++ b/TracingDB/DB.cs @@ -5,16 +5,20 @@ using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; +using log4net; namespace TracingDB { - public static class FluentNH + public static class DB { - /// + static readonly ILog log = LogManager.GetLogger(typeof(DB)); + + /// /// Current session factory for the last used connection string or null /// public static ISessionFactory SessionFactory; + public static ISession Session; /// Connection string for all sessions static string connectionString; @@ -206,5 +210,84 @@ namespace TracingDB } } } + + public static bool RegisterWorkplace(ISession session, string workplace, string user, string ipAddress, string processName, string workstepName, DateTime valiUntil) + { + try + { + IList wpRegs = session + .QueryOver() + .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); + 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; + } + } + + public static bool UnregisterWorkplace(ISession session, string workplace) + { + try + { + IList wpRegs = session + .QueryOver() + .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); + 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; + } + } } } diff --git a/TracingDB/Entities/Process.cs b/TracingDB/Entities/Process.cs index ff34d3ccf..47f73f681 100644 --- a/TracingDB/Entities/Process.cs +++ b/TracingDB/Entities/Process.cs @@ -8,14 +8,24 @@ namespace TracingDB.Entities public virtual int Id { get; protected set; } public virtual int ItemNr { get; set; } public virtual string Name { get; set; } - public virtual string Description { get; set; } - public virtual ReleaseStatus ReleaseStatus { get; set; } - public virtual DateTime TimeStamp { get; set; } - public virtual string UserName { get; set; } + public virtual int SubClass { get; set; } /// Main process: 1, Sub processes: 2, 4, 8, ... + public virtual string Description { get; set; } + public virtual string CreatedBy { get; set; } + public virtual DateTime TimeStamp { get; set; } + public virtual string ApprovedBy { get; set; } + public virtual DateTime TimeStamp2 { get; set; } + public virtual string ReleaseNotes { get; set; } + public virtual ReleaseStatus ReleaseStatus { get; set; } public virtual IList Parts { get; set; } public virtual IList Worksteps { get; set; } + + /// Wrappers + public virtual SubClass GetSubClass() { return (SubClass)SubClass; } + public virtual void SetSubClass(SubClass subClass) { SubClass = (int)subClass; } + + /// /// Default (private) constructor inicializing lists /// @@ -33,11 +43,15 @@ namespace TracingDB.Entities : this() { Name = name; + SubClass = 0; Description = string.Empty; - ReleaseStatus = ReleaseStatus.In_preparation; - TimeStamp = DateTime.Now; - UserName = "admin"; - } + ReleaseNotes = string.Empty; + CreatedBy = "admin"; + TimeStamp = DateTime.Now; + ApprovedBy = string.Empty; + TimeStamp2 = DateTime.Now; + ReleaseStatus = ReleaseStatus.In_preparation; + } /// /// Create a copy of a process with a new name @@ -47,7 +61,14 @@ namespace TracingDB.Entities public virtual Process Clone(string name) { Process rslt = new Process(name); - rslt.Description = Description; + rslt.SubClass = SubClass; + rslt.Description = Description; + rslt.ReleaseNotes = ReleaseNotes; + CreatedBy = "admin"; + TimeStamp = DateTime.Now; + ApprovedBy = string.Empty; + TimeStamp2 = DateTime.Now; + ReleaseStatus = ReleaseStatus.In_preparation; foreach (var part in Parts) rslt.Parts.Add(part.Clone(rslt)); foreach (var workstep in Worksteps) rslt.Worksteps.Add(workstep.Clone(rslt)); @@ -57,12 +78,7 @@ namespace TracingDB.Entities public override string ToString() { - return string.Format("{0} '{1}' ({2}) {3} {4}", - ItemNr, - Name, - TimeStamp.Date.ToShortDateString(), - (Description == null) ? string.Empty : Description, - ReleaseStatus); + return string.IsNullOrEmpty(Name) ? string.Empty : Name; } } } diff --git a/TracingDB/Entities/WorkplaceRegistration.cs b/TracingDB/Entities/WorkplaceRegistration.cs new file mode 100644 index 000000000..244575794 --- /dev/null +++ b/TracingDB/Entities/WorkplaceRegistration.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TracingDB.Entities +{ + public class WorkplaceRegistration + { + public virtual int Id { get; protected set; } + public virtual string Workplace { get; set; } + public virtual bool Active { get; set; } + public virtual DateTime TimeStamp { get; set; } + public virtual DateTime ValidUntil { get; set; } + + public virtual string UserName { get; set; } + public virtual string IPAddress { get; set; } + public virtual string ProcessName { get; set; } + public virtual string WorkstepName { get; set; } + + public virtual int Count { get; set; } /// Count of produced parts, not mapped to the database + + + /// + /// Default (private) constructor inicializing lists + /// + protected WorkplaceRegistration() + { + } + + /// + /// Public constructor + /// + /// Workplace name + /// User name + /// IP address + /// Process name + /// Workstep name + public WorkplaceRegistration(string workplace, string user, string ipAddress, string processName, string workstepName) + { + this.Workplace = workplace; + this.Active = true; + this.TimeStamp = DateTime.Now; + this.ValidUntil = DateTime.Now + new TimeSpan(8, 0, 0); + this.UserName = user; + this.IPAddress = ipAddress; + this.ProcessName = processName; + this.WorkstepName = workstepName; + } + } +} diff --git a/TracingDB/Enums.cs b/TracingDB/Enums.cs index 7683f5ce7..3a7ca5cc8 100644 --- a/TracingDB/Enums.cs +++ b/TracingDB/Enums.cs @@ -1,23 +1,73 @@ -namespace TracingDB +using System; +using System.Reflection; + + +namespace TracingDB { + /// + /// Helper class to assign descriptions to enum values + /// + public class Description : Attribute + { + public string Text; + public Description(string t) + { + Text = t; + } + } + + public static class GetDescription + { + /// Extension method for enum-s + public static string ToDescription(this Enum enm) + { + Type type = enm.GetType(); + MemberInfo[] memInfo = type.GetMember(enm.ToString()); + + if (memInfo != null && memInfo.Length > 0) + { + object[] attrs = memInfo[0].GetCustomAttributes(typeof(Description), false); + if (attrs != null && attrs.Length > 0) + return ((Description)attrs[0]).Text; + } + + return enm.ToString(); /// Return ToString() value in case there is no description + } + } + + public enum CodeType { + [Description("-")] UniqueNr, + + [Description("PCB")] FlowtubeNr, /// prvé 3 znaky sa zhodujú s poslednými 3 znakmi názvu + + [Description("Flowt.")] FlowtubeNrLU, /// začiatok kódu sa zhoduje s názvom + + [Description("1")] BatchNr, + + [Description("2")] BatchNrContainingPartName, + + [Description("3")] DateMMYY, - QualityCheck, + + [Description("4")] + QualityCheck, + Count } public enum CodeForm { - Barcode, - QRCode, - Keyboard, - OkNok, + Barcode, /// Barcode + QRCode, /// QR code + Keyboard, /// Data entered by a keyboard + OkNok, /// OK/NOK or Yes/No data entered by a keyboard or a mouse Count } @@ -35,12 +85,35 @@ Count, } + public enum SubClass + { + [Description("invalid")] + Invalid = 0, + + [Description("vodomery")] + Normal = 1, /// Original process type + + [Description("vodomery bez PCB")] + NormalWithoutPCB = 2, /// + + [Description("flowtuby")] + FlowTube = 4, /// FlowTube + + [Description("vodomery odvodene z flowtuby")] + InheritsFlowTube = 8, /// + + [Description("vodomery z flowtuby bez PCB")] + InheritsFlowTubeWithoutPCB = 16, /// + } + public enum ReleaseStatus { - In_preparation, - Released, - ReleasedActive, - Deactivated, + In_preparation, /// Process definition is not completed, cannot be used in production + ToBeApproved, /// Process is completed, protected against changes and waits for an approval + Released, /// Process is ready for production (completed, protected, approved), but it is inactive + ReleasedActive, /// Process is ready for production, it is active = enabled + Deactivated, /// Process was used in production but it was de-activated (should never be deleted as there are references to the process) + Separator, /// 'Process' is only a named separator between other process items Count, } diff --git a/TracingDB/Forms/SettingsDlg.Designer.cs b/TracingDB/Forms/SettingsDlg.Designer.cs index 8aaabe880..b011634ec 100644 --- a/TracingDB/Forms/SettingsDlg.Designer.cs +++ b/TracingDB/Forms/SettingsDlg.Designer.cs @@ -45,10 +45,12 @@ 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.label1 = new System.Windows.Forms.Label(); + this.processFilterGroupBox = new System.Windows.Forms.GroupBox(); + this.processFilterComboBox = new System.Windows.Forms.ComboBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -56,6 +58,7 @@ this.oracleGroupBox.SuspendLayout(); this.groupBox5.SuspendLayout(); this.timeGroupBox.SuspendLayout(); + this.processFilterGroupBox.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -113,7 +116,7 @@ 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(622, 50); + this.groupBox3.Size = new System.Drawing.Size(300, 50); this.groupBox3.TabIndex = 0; this.groupBox3.TabStop = false; this.groupBox3.Text = "Meno pracoviska"; @@ -122,7 +125,7 @@ // this.workplaceNameTextBox.Location = new System.Drawing.Point(17, 18); this.workplaceNameTextBox.Name = "workplaceNameTextBox"; - this.workplaceNameTextBox.Size = new System.Drawing.Size(586, 20); + this.workplaceNameTextBox.Size = new System.Drawing.Size(265, 20); this.workplaceNameTextBox.TabIndex = 0; // // saveButton @@ -227,6 +230,15 @@ 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; @@ -252,20 +264,31 @@ this.timePicker1.Size = new System.Drawing.Size(98, 20); this.timePicker1.TabIndex = 0; // - // label1 + // processFilterGroupBox // - 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ť"; + 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); @@ -294,6 +317,7 @@ this.groupBox5.PerformLayout(); this.timeGroupBox.ResumeLayout(false); this.timeGroupBox.PerformLayout(); + this.processFilterGroupBox.ResumeLayout(false); this.ResumeLayout(false); } @@ -321,5 +345,7 @@ 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; } } \ No newline at end of file diff --git a/TracingDB/Forms/SettingsDlg.cs b/TracingDB/Forms/SettingsDlg.cs index 63edec45b..f581b8706 100644 --- a/TracingDB/Forms/SettingsDlg.cs +++ b/TracingDB/Forms/SettingsDlg.cs @@ -8,12 +8,62 @@ namespace TracingDB.Forms 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; } @@ -87,11 +137,19 @@ namespace TracingDB.Forms 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; diff --git a/TracingDB/Forms/TrivialLoginDlg.cs b/TracingDB/Forms/TrivialLoginDlg.cs deleted file mode 100644 index 334e53dc6..000000000 --- a/TracingDB/Forms/TrivialLoginDlg.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace TracingDB.Forms -{ - public partial class TrivialLoginDlg : Form - { - public LoginLevel LoginLevel; - - public TrivialLoginDlg() - { - InitializeComponent(); - LoginLevel = LoginLevel.None; - } - - private void okButton_Click(object sender, EventArgs e) - { - if (passwordTextBox.Text.ToLower().Equals("barcode")) - { - LoginLevel = LoginLevel.Administrator; - DialogResult = DialogResult.OK; - Close(); - } - else if (passwordTextBox.Text.ToLower().Equals("teamleader")) - { - LoginLevel = LoginLevel.TeamLeader; - DialogResult = DialogResult.OK; - Close(); - } - else if (passwordTextBox.Text.ToLower().Equals("kremik")) - { - LoginLevel = LoginLevel.MH; - DialogResult = DialogResult.OK; - Close(); - } - else - { - DialogResult = DialogResult.Cancel; - Close(); - } - } - - private void cancelButton_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - } -} diff --git a/TracingDB/Forms/TrivialLoginDlg.designer.cs b/TracingDB/Forms/TrivialLoginDlg.designer.cs deleted file mode 100644 index 31cfc85cf..000000000 --- a/TracingDB/Forms/TrivialLoginDlg.designer.cs +++ /dev/null @@ -1,105 +0,0 @@ -namespace TracingDB.Forms -{ - partial class TrivialLoginDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.passwordGroupBox = new System.Windows.Forms.GroupBox(); - this.passwordTextBox = new System.Windows.Forms.TextBox(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.passwordGroupBox.SuspendLayout(); - this.SuspendLayout(); - // - // passwordGroupBox - // - this.passwordGroupBox.Controls.Add(this.passwordTextBox); - this.passwordGroupBox.Location = new System.Drawing.Point(12, 10); - this.passwordGroupBox.Name = "passwordGroupBox"; - this.passwordGroupBox.Size = new System.Drawing.Size(200, 49); - this.passwordGroupBox.TabIndex = 0; - this.passwordGroupBox.TabStop = false; - this.passwordGroupBox.Text = "Heslo"; - // - // passwordTextBox - // - this.passwordTextBox.Location = new System.Drawing.Point(51, 18); - this.passwordTextBox.Name = "passwordTextBox"; - this.passwordTextBox.PasswordChar = '*'; - this.passwordTextBox.Size = new System.Drawing.Size(100, 20); - this.passwordTextBox.TabIndex = 0; - // - // okButton - // - this.okButton.Location = new System.Drawing.Point(237, 18); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 39); - this.okButton.TabIndex = 1; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(330, 18); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 39); - this.cancelButton.TabIndex = 2; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // LoginDlg - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(426, 73); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.passwordGroupBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "LoginDlg"; - this.Text = "LoginDlg"; - this.passwordGroupBox.ResumeLayout(false); - this.passwordGroupBox.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox passwordGroupBox; - private System.Windows.Forms.TextBox passwordTextBox; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - } -} \ No newline at end of file diff --git a/TracingDB/Forms/TrivialLoginDlg.resx b/TracingDB/Forms/TrivialLoginDlg.resx deleted file mode 100644 index 1af7de150..000000000 --- a/TracingDB/Forms/TrivialLoginDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/TracingDB/ItemSpec.cs b/TracingDB/ItemSpec.cs index 90864c527..2677765f4 100644 --- a/TracingDB/ItemSpec.cs +++ b/TracingDB/ItemSpec.cs @@ -97,25 +97,51 @@ namespace TracingDB 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) => string.IsNullOrEmpty(f) ? ((Workstep)x).Name : string.Format(f, ((Workstep)x).Name), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.Workplace, Strings.Workplace, (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.UserName, Strings.User_name, (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.Barcode, Strings.Barcode, (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode, Strings.Part_barcode, (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord)); + 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.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.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) => string.IsNullOrEmpty(f) ? ((Workstep)x).Name : string.Format(f, ((Workstep)x).Name), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.Workplace2, Strings.Workplace+"2", (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.UserName2, Strings.User_name+"2", (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.Barcode2, Strings.Barcode+"2", (x, f, p, w) => string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord)); - AllItems.Add(new ItemSpec(ItemSpecID.PartBarcode2, Strings.Part_barcode+"2",(x, f, p, w)=> string.IsNullOrEmpty(f) ? (string)x : string.Format(f, x), ItemSpecCaps.ReferenceRecord | ItemSpecCaps.AssociatedRecord)); + 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.Max_pruefindex, (x, f, p, w) => x as string, ItemSpecCaps.ReferenceRecord | ItemSpecCaps.OracleQuery)); - - AllItems.Add(new ItemSpec(ItemSpecID.Process, Strings.Process, (x, f, p, w) => string.IsNullOrEmpty(f) ? ((Process)x).Name : string.Format(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)); + } + + + public static string FormatStr(string format, object value) + { + int len; + + if (string.IsNullOrEmpty(format)) + { + return (string)value; + } + else if (int.TryParse(format, out len) && len > 0) + { + if (((string)value).Length >= len) + { + return ((string)value).Substring(0, len); + } + else + { + return (string)value; + } + } + else + { + return string.Format(format, value); + } } public PropertyProjection GetProperty(ReferenceRecord refRecord, Record record) diff --git a/TracingDB/Mappings/ProcessMap.cs b/TracingDB/Mappings/ProcessMap.cs index 997b1bc81..472aae972 100644 --- a/TracingDB/Mappings/ProcessMap.cs +++ b/TracingDB/Mappings/ProcessMap.cs @@ -7,16 +7,25 @@ namespace TracingDB.Mappings public ProcessMap() { Id(x => x.Id); + Map(x => x.ItemNr); Map(x => x.Name); - Map(x => x.Description); - Map(x => x.ReleaseStatus); - Map(x => x.TimeStamp); - Map(x => x.UserName); + Map(x => x.SubClass); + Map(x => x.Description); + Map(x => x.ReleaseNotes) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.CreatedBy) + .Column("UserName"); + Map(x => x.TimeStamp); + Map(x => x.ApprovedBy); + Map(x => x.TimeStamp2); + Map(x => x.ReleaseStatus); HasMany(x => x.Parts) .OrderBy("Name") .Cascade.All(); + HasMany(x => x.Worksteps) .OrderBy("WorkstepNr") .Cascade.All(); diff --git a/TracingDB/Mappings/WorkplaceRegistrationMap.cs b/TracingDB/Mappings/WorkplaceRegistrationMap.cs new file mode 100644 index 000000000..a3ba43c23 --- /dev/null +++ b/TracingDB/Mappings/WorkplaceRegistrationMap.cs @@ -0,0 +1,20 @@ +using FluentNHibernate.Mapping; + +namespace TracingDB.Mappings +{ + class WorkplaceRegistrationMap : ClassMap + { + public WorkplaceRegistrationMap() + { + Id(x => x.Id); + Map(x => x.Workplace); + Map(x => x.Active); + Map(x => x.TimeStamp); + Map(x => x.ValidUntil); + Map(x => x.UserName); + Map(x => x.IPAddress); + Map(x => x.ProcessName); + Map(x => x.WorkstepName); + } + } +} diff --git a/TracingDB/Properties/AssemblyInfo.cs b/TracingDB/Properties/AssemblyInfo.cs index 2d8125e56..d428d293b 100644 --- a/TracingDB/Properties/AssemblyInfo.cs +++ b/TracingDB/Properties/AssemblyInfo.cs @@ -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("1.5.61.0")] -[assembly: AssemblyFileVersion("1.5.61.0")] +[assembly: AssemblyVersion("2.0.65.0")] +[assembly: AssemblyFileVersion("2.0.65.0")] diff --git a/TracingDB/TracingDB.csproj b/TracingDB/TracingDB.csproj index 070ac0517..eaee38869 100644 --- a/TracingDB/TracingDB.csproj +++ b/TracingDB/TracingDB.csproj @@ -64,15 +64,10 @@ + Component - - Form - - - TrivialLoginDlg.cs - Form @@ -95,6 +90,7 @@ + True @@ -110,7 +106,7 @@ - + @@ -127,9 +123,6 @@ ListViewEx.cs - - TrivialLoginDlg.cs - ModelessForm.cs