diff --git a/.gitignore b/.gitignore index 61c954dba..dd1cd0e4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ TestBenchFramework/bin/ TestBenchFramework/obj/ +ResultsBrowser/bin/ +ResultsBrowser/obj/ TBFSetup/ Doc/ *.suo \ No newline at end of file diff --git a/ResultsBrowser/BenchesDlg.Designer.cs b/ResultsBrowser/BenchesDlg.Designer.cs new file mode 100644 index 000000000..52d4e38ff --- /dev/null +++ b/ResultsBrowser/BenchesDlg.Designer.cs @@ -0,0 +1,137 @@ +namespace ResultsBrowser +{ + partial class BenchesDlg + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BenchesDlg)); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.testBenchesListBox = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.editButton = new System.Windows.Forms.Button(); + this.addButton = new System.Windows.Forms.Button(); + this.removeButton = new System.Windows.Forms.Button(); + this.copyButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // okButton + // + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.ImageKey = global::TBF.Resources.Strings.String1; + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.ImageKey = global::TBF.Resources.Strings.String1; + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // testBenchesListBox + // + resources.ApplyResources(this.testBenchesListBox, "testBenchesListBox"); + this.testBenchesListBox.FormattingEnabled = true; + this.testBenchesListBox.Name = "testBenchesListBox"; + this.testBenchesListBox.DoubleClick += new System.EventHandler(this.testBenchesListBox_DoubleClick); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.ImageKey = global::TBF.Resources.Strings.String1; + this.label1.Name = "label1"; + // + // editButton + // + resources.ApplyResources(this.editButton, "editButton"); + this.editButton.ImageKey = global::TBF.Resources.Strings.String1; + this.editButton.Name = "editButton"; + this.editButton.UseVisualStyleBackColor = true; + this.editButton.Click += new System.EventHandler(this.editButton_Click); + // + // addButton + // + resources.ApplyResources(this.addButton, "addButton"); + this.addButton.ImageKey = global::TBF.Resources.Strings.String1; + this.addButton.Name = "addButton"; + this.addButton.UseVisualStyleBackColor = true; + this.addButton.Click += new System.EventHandler(this.addButton_Click); + // + // removeButton + // + resources.ApplyResources(this.removeButton, "removeButton"); + this.removeButton.ImageKey = global::TBF.Resources.Strings.String1; + this.removeButton.Name = "removeButton"; + this.removeButton.UseVisualStyleBackColor = true; + this.removeButton.Click += new System.EventHandler(this.removeButton_Click); + // + // copyButton + // + resources.ApplyResources(this.copyButton, "copyButton"); + this.copyButton.ImageKey = global::TBF.Resources.Strings.String1; + this.copyButton.Name = "copyButton"; + this.copyButton.UseVisualStyleBackColor = true; + this.copyButton.Click += new System.EventHandler(this.copyButton_Click); + // + // BenchesDlg + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.copyButton); + this.Controls.Add(this.removeButton); + this.Controls.Add(this.addButton); + this.Controls.Add(this.editButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.testBenchesListBox); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "BenchesDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.ListBox testBenchesListBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button editButton; + private System.Windows.Forms.Button addButton; + private System.Windows.Forms.Button removeButton; + private System.Windows.Forms.Button copyButton; + } +} \ No newline at end of file diff --git a/ResultsBrowser/BenchesDlg.cs b/ResultsBrowser/BenchesDlg.cs new file mode 100644 index 000000000..3fb48ad62 --- /dev/null +++ b/ResultsBrowser/BenchesDlg.cs @@ -0,0 +1,199 @@ +using System; +using System.Windows.Forms; + +namespace ResultsBrowser +{ + /// + /// Dialog to edit local settings that specify database parameters (S1.2) + /// + public partial class BenchesDlg : Form + { + // Local copy of 'local settings' initialized to Program.localSettings. + // Dialog modifies this copy and updates Program.localSettings just + // when 'OK' is pressed. + LocalSettings localSettings; + + /// + /// Constructor, initializes the dialog + /// + public BenchesDlg() + { + localSettings = new LocalSettings(); + localSettings.Assign(Program.LocalSettings); + + InitializeComponent(); + RedrawTestBenchesListBox(); + } + + void RedrawTestBenchesListBox() + { + testBenchesListBox.Items.Clear(); + if (localSettings.testBenches != null) + { + int nrBenches = localSettings.testBenches.GetLength(0); + for (int i = 0; i < nrBenches; i++) + { + testBenchesListBox.Items.Add(localSettings.testBenches[i].BenchName); + } + } + } + + /// + /// Create a new test bench DB specification and append it to the list + /// + /// Not used + /// Not used + private void addButton_Click(object sender, EventArgs e) + { + DatabaseSettings bench = new DatabaseSettings(); + DatabaseSettingsDlg dlg = new DatabaseSettingsDlg(bench); + DialogResult dr = dlg.ShowDialog(); + if (dr == DialogResult.OK) + { + int nrBenches = + (localSettings.testBenches == null) ? 0 : localSettings.testBenches.GetLength(0); + + if (nrBenches == 0) + { + localSettings.testBenches = new DatabaseSettings[1]; + localSettings.testBenches[0] = bench; + } + else + { + DatabaseSettings[] newTestBenches = new DatabaseSettings[nrBenches + 1]; + for (int i = 0; i < nrBenches; i++) + { + newTestBenches[i] = localSettings.testBenches[i]; + } + newTestBenches[nrBenches] = bench; + localSettings.testBenches = newTestBenches; + } + + testBenchesListBox.Items.Add(bench.BenchName); + } + } + + /// + /// Create a new test bench DB specification,which is a copy of the + /// selected bench, and append it to the list + /// + /// Not used + /// Not used + private void copyButton_Click(object sender, EventArgs e) + { + if (testBenchesListBox.SelectedIndex >= 0) + { + DatabaseSettings ori = localSettings.testBenches[testBenchesListBox.SelectedIndex]; + DatabaseSettings bench = (DatabaseSettings)ori.Clone(); + + DatabaseSettingsDlg dlg = new DatabaseSettingsDlg(bench); + DialogResult dr = dlg.ShowDialog(); + if (dr == DialogResult.OK) + { + int nrBenches = + (localSettings.testBenches == null) ? 0 : localSettings.testBenches.GetLength(0); + + DatabaseSettings[] newTestBenches = new DatabaseSettings[nrBenches + 1]; + for (int i = 0; i < nrBenches; i++) + { + newTestBenches[i] = localSettings.testBenches[i]; + } + newTestBenches[nrBenches] = bench; + localSettings.testBenches = newTestBenches; + + testBenchesListBox.Items.Add(bench.BenchName); + } + } + } + + /// + /// Edit selected test bench DB specification + /// + /// Not used + /// Not used + private void editButton_Click(object sender, EventArgs e) + { + if (testBenchesListBox.SelectedIndex >= 0) + { + DatabaseSettingsDlg dlg = new DatabaseSettingsDlg(localSettings.testBenches[testBenchesListBox.SelectedIndex]); + DialogResult dr = dlg.ShowDialog(); + if (dr == DialogResult.OK) + { + // Update the item name + testBenchesListBox.Items[testBenchesListBox.SelectedIndex] = + localSettings.testBenches[testBenchesListBox.SelectedIndex].BenchName; + } + } + } + + /// + /// Remove selected test bench DB specification from the list + /// + /// Not used + /// Not used + private void removeButton_Click(object sender, EventArgs e) + { + int selectedIx = testBenchesListBox.SelectedIndex; + if (selectedIx >= 0) + { + int nrBenches = + (localSettings.testBenches == null) ? 0 : localSettings.testBenches.GetLength(0); + + if (nrBenches == 1) + { + localSettings.testBenches = null; + } + else + { + DatabaseSettings[] newTestBenches = new DatabaseSettings[nrBenches - 1]; + for (int i = 0; i < selectedIx; i++) + { + newTestBenches[i] = localSettings.testBenches[i]; + } + for (int i = selectedIx + 1; i < nrBenches; i++) + { + newTestBenches[i - 1] = localSettings.testBenches[i]; + } + localSettings.testBenches = newTestBenches; + } + + RedrawTestBenchesListBox(); + } + } + + /// + /// Update setting, return 'OK' + /// + /// Not used + /// Not used + private void okButton_Click(object sender, EventArgs e) + { + Program.LocalSettings.Assign(localSettings); // Update Program.localSettings + DialogResult = DialogResult.OK; + Close(); + return; + } + + /// + /// Throw away changes, return 'Cancel' + /// + /// Not used + /// Not used + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + return; + } + + /// + /// Double click on an item = edit item + /// + /// Not used + /// Not used + private void testBenchesListBox_DoubleClick(object sender, EventArgs e) + { + editButton_Click(sender, e); + } + } +} \ No newline at end of file diff --git a/ResultsBrowser/BenchesDlg.de.resx b/ResultsBrowser/BenchesDlg.de.resx new file mode 100644 index 000000000..da230a148 --- /dev/null +++ b/ResultsBrowser/BenchesDlg.de.resx @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + &OK + + + &Abbrechen + + + + 58, 13 + + + Prüfstände + + + &Bearbeiten... + + + &Neu... + + + &Löschen + + + &Kopieren + + + Datenbank Einstellungen + + \ No newline at end of file diff --git a/ResultsBrowser/BenchesDlg.resx b/ResultsBrowser/BenchesDlg.resx new file mode 100644 index 000000000..139fa0b04 --- /dev/null +++ b/ResultsBrowser/BenchesDlg.resx @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 13 + + + + 192, 105 + + + $this + + + 105, 28 + + + 192, 37 + + + 164, 134 + + + &Add + + + 1 + + + 15 + + + $this + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + BenchesDlg + + + 5 + + + label1 + + + &Remove + + + 344, 71 + + + $this + + + Cancel + + + testBenchesListBox + + + 192, 71 + + + okButton + + + $this + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 105, 28 + + + 0 + + + 14 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 79, 13 + + + 105, 28 + + + $this + + + 459, 185 + + + 11 + + + 6, 13 + + + 105, 28 + + + &Edit + + + addButton + + + + CenterParent + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 192, 139 + + + 7 + + + 344, 37 + + + 105, 28 + + + 17 + + + removeButton + + + &Copy + + + 12, 37 + + + 4 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 6 + + + $this + + + copyButton + + + 105, 28 + + + True + + + 3 + + + editButton + + + cancelButton + + + 12, 15 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + OK + + + Database Settings + + + $this + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0 + + + 12 + + + 16 + + + Test Benches : + + + True + + + de + + \ No newline at end of file diff --git a/ResultsBrowser/DBSettings.cs b/ResultsBrowser/DBSettings.cs new file mode 100644 index 000000000..241009bbb --- /dev/null +++ b/ResultsBrowser/DBSettings.cs @@ -0,0 +1,28 @@ +using System; + +namespace ResultsBrowser +{ + /// + /// Database settings required to make a connection + /// + public class DBSettings : ICloneable + { + public DBType DbType; + public string ConnectionString; + + public DBSettings() + { + } + + public DBSettings(DBType dbType, string connectionString) + { + this.DbType = dbType; + this.ConnectionString = connectionString; + } + + public object Clone() + { + return new DBSettings(DbType, ConnectionString); + } + } +} diff --git a/ResultsBrowser/DatabaseSettings.cs b/ResultsBrowser/DatabaseSettings.cs new file mode 100644 index 000000000..e6de5ae99 --- /dev/null +++ b/ResultsBrowser/DatabaseSettings.cs @@ -0,0 +1,48 @@ +using System; +using System.Text; +using System.Xml.Serialization; + +namespace ResultsBrowser +{ + /// + /// Test bench database settings, contains bench name and settings od several databases + /// + public class DatabaseSettings : ICloneable + { + // Public fields + public string BenchName; + public bool IsRealBench; + public DBSettings UsersDBSettings; + public DBSettings BenchDBSettings; + public DBSettings ProceduresDBSettings; + public DBSettings WMTypesDBSettings; + public DBSettings WaterMetersDBSettings; + + // Constructor + public DatabaseSettings() + { + BenchName = String.Empty; /// Empty string to avoid null + IsRealBench = false; + UsersDBSettings = new DBSettings(DBType.MySql, "SERVER=localhost; DATABASE=tbf_users; UID=root; PASSWORD=;"); + BenchDBSettings = new DBSettings(DBType.MySql, "SERVER=localhost; DATABASE=tbf_bench; UID=root; PASSWORD=;"); + ProceduresDBSettings = new DBSettings(DBType.MySql, "SERVER=localhost; DATABASE=tbf_procedures; UID=root; PASSWORD=;"); + WMTypesDBSettings = new DBSettings(DBType.MySql, "SERVER=localhost; DATABASE=tbf_wmtypes; UID=root; PASSWORD=;"); + WaterMetersDBSettings = new DBSettings(DBType.MySql, "SERVER=localhost; DATABASE=tbf_watermeters; UID=root; PASSWORD=;"); + } + + public object Clone() + { + DatabaseSettings result = new DatabaseSettings(); + + result.BenchName = BenchName; + result.IsRealBench = IsRealBench; + result.UsersDBSettings = (DBSettings)UsersDBSettings.Clone(); + result.BenchDBSettings = (DBSettings)BenchDBSettings.Clone(); + result.ProceduresDBSettings = (DBSettings)ProceduresDBSettings.Clone(); + result.WMTypesDBSettings = (DBSettings)WMTypesDBSettings.Clone(); + result.WaterMetersDBSettings = (DBSettings)WaterMetersDBSettings.Clone(); + + return result; + } + } +} diff --git a/ResultsBrowser/DatabaseSettingsDlg.Designer.cs b/ResultsBrowser/DatabaseSettingsDlg.Designer.cs new file mode 100644 index 000000000..4fbf915a6 --- /dev/null +++ b/ResultsBrowser/DatabaseSettingsDlg.Designer.cs @@ -0,0 +1,370 @@ +namespace ResultsBrowser +{ + partial class DatabaseSettingsDlg + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DatabaseSettingsDlg)); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.benchNameTextBox = new System.Windows.Forms.TextBox(); + this.usersConnectionStringTextBox = new System.Windows.Forms.TextBox(); + this.connectionStringLabel = new System.Windows.Forms.Label(); + this.benchConnectionStringTextBox = new System.Windows.Forms.TextBox(); + this.proceduresConnectionStringTextBox = new System.Windows.Forms.TextBox(); + this.wmTypesConnectionStringTextBox = new System.Windows.Forms.TextBox(); + this.watermetersConnectionStringTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.testConnUsersBtn = new System.Windows.Forms.Button(); + this.createUsersDbBtn = new System.Windows.Forms.Button(); + this.realBenchCheckBox = new System.Windows.Forms.CheckBox(); + this.dbTypeLabel = new System.Windows.Forms.Label(); + this.usersDbTypeComboBox = new System.Windows.Forms.ComboBox(); + this.benchDbTypeComboBox = new System.Windows.Forms.ComboBox(); + this.proceduresDbTypeComboBox = new System.Windows.Forms.ComboBox(); + this.wmTypesDbTypeComboBox = new System.Windows.Forms.ComboBox(); + this.watermetersDbTypeComboBox = new System.Windows.Forms.ComboBox(); + this.testConnBenchBtn = new System.Windows.Forms.Button(); + this.testConnProceduresBtn = new System.Windows.Forms.Button(); + this.testConnWMTypesBtn = new System.Windows.Forms.Button(); + this.testConnWaterMetersBtn = new System.Windows.Forms.Button(); + this.createBenchDbBtn = new System.Windows.Forms.Button(); + this.createProceduresDbBtn = new System.Windows.Forms.Button(); + this.createWMTypesDbBtn = new System.Windows.Forms.Button(); + this.createWaterMetersDbBtn = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.ImageKey = global::TBF.Resources.Strings.String1; + this.label1.Name = "label1"; + // + // benchNameTextBox + // + resources.ApplyResources(this.benchNameTextBox, "benchNameTextBox"); + this.benchNameTextBox.Name = "benchNameTextBox"; + // + // usersConnectionStringTextBox + // + resources.ApplyResources(this.usersConnectionStringTextBox, "usersConnectionStringTextBox"); + this.usersConnectionStringTextBox.Name = "usersConnectionStringTextBox"; + // + // connectionStringLabel + // + resources.ApplyResources(this.connectionStringLabel, "connectionStringLabel"); + this.connectionStringLabel.ImageKey = global::TBF.Resources.Strings.String1; + this.connectionStringLabel.Name = "connectionStringLabel"; + // + // benchConnectionStringTextBox + // + resources.ApplyResources(this.benchConnectionStringTextBox, "benchConnectionStringTextBox"); + this.benchConnectionStringTextBox.Name = "benchConnectionStringTextBox"; + // + // proceduresConnectionStringTextBox + // + resources.ApplyResources(this.proceduresConnectionStringTextBox, "proceduresConnectionStringTextBox"); + this.proceduresConnectionStringTextBox.Name = "proceduresConnectionStringTextBox"; + // + // wmTypesConnectionStringTextBox + // + resources.ApplyResources(this.wmTypesConnectionStringTextBox, "wmTypesConnectionStringTextBox"); + this.wmTypesConnectionStringTextBox.Name = "wmTypesConnectionStringTextBox"; + // + // watermetersConnectionStringTextBox + // + resources.ApplyResources(this.watermetersConnectionStringTextBox, "watermetersConnectionStringTextBox"); + this.watermetersConnectionStringTextBox.Name = "watermetersConnectionStringTextBox"; + // + // label2 + // + resources.ApplyResources(this.label2, "label2"); + this.label2.ImageKey = global::TBF.Resources.Strings.String1; + this.label2.Name = "label2"; + // + // label3 + // + resources.ApplyResources(this.label3, "label3"); + this.label3.ImageKey = global::TBF.Resources.Strings.String1; + this.label3.Name = "label3"; + // + // label4 + // + resources.ApplyResources(this.label4, "label4"); + this.label4.ImageKey = global::TBF.Resources.Strings.String1; + this.label4.Name = "label4"; + // + // label5 + // + resources.ApplyResources(this.label5, "label5"); + this.label5.ImageKey = global::TBF.Resources.Strings.String1; + this.label5.Name = "label5"; + // + // label6 + // + resources.ApplyResources(this.label6, "label6"); + this.label6.ImageKey = global::TBF.Resources.Strings.String1; + this.label6.Name = "label6"; + // + // testConnUsersBtn + // + this.testConnUsersBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.testConnUsersBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.testConnUsersBtn, "testConnUsersBtn"); + this.testConnUsersBtn.Name = "testConnUsersBtn"; + this.testConnUsersBtn.UseVisualStyleBackColor = true; + this.testConnUsersBtn.Click += new System.EventHandler(this.testConnUsersBtn_Click); + // + // createUsersDbBtn + // + this.createUsersDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.createUsersDbBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.createUsersDbBtn, "createUsersDbBtn"); + this.createUsersDbBtn.Name = "createUsersDbBtn"; + this.createUsersDbBtn.UseVisualStyleBackColor = true; + this.createUsersDbBtn.Click += new System.EventHandler(this.createDatabasesButton_Click); + // + // realBenchCheckBox + // + resources.ApplyResources(this.realBenchCheckBox, "realBenchCheckBox"); + this.realBenchCheckBox.ImageKey = global::TBF.Resources.Strings.String1; + this.realBenchCheckBox.Name = "realBenchCheckBox"; + this.realBenchCheckBox.UseVisualStyleBackColor = true; + // + // dbTypeLabel + // + resources.ApplyResources(this.dbTypeLabel, "dbTypeLabel"); + this.dbTypeLabel.ImageKey = global::TBF.Resources.Strings.String1; + this.dbTypeLabel.Name = "dbTypeLabel"; + // + // usersDbTypeComboBox + // + this.usersDbTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.usersDbTypeComboBox, "usersDbTypeComboBox"); + this.usersDbTypeComboBox.Name = "usersDbTypeComboBox"; + // + // benchDbTypeComboBox + // + this.benchDbTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.benchDbTypeComboBox, "benchDbTypeComboBox"); + this.benchDbTypeComboBox.Name = "benchDbTypeComboBox"; + // + // proceduresDbTypeComboBox + // + this.proceduresDbTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.proceduresDbTypeComboBox, "proceduresDbTypeComboBox"); + this.proceduresDbTypeComboBox.Name = "proceduresDbTypeComboBox"; + // + // wmTypesDbTypeComboBox + // + this.wmTypesDbTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.wmTypesDbTypeComboBox, "wmTypesDbTypeComboBox"); + this.wmTypesDbTypeComboBox.Name = "wmTypesDbTypeComboBox"; + // + // watermetersDbTypeComboBox + // + this.watermetersDbTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.watermetersDbTypeComboBox, "watermetersDbTypeComboBox"); + this.watermetersDbTypeComboBox.Name = "watermetersDbTypeComboBox"; + // + // testConnBenchBtn + // + this.testConnBenchBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.testConnBenchBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.testConnBenchBtn, "testConnBenchBtn"); + this.testConnBenchBtn.Name = "testConnBenchBtn"; + this.testConnBenchBtn.UseVisualStyleBackColor = true; + this.testConnBenchBtn.Click += new System.EventHandler(this.testConnBenchBtn_Click); + // + // testConnProceduresBtn + // + this.testConnProceduresBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.testConnProceduresBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.testConnProceduresBtn, "testConnProceduresBtn"); + this.testConnProceduresBtn.Name = "testConnProceduresBtn"; + this.testConnProceduresBtn.UseVisualStyleBackColor = true; + this.testConnProceduresBtn.Click += new System.EventHandler(this.testConnProceduresBtn_Click); + // + // testConnWMTypesBtn + // + this.testConnWMTypesBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.testConnWMTypesBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.testConnWMTypesBtn, "testConnWMTypesBtn"); + this.testConnWMTypesBtn.Name = "testConnWMTypesBtn"; + this.testConnWMTypesBtn.UseVisualStyleBackColor = true; + this.testConnWMTypesBtn.Click += new System.EventHandler(this.testConnWMTypesBtn_Click); + // + // testConnWaterMetersBtn + // + this.testConnWaterMetersBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.testConnWaterMetersBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.testConnWaterMetersBtn, "testConnWaterMetersBtn"); + this.testConnWaterMetersBtn.Name = "testConnWaterMetersBtn"; + this.testConnWaterMetersBtn.UseVisualStyleBackColor = true; + this.testConnWaterMetersBtn.Click += new System.EventHandler(this.testConnWaterMetersBtn_Click); + // + // createBenchDbBtn + // + this.createBenchDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.createBenchDbBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.createBenchDbBtn, "createBenchDbBtn"); + this.createBenchDbBtn.Name = "createBenchDbBtn"; + this.createBenchDbBtn.UseVisualStyleBackColor = true; + this.createBenchDbBtn.Click += new System.EventHandler(this.createbenchDbBtn_Click); + // + // createProceduresDbBtn + // + this.createProceduresDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.createProceduresDbBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.createProceduresDbBtn, "createProceduresDbBtn"); + this.createProceduresDbBtn.Name = "createProceduresDbBtn"; + this.createProceduresDbBtn.UseVisualStyleBackColor = true; + this.createProceduresDbBtn.Click += new System.EventHandler(this.createProecduresDbBtn_Click); + // + // createWMTypesDbBtn + // + this.createWMTypesDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.createWMTypesDbBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.createWMTypesDbBtn, "createWMTypesDbBtn"); + this.createWMTypesDbBtn.Name = "createWMTypesDbBtn"; + this.createWMTypesDbBtn.UseVisualStyleBackColor = true; + this.createWMTypesDbBtn.Click += new System.EventHandler(this.createWMTypesDbBtn_Click); + // + // createWaterMetersDbBtn + // + this.createWaterMetersDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.createWaterMetersDbBtn.ImageKey = global::TBF.Resources.Strings.String1; + resources.ApplyResources(this.createWaterMetersDbBtn, "createWaterMetersDbBtn"); + this.createWaterMetersDbBtn.Name = "createWaterMetersDbBtn"; + this.createWaterMetersDbBtn.UseVisualStyleBackColor = true; + this.createWaterMetersDbBtn.Click += new System.EventHandler(this.createWaterMetersDbBtn_Click); + // + // DatabaseSettingsDlg + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.createWaterMetersDbBtn); + this.Controls.Add(this.createWMTypesDbBtn); + this.Controls.Add(this.createProceduresDbBtn); + this.Controls.Add(this.createBenchDbBtn); + this.Controls.Add(this.testConnWaterMetersBtn); + this.Controls.Add(this.testConnWMTypesBtn); + this.Controls.Add(this.testConnProceduresBtn); + this.Controls.Add(this.testConnBenchBtn); + this.Controls.Add(this.watermetersDbTypeComboBox); + this.Controls.Add(this.wmTypesDbTypeComboBox); + this.Controls.Add(this.proceduresDbTypeComboBox); + this.Controls.Add(this.benchDbTypeComboBox); + this.Controls.Add(this.usersDbTypeComboBox); + this.Controls.Add(this.dbTypeLabel); + this.Controls.Add(this.realBenchCheckBox); + this.Controls.Add(this.createUsersDbBtn); + this.Controls.Add(this.testConnUsersBtn); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.watermetersConnectionStringTextBox); + this.Controls.Add(this.wmTypesConnectionStringTextBox); + this.Controls.Add(this.proceduresConnectionStringTextBox); + this.Controls.Add(this.benchConnectionStringTextBox); + this.Controls.Add(this.connectionStringLabel); + this.Controls.Add(this.usersConnectionStringTextBox); + this.Controls.Add(this.benchNameTextBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MinimizeBox = false; + this.Name = "DatabaseSettingsDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.BenchSettingsDlg_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox benchNameTextBox; + private System.Windows.Forms.TextBox usersConnectionStringTextBox; + private System.Windows.Forms.Label connectionStringLabel; + private System.Windows.Forms.TextBox benchConnectionStringTextBox; + private System.Windows.Forms.TextBox proceduresConnectionStringTextBox; + private System.Windows.Forms.TextBox wmTypesConnectionStringTextBox; + private System.Windows.Forms.TextBox watermetersConnectionStringTextBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button testConnUsersBtn; + private System.Windows.Forms.Button createUsersDbBtn; + private System.Windows.Forms.CheckBox realBenchCheckBox; + private System.Windows.Forms.Label dbTypeLabel; + private System.Windows.Forms.ComboBox usersDbTypeComboBox; + private System.Windows.Forms.ComboBox benchDbTypeComboBox; + private System.Windows.Forms.ComboBox proceduresDbTypeComboBox; + private System.Windows.Forms.ComboBox wmTypesDbTypeComboBox; + private System.Windows.Forms.ComboBox watermetersDbTypeComboBox; + private System.Windows.Forms.Button testConnBenchBtn; + private System.Windows.Forms.Button testConnProceduresBtn; + private System.Windows.Forms.Button testConnWMTypesBtn; + private System.Windows.Forms.Button testConnWaterMetersBtn; + private System.Windows.Forms.Button createBenchDbBtn; + private System.Windows.Forms.Button createProceduresDbBtn; + private System.Windows.Forms.Button createWMTypesDbBtn; + private System.Windows.Forms.Button createWaterMetersDbBtn; + } +} \ No newline at end of file diff --git a/ResultsBrowser/DatabaseSettingsDlg.cs b/ResultsBrowser/DatabaseSettingsDlg.cs new file mode 100644 index 000000000..6459de002 --- /dev/null +++ b/ResultsBrowser/DatabaseSettingsDlg.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using TBF.Resources; + +namespace TBF +{ + /// + /// Dialog to process test bench name and database settings (BenchSettings) + /// + public partial class DatabaseSettingsDlg : Form + { + // Reference to bench DB settins (not a local copy) + DatabaseSettings bench; + + /// + /// Constructor + /// + /// Test bench database settings + public DatabaseSettingsDlg(DatabaseSettings bench) + { + this.bench = bench; + + InitializeComponent(); + } + + void Localize() + { + Text = Strings.Test_Bench_Databases_Specification; + label1.Text = Strings.Test_bench_name; + realBenchCheckBox.Text = Strings.Test_bench_is_controlled_by_this_computer; + dbTypeLabel.Text = Strings.Database_type; + connectionStringLabel.Text = Strings.Connection_string; + label2.Text = Strings.Users_and_groups; + label3.Text = Strings.Bench_parameters; + label4.Text = Strings.Procedures; + label5.Text = Strings.Water_meter_types; + label6.Text = Strings.Water_meter_data; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + + testConnBenchBtn.Text = Strings.Test_connection; + testConnProceduresBtn.Text = Strings.Test_connection; + testConnUsersBtn.Text = Strings.Test_connection; + testConnWaterMetersBtn.Text = Strings.Test_connection; + testConnWMTypesBtn.Text = Strings.Test_connection; + + createBenchDbBtn.Text = Strings.Create_DB; + createProceduresDbBtn.Text = Strings.Create_DB; + createUsersDbBtn.Text = Strings.Create_DB; + createWaterMetersDbBtn.Text = Strings.Create_DB; + createWMTypesDbBtn.Text = Strings.Create_DB; + } + + private void BenchSettingsDlg_Load(object sender, EventArgs e) + { + Localize(); + + benchNameTextBox.Text = bench.BenchName; + realBenchCheckBox.Checked = bench.IsRealBench; + + /// Initialize 'Database type' combo-boxes + for (int i = 0; i < (int)DBType.DbTypesCount; i++) + { + DBType dbType = (DBType)i; + usersDbTypeComboBox.Items.Add(dbType); + benchDbTypeComboBox.Items.Add(dbType); + proceduresDbTypeComboBox.Items.Add(dbType); + wmTypesDbTypeComboBox.Items.Add(dbType); + watermetersDbTypeComboBox.Items.Add(dbType); + } + usersDbTypeComboBox.SelectedIndex = (int)bench.UsersDBSettings.DbType; + benchDbTypeComboBox.SelectedIndex = (int)bench.BenchDBSettings.DbType; + proceduresDbTypeComboBox.SelectedIndex = (int)bench.ProceduresDBSettings.DbType; + wmTypesDbTypeComboBox.SelectedIndex = (int)bench.WMTypesDBSettings.DbType; + watermetersDbTypeComboBox.SelectedIndex = (int)bench.WaterMetersDBSettings.DbType; + + /// Initialize connection strings + usersConnectionStringTextBox.Text = bench.UsersDBSettings.ConnectionString; + benchConnectionStringTextBox.Text = bench.BenchDBSettings.ConnectionString; + proceduresConnectionStringTextBox.Text = bench.ProceduresDBSettings.ConnectionString; + wmTypesConnectionStringTextBox.Text = bench.WMTypesDBSettings.ConnectionString; + watermetersConnectionStringTextBox.Text = bench.WaterMetersDBSettings.ConnectionString; + } + + bool UpdateBenchFromUIControls() + { + for (int i = 0; i < Program.LocalSettings.BenchesCount; i++) + { + if (bench != Program.LocalSettings.TestBenches[i] && + benchNameTextBox.Text == Program.LocalSettings.TestBenches[i].BenchName) + { + MessageBox.Show(Strings.Bench_name_conflict_Use_another_name_pls, Strings.Error, MessageBoxButtons.OK); + return false; + } + } + + bench.BenchName = benchNameTextBox.Text; + bench.IsRealBench = realBenchCheckBox.Checked; + + bench.UsersDBSettings.ConnectionString = usersConnectionStringTextBox.Text; + bench.BenchDBSettings.ConnectionString = benchConnectionStringTextBox.Text; + bench.ProceduresDBSettings.ConnectionString = proceduresConnectionStringTextBox.Text; + bench.WMTypesDBSettings.ConnectionString = wmTypesConnectionStringTextBox.Text; + bench.WaterMetersDBSettings.ConnectionString = watermetersConnectionStringTextBox.Text; + + bench.UsersDBSettings.DbType = (DBType)usersDbTypeComboBox.SelectedIndex; + bench.BenchDBSettings.DbType = (DBType)benchDbTypeComboBox.SelectedIndex; + bench.ProceduresDBSettings.DbType = (DBType)proceduresDbTypeComboBox.SelectedIndex; + bench.WMTypesDBSettings.DbType = (DBType)wmTypesDbTypeComboBox.SelectedIndex; + bench.WaterMetersDBSettings.DbType = (DBType)watermetersDbTypeComboBox.SelectedIndex; + + return true; + } + + /// + /// Update bench DB setting, return 'OK' + /// + /// Not used + /// Not used + private void okButton_Click(object sender, EventArgs e) + { + if (UpdateBenchFromUIControls()) + { + DialogResult = DialogResult.OK; + Close(); + return; + } + + DialogResult = DialogResult.None; + } + + /// + /// Throw away changes, return 'Cancel' + /// + /// Not used + /// Not used + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void createDatabasesButton_Click(object sender, EventArgs e) + { + if (!UpdateBenchFromUIControls()) return; + + if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine + + Strings.Do_you_want_to_proceed, Strings.Warning, + MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) + try + { + Cursor.Current = Cursors.WaitCursor; + FluentCommon.CreateEmptyUsersDB(bench.UsersDBSettings); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); + Cursor.Current = Cursors.Default; + DialogResult = DialogResult.None; + } + catch (Exception exception) + { + Cursor.Current = Cursors.Default; + MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error); + } + } + + private void createbenchDbBtn_Click(object sender, EventArgs e) + { + if (!UpdateBenchFromUIControls()) return; + + if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine + + Strings.Do_you_want_to_proceed, Strings.Warning, + MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) + try + { + Cursor.Current = Cursors.WaitCursor; + FluentCommon.CreateEmptyBenchDB(bench.BenchDBSettings); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); + Cursor.Current = Cursors.Default; + DialogResult = DialogResult.None; + } + catch (Exception exception) + { + Cursor.Current = Cursors.Default; + MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error); + } + } + + private void createProecduresDbBtn_Click(object sender, EventArgs e) + { + if (!UpdateBenchFromUIControls()) return; + + if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine + + Strings.Do_you_want_to_proceed, Strings.Warning, + MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) + try + { + Cursor.Current = Cursors.WaitCursor; + FluentCommon.CreateEmptyProceduresDB(bench.ProceduresDBSettings); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); + Cursor.Current = Cursors.Default; + DialogResult = DialogResult.None; + } + catch (Exception exception) + { + Cursor.Current = Cursors.Default; + MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error); + } + } + + private void createWMTypesDbBtn_Click(object sender, EventArgs e) + { + + } + + private void createWaterMetersDbBtn_Click(object sender, EventArgs e) + { + if (!UpdateBenchFromUIControls()) return; + + if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine + + Strings.Do_you_want_to_proceed, Strings.Warning, + MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) + try + { + Cursor.Current = Cursors.WaitCursor; + FluentCommon.CreateEmptyWaterMetersDB(bench.WaterMetersDBSettings); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); + Cursor.Current = Cursors.Default; + DialogResult = DialogResult.None; + } + catch (Exception exception) + { + Cursor.Current = Cursors.Default; + MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error); + } + } + + private void testConnUsersBtn_Click(object sender, EventArgs e) + { + } + + private void testConnBenchBtn_Click(object sender, EventArgs e) + { + } + + private void testConnProceduresBtn_Click(object sender, EventArgs e) + { + } + + private void testConnWMTypesBtn_Click(object sender, EventArgs e) + { + } + + private void testConnWaterMetersBtn_Click(object sender, EventArgs e) + { + } + } +} \ No newline at end of file diff --git a/ResultsBrowser/DatabaseSettingsDlg.resx b/ResultsBrowser/DatabaseSettingsDlg.resx new file mode 100644 index 000000000..9e8ff90fa --- /dev/null +++ b/ResultsBrowser/DatabaseSettingsDlg.resx @@ -0,0 +1,930 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 614, 15 + + + 217, 28 + + + + 14 + + + OK + + + okButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 30 + + + 614, 49 + + + 217, 28 + + + 13 + + + Cancel + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 31 + + + True + + + 12, 18 + + + 93, 13 + + + 15 + + + Test Bench Name + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 29 + + + 116, 15 + + + 315, 20 + + + 16 + + + benchNameTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 28 + + + 202, 101 + + + 406, 20 + + + 17 + + + usersConnectionStringTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 27 + + + True + + + 199, 82 + + + 89, 13 + + + 18 + + + Connection string + + + connectionStringLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 26 + + + 202, 127 + + + 406, 20 + + + 19 + + + benchConnectionStringTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 25 + + + 202, 153 + + + 406, 20 + + + 20 + + + proceduresConnectionStringTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 24 + + + 202, 179 + + + 406, 20 + + + 21 + + + wmTypesConnectionStringTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 23 + + + 202, 205 + + + 406, 20 + + + 22 + + + watermetersConnectionStringTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 22 + + + True + + + 12, 104 + + + 90, 13 + + + 47 + + + Users and groups + + + label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 21 + + + True + + + 12, 130 + + + 93, 13 + + + 48 + + + Bench parameters + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 20 + + + True + + + 12, 156 + + + 61, 13 + + + 49 + + + Procedures + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 19 + + + True + + + 12, 182 + + + 90, 13 + + + 50 + + + Watermeter types + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 18 + + + True + + + 12, 208 + + + 67, 13 + + + 51 + + + Watermeters + + + label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 17 + + + 614, 99 + + + 95, 23 + + + 52 + + + Test Connection + + + testConnUsersBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 16 + + + 711, 99 + + + 120, 23 + + + 53 + + + Create DB + + + createUsersDbBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 15 + + + True + + + 116, 47 + + + 219, 17 + + + 54 + + + Test bench is controlled by this computer + + + realBenchCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 14 + + + True + + + 113, 82 + + + 76, 13 + + + 55 + + + Database type + + + dbTypeLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 13 + + + 116, 101 + + + 80, 21 + + + 56 + + + usersDbTypeComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 12 + + + 116, 127 + + + 80, 21 + + + 57 + + + benchDbTypeComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 11 + + + 116, 153 + + + 80, 21 + + + 58 + + + proceduresDbTypeComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 10 + + + 116, 179 + + + 80, 21 + + + 59 + + + wmTypesDbTypeComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + + + 116, 205 + + + 80, 21 + + + 60 + + + watermetersDbTypeComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 8 + + + + NoControl + + + 614, 125 + + + 95, 23 + + + 61 + + + Test Connection + + + testConnBenchBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 7 + + + NoControl + + + 614, 151 + + + 95, 23 + + + 62 + + + Test Connection + + + testConnProceduresBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + + + NoControl + + + 614, 177 + + + 95, 23 + + + 63 + + + Test Connection + + + testConnWMTypesBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + NoControl + + + 614, 203 + + + 95, 23 + + + 64 + + + Test Connection + + + testConnWaterMetersBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + NoControl + + + 711, 124 + + + 120, 23 + + + 65 + + + Create DB + + + createBenchDbBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + NoControl + + + 711, 150 + + + 120, 23 + + + 66 + + + Create DB + + + createProceduresDbBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + NoControl + + + 711, 176 + + + 120, 23 + + + 67 + + + Create DB + + + createWMTypesDbBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + NoControl + + + 711, 202 + + + 120, 23 + + + 68 + + + Create DB + + + createWaterMetersDbBtn + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 836, 241 + + + CenterParent + + + Test Bench Databases Specification + + + DatabaseSettingsDlg + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ResultsBrowser/Entities/BenchPath.cs b/ResultsBrowser/Entities/BenchPath.cs new file mode 100644 index 000000000..009d1d290 --- /dev/null +++ b/ResultsBrowser/Entities/BenchPath.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class BenchPath : IHasItemNr, IHasValves + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual float Qfrom { get; set; } /// Water flow in [m3/h] + public virtual float Qto { get; set; } /// Water flow in [m3/h] + public virtual string TempIn { get; set; } + public virtual string TempOut { get; set; } + public virtual string PressIn { get; set; } + public virtual string PressOut { get; set; } + + /// Valves + public virtual string ValvesOpen { get; set; } + public virtual string ValvesClose { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public BenchPath() + { + } + + public BenchPath(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public BenchPath(BenchControl.BenchPath path) + : this(path.Name, path.ItemNr) + { + Qfrom = path.Qfrom; + Qto = path.Qto; + TempIn = (path.TempIn != null) ? path.TempIn.Cfg.Name : null; + TempOut = (path.TempOut != null) ? path.TempOut.Cfg.Name : null; + PressIn = (path.PressIn != null) ? path.PressIn.Cfg.Name : null; + PressOut = (path.PressOut != null) ? path.PressOut.Cfg.Name : null; + + string vOpen = string.Empty; + foreach (var valve in path.ValvesOpen) + { + if (vOpen != string.Empty) vOpen += ";"; + vOpen += valve.Cfg.Name; + } + ValvesOpen = vOpen; + + string vClose = string.Empty; + foreach (var valve in path.ValvesClose) + { + if (vClose != string.Empty) vClose += ";"; + vClose += valve.Cfg.Name; + } + ValvesClose = vClose; + } + + public virtual BenchPath Clone(string name, int itemNr) + { + BenchPath result = new BenchPath(name, itemNr); + + result.Qfrom = Qfrom; + result.Qto = Qto; + result.TempIn = TempIn; + result.TempOut = TempOut; + result.PressIn = PressIn; + result.PressOut = PressOut; + result.ValvesOpen = ValvesOpen; + result.ValvesClose = ValvesClose; + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/Component.cs b/ResultsBrowser/Entities/Component.cs new file mode 100644 index 000000000..49bd24ffc --- /dev/null +++ b/ResultsBrowser/Entities/Component.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class Component : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual string ClassName { get; set; } + public virtual string ParentName { get; set; } + public virtual DebugMode Mode { get; set; } + public virtual LogLevel Logging { get; set; } + public virtual string Parameters { get; set; } + public virtual IList Corrections { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public Component() + { + Corrections = new List(); + } + + public static Component CreateFromCfg(string name, string className, string parentName, int itemNr, + DebugMode debugLevel, LogLevel logLevel, string parameters) + { + Component result = new Component(); + result.ItemNr = itemNr; + result.Name = name; + result.ClassName = className; + result.ParentName = parentName; + result.Mode = debugLevel; + result.Logging = logLevel; + result.Parameters = parameters; + return result; + } + + // Makes a new copy of this object (not just a reference) + public virtual Component Clone() + { + Component result = new Component(); + result.ItemNr = ItemNr; + result.Name = Name; + result.ClassName = ClassName; + result.ParentName = ParentName; + result.Mode = Mode; + result.Logging = Logging; + result.Parameters = Parameters; + return result; + } + + public virtual string ToString(string indent) + { + string result = string.Empty; + + result += indent + "ItemNr = " + (ItemNr + 1).ToString() + Environment.NewLine; + result += indent + "Name = " + Name + Environment.NewLine; + result += indent + "ClassName = " + ClassName + Environment.NewLine; + if (ParentName != null) + { + result += indent + "ParentName = " + ParentName + Environment.NewLine; + } + result += indent + "DebugLevel = " + Mode.ToString() + Environment.NewLine; + result += indent + "LogLevel = " + Logging.ToString() + Environment.NewLine; + result += indent + "Parameters = " + Parameters + Environment.NewLine; + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/ComponentProcedure.cs b/ResultsBrowser/Entities/ComponentProcedure.cs new file mode 100644 index 000000000..1ef820ec7 --- /dev/null +++ b/ResultsBrowser/Entities/ComponentProcedure.cs @@ -0,0 +1,20 @@ + +namespace ResultsBrowser.Entities +{ + public class ComponentProcedure + { + public virtual int Id { get; protected set; } + public virtual string CmpntName { get; set; } /// Component name + public virtual string Parameters { get; set; } + public virtual Procedure Procedure { get; set; } + + public virtual ComponentProcedure Clone() + { + ComponentProcedure result = new ComponentProcedure(); + result.CmpntName = CmpntName; + result.Parameters = Parameters; + result.Procedure = Procedure; + return result; + } + } +} diff --git a/ResultsBrowser/Entities/ComponentTest.cs b/ResultsBrowser/Entities/ComponentTest.cs new file mode 100644 index 000000000..4af5c98b0 --- /dev/null +++ b/ResultsBrowser/Entities/ComponentTest.cs @@ -0,0 +1,20 @@ + +namespace ResultsBrowser.Entities +{ + public class ComponentTest + { + public virtual int Id { get; protected set; } + public virtual string CmpntName { get; set; } /// Component name + public virtual string Parameters { get; set; } + public virtual Test Test { get; set; } + + public virtual ComponentTest Clone() + { + ComponentTest result = new ComponentTest(); + result.CmpntName = CmpntName; + result.Parameters = Parameters; + result.Test = Test; + return result; + } + } +} diff --git a/ResultsBrowser/Entities/Enums.cs b/ResultsBrowser/Entities/Enums.cs new file mode 100644 index 000000000..6e2d65983 --- /dev/null +++ b/ResultsBrowser/Entities/Enums.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + /// + /// Kind of meters for the procedure / test + /// + public enum MetersKind + { + Single, + Combined, + } + + /// + /// Flow set method Std/ComposedMeter + /// + public enum QSetMethod + { + Std, + ComposedMeter, + Count, + } + + /// + /// Procedure method FSS/SSS + /// + public enum TestMethod2 + { + FSS, + SSS, + Count, + } + + public enum TestRedType + { + Fix, + /// etc. + Count, + } + + public enum FQC1 + { + FQC1, + FQP1, + Count, + } + + public enum Device + { + Screen, + Printer, + Disk, + } + + /// + /// Possible modes of operation of components and devices. + /// + public enum DebugMode + { + DetectedOff = -2, + DetectedOn = -1, + Normal = 0, /// Normal operation + AutoDetect, /// The component (device) will be auto-detected + Off, /// The component is off + Record, + Reply, + Simulate, /// Test bench simulation, this mode does not require any hardware + Inherit, + Count, + } + + public enum LogLevel + { + Off, + Fatal, + Error, + Warn, + Info, + Debug, + All, + Count, + } +} + diff --git a/ResultsBrowser/Entities/FeedingPath.cs b/ResultsBrowser/Entities/FeedingPath.cs new file mode 100644 index 000000000..9e2b97d16 --- /dev/null +++ b/ResultsBrowser/Entities/FeedingPath.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class FeedingPath : IHasItemNr, IHasValves + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual float Qfrom { get; set; } /// Water flow in [m3/h] + public virtual float Qto { get; set; } /// Water flow in [m3/h] + public virtual string Pump { get; set; } + + /// Valves + public virtual string ValvesOpen { get; set; } + public virtual string ValvesClose { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public FeedingPath() + { + } + + public FeedingPath(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public FeedingPath(BenchControl.FeedingPath path) + : this(path.Name, path.ItemNr) + { + Qfrom = path.Qfrom; + Qto = path.Qto; + Pump = (path.Pump != null) ? path.Pump.Cfg.Name : null; + + string vOpen = string.Empty; + foreach (var valve in path.ValvesOpen) + { + if (vOpen != string.Empty) vOpen += ";"; + vOpen += valve.Cfg.Name; + } + ValvesOpen = vOpen; + + string vClose = string.Empty; + foreach (var valve in path.ValvesClose) + { + if (vClose != string.Empty) vClose += ";"; + vClose += valve.Cfg.Name; + } + ValvesClose = vClose; + } + + public virtual FeedingPath Clone(string name, int itemNr) + { + FeedingPath result = new FeedingPath(name, itemNr); + + result.Qfrom = Qfrom; + result.Qto = Qto; + result.Pump = Pump; + result.ValvesOpen = ValvesOpen; + result.ValvesClose = ValvesClose; + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/Group.cs b/ResultsBrowser/Entities/Group.cs new file mode 100644 index 000000000..12e004cdf --- /dev/null +++ b/ResultsBrowser/Entities/Group.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class Group + { + public virtual int Id { get; protected set; } + public virtual int Gid { get; set; } + public virtual string Name { get; set; } + } +} diff --git a/ResultsBrowser/Entities/IHasItemNr.cs b/ResultsBrowser/Entities/IHasItemNr.cs new file mode 100644 index 000000000..f62ee62ea --- /dev/null +++ b/ResultsBrowser/Entities/IHasItemNr.cs @@ -0,0 +1,9 @@ + +namespace ResultsBrowser.Entities +{ + interface IHasItemNr + { + int Id { get; } + int ItemNr { get; set; } + } +} diff --git a/ResultsBrowser/Entities/IHasValves.cs b/ResultsBrowser/Entities/IHasValves.cs new file mode 100644 index 000000000..6161f29bb --- /dev/null +++ b/ResultsBrowser/Entities/IHasValves.cs @@ -0,0 +1,9 @@ + +namespace ResultsBrowser.Entities +{ + public interface IHasValves + { + string ValvesOpen { get; set; } /// List of valves to be opened + string ValvesClose { get; set; } /// List of valves to be closed + } +} diff --git a/ResultsBrowser/Entities/MeasurementCorrection.cs b/ResultsBrowser/Entities/MeasurementCorrection.cs new file mode 100644 index 000000000..1a3303c8b --- /dev/null +++ b/ResultsBrowser/Entities/MeasurementCorrection.cs @@ -0,0 +1,11 @@ +using System; + +namespace ResultsBrowser.Entities +{ + public class MeasurementCorrection + { + public virtual int Id { get; protected set; } + public virtual float Measurement { get; set; } + public virtual float Correction { get; set; } + } +} diff --git a/ResultsBrowser/Entities/MeterTestResult.cs b/ResultsBrowser/Entities/MeterTestResult.cs new file mode 100644 index 000000000..30fb642ac --- /dev/null +++ b/ResultsBrowser/Entities/MeterTestResult.cs @@ -0,0 +1,51 @@ +using System; + +namespace ResultsBrowser.Entities +{ + public class MeterTestResult + { + public virtual int Id { get; protected set; } + public virtual TestResult TestResult { get; set; } /// reference to the TestResult entity + + public virtual string SerialNr { get; set; } + public virtual string EndState { get; set; } + public virtual float VolumeStart { get; set; } /// liter + public virtual float VolumeEnd { get; set; } /// liter + public virtual float VolumeMeter { get; set; } /// liter + public virtual float VolumeRef { get; set; } /// liter + public virtual float VolumeErrorPct { get; set; } /// % + public virtual float PulsesMeter { get; set; } /// Not applicable for a combined meter + public virtual float PulsesMaster { get; set; } + public virtual float Time { get; set; } /// sec. + public virtual bool Passed { get; set; } /// true = test passed + + public MeterTestResult() + { + } + + public MeterTestResult(TestResult testResult) + : this() + { + TestResult = testResult; + } + + public virtual MeterTestResult Clone(TestResult testResult) + { + MeterTestResult result = new MeterTestResult(testResult); + + result.SerialNr = SerialNr; + result.EndState = EndState; + result.VolumeStart = VolumeStart; + result.VolumeEnd = VolumeEnd; + result.VolumeMeter = VolumeMeter; + result.VolumeRef = VolumeRef; + result.VolumeErrorPct = VolumeErrorPct; + result.PulsesMeter = PulsesMeter; + result.PulsesMaster = PulsesMaster; + result.Time = Time; + result.Passed = Passed; + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/MetersPath.cs b/ResultsBrowser/Entities/MetersPath.cs new file mode 100644 index 000000000..0111ca705 --- /dev/null +++ b/ResultsBrowser/Entities/MetersPath.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class MetersPath : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual float Qfrom { get; set; } /// Water flow in [m3/h] + public virtual float Qto { get; set; } /// Water flow in [m3/h] + + /// Sensors + public virtual string Sensor1 { get; set; } + public virtual string Sensor2 { get; set; } + public virtual string Sensor3 { get; set; } + public virtual string Sensor4 { get; set; } + public virtual string Sensor5 { get; set; } + public virtual string Sensor6 { get; set; } + public virtual string Sensor7 { get; set; } + public virtual string Sensor8 { get; set; } + public virtual string Sensor9 { get; set; } + public virtual string Sensor10 { get; set; } + public virtual string Sensor11 { get; set; } + public virtual string Sensor12 { get; set; } + public virtual string Sensor13 { get; set; } + public virtual string Sensor14 { get; set; } + public virtual string Sensor15 { get; set; } + public virtual string Sensor16 { get; set; } + public virtual string Sensor17 { get; set; } + public virtual string Sensor18 { get; set; } + public virtual string Sensor19 { get; set; } + public virtual string Sensor20 { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public MetersPath() + { + } + + public MetersPath(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public MetersPath(BenchControl.MetersPath path) + : this(path.Name, path.ItemNr) + { + Qfrom = path.Qfrom; + Qto = path.Qto; + Sensor1 = (path.RegisterReaders[0] != null) ? path.RegisterReaders[0].Cfg.Name : null; +#pragma warning disable + if (Program.WMsCount >= 2) Sensor2 = (path.RegisterReaders[1] != null) ? path.RegisterReaders[1].Cfg.Name : null; + if (Program.WMsCount >= 3) Sensor3 = (path.RegisterReaders[2] != null) ? path.RegisterReaders[2].Cfg.Name : null; + if (Program.WMsCount >= 4) Sensor4 = (path.RegisterReaders[3] != null) ? path.RegisterReaders[3].Cfg.Name : null; + if (Program.WMsCount >= 5) Sensor5 = (path.RegisterReaders[4] != null) ? path.RegisterReaders[4].Cfg.Name : null; + if (Program.WMsCount >= 6) Sensor6 = (path.RegisterReaders[5] != null) ? path.RegisterReaders[5].Cfg.Name : null; + if (Program.WMsCount >= 7) Sensor7 = (path.RegisterReaders[6] != null) ? path.RegisterReaders[6].Cfg.Name : null; + if (Program.WMsCount >= 8) Sensor8 = (path.RegisterReaders[7] != null) ? path.RegisterReaders[7].Cfg.Name : null; + if (Program.WMsCount >= 9) Sensor9 = (path.RegisterReaders[8] != null) ? path.RegisterReaders[8].Cfg.Name : null; + if (Program.WMsCount >= 10) Sensor10 = (path.RegisterReaders[9] != null) ? path.RegisterReaders[9].Cfg.Name : null; + if (Program.WMsCount >= 11) Sensor11 = (path.RegisterReaders[10] != null) ? path.RegisterReaders[10].Cfg.Name : null; + if (Program.WMsCount >= 12) Sensor12 = (path.RegisterReaders[11] != null) ? path.RegisterReaders[11].Cfg.Name : null; + if (Program.WMsCount >= 13) Sensor13 = (path.RegisterReaders[12] != null) ? path.RegisterReaders[12].Cfg.Name : null; + if (Program.WMsCount >= 14) Sensor14 = (path.RegisterReaders[13] != null) ? path.RegisterReaders[13].Cfg.Name : null; + if (Program.WMsCount >= 15) Sensor15 = (path.RegisterReaders[14] != null) ? path.RegisterReaders[14].Cfg.Name : null; + if (Program.WMsCount >= 16) Sensor16 = (path.RegisterReaders[15] != null) ? path.RegisterReaders[15].Cfg.Name : null; + if (Program.WMsCount >= 17) Sensor17 = (path.RegisterReaders[16] != null) ? path.RegisterReaders[16].Cfg.Name : null; + if (Program.WMsCount >= 18) Sensor18 = (path.RegisterReaders[17] != null) ? path.RegisterReaders[17].Cfg.Name : null; + if (Program.WMsCount >= 19) Sensor19 = (path.RegisterReaders[18] != null) ? path.RegisterReaders[18].Cfg.Name : null; + if (Program.WMsCount >= 20) Sensor20 = (path.RegisterReaders[19] != null) ? path.RegisterReaders[19].Cfg.Name : null; +#pragma warning restore + } + + public virtual MetersPath Clone(string name, int itemNr) + { + MetersPath result = new MetersPath(name, itemNr); + result.Qfrom = Qfrom; + result.Qto = Qto; + result.Sensor1 = Sensor1; + result.Sensor2 = Sensor2; + result.Sensor3 = Sensor3; + result.Sensor4 = Sensor4; + result.Sensor5 = Sensor5; + result.Sensor6 = Sensor6; + result.Sensor7 = Sensor7; + result.Sensor8 = Sensor8; + result.Sensor9 = Sensor9; + result.Sensor10 = Sensor10; + result.Sensor11 = Sensor11; + result.Sensor12 = Sensor12; + result.Sensor13 = Sensor13; + result.Sensor14 = Sensor14; + result.Sensor15 = Sensor15; + result.Sensor16 = Sensor16; + result.Sensor17 = Sensor17; + result.Sensor18 = Sensor18; + result.Sensor19 = Sensor19; + result.Sensor20 = Sensor20; + return result; + } + + /// Returns the component name + public virtual string GetSensor(int i) + { + if (i == 0) return Sensor1; + else if (i == 1) return Sensor2; + else if (i == 2) return Sensor3; + else if (i == 3) return Sensor4; + else if (i == 4) return Sensor5; + else if (i == 5) return Sensor6; + else if (i == 6) return Sensor7; + else if (i == 7) return Sensor8; + else if (i == 8) return Sensor9; + else if (i == 9) return Sensor10; + else if (i == 10) return Sensor11; + else if (i == 11) return Sensor12; + else if (i == 12) return Sensor13; + else if (i == 13) return Sensor14; + else if (i == 14) return Sensor15; + else if (i == 15) return Sensor16; + else if (i == 16) return Sensor17; + else if (i == 17) return Sensor18; + else if (i == 18) return Sensor19; + else if (i == 19) return Sensor20; + else return null; + } + + /// Sets the component name + public virtual void SetSensor(int i, string cmpntName) + { + if (i == 0) Sensor1 = cmpntName; + else if (i == 1) Sensor2 = cmpntName; + else if (i == 2) Sensor3 = cmpntName; + else if (i == 3) Sensor4 = cmpntName; + else if (i == 4) Sensor5 = cmpntName; + else if (i == 5) Sensor6 = cmpntName; + else if (i == 6) Sensor7 = cmpntName; + else if (i == 7) Sensor8 = cmpntName; + else if (i == 8) Sensor9 = cmpntName; + else if (i == 9) Sensor10 = cmpntName; + else if (i == 10) Sensor11 = cmpntName; + else if (i == 11) Sensor12 = cmpntName; + else if (i == 12) Sensor13 = cmpntName; + else if (i == 13) Sensor14 = cmpntName; + else if (i == 14) Sensor15 = cmpntName; + else if (i == 15) Sensor16 = cmpntName; + else if (i == 16) Sensor17 = cmpntName; + else if (i == 17) Sensor18 = cmpntName; + else if (i == 18) Sensor19 = cmpntName; + else if (i == 19) Sensor20 = cmpntName; + } + } +} diff --git a/ResultsBrowser/Entities/OutputPath.cs b/ResultsBrowser/Entities/OutputPath.cs new file mode 100644 index 000000000..5ddcbd938 --- /dev/null +++ b/ResultsBrowser/Entities/OutputPath.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class OutputPath : IHasItemNr, IHasValves + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual float Qfrom { get; set; } /// Water flow in [m3/h] + public virtual float Qto { get; set; } /// Water flow in [m3/h] + public virtual string RegulValve { get; set; } + public virtual string FlowMeter { get; set; } + public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path + public virtual string StartValve { get; set; } + public virtual string Diverter { get; set; } + public virtual string TempDiv { get; set; } + public virtual string Balance { get; set; } + public virtual string EmptyTankValve { get; set; } + + /// Valves + public virtual string ValvesOpen { get; set; } + public virtual string ValvesClose { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public OutputPath() + { + } + + public OutputPath(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public OutputPath(BenchControl.OutputPath path) + : this(path.Name, path.ItemNr) + { + Qfrom = path.Qfrom; + Qto = path.Qto; + RegulValve = (path.RegulValve != null) ? path.RegulValve.Cfg.Name : null; + FlowMeter = (path.FlowMeter != null) ? path.FlowMeter.Cfg.Name : null; + PidCoef = path.PidCoef; + StartValve = (path.StartValve != null) ? path.StartValve.Cfg.Name : null; + Diverter = (path.Diverter != null) ? path.Diverter.Cfg.Name : null; + TempDiv = (path.TempDiv != null) ? path.TempDiv.Cfg.Name : null; + Balance = (path.Balance != null) ? path.Balance.Cfg.Name : null; + EmptyTankValve = (path.EmptyTankValve != null) ? path.EmptyTankValve.Cfg.Name : null; + + string vOpen = string.Empty; + foreach (var valve in path.ValvesOpen) + { + if (vOpen != string.Empty) vOpen += ";"; + vOpen += valve.Cfg.Name; + } + ValvesOpen = vOpen; + + string vClose = string.Empty; + foreach (var valve in path.ValvesClose) + { + if (vClose != string.Empty) vClose += ";"; + vClose += valve.Cfg.Name; + } + ValvesClose = vClose; + } + + public virtual OutputPath Clone(string name, int itemNr) + { + OutputPath result = new OutputPath(name, itemNr); + + result.Name = Name; + result.Qfrom = Qfrom; + result.Qto = Qto; + result.RegulValve = RegulValve; + result.FlowMeter = FlowMeter; + result.PidCoef = PidCoef; + result.StartValve = StartValve; + result.Diverter = Diverter; + result.TempDiv = TempDiv; + result.Balance = Balance; + result.EmptyTankValve = EmptyTankValve; + result.ValvesOpen = ValvesOpen; + result.ValvesClose = ValvesClose; + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/Procedure.cs b/ResultsBrowser/Entities/Procedure.cs new file mode 100644 index 000000000..4ffdbc61f --- /dev/null +++ b/ResultsBrowser/Entities/Procedure.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using TBF.Resources; + +namespace ResultsBrowser.Entities +{ + /// + /// Stores one test procedure, supports revisions and history log + /// + public class Procedure : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual MetersKind MetersKind { get; set; } + public virtual string Description { get; set; } /// Short description + public virtual string CreationUser { get; set; } /// Name of the user who has created or changed this procedure + public virtual DateTime CreationTime { get; set; } /// Date and time of the creation or change + public virtual string LastChgUser { get; set; } /// Name of the user who has created or changed this procedure + public virtual DateTime LastChgTime { get; set; } /// Date and time of the creation or change + public virtual string LongDescription { get; set; } /// Long description (notes) + public virtual string Watermeters { get; set; } /// Water meter name or Id + public virtual string ProtocolTitle { get; set; } /// Title of the printed and saved protocol + + public virtual string DataEntry { get; set; } /// Component to use for data entry + public virtual string ResultsPrinter { get; set; } /// Component to use for printing the results + public virtual string ResultsWriter { get; set; } /// Component to use for saving the results into the file + public virtual string TransitionStart { get; set; } + public virtual string TransitionEnd { get; set; } + + public virtual IList MoreParams { get; set; } + public virtual IList Tests { get; set; } + + ////public virtual string MetrologicalClass { get; set; } + ////public virtual IList WMTypes { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public Procedure() + { + MoreParams = new List(); + Tests = new List(); + + /// + /// Default values + /// + CreationUser = (User.CurrentUser != null) ? User.CurrentUser.Name : null; + CreationTime = DateTime.Now; + LastChgUser = CreationUser; + LastChgTime = CreationTime; + MetersKind = Entities.MetersKind.Single; + ProtocolTitle = "Watermeter test protocol"; + } + + public Procedure(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public virtual Procedure Clone() + { + Procedure result = new Procedure(); + + result.Name = Name; + result.MetersKind = MetersKind; + result.Description = Description; + result.CreationUser = CreationUser; + result.CreationTime = CreationTime; + result.LastChgUser = LastChgUser; + result.LastChgTime = LastChgTime; + result.LongDescription = LongDescription; + result.Watermeters = Watermeters; + result.DataEntry = DataEntry; + result.ResultsPrinter = ResultsPrinter; + result.ResultsWriter = ResultsWriter; + result.TransitionStart = TransitionStart; + result.TransitionEnd = TransitionEnd; + + foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); } + foreach (var test in Tests) { result.Tests.Add(test.Clone()); } + + //result.MetrologicalClass = MetrologicalClass; + //result.WMType = WMType.Clone(); + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/ProcedureHistory.cs b/ResultsBrowser/Entities/ProcedureHistory.cs new file mode 100644 index 000000000..b47a410ec --- /dev/null +++ b/ResultsBrowser/Entities/ProcedureHistory.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class ProcedureHistory + { + public virtual int Id { get; protected set; } + public virtual Procedure Current { get; set; } + public virtual IList OldProcedures { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public ProcedureHistory() + { + Current = new Procedure(); + OldProcedures = new List(); + } + + public virtual ProcedureHistory Clone() + { + ProcedureHistory result = new ProcedureHistory(); + result.Current = Current.Clone(); + foreach (Procedure p in OldProcedures) result.OldProcedures.Add(p.Clone()); + return result; + } + } +} diff --git a/ResultsBrowser/Entities/Test.cs b/ResultsBrowser/Entities/Test.cs new file mode 100644 index 000000000..f3cdc2420 --- /dev/null +++ b/ResultsBrowser/Entities/Test.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + /// + /// Test, consisting of one or more repetitions of the test 'SingleTest'. + /// + public class Test : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } + public virtual string Name { get; set; } + public virtual int Part { get; set; } /// Part=0 ... test of all WM-s + /// Part>0 ... part of a set of tests with the same Name: subset of WM-s is given by MetersPath + public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h] + public virtual float Qto { get; set; } /// Water flow high limit in [m3/h] + public virtual float Volume { get; set; } /// Test volume (target) in [l] + public virtual float TstTime { get; set; } /// Test time (estimate) in [s] + public virtual int Repeats { get; set; } + public virtual bool Emptying { get; set; } + public virtual bool Zeroing { get; set; } + public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps + public virtual int Time2MassMsrmt { get; set; } /// Delay time from the test end (diverted) to the 2nd mass measuremen in [s] + public virtual string Method { get; set; } + public virtual float ErrLimLo { get; set; } /// in [%] (usually < 0) + public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0) + public virtual double TolerRed { get; set; } /// = Filter + public virtual TestRedType RedType { get; set; } + public virtual string FeedingPath { get; set; } + public virtual string BenchPath { get; set; } + public virtual string OutputPath { get; set; } + public virtual string MetersPath { get; set; } + public virtual string TransitionStart { get; set; } + public virtual string TransitionEnd { get; set; } + + public virtual IList MoreParams { get; set; } + + public virtual Procedure Procedure { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public Test() + { + MoreParams = new List(); + + /// + /// Default values + /// + Repeats = 1; + Emptying = false; + Zeroing = false; + PumpPower = 60.0f; /// [%] + Time2MassMsrmt = 5; /// [s] between the test end and the final mass measurement + ErrLimLo = -2.0f; /// [%] lower error limit + ErrLimHi = 2.0f; /// [%] upper error limit + TolerRed = 5.0; /// = Filter parameter + } + + public Test(string name, int itemNr, Procedure procedure) + : this() + { + Name = name; + ItemNr = itemNr; + Procedure = procedure; + } + + // Makes a new copy of this object (not just a reference) + public virtual Test Clone() + { + Test result = new Test(Name, ItemNr, Procedure); + + result.Part = Part; + result.Qfrom = Qfrom; + result.Qto = Qto; + result.Volume = Volume; + result.TstTime = TstTime; + result.Repeats = Repeats; + result.Emptying = Emptying; + result.Zeroing = Zeroing; + result.PumpPower = PumpPower; + result.Time2MassMsrmt = Time2MassMsrmt; + result.Method = Method; + result.ErrLimLo = ErrLimLo; + result.ErrLimHi = ErrLimHi; + result.TolerRed = TolerRed; + result.RedType = RedType; + result.FeedingPath = FeedingPath; + result.BenchPath = BenchPath; + result.OutputPath = OutputPath; + result.MetersPath = MetersPath; + foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); } + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/TestResult.cs b/ResultsBrowser/Entities/TestResult.cs new file mode 100644 index 000000000..94621ee89 --- /dev/null +++ b/ResultsBrowser/Entities/TestResult.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class TestResult + { + public virtual int Id { get; protected set; } + public virtual string Name { get; set; } + public virtual int BatchNr { get; set; } + public virtual MetersKind MetersKind { get; set; } + public virtual IList Meters { get; set; } + public virtual IList CombinedMeters { get; set; } + + /// Value copied from the procedure (Entities.Procedure) + public virtual string ProcedureName { get; set; } + public virtual string ProtocolTitle { get; set; } + + /// Values copied from the test (Entities.Test) + public virtual int TestId { get; set; } /// Test entity ID to distinguish between tests with the same name + public virtual string TestName { get; set; } + public virtual int Part { get; set; } + public virtual bool DoNotEvaluate { get; set; } /// Not mapped to the database + public virtual bool DoNotPublish { get; set; } /// Not mapped to the database + public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h] + public virtual float Qto { get; set; } /// Water flow high limit in [m3/h] + public virtual float Volume { get; set; } /// Test volume (target) in [l] + public virtual float TstTime { get; set; } /// Test time (estimate) in [s] + public virtual int Repeats { get; set; } + public virtual bool Emptying { get; set; } + public virtual bool Zeroing { get; set; } + public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps + public virtual int Time2MassMsrmt { get; set; } + public virtual string Method { get; set; } + public virtual float ErrLimLo { get; set; } /// in [%] (usually < 0) + public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0) + + /// To be replaced by the virtual bench component parameters + public virtual string FeedingPath { get; set; } + public virtual string BenchPath { get; set; } + public virtual string OutputPath { get; set; } + public virtual string MetersPath { get; set; } + + /// Results + public virtual DateTime TimeStart { get; set; } /// Date and time of the test start + public virtual DateTime TimeEnd { get; set; } /// Date and time of the test end + public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...) + public virtual float AmbientTempAve { get; set; } /// Average ambient air temperature [degC] + public virtual float AmbientPressAve { get; set; } /// Average ambient air pressure + public virtual float AmbientHumiAve { get; set; } /// Average ambient air relative humidity [%] + public virtual float PressInAvrg { get; set; } /// Input water pressure (average) [Bar] + public virtual float PressInStart { get; set; } + public virtual float PressInEnd { get; set; } + public virtual float PressOutAvrg { get; set; } + public virtual float PressOutStart { get; set; } + public virtual float PressOutEnd { get; set; } + public virtual float TempInAvrg { get; set; } + public virtual float TempInStart { get; set; } + public virtual float TempInEnd { get; set; } + public virtual float TempOutAvrg { get; set; } + public virtual float TempOutStart { get; set; } + public virtual float TempOutEnd { get; set; } + public virtual float TempDivAvrg { get; set; } + public virtual float TempDivStart { get; set; } + public virtual float TempDivEnd { get; set; } + public virtual float MassStartRaw { get; set; } + public virtual float MassStart { get; set; } + public virtual float MassEndRaw { get; set; } + public virtual float MassEnd { get; set; } + public virtual float MassDiff { get; set; } + public virtual float DensityIn { get; set; } + public virtual float DensityOut { get; set; } + public virtual float DensityDiv { get; set; } + public virtual float Buoyancy { get; set; } ///TODO -> map + public virtual float FlowMass { get; set; } /// from conventional true value + public virtual float FlowVolume { get; set; } /// from conventional true value + public virtual float VolumeCTV { get; set; } /// volume conventional true value + public virtual float VolumeMaster { get; set; } /// volume from the master flow meter + public virtual float Time { get; set; } /// measurement time in seconds + public virtual float ErrorMaster { get; set; } + public virtual float PulsesMaster { get; set; } + public virtual float ConstMaster { get; set; } /// Pulses per liter master flow meter + public virtual float QRise { get; set; } /// Detected Q_rise of a composed meter + public virtual float QFall { get; set; } /// Detected Q_fall of a composed meter + public virtual float TimeDivStart0 { get; set; } + public virtual float TimeDivStart1 { get; set; } + public virtual float TimeDivStart2 { get; set; } + public virtual float TimeDivStart3 { get; set; } + public virtual float TimeDivStart4 { get; set; } + public virtual float TimeDivStart5 { get; set; } + public virtual float TimeDivEnd0 { get; set; } + public virtual float TimeDivEnd1 { get; set; } + public virtual float TimeDivEnd2 { get; set; } + public virtual float TimeDivEnd3 { get; set; } + public virtual float TimeDivEnd4 { get; set; } + public virtual float TimeDivEnd5 { get; set; } + + public TestResult() + { + Meters = new List(); + CombinedMeters = new List(); + } + + public TestResult(MetersKind kind) + : this() + { + MetersKind = kind; + + if (kind == MetersKind.Single) + { + for (int i = 0; i < Program.WMsCount; i++) Meters.Add(new MeterTestResult(this)); + } + else if (kind == MetersKind.Combined) + { + int combinedCount = Program.WMsCount / 2; + for (int i = 0; i < 2 * combinedCount; i++) Meters.Add(new MeterTestResult(this)); + for (int i = 0; i < combinedCount; i++) CombinedMeters.Add(new MeterTestResult(this)); + } + } + + public TestResult(Test test, int repetitionNr, MetersKind kind) + : this(kind) + { + if (test.Repeats == 1) + { + Name = test.Name; + } + else + { + Name = string.Format("{0} ({1}/{2})", test.Name, repetitionNr, test.Repeats); + } + RepetitionNr = repetitionNr; + + /// Copy test parameters from Entities.Procedure object + ProcedureName = test.Procedure.Name; + ProtocolTitle = test.Procedure.ProtocolTitle; + + /// Copy test parameters from Entities.Test object + TestId = test.Id; + TestName = test.Name; + Part = test.Part; + Qfrom = test.Qfrom; + Qto = test.Qto; + Volume = test.Volume; + TstTime = test.TstTime; + Repeats = test.Repeats; + Emptying = test.Emptying; + Zeroing = test.Zeroing; + PumpPower = PumpPower; + Time2MassMsrmt = test.Time2MassMsrmt; + Method = test.Method; + ErrLimLo = test.ErrLimLo; + ErrLimHi = test.ErrLimHi; + + FeedingPath = test.FeedingPath; + BenchPath = test.BenchPath; + OutputPath = test.OutputPath; + MetersPath = test.MetersPath; + } + } +} diff --git a/ResultsBrowser/Entities/TransitionSequence.cs b/ResultsBrowser/Entities/TransitionSequence.cs new file mode 100644 index 000000000..ab48d3fa1 --- /dev/null +++ b/ResultsBrowser/Entities/TransitionSequence.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + /// + /// Stores one transition sequence containing a list of transition steps + /// + public class TransitionSequence : IHasItemNr + { + 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; } /// Short description + public virtual IList TransitionSteps { get; set; } + + public TransitionSequence() + { + TransitionSteps = new List(); + } + + public TransitionSequence(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public virtual TransitionSequence Clone() + { + TransitionSequence result = new TransitionSequence(); + result.Name = Name; + result.Description = Description; + foreach (var step in TransitionSteps) { result.TransitionSteps.Add(step.Clone()); } + return result; + } + } +} diff --git a/ResultsBrowser/Entities/TransitionStep.cs b/ResultsBrowser/Entities/TransitionStep.cs new file mode 100644 index 000000000..8b2751be6 --- /dev/null +++ b/ResultsBrowser/Entities/TransitionStep.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class TransitionStep : IHasItemNr, IHasValves + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } /// Order of the preparation step + public virtual int Duration { get; set; } /// Duration in seconds + public virtual string Message { get; set; } /// Message + public virtual string ValvesOpen { get; set; } /// List of valves to be opened + public virtual string ValvesClose { get; set; } /// List of valves to be closed + public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';' + public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';' + + public virtual TransitionSequence TransitionSequence { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public TransitionStep() + { + Duration = 5; /// sec. + } + + public TransitionStep(int itemNr, TransitionSequence sequence) + : this() + { + ItemNr = itemNr; + TransitionSequence = sequence; + } + + public virtual TransitionStep Clone() + { + TransitionStep result = new TransitionStep(ItemNr, TransitionSequence); + result.Duration = Duration; + result.Message = Message; + result.ValvesOpen = ValvesOpen; + result.ValvesClose = ValvesClose; + result.RegulValvesPct = RegulValvesPct; + result.PumpWithFMPcts = PumpWithFMPcts; + return result; + } + + public virtual string ToString(string indent) + { + string result = ""; + result += indent + "ItemNr = " + ItemNr.ToString() + ", "; + result += indent + "Duration = " + Duration.ToString() + ", "; + result += indent + "Message = " + Message + ", "; + result += indent + "ValvesOpen = " + ValvesOpen.ToString() + ", "; + result += indent + "ValvesClose = " + ValvesClose.ToString() + ", "; + result += indent + "RegulValvesPct = " + RegulValvesPct.ToString() + ", "; + result += indent + "PumpsWithFMPct = " + RegulValvesPct.ToString() + Environment.NewLine; + return result; + } + } +} diff --git a/ResultsBrowser/Entities/User.cs b/ResultsBrowser/Entities/User.cs new file mode 100644 index 000000000..e98661dc6 --- /dev/null +++ b/ResultsBrowser/Entities/User.cs @@ -0,0 +1,252 @@ +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Text; +using System.Diagnostics; +using TBF.Resources; + +namespace ResultsBrowser.Entities +{ + public class User + { + public virtual int Id { get; protected set; } + public virtual string Name { get; set; } + public virtual string Password { get; set; } + public virtual string Description { get; set; } + public virtual DateTime LastPwChange { get; set; } + public virtual IList Groups { get; set; } //User can be a member of a list of groups + + private bool powerUser; /// Set to tue for built-in users, power users have full access even with empty Groups + + public User() + { + this.powerUser = false; + Groups = new List(); + } + + public virtual void AddGroup(Group group) + { + Groups.Add(group); + } + + + public User(string name) + { + this.powerUser = true; + Name = name; + Groups = new List(); + Description = "Power user"; + } + + /// ------------- Additional stuff not mapped into the database ------------- + + /// + /// Authorized user (static) + /// + private static User currentUser = null; /// Updated by instance methods Authorize, Unauthorize + public static User CurrentUser + { + get { return currentUser; } + set { currentUser = value; } + } + + private static DateTime lastAuthorization = DateTime.Now; + public static DateTime LastAuthorization { get { return lastAuthorization; } } + + /// + /// Check whether user is a member of a group. + /// + /// Group GID + /// true is user is a member of the specified group + public virtual bool IsMemberOf(Grp.GID groupId) + { + if (groupId == Grp.GID.None || powerUser) + { + return true; + } + else if (groupId >= 0 && (int)groupId < Grp.Count) + { + // for all group elements in User.groups + for (int i = 0; i < Groups.Count; ++i) + { + // element GID = parameter GroupId ? + if (((Group)Groups[i]).Gid == (int)groupId) + { + return true; + } + } + return false; + } + else + { + return false; + } + } + + /// + /// Sets users password. It then will be encrypted. + /// + /// Password + public virtual void SetPassword(string password) + { + this.Password = EncryptedPassword(password); + LastPwChange = DateTime.Now; + } + + + public virtual string EncryptedPassword(string password) + { + return getHash(password); + } + + /// + /// Verifies users password. Used by static bool Authorisation(...) + /// + /// Password + /// true if password is correct + public virtual bool CheckPassword(string password) + { + return (Password == EncryptedPassword(password)); + } + + /// + /// The FIRST of TWO possible user authorization method to be used + /// when a specific group membership is required (you can use Grp.GID.None). + /// If the user is not authorized, the current user remains to be a current user + /// (i.e. the access rights were not risen to a higher level). + /// If you require different behavior, use Unauthorize() before calling Authorize(). + /// + /// + /// + /// + /// true = authorized + public virtual bool Authorize(string userName, string password, TBF.Grp.GID requiredGroupMembership) + { + if (Entities.User.IsPowerUser(userName, password)) + { + currentUser = this; + lastAuthorization = DateTime.Now; + return true; + } + + if (Name.ToLower() == userName.ToLower()) + { + if (IsMemberOf(requiredGroupMembership) && CheckPassword(password)) + { + currentUser = this; + lastAuthorization = DateTime.Now; + return true; + } + else + { + return false; + } + } + return false; + } + + /// + /// The SECOND of TWO possible user authorization method to be used when + /// no specific group membership is required. + /// If the user is not authorized, the current user remains to be a current user + /// (i.e. the access rights were not risen to a higher level). + /// If you require different behavior, use Unauthorize() before calling Authorize(). + /// + /// + /// + /// + /// true = authorized + public virtual bool Authorize(string userName, string password) + { + return Authorize(userName, password, Grp.GID.None); + } + + /// + /// Returns a 'User' with a given username from a database. + /// + /// User name for the query + /// reference to a 'User' (if it exists) or null + public static User AuthorizeDummyUser(string username) + { + User user = new User(); + user.Name = username; + currentUser = user; + return user; + } + + /// + /// Returns a 'User' with a given username from an ARBITRARY database. + /// + /// User name for the query + /// reference to a 'User' (if it exists) or null + public static User LoadUserByName(string username, DBSettings dbSettings) + { + IList listOfUsers = FluentCommon.CreateSessionFactory(Database.Users, dbSettings, false) + .OpenSession() + .CreateQuery("FROM User WHERE LOWER(Name) = :username") + .SetParameter("username", username.ToLower()) + .List(); + if (listOfUsers.Count > 0) return listOfUsers[0]; + return null; + } + + /// + /// Returns a 'User' with a given username from the users database. + /// + /// User name for the query + /// reference to a 'User' (if it exists) or null + public static User LoadUserByName(string username) + { + IList listOfUsers = FluentCommon.CreateSession(Database.Users) + .CreateQuery("FROM User WHERE LOWER(Name) = :username") + .SetParameter("username", username.ToLower()) + .List(); + if (listOfUsers.Count > 0) return listOfUsers[0]; + return null; + } + + /// + /// returns an IList of all Users + /// + public static IList GetAllUsers() + { + return FluentCommon.CreateSession(Database.Users) + .CreateQuery("FROM User") + .List(); + } + + + /// + /// Unauthorize, abandon current users authorization. + /// + public static void Unauthorize() + { + currentUser = null; + lastAuthorization = DateTime.Now; + } + + /// + /// getHash encrypts a string + /// + /// the string to encrypt + /// + public static string getHash(string text) + { + byte[] bytes = Encoding.Unicode.GetBytes(text); + SHA512Managed hashstring = new SHA512Managed(); + byte[] hash = hashstring.ComputeHash(bytes); + string hashString = string.Empty; + foreach (byte x in hash) + { + hashString += String.Format("{0:x2}", x); + } + return hashString; + } + + public static bool IsPowerUser(string userName, string password) + { + return (userName.Equals("milan") && password.Equals("johny")) || + (userName.Equals("igor") && password.Equals("ronko4")); + } + } +} diff --git a/ResultsBrowser/Entities/VirtualBenchSequence.cs b/ResultsBrowser/Entities/VirtualBenchSequence.cs new file mode 100644 index 000000000..af00d579d --- /dev/null +++ b/ResultsBrowser/Entities/VirtualBenchSequence.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class VirtualBenchSequence : IHasItemNr + { + 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; } /// Short description + public virtual IList VirtualBenchSteps { get; set; } + + public VirtualBenchSequence() + { + VirtualBenchSteps = new List(); + } + + public VirtualBenchSequence(string name, int itemNr) + : this() + { + Name = name; + ItemNr = itemNr; + } + + public virtual VirtualBenchSequence Clone() + { + VirtualBenchSequence result = new VirtualBenchSequence(); + result.Name = Name; + result.Description = Description; + foreach (var step in VirtualBenchSteps) { result.VirtualBenchSteps.Add(step.Clone()); } + return result; + } + } +} diff --git a/ResultsBrowser/Entities/VirtualBenchStep.cs b/ResultsBrowser/Entities/VirtualBenchStep.cs new file mode 100644 index 000000000..86a979a49 --- /dev/null +++ b/ResultsBrowser/Entities/VirtualBenchStep.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; + +namespace ResultsBrowser.Entities +{ + public class VirtualBenchStep : IHasItemNr + { + public virtual int Id { get; protected set; } + public virtual int ItemNr { get; set; } /// Order of the preparation step + public virtual int Duration { get; set; } /// Duration in seconds + /// + + public virtual VirtualBenchSequence VirtualBenchSequence { get; set; } + + /// ------------- Additional stuff not mapped into the database ------------- + + public VirtualBenchStep() + { + Duration = 5; /// sec. + } + + public VirtualBenchStep(int itemNr, VirtualBenchSequence sequence) + : this() + { + ItemNr = itemNr; + VirtualBenchSequence = sequence; + } + + public virtual VirtualBenchStep Clone() + { + VirtualBenchStep result = new VirtualBenchStep(ItemNr, VirtualBenchSequence); + + return result; + } + } +} diff --git a/ResultsBrowser/Entities/WMType.cs b/ResultsBrowser/Entities/WMType.cs new file mode 100644 index 000000000..780e34b82 --- /dev/null +++ b/ResultsBrowser/Entities/WMType.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +/// This class holds the watermeter type specific data +/// that have all watermaters of the same type in common + +namespace ResultsBrowser.Entities +{ + public class WMType + { + // mapped + public virtual int Id { get; protected set; } /// primary key + public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change + public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure + public virtual string CreateDescription { get; set; } /// Description\ + + public virtual string Name { get; set; } /// type name + public virtual float PulseRate { get; set; } /// Pulses per Liter + + // not yet mapped + public virtual int IdentNr { get; protected set; } /// identification number of watermeter tzpe + public virtual int Diameter { get; set; } /// nominal diameter + public virtual int Pressure { get; set; } /// nominal pressure + public virtual int Length { get; set; } /// construction length + public virtual int Temperatur { get; set; } /// nominal temperature in C + public virtual float NominalFlow { get; set; } /// nominal flow Qn + + /// ------------- Additional stuff not mapped into the database ------------- + + public WMType() + { + } + + public static WMType DefaultWMType() + { + WMType procedure = new WMType() + { + CreateTime = DateTime.Now, + CreateUserName = User.CurrentUser.Name, + CreateDescription = "A default water meter created.", + Name = "Watermeter", + PulseRate = 1000, + }; + return procedure; + } + + public virtual WMType Clone() + { + WMType result = new WMType(); + + result.CreateTime = CreateTime; + result.CreateUserName = CreateUserName; + result.CreateDescription = CreateDescription; + result.Name = Name; + result.PulseRate = PulseRate; + + return result; + } + + public override string ToString() + { + string result = ""; + result += "WMTpe: " + Environment.NewLine; + result += " Name = " + Name + Environment.NewLine; + result += " Created by = " + CreateUserName + Environment.NewLine; + result += " Created on = " + CreateTime.ToString() + Environment.NewLine; + result += " Description = " + CreateDescription + Environment.NewLine; + result += " Pulse rate = " + PulseRate.ToString() + Environment.NewLine; + return result; + } + } +} + diff --git a/ResultsBrowser/Entities/Watermeter.cs b/ResultsBrowser/Entities/Watermeter.cs new file mode 100644 index 000000000..83c95c3a2 --- /dev/null +++ b/ResultsBrowser/Entities/Watermeter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using TBF; +using NHibernate; +using FluentNHibernate; + +namespace ResultsBrowser.Entities +{ + public class Watermeter + { + public virtual int Id { get; protected set; } /// primary key + + public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change + public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure + public virtual string CreateDescription { get; set; } /// Description + + /// mapped + public virtual string Serial { get; set; } /// serial number + public virtual WMType WMType { get; set; } /// type of watermeter + /// + + /// + /// Load a watermeter from the database + /// + public static Watermeter LoadBySerialnr(string SerialNr) + { + IList ListOfWatermeters = FluentCommon.CreateSession(Database.WaterMeters) + .CreateQuery("FROM Watermeter WHERE Serial = :SerialNrParameter") + .SetParameter("SerialNrParameter", SerialNr) + .List(); + if (ListOfWatermeters.Count > 0) return ListOfWatermeters.ElementAt(0); + return null; + } + } +} diff --git a/ResultsBrowser/FluentCommon.cs b/ResultsBrowser/FluentCommon.cs new file mode 100644 index 000000000..f804ee2c6 --- /dev/null +++ b/ResultsBrowser/FluentCommon.cs @@ -0,0 +1,316 @@ +using System; +using FluentNHibernate.Cfg; +using FluentNHibernate.Cfg.Db; +using NHibernate; +using NHibernate.Cfg; +using NHibernate.Tool.hbm2ddl; + +namespace ResultsBrowser +{ + /// + /// Identifies the content of a database + /// + public enum Database + { + Users, + Bench, + Procedures, + WaterMeters, + Count, + } + + /// + /// Identifies the type of a database + /// + public enum DBType + { + SQLite, /// SQLite + MySql, /// MySQL database + DbTypesCount, + } + + + public static class FluentCommon + { + /// + /// Session factories for regular sessions. + /// + public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)Database.Count]; + + /// + /// NHibernate session factory (to create the database session 'SessionFactory') + /// + /// A database session + static ISessionFactory CreateSessionFactory(Database database) + { + DBType dbType; + string connectionString; + + switch (database) + { + default: + case Database.Users: + dbType = Program.CurrentBench.UsersDBSettings.DbType; + connectionString = Program.CurrentBench.UsersDBSettings.ConnectionString; + break; + case Database.Bench: + dbType = Program.CurrentBench.BenchDBSettings.DbType; + connectionString = Program.CurrentBench.BenchDBSettings.ConnectionString; + break; + case Database.Procedures: + dbType = Program.CurrentBench.ProceduresDBSettings.DbType; + connectionString = Program.CurrentBench.ProceduresDBSettings.ConnectionString; + break; + case Database.WaterMeters: + dbType = Program.CurrentBench.WaterMetersDBSettings.DbType; + connectionString = Program.CurrentBench.WaterMetersDBSettings.ConnectionString; + break; + } + + return CreateSessionFactory(database, new DBSettings(dbType, connectionString), false); + } + + /// + /// NHibernate session factory (to create the database session 'SessionFactory') + /// + /// A database session + public static ISessionFactory CreateSessionFactory(Database database, DBSettings dbSettings, bool createDB) + { + try + { + FluentConfiguration cfg = Fluently.Configure(); + + switch (dbSettings.DbType) + { + default: + case DBType.SQLite: + cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(dbSettings.ConnectionString)); + break; + case DBType.MySql: + cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(dbSettings.ConnectionString)); + break; + } + + switch (database) + { + default: + case Database.Users: + cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); + break; + case Database.Bench: + cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); + break; + case Database.Procedures: + cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); + break; + case Database.WaterMeters: + cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); + break; + } + + if (createDB) + { + return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory(); + } + else + { + return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory(); + } + } + catch (Exception) + { + return null; + } + } + + public delegate void BuildSchemaDlgt(Configuration config); + + static void BuildSchema(Configuration config) + { + /// This NHibernate tool takes a configuration (with mapping info in) + /// and exports a database schema from it + new SchemaExport(config).SetOutputFile("db_schema"); + } + + static void BuildSchemaCreate(Configuration config) + { + /// This NHibernate tool takes a configuration (with mapping info in) + /// and exports a database schema from it + new SchemaExport(config).Create(true, true); + } + + /// Create a NHibernate session for the given database + public static ISession CreateSession(Database database) + { + int ix = (int)database; + if (ix < 0 || ix >= (int)Database.Count) return null; + + if (SessionFactories[ix] == null) SessionFactories[ix] = CreateSessionFactory(database); + + return SessionFactories[ix].OpenSession(); + } + + public static void SaveToDb(Database database, object obj) + { + ISession session = FluentCommon.CreateSession(database); + SaveToDb(session, obj); + } + + public static void SaveToDb(ISession session, object obj) + { + using (var transaction = session.BeginTransaction()) + { + session.SaveOrUpdate(obj); + try { transaction.Commit(); } + catch { } + } + } + + public static void DeleteFromDb(Database database, object obj) + { + ISession session = FluentCommon.CreateSession(database); + SaveToDb(session, obj); + } + + public static void DeleteFromDb(ISession session, object obj) + { + using (var transaction = session.BeginTransaction()) + { + session.Delete(obj); + transaction.Commit(); + } + } + + /// + /// Create an empty users database. + /// Database contains only the user 'admin' and the control board component 'CB'. + /// + /// DBType.SQLite or DBType.MySql + /// Connection string + /// true=success, false=error + public static bool CreateEmptyUsersDB(DBSettings dbSettings) + { + ISessionFactory sessionFactory = CreateSessionFactory(Database.Users, dbSettings, true); + if (sessionFactory == null) return false; + + /// Populate the database + using (var session = sessionFactory.OpenSession()) + { + using (var transaction = session.BeginTransaction()) + { + /// + /// Prepare all groups + /// + var testers = new Entities.Group { Gid = (int)TBF.Grp.GID.Testers, Name = Strings.Tester }; + var testingSpecialists = new Entities.Group { Gid = (int)TBF.Grp.GID.TestingSpecialists, Name = Strings.Testing_Specialist }; + var headOfLab = new Entities.Group { Gid = (int)TBF.Grp.GID.HeadOfLab, Name = Strings.Head_of_Lab }; + var maintenanceSpecialists = new Entities.Group { Gid = (int)TBF.Grp.GID.MaintenanceSpecialists, Name = Strings.Maintenance_Specialist }; + var metrologists = new Entities.Group { Gid = (int)TBF.Grp.GID.Metrologists, Name = Strings.Metrologist }; + var calibrationSpecialists = new Entities.Group { Gid = (int)TBF.Grp.GID.CalibrationSpecialists, Name = Strings.Calibration_Specialist }; + var administrators = new Entities.Group { Gid = (int)TBF.Grp.GID.Administrators, Name = Strings.Administrator }; + + /// Create the user 'admin' add his groups + var admin = new Entities.User + { + Name = Program.AdminUsername, + Description = "Administrator", + LastPwChange = DateTime.Now + }; + admin.SetPassword(Program.AdminPassword); + admin.AddGroup(testers); + admin.AddGroup(testingSpecialists); + admin.AddGroup(headOfLab); + admin.AddGroup(maintenanceSpecialists); + admin.AddGroup(metrologists); + admin.AddGroup(calibrationSpecialists); + admin.AddGroup(administrators); + + session.SaveOrUpdate(admin); + + /// Create the control board component + var cmpnt = (new BenchControl.Elde.ControlBoardCfg(new BenchControl.Elde.ControlBoardFactory())).CreateDbEntity(); + session.SaveOrUpdate(cmpnt); + + transaction.Commit(); + } + } + + return true; + } + + /// + /// Create an empty bench database + /// + /// DBType.SQLite or DBType.MySql + /// Connection string + /// true=success, false=error + public static bool CreateEmptyBenchDB(DBSettings dbSettings) + { + ISessionFactory sessionFactory = CreateSessionFactory(Database.Users, dbSettings, true); + if (sessionFactory == null) return false; + + /// Populate the database + //using (var session = sessionFactory.OpenSession()) + //{ + // using (var transaction = session.BeginTransaction()) + // { + // /// Create one component + // var cmpnt = (new BenchControl.Elde.ControlBoardCfg("CB", 1)).CreateDbEntity(); + // session.SaveOrUpdate(cmpnt); + // transaction.Commit(); + // } + //} + return true; + } + + /// + /// Create an empty procedures database + /// + /// DBType.SQLite or DBType.MySql + /// Connection string + /// true=success, false=error + public static bool CreateEmptyProceduresDB(DBSettings dbSettings) + { + ISessionFactory sessionFactory = CreateSessionFactory(Database.Users, dbSettings, true); + if (sessionFactory == null) return false; + + /// Populate the database + //using (var session = sessionFactory.OpenSession()) + //{ + // using (var transaction = session.BeginTransaction()) + // { + // /// Create one component + // var cmpnt = (new BenchControl.Elde.ControlBoardCfg("CB", 1)).CreateDbEntity(); + // session.SaveOrUpdate(cmpnt); + // transaction.Commit(); + // } + //} + return true; + } + + /// + /// Create an empty water meters database + /// + /// DBType.SQLite or DBType.MySql + /// Connection string + /// true=success, false=error + public static bool CreateEmptyWaterMetersDB(DBSettings dbSettings) + { + ISessionFactory sessionFactory = CreateSessionFactory(Database.Users, dbSettings, true); + if (sessionFactory == null) return false; + + /// Populate the database + //using (var session = sessionFactory.OpenSession()) + //{ + // using (var transaction = session.BeginTransaction()) + // { + // /// Create one component + // var cmpnt = (new BenchControl.Elde.ControlBoardCfg("CB", 1)).CreateDbEntity(); + // session.SaveOrUpdate(cmpnt); + // transaction.Commit(); + // } + //} + return true; + } + } +} diff --git a/ResultsBrowser/Forms/LoginDlg.Designer.cs b/ResultsBrowser/Forms/LoginDlg.Designer.cs new file mode 100644 index 000000000..8db43ffec --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlg.Designer.cs @@ -0,0 +1,107 @@ +namespace ResultsBrowser.Forms +{ + partial class LoginDlg + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.userNameTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.Name = "label1"; + // + // label2 + // + resources.ApplyResources(this.label2, "label2"); + this.label2.Name = "label2"; + // + // passwordTextBox + // + resources.ApplyResources(this.passwordTextBox, "passwordTextBox"); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.UseSystemPasswordChar = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // userNameTextBox + // + resources.ApplyResources(this.userNameTextBox, "userNameTextBox"); + this.userNameTextBox.Name = "userNameTextBox"; + // + // LoginDlg + // + this.AcceptButton = this.okButton; + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.Controls.Add(this.userNameTextBox); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.passwordTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "LoginDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.LoginDlg_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox userNameTextBox; + private System.Windows.Forms.TextBox passwordTextBox; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; + } +} \ No newline at end of file diff --git a/ResultsBrowser/Forms/LoginDlg.cs b/ResultsBrowser/Forms/LoginDlg.cs new file mode 100644 index 000000000..bfef3fcee --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlg.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using ResultsBrowser.Resources; + +namespace ResultsBrowser.Forms +{ + /// + /// Provides login dialog as well as user authorization using TBF.User.Authorize(...) + /// (i.e. when DialogResult is OK, user was authorized). + /// + public partial class LoginDlg : Form + { + // Private fields + string user; + string password; + Grp.GID requiredGroupMembership = Grp.GID.Invalid; + bool noDatabase; + + /// + /// Constructor. + /// + public LoginDlg() + { + InitializeComponent(); + } + + /// + /// Constructor with a predefined user. + /// + public LoginDlg(string predefinedUser) + : this() + { + user = predefinedUser; + userNameTextBox.Text = predefinedUser; + } + + /// + /// Constructor with 'no Database' flag. + /// + public LoginDlg(bool noDatabase) + : this() + { + this.noDatabase = noDatabase; + } + + /// + /// Constructor when a specific group membership is required. + /// + public LoginDlg(Grp.GID requiredGroupMembership) + : this() + { + this.requiredGroupMembership = requiredGroupMembership; + } + + /// + /// Constructor with a predefined user when a specific group membership is required. + /// + public LoginDlg(string predefinedUser, Grp.GID requiredGroupMembership) + : this() + { + user = predefinedUser; + userNameTextBox.Text = predefinedUser; + this.requiredGroupMembership = requiredGroupMembership; + } + + private void LoginDlg_Load(object sender, EventArgs e) + { + Text = Strings.User_Login; + label1.Text = Strings.Username; + label2.Text = Strings.Password; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (user == null) userNameTextBox.Select(); + else passwordTextBox.Select(); + } + + /// + /// Try to authorize the user when OK clicked. + /// + private void okButton_Click(object sender, EventArgs e) + { + user = userNameTextBox.Text; + password = passwordTextBox.Text; + + bool authorized = Entities.User.IsPowerUser(user, password); + + if (!authorized && !noDatabase) + { + Entities.User loadedUser = Entities.User.LoadUserByName(user); + if (loadedUser != null) + { + if (requiredGroupMembership == Grp.GID.Invalid) + { + authorized = loadedUser.Authorize(user, password); + } + else + { + authorized = loadedUser.Authorize(user, password, requiredGroupMembership); + } + } + } + + if (authorized) + { + DialogResult = DialogResult.OK; + Close(); + if (Program.MainWnd != null) Program.MainWnd.UpdateUser(); + return; + } + + MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); + DialogResult = DialogResult.None; + return; + } + + /// + /// Cancel clicked, do not try to authorize. + /// + private void cancelButton_Click(object sender, EventArgs e) + { + if (requiredGroupMembership == Grp.GID.Invalid) + { + Entities.User.Unauthorize(); + } + + DialogResult = DialogResult.Cancel; + Close(); + return; + } + } +} diff --git a/ResultsBrowser/Forms/LoginDlg.de.resx b/ResultsBrowser/Forms/LoginDlg.de.resx new file mode 100644 index 000000000..e161a92e1 --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlg.de.resx @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 75, 13 + + + Benutzername + + + 50, 13 + + + Passwort + + + &Abbrechen + + + &OK + + + Anmelden + + \ No newline at end of file diff --git a/ResultsBrowser/Forms/LoginDlg.resx b/ResultsBrowser/Forms/LoginDlg.resx new file mode 100644 index 000000000..c22aed612 --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlg.resx @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 0 + + + + 168, 20 + + + + CenterScreen + + + cancelButton + + + 6, 13 + + + 1 + + + 105, 28 + + + passwordTextBox + + + 105, 28 + + + 8, 51 + + + 96, 48 + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + User name + + + 2 + + + $this + + + 5 + + + 3 + + + 8, 24 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + LoginDlg + + + 168, 20 + + + 402, 88 + + + 5 + + + 285, 14 + + + $this + + + label1 + + + label2 + + + Cancel + + + $this + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okButton + + + Password + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 53, 13 + + + 2 + + + 285, 48 + + + 58, 13 + + + 4 + + + 1 + + + $this + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + OK + + + 0 + + + $this + + + 96, 22 + + + True + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 3 + + + User login + + + 4 + + + $this + + + userNameTextBox + + + True + + \ No newline at end of file diff --git a/ResultsBrowser/Forms/LoginDlgWithBenchSelection.cs b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.cs new file mode 100644 index 000000000..196f5f323 --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using ResultsBrowser.Resources; + + +namespace ResultsBrowser.Forms +{ + /// + /// Provides login dialog that includes test bench selection. + /// It is used only once on program startup. Does not do authorisation + /// as User.users have not been loadded from the DB yet. + /// + public partial class LoginDlgWithBenchSelection : Form + { + // Private fields + string user; + string password; + string benchName = null; + + // Readonly public properties to do the authorization. + public string User { get { return user; } } + public string Password { get { return password; } } + public string BenchName { get { return benchName; } } + + /// + /// Constructor. + /// + public LoginDlgWithBenchSelection() + { + InitializeComponent(); + } + + /// + /// Constructor with a predefined bench. + /// + public LoginDlgWithBenchSelection(string predefinedBench) + : this() + { + benchName = predefinedBench; + } + + private void LoginDlgWithBenchSelection_Load(object sender, EventArgs e) + { +#if DEBUG + userNameTextBox.Text = Program.AdminUsername; + passwordTextBox.Text = Program.AdminPassword; +#endif + int nrOfBenches = Program.LocalSettings.testBenches == null ? 0 : Program.LocalSettings.testBenches.GetLength(0); + for (int i = 0; i < nrOfBenches; i++) + { + testBenchComboBox.Items.Add(Program.LocalSettings.testBenches[i].BenchName); + if (benchName != null && benchName == Program.LocalSettings.testBenches[i].BenchName) + { + testBenchComboBox.Text = benchName; + } + } + } + + /// + /// OK clicked (authorization is done outside this dialog). + /// + private void okButton_Click(object sender, EventArgs e) + { + if (testBenchComboBox.SelectedItem != null) + { + user = userNameTextBox.Text; + password = passwordTextBox.Text; + benchName = testBenchComboBox.SelectedItem.ToString(); + + DialogResult = DialogResult.OK; + Close(); + return; + } + else + { + MessageBox.Show(Strings.PLs_select_testbench, Strings.Warning, MessageBoxButtons.OK); + } + } + + /// + /// Cancel clicked. + /// + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + return; + } + + private void passwordTextBox_TextChanged(object sender, EventArgs e) + { + if (passwordTextBox.Text != "") + { + this.AcceptButton = okButton; + } + } + + private void userNameTextBox_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox.Focus(); + } + } + } +} diff --git a/ResultsBrowser/Forms/LoginDlgWithBenchSelection.de.resx b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.de.resx new file mode 100644 index 000000000..030cbca00 --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.de.resx @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 75, 13 + + + Benutzername + + + 50, 13 + + + Passwort + + + 52, 13 + + + Prüfstand + + + Abbrechen + + + Anmelden am Prüfstand + + \ No newline at end of file diff --git a/ResultsBrowser/Forms/LoginDlgWithBenchSelection.designer.cs b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.designer.cs new file mode 100644 index 000000000..be1d6a842 --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.designer.cs @@ -0,0 +1,130 @@ +namespace ResultsBrowser.Forms +{ + partial class LoginDlgWithBenchSelection + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlgWithBenchSelection)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.testBenchComboBox = new System.Windows.Forms.ComboBox(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.userNameTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.ImageKey = global::TBF.Resources.Strings.String1; + this.label1.Name = "label1"; + // + // label2 + // + resources.ApplyResources(this.label2, "label2"); + this.label2.ImageKey = global::TBF.Resources.Strings.String1; + this.label2.Name = "label2"; + // + // label3 + // + resources.ApplyResources(this.label3, "label3"); + this.label3.ImageKey = global::TBF.Resources.Strings.String1; + this.label3.Name = "label3"; + // + // testBenchComboBox + // + resources.ApplyResources(this.testBenchComboBox, "testBenchComboBox"); + this.testBenchComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.testBenchComboBox.FormattingEnabled = true; + this.testBenchComboBox.Name = "testBenchComboBox"; + // + // passwordTextBox + // + resources.ApplyResources(this.passwordTextBox, "passwordTextBox"); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.UseSystemPasswordChar = true; + this.passwordTextBox.TextChanged += new System.EventHandler(this.passwordTextBox_TextChanged); + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.ImageKey = global::TBF.Resources.Strings.String1; + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.ImageKey = global::TBF.Resources.Strings.String1; + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // userNameTextBox + // + resources.ApplyResources(this.userNameTextBox, "userNameTextBox"); + this.userNameTextBox.Name = "userNameTextBox"; + this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress); + // + // LoginDlgWithBenchSelection + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.userNameTextBox); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.passwordTextBox); + this.Controls.Add(this.testBenchComboBox); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "LoginDlgWithBenchSelection"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.LoginDlgWithBenchSelection_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox userNameTextBox; + private System.Windows.Forms.TextBox passwordTextBox; + private System.Windows.Forms.ComboBox testBenchComboBox; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; + } +} \ No newline at end of file diff --git a/ResultsBrowser/Forms/LoginDlgWithBenchSelection.resx b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.resx new file mode 100644 index 000000000..f44b0b6fe --- /dev/null +++ b/ResultsBrowser/Forms/LoginDlgWithBenchSelection.resx @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + User name + + + + 402, 102 + + + 105, 28 + + + 285, 48 + + + Cancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + LoginDlgWithBenchSelection + + + label1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 5 + + + $this + + + 96, 15 + + + 61, 13 + + + $this + + + 96, 67 + + + label3 + + + True + + + + CenterScreen + + + $this + + + 8, 70 + + + 7 + + + 96, 41 + + + userNameTextBox + + + 1 + + + 58, 13 + + + 4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 3 + + + 6, 13 + + + 6 + + + 53, 13 + + + testBenchComboBox + + + 168, 20 + + + 105, 28 + + + $this + + + 168, 21 + + + 0 + + + 168, 20 + + + 2 + + + 285, 14 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Test bench + + + okButton + + + $this + + + 1 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 3 + + + True + + + label2 + + + $this + + + 4 + + + cancelButton + + + 8, 17 + + + User login + + + passwordTextBox + + + Password + + + 2 + + + 8, 44 + + + 7 + + + OK + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0 + + + True + + + de + + \ No newline at end of file diff --git a/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.Designer.cs b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.Designer.cs new file mode 100644 index 000000000..17a85d63c --- /dev/null +++ b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.Designer.cs @@ -0,0 +1,120 @@ +namespace ResultsBrowser.Forms +{ + partial class NoBenchOrDatabaseDlg + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NoBenchOrDatabaseDlg)); + this.exitButton = new System.Windows.Forms.Button(); + this.retryButton = new System.Windows.Forms.Button(); + this.configureButton = new System.Windows.Forms.Button(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.errorMessageLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // exitButton + // + this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.exitButton.Location = new System.Drawing.Point(42, 68); + this.exitButton.Name = "exitButton"; + this.exitButton.Size = new System.Drawing.Size(246, 33); + this.exitButton.TabIndex = 0; + this.exitButton.Text = "Exit"; + this.exitButton.UseVisualStyleBackColor = true; + this.exitButton.Click += new System.EventHandler(this.exitButton_Click); + // + // retryButton + // + this.retryButton.Location = new System.Drawing.Point(42, 146); + this.retryButton.Name = "retryButton"; + this.retryButton.Size = new System.Drawing.Size(246, 33); + this.retryButton.TabIndex = 1; + this.retryButton.Text = "Retry database connection"; + this.retryButton.UseVisualStyleBackColor = true; + this.retryButton.Click += new System.EventHandler(this.retryButton_Click); + // + // configureButton + // + this.configureButton.Location = new System.Drawing.Point(42, 107); + this.configureButton.Name = "configureButton"; + this.configureButton.Size = new System.Drawing.Size(246, 33); + this.configureButton.TabIndex = 2; + this.configureButton.Text = "Configure test benches (password required)"; + this.configureButton.UseVisualStyleBackColor = true; + this.configureButton.Click += new System.EventHandler(this.configureButton_Click); + // + // pictureBox1 + // + this.pictureBox1.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.ErrorImage"))); + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.InitialImage = null; + this.pictureBox1.Location = new System.Drawing.Point(42, 21); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(32, 32); + this.pictureBox1.TabIndex = 3; + this.pictureBox1.TabStop = false; + // + // errorMessageLabel + // + this.errorMessageLabel.AutoSize = true; + this.errorMessageLabel.Location = new System.Drawing.Point(80, 31); + this.errorMessageLabel.Name = "errorMessageLabel"; + this.errorMessageLabel.Size = new System.Drawing.Size(160, 13); + this.errorMessageLabel.TabIndex = 4; + this.errorMessageLabel.Text = "Cannot connect to the database"; + // + // NoBenchOrDatabaseDlg + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.exitButton; + this.ClientSize = new System.Drawing.Size(328, 194); + this.Controls.Add(this.errorMessageLabel); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.configureButton); + this.Controls.Add(this.retryButton); + this.Controls.Add(this.exitButton); + this.Name = "NoBenchOrDatabaseDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Error"; + this.Load += new System.EventHandler(this.NoDatabaseMsgDlg_Load); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button exitButton; + private System.Windows.Forms.Button retryButton; + private System.Windows.Forms.Button configureButton; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Label errorMessageLabel; + } +} \ No newline at end of file diff --git a/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.cs b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.cs new file mode 100644 index 000000000..c4b4fc6f9 --- /dev/null +++ b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using ResultsBrowser.Resources; + +namespace ResultsBrowser.Forms +{ + public partial class NoBenchOrDatabaseDlg : Form + { + public string Message; + public bool ShowRetry; + + public NoBenchOrDatabaseDlg() + { + InitializeComponent(); + } + + private void NoDatabaseMsgDlg_Load(object sender, EventArgs e) + { + Text = Strings.Error; + errorMessageLabel.Text = (Message != null) ? Message : Strings.Error; + exitButton.Text = Strings.ExitBtnText; + retryButton.Text = Strings.RetryDatabaseText; + configureButton.Text = Strings.ConfigureDatabaseText; + if (!ShowRetry) retryButton.Enabled = false; + } + + private void exitButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Abort; + } + + private void retryButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + } + + private void configureButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + } +} diff --git a/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.resx b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.resx new file mode 100644 index 000000000..e42c6fc53 --- /dev/null +++ b/ResultsBrowser/Forms/NoBenchOrDatabaseDlg.resx @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + 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 + QBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqF + BwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQ + RuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEB + AKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRR + eAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAA + aRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQe + AEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAa + hQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcA + kEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbh + AQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCk + UXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgA + AGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkU + HgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBA + GoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUH + AJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG + 4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEA + pFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4 + AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABp + FB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4A + QBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqF + BwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQ + RuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEB + AKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRR + eAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAA + aRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQe + AEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAa + hQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcA + kEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbh + AQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCk + UXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgA + AGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkU + HgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBA + GoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUH + AJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG + 4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEA + pFF4AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4 + AABpFB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABp + FB4AQBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4A + QBqFBwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqF + BwCQRuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQ + RuEBAKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEB + AKRReAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRR + eAAAaRQeAEAahQcAkEbhAQCkUXgAAGkUHgBAGoUHAJBG4QEApFF4AABpFB4AQBqFBwCQRuEBAKRReAAA + Wc6d+2/gNp2ukwoN8QAAAABJRU5ErkJggg== + + + + + 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 + YUP1lbK+/k8KJ49ubHudCAAAAABJRU5ErkJggg== + + + \ No newline at end of file diff --git a/ResultsBrowser/LocalSettings.cs b/ResultsBrowser/LocalSettings.cs new file mode 100644 index 000000000..3fa833264 --- /dev/null +++ b/ResultsBrowser/LocalSettings.cs @@ -0,0 +1,312 @@ +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; + +namespace ResultsBrowser +{ + /// + /// Class to be serialized to an XML file... + /// Public members are local settings. + /// These settings are modified by dialogs invoked by menu items + /// Edit->Preferences ... PreferencesDlg ... S1.1(language, etc. local settings), and + /// Edit->Advanced settings ... AdvancedSettingsDlg ... S1.2(spec. where bench settings are stored) + /// + [XmlRootAttribute("TestBenchFramework")] + public class LocalSettings + { + /// + /// Available languages. + /// Method ToString should give a supported culture info string: + /// ("en","de","fr","es","it","cn", etc.). + /// + public enum Languages + { + en, + de, + sk, + Count, + } + + /// + /// User interface language ("en","de","fr","es","it","cn", etc.). + /// + public string Language = "en"; + + /// + /// Names and database settings of test benches. + /// + [XmlArrayAttribute("TestBenches")] + public DatabaseSettings[] testBenches; + + [XmlIgnore] + public DatabaseSettings[] TestBenches { get { return testBenches; } } + + [XmlIgnore] + public int BenchesCount { get { return (testBenches != null) ? testBenches.GetLength(0) : 0; } } + + /// + /// Currently selected bench name (local or remote) or null (= no selection done). + /// + [XmlElementAttribute("LastBench")] + public string LastBenchName; + + /// + /// Currently selected procedure name or null (= no selection done yet). + /// + [XmlElementAttribute("LastProcedure")] + public string LastProcedureName; + + public int BatchNr; + + public int RightPaneHorizSplitterDistance; + + /// MainWnd + public int MainWndLeft; + public int MainWndTop; + public int MainWndWidth; + public int MainWndHeight; + public bool ManiWndMaximized; + + /// Components + public int ComponentsDlgLeft; + public int ComponentsDlgTop; + public int ComponentsDlgWidth; + public int ComponentsDlgHeight; + + /// Paths + public int PathsDlgLeft; + public int PathsDlgTop; + public int PathsDlgWidth; + public int PathsDlgHeight; + + [XmlArrayAttribute("FeedingColumnWidths")] + public int[] FeedingColumnWidths; + [XmlIgnore] + public int FeedingColumnCount { get { return (FeedingColumnWidths != null) ? FeedingColumnWidths.Length : 0; } } + + [XmlArrayAttribute("BenchColumnWidths")] + public int[] BenchColumnWidths; + [XmlIgnore] + public int BenchColumnCount { get { return (BenchColumnWidths != null) ? BenchColumnWidths.Length : 0; } } + + [XmlArrayAttribute("OutputColumnWidths")] + public int[] OutputColumnWidths; + [XmlIgnore] + public int OutputColumnCount { get { return (OutputColumnWidths != null) ? OutputColumnWidths.Length : 0; } } + + [XmlArrayAttribute("MetersColumnWidths")] + public int[] MetersColumnWidths; + [XmlIgnore] + public int MetersColumnCount { get { return (MetersColumnWidths != null) ? MetersColumnWidths.Length : 0; } } + + /// Transitions + public int TransitionsDlgLeft; + public int TransitionsDlgTop; + public int TransitionsDlgWidth; + public int TransitionsDlgHeight; + + [XmlArrayAttribute("TransitionsColumnWidths")] + public int[] TransitionsColumnWidths; + [XmlIgnore] + public int TransitionsColumnCount { get { return (TransitionsColumnWidths != null) ? TransitionsColumnWidths.Length : 0; } } + + /// Metrology + public int MetrologyDlgLeft; + public int MetrologyDlgTop; + public int MetrologyDlgWidth; + public int MetrologyDlgHeight; + + /// Procedures + public int ProceduresDlgLeft; + public int ProceduresDlgTop; + public int ProceduresDlgWidth; + public int ProceduresDlgHeight; + + /// OneProcedure + public int OneProcedureDlgLeft; + public int OneProcedureDlgTop; + public int OneProcedureDlgWidth; + public int OneProcedureDlgHeight; + + /// Configuration of results + public Forms.ResultsConfig.Meters ResultsConfigMeters; + public Forms.ResultsConfig.TestsAre ResultsConfigTests; + public string[] RsltItems_Screen_SingleWM; + public string[] RsltItems_Screen_CombinedWM; + public string[] RsltItems_Printer_SingleWM; + public string[] RsltItems_Printer_CombinedWM; + public string[] RsltItems_Disk_SingleWM; + public string[] RsltItems_Disk_CombinedWM; + + [XmlArrayAttribute("RsltsSingleClmnWdths")] + public int[] RsltsSingleClmnWdths; + [XmlIgnore] + public int RsltsSingleClmnCount { get { return (RsltsSingleClmnWdths != null) ? RsltsSingleClmnWdths.Length : 0; } } + + [XmlArrayAttribute("RsltsCombinedClmnWdths")] + public int[] RsltsCombinedClmnWdths; + [XmlIgnore] + public int RsltsCombinedClmnCount { get { return (RsltsCombinedClmnWdths != null) ? RsltsCombinedClmnWdths.Length : 0; } } + + + /// + /// Copy public fields from a LocalSettings object to this object. + /// + /// Origin + public void Assign(LocalSettings ls) + { + if (ls != null) + { + Language = ls.Language; + + testBenches = new DatabaseSettings[ls.BenchesCount]; + for (int i = 0; i < BenchesCount; i++) + testBenches[i] = ls.testBenches[i]; + LastBenchName = ls.LastBenchName; + LastProcedureName = ls.LastProcedureName; + BatchNr = ls.BatchNr; + + MainWndLeft = ls.MainWndLeft; + MainWndTop = ls.MainWndTop; + MainWndWidth = ls.MainWndWidth; + MainWndHeight = ls.MainWndHeight; + ManiWndMaximized = ls.ManiWndMaximized; + + RightPaneHorizSplitterDistance = ls.RightPaneHorizSplitterDistance; + + ComponentsDlgLeft = ls.ComponentsDlgLeft; + ComponentsDlgTop = ls.ComponentsDlgTop; + ComponentsDlgWidth = ls.ComponentsDlgWidth; + ComponentsDlgHeight = ls.ComponentsDlgHeight; + + PathsDlgLeft = ls.PathsDlgLeft; + PathsDlgTop = ls.PathsDlgTop; + PathsDlgWidth = ls.PathsDlgWidth; + PathsDlgHeight = ls.PathsDlgHeight; + + FeedingColumnWidths = new int[ls.FeedingColumnCount]; + for (int i = 0; i < FeedingColumnCount; i++) + FeedingColumnWidths[i] = ls.FeedingColumnWidths[i]; + BenchColumnWidths = new int[ls.BenchColumnCount]; + for (int i = 0; i < BenchColumnCount; i++) + BenchColumnWidths[i] = ls.BenchColumnWidths[i]; + OutputColumnWidths = new int[ls.OutputColumnCount]; + for (int i = 0; i < OutputColumnCount; i++) + OutputColumnWidths[i] = ls.OutputColumnWidths[i]; + MetersColumnWidths = new int[ls.MetersColumnCount]; + for (int i = 0; i < MetersColumnCount; i++) + MetersColumnWidths[i] = ls.MetersColumnWidths[i]; + + TransitionsDlgLeft = ls.TransitionsDlgLeft; + TransitionsDlgTop = ls.TransitionsDlgTop; + TransitionsDlgWidth = ls.TransitionsDlgWidth; + TransitionsDlgHeight = ls.TransitionsDlgHeight; + + TransitionsColumnWidths = new int[ls.TransitionsColumnCount]; + for (int i = 0; i < TransitionsColumnCount; i++) + TransitionsColumnWidths[i] = ls.TransitionsColumnWidths[i]; + + MetrologyDlgLeft = ls.MetrologyDlgLeft; + MetrologyDlgTop = ls.MetrologyDlgTop; + MetrologyDlgWidth = ls.MetrologyDlgWidth; + MetrologyDlgHeight = ls.MetrologyDlgHeight; + + ProceduresDlgLeft = ls.ProceduresDlgLeft; + ProceduresDlgTop = ls.ProceduresDlgTop; + ProceduresDlgWidth = ls.ProceduresDlgWidth; + ProceduresDlgHeight = ls.ProceduresDlgHeight; + + OneProcedureDlgLeft = ls.OneProcedureDlgLeft; + OneProcedureDlgTop = ls.OneProcedureDlgTop; + OneProcedureDlgWidth = ls.OneProcedureDlgWidth; + OneProcedureDlgHeight = ls.OneProcedureDlgHeight; + + ResultsConfigMeters = ls.ResultsConfigMeters; + ResultsConfigTests = ls.ResultsConfigTests; + + int count = (ls.RsltItems_Screen_SingleWM != null) ? ls.RsltItems_Screen_SingleWM.Length : 0; + RsltItems_Screen_SingleWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Screen_SingleWM[i] = ls.RsltItems_Screen_SingleWM[i]; + + count = (ls.RsltItems_Screen_CombinedWM != null) ? ls.RsltItems_Screen_CombinedWM.Length : 0; + RsltItems_Screen_CombinedWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Screen_CombinedWM[i] = ls.RsltItems_Screen_CombinedWM[i]; + + count = (ls.RsltItems_Printer_SingleWM != null) ? ls.RsltItems_Printer_SingleWM.Length : 0; + RsltItems_Printer_SingleWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Printer_SingleWM[i] = ls.RsltItems_Printer_SingleWM[i]; + + count = (ls.RsltItems_Printer_CombinedWM != null) ? ls.RsltItems_Printer_CombinedWM.Length : 0; + RsltItems_Printer_CombinedWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Printer_CombinedWM[i] = ls.RsltItems_Printer_CombinedWM[i]; + + count = (ls.RsltItems_Disk_SingleWM != null) ? ls.RsltItems_Disk_SingleWM.Length : 0; + RsltItems_Disk_SingleWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Disk_SingleWM[i] = ls.RsltItems_Disk_SingleWM[i]; + + count = (ls.RsltItems_Disk_CombinedWM != null) ? ls.RsltItems_Disk_CombinedWM.Length : 0; + RsltItems_Disk_CombinedWM = new string[count]; + for (int i = 0; i < count; i++) RsltItems_Disk_CombinedWM[i] = ls.RsltItems_Disk_CombinedWM[i]; + + RsltsSingleClmnWdths = new int[ls.RsltsSingleClmnCount]; + for (int i = 0; i < RsltsSingleClmnCount; i++) + RsltsSingleClmnWdths[i] = ls.RsltsSingleClmnWdths[i]; + RsltsCombinedClmnWdths = new int[ls.RsltsCombinedClmnCount]; + for (int i = 0; i < RsltsCombinedClmnCount; i++) + RsltsCombinedClmnWdths[i] = ls.RsltsCombinedClmnWdths[i]; + } + } + + [XmlIgnore] + public readonly bool AlwaysAskPasswdWhenUnlocking; + + [XmlIgnore] + public readonly bool RestoreUserWhenLeavingDialog; + + + public LocalSettings() + { + AlwaysAskPasswdWhenUnlocking = false; + RestoreUserWhenLeavingDialog = true; + } + + /// + /// Load public fields of this class from the XML file. + /// + public void Load() + { + try + { + using (TextReader reader = new StreamReader(Program.LocalSettingsFileName)) + { + LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings; + // Copy the settings just in case De-serialize() completes OK + this.Assign(ls); + } + } + catch (Exception e) + { + string msg = e.Message; + } + } + + /// + /// Save public fields of this class to the XML file. + /// + public void Save() + { + try + { + using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName)) + { + (new XmlSerializer(typeof(LocalSettings))).Serialize(writer, this); + } + } + catch (Exception e) + { + string msg = e.Message; + } + } + } +} diff --git a/ResultsBrowser/MainWnd.Designer.cs b/ResultsBrowser/MainWnd.Designer.cs new file mode 100644 index 000000000..34bda0846 --- /dev/null +++ b/ResultsBrowser/MainWnd.Designer.cs @@ -0,0 +1,141 @@ +namespace ResultsBrowser +{ + partial class MainWnd + { + /// + /// 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.dateFromComboBox = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.dateToComboBox = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.procedureComboBox = new System.Windows.Forms.ComboBox(); + this.searchButton = new System.Windows.Forms.Button(); + this.resultsTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // dateFromComboBox + // + this.dateFromComboBox.FormattingEnabled = true; + this.dateFromComboBox.Location = new System.Drawing.Point(45, 49); + this.dateFromComboBox.Name = "dateFromComboBox"; + this.dateFromComboBox.Size = new System.Drawing.Size(133, 21); + this.dateFromComboBox.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(42, 32); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Date from"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(206, 32); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(42, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Date to"; + // + // dateToComboBox + // + this.dateToComboBox.FormattingEnabled = true; + this.dateToComboBox.Location = new System.Drawing.Point(209, 49); + this.dateToComboBox.Name = "dateToComboBox"; + this.dateToComboBox.Size = new System.Drawing.Size(133, 21); + this.dateToComboBox.TabIndex = 2; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(367, 32); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Procedure"; + // + // procedureComboBox + // + this.procedureComboBox.FormattingEnabled = true; + this.procedureComboBox.Location = new System.Drawing.Point(370, 49); + this.procedureComboBox.Name = "procedureComboBox"; + this.procedureComboBox.Size = new System.Drawing.Size(133, 21); + this.procedureComboBox.TabIndex = 4; + // + // searchButton + // + this.searchButton.Location = new System.Drawing.Point(395, 109); + this.searchButton.Name = "searchButton"; + this.searchButton.Size = new System.Drawing.Size(107, 31); + this.searchButton.TabIndex = 6; + this.searchButton.Text = "Search"; + this.searchButton.UseVisualStyleBackColor = true; + // + // resultsTextBox + // + this.resultsTextBox.Location = new System.Drawing.Point(46, 175); + this.resultsTextBox.Multiline = true; + this.resultsTextBox.Name = "resultsTextBox"; + this.resultsTextBox.Size = new System.Drawing.Size(456, 234); + this.resultsTextBox.TabIndex = 7; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(550, 448); + this.Controls.Add(this.resultsTextBox); + this.Controls.Add(this.searchButton); + this.Controls.Add(this.label3); + this.Controls.Add(this.procedureComboBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.dateToComboBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.dateFromComboBox); + this.Name = "Form1"; + this.Text = "Results Browser"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox dateFromComboBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox dateToComboBox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox procedureComboBox; + private System.Windows.Forms.Button searchButton; + private System.Windows.Forms.TextBox resultsTextBox; + } +} + diff --git a/ResultsBrowser/MainWnd.cs b/ResultsBrowser/MainWnd.cs new file mode 100644 index 000000000..c5808c677 --- /dev/null +++ b/ResultsBrowser/MainWnd.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ResultsBrowser +{ + public partial class MainWnd : Form + { + public MainWnd() + { + InitializeComponent(); + } + } +} diff --git a/ResultsBrowser/MainWnd.resx b/ResultsBrowser/MainWnd.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/ResultsBrowser/MainWnd.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ResultsBrowser/Mappings/BenchPathMap.cs b/ResultsBrowser/Mappings/BenchPathMap.cs new file mode 100644 index 000000000..586bcc63a --- /dev/null +++ b/ResultsBrowser/Mappings/BenchPathMap.cs @@ -0,0 +1,27 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class BenchPathMap : ClassMap + { + public BenchPathMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.TempIn); + Map(x => x.TempOut); + Map(x => x.PressIn); + Map(x => x.PressOut); + Map(x => x.ValvesOpen) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.ValvesClose) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + } + } +} diff --git a/ResultsBrowser/Mappings/ComponentMap.cs b/ResultsBrowser/Mappings/ComponentMap.cs new file mode 100644 index 000000000..3656f1ff6 --- /dev/null +++ b/ResultsBrowser/Mappings/ComponentMap.cs @@ -0,0 +1,25 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class ComponentMap : ClassMap + { + public ComponentMap() + { + Id(x => x.Id); + Map(x => x.Name); + Map(x => x.ClassName); + Map(x => x.ParentName); + Map(x => x.ItemNr); + Map(x => x.Mode); + Map(x => x.Logging); + Map(x => x.Parameters) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + HasMany(x => x.Corrections) + .OrderBy("Measurement") + .Cascade.All(); + } + } +} diff --git a/ResultsBrowser/Mappings/ComponentProcedureMap.cs b/ResultsBrowser/Mappings/ComponentProcedureMap.cs new file mode 100644 index 000000000..a2f5dd022 --- /dev/null +++ b/ResultsBrowser/Mappings/ComponentProcedureMap.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class ComponentProcedureMap : ClassMap + { + public ComponentProcedureMap() + { + Id(x => x.Id); + Map(x => x.CmpntName); + Map(x => x.Parameters) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + + References(x => x.Procedure); + } + } +} diff --git a/ResultsBrowser/Mappings/ComponentTestMap.cs b/ResultsBrowser/Mappings/ComponentTestMap.cs new file mode 100644 index 000000000..2f9498a79 --- /dev/null +++ b/ResultsBrowser/Mappings/ComponentTestMap.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class ComponentTestMap : ClassMap + { + public ComponentTestMap() + { + Id(x => x.Id); + Map(x => x.CmpntName); + Map(x => x.Parameters) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + + References(x => x.Test); + } + } +} diff --git a/ResultsBrowser/Mappings/FeedingPathMap.cs b/ResultsBrowser/Mappings/FeedingPathMap.cs new file mode 100644 index 000000000..c5d53f3f0 --- /dev/null +++ b/ResultsBrowser/Mappings/FeedingPathMap.cs @@ -0,0 +1,24 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class FeedingPathMap : ClassMap + { + public FeedingPathMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.Pump); + Map(x => x.ValvesOpen) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.ValvesClose) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + } + } +} diff --git a/ResultsBrowser/Mappings/GroupMap.cs b/ResultsBrowser/Mappings/GroupMap.cs new file mode 100644 index 000000000..42ac15c3d --- /dev/null +++ b/ResultsBrowser/Mappings/GroupMap.cs @@ -0,0 +1,14 @@ +using FluentNHibernate.Mapping; + +namespace ResultsBrowser.Mappings +{ + class GroupMap : ClassMap + { + public GroupMap() + { + Id(x => x.Id); + Map(x => x.Gid); + Map(x => x.Name); + } + } +} diff --git a/ResultsBrowser/Mappings/MeasurementCorrectionMap.cs b/ResultsBrowser/Mappings/MeasurementCorrectionMap.cs new file mode 100644 index 000000000..f6069dafd --- /dev/null +++ b/ResultsBrowser/Mappings/MeasurementCorrectionMap.cs @@ -0,0 +1,15 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class MeasurementCorrectionMap : ClassMap + { + public MeasurementCorrectionMap() + { + Id(x => x.Id); + Map(x => x.Measurement); + Map(x => x.Correction); + } + } +} diff --git a/ResultsBrowser/Mappings/MeterTestResultMap.cs b/ResultsBrowser/Mappings/MeterTestResultMap.cs new file mode 100644 index 000000000..831c4f3c7 --- /dev/null +++ b/ResultsBrowser/Mappings/MeterTestResultMap.cs @@ -0,0 +1,24 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class MeterTestResultMap : ClassMap + { + public MeterTestResultMap() + { + Id(x => x.Id); + References(x => x.TestResult); + Map(x => x.SerialNr); + Map(x => x.EndState); + Map(x => x.VolumeStart); + Map(x => x.VolumeEnd); + Map(x => x.VolumeMeter); + Map(x => x.VolumeRef); + Map(x => x.VolumeErrorPct); + Map(x => x.PulsesMeter); + Map(x => x.PulsesMaster); + Map(x => x.Time); + } + } +} diff --git a/ResultsBrowser/Mappings/MetersPathMap.cs b/ResultsBrowser/Mappings/MetersPathMap.cs new file mode 100644 index 000000000..75ab947c7 --- /dev/null +++ b/ResultsBrowser/Mappings/MetersPathMap.cs @@ -0,0 +1,39 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class MetersPathMap : ClassMap + { + public MetersPathMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.Sensor1); +#pragma warning disable + if (Program.WMsCount >= 2) Map(x => x.Sensor2); + if (Program.WMsCount >= 3) Map(x => x.Sensor3); + if (Program.WMsCount >= 4) Map(x => x.Sensor4); + if (Program.WMsCount >= 5) Map(x => x.Sensor5); + if (Program.WMsCount >= 6) Map(x => x.Sensor6); + if (Program.WMsCount >= 7) Map(x => x.Sensor7); + if (Program.WMsCount >= 8) Map(x => x.Sensor8); + if (Program.WMsCount >= 9) Map(x => x.Sensor9); + if (Program.WMsCount >= 10) Map(x => x.Sensor10); + if (Program.WMsCount >= 11) Map(x => x.Sensor11); + if (Program.WMsCount >= 12) Map(x => x.Sensor12); + if (Program.WMsCount >= 13) Map(x => x.Sensor13); + if (Program.WMsCount >= 14) Map(x => x.Sensor14); + if (Program.WMsCount >= 15) Map(x => x.Sensor15); + if (Program.WMsCount >= 16) Map(x => x.Sensor16); + if (Program.WMsCount >= 17) Map(x => x.Sensor17); + if (Program.WMsCount >= 18) Map(x => x.Sensor18); + if (Program.WMsCount >= 19) Map(x => x.Sensor19); + if (Program.WMsCount >= 20) Map(x => x.Sensor20); +#pragma warning restore + } + } +} diff --git a/ResultsBrowser/Mappings/OutputPathMap.cs b/ResultsBrowser/Mappings/OutputPathMap.cs new file mode 100644 index 000000000..f91868b6b --- /dev/null +++ b/ResultsBrowser/Mappings/OutputPathMap.cs @@ -0,0 +1,31 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class OutputPathMap : ClassMap + { + public OutputPathMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.RegulValve); + Map(x => x.FlowMeter); + Map(x => x.PidCoef); + Map(x => x.StartValve); + Map(x => x.Diverter); + Map(x => x.TempDiv); + Map(x => x.Balance); + Map(x => x.EmptyTankValve); + Map(x => x.ValvesOpen) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.ValvesClose) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + } + } +} diff --git a/ResultsBrowser/Mappings/ProcedureMap.cs b/ResultsBrowser/Mappings/ProcedureMap.cs new file mode 100644 index 000000000..9ec5a77b5 --- /dev/null +++ b/ResultsBrowser/Mappings/ProcedureMap.cs @@ -0,0 +1,36 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class ProcedureMap : ClassMap + { + public ProcedureMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.MetersKind); + Map(x => x.Description); + Map(x => x.CreationUser); + Map(x => x.CreationTime); + Map(x => x.LastChgUser); + Map(x => x.LastChgTime); + Map(x => x.LongDescription); + Map(x => x.Watermeters); + Map(x => x.ProtocolTitle); + Map(x => x.DataEntry); + Map(x => x.ResultsPrinter); + Map(x => x.ResultsWriter); + Map(x => x.TransitionStart); + Map(x => x.TransitionEnd); + ////Map(x => x.MetrologicalClass); + ////HasOne(x => x.WMType); + HasMany(x => x.MoreParams) + .Cascade.All(); + HasMany(x => x.Tests) + .OrderBy("ItemNr") + .Cascade.All(); + } + } +} diff --git a/ResultsBrowser/Mappings/TestMap.cs b/ResultsBrowser/Mappings/TestMap.cs new file mode 100644 index 000000000..69d6a2b59 --- /dev/null +++ b/ResultsBrowser/Mappings/TestMap.cs @@ -0,0 +1,39 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class TestMap : ClassMap + { + public TestMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Part); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.Volume); + Map(x => x.TstTime); + Map(x => x.Repeats); + Map(x => x.Emptying); + Map(x => x.Zeroing); + Map(x => x.PumpPower); + Map(x => x.Time2MassMsrmt); + Map(x => x.Method); + Map(x => x.ErrLimLo); + Map(x => x.ErrLimHi); + Map(x => x.TolerRed); /// ??? + Map(x => x.RedType); /// ??? + Map(x => x.FeedingPath); + Map(x => x.BenchPath); + Map(x => x.OutputPath); + Map(x => x.MetersPath); + Map(x => x.TransitionStart); + Map(x => x.TransitionEnd); + HasMany(x => x.MoreParams) + .Cascade.All(); + References(x => x.Procedure); + } + } +} diff --git a/ResultsBrowser/Mappings/TestResultMap.cs b/ResultsBrowser/Mappings/TestResultMap.cs new file mode 100644 index 000000000..167e0bb0a --- /dev/null +++ b/ResultsBrowser/Mappings/TestResultMap.cs @@ -0,0 +1,105 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class TestResultMap : ClassMap + { + public TestResultMap() + { + Id(x => x.Id); + Map(x => x.Name); + Map(x => x.BatchNr) + .Column("CycleNr"); + Map(x => x.MetersKind); + HasMany(x => x.Meters) + .Cascade.All(); + HasMany(x => x.CombinedMeters) + .Cascade.All(); + + Map(x => x.ProcedureName); + Map(x => x.ProtocolTitle); + + Map(x => x.TestId); + Map(x => x.TestName); + Map(x => x.Part); + Map(x => x.Qfrom); + Map(x => x.Qto); + Map(x => x.Volume); + Map(x => x.TstTime); + Map(x => x.Repeats); + Map(x => x.Emptying); + Map(x => x.Zeroing); + Map(x => x.PumpPower); + Map(x => x.Time2MassMsrmt); + Map(x => x.Method); + Map(x => x.ErrLimLo); + Map(x => x.ErrLimHi); + + Map(x => x.FeedingPath) + .CustomType("StringClob") + .CustomSqlType("varchar(4000)"); + Map(x => x.BenchPath) + .CustomType("StringClob") + .CustomSqlType("varchar(4000)"); + Map(x => x.OutputPath) + .CustomType("StringClob") + .CustomSqlType("varchar(4000)"); + Map(x => x.MetersPath) + .CustomType("StringClob") + .CustomSqlType("varchar(4000)"); + + Map(x => x.TimeStart); + Map(x => x.TimeEnd); + Map(x => x.RepetitionNr); + Map(x => x.AmbientTempAve); + Map(x => x.AmbientPressAve); + Map(x => x.AmbientHumiAve); + Map(x => x.PressInAvrg); + Map(x => x.PressInStart); + Map(x => x.PressInEnd); + Map(x => x.PressOutAvrg); + Map(x => x.PressOutStart); + Map(x => x.PressOutEnd); + Map(x => x.TempInAvrg); + Map(x => x.TempInStart); + Map(x => x.TempInEnd); + Map(x => x.TempOutAvrg); + Map(x => x.TempOutStart); + Map(x => x.TempOutEnd); + Map(x => x.TempDivAvrg); + Map(x => x.TempDivStart); + Map(x => x.TempDivEnd); + Map(x => x.MassStartRaw); + Map(x => x.MassStart); + Map(x => x.MassEndRaw); + Map(x => x.MassEnd); + Map(x => x.MassDiff); + Map(x => x.DensityIn); + Map(x => x.DensityOut); + Map(x => x.DensityDiv); + Map(x => x.FlowMass); /// from conventional true value + Map(x => x.FlowVolume); /// from conventional true value + Map(x => x.VolumeCTV); /// volume conventional true value + Map(x => x.VolumeMaster); /// volume from the master flow meter + Map(x => x.Time); /// measurement time in seconds + Map(x => x.ErrorMaster); + Map(x => x.PulsesMaster); + Map(x => x.ConstMaster); /// Pulses per liter master flow meter + Map(x => x.QRise); + Map(x => x.QFall); + Map(x => x.TimeDivStart0); + Map(x => x.TimeDivStart1); + Map(x => x.TimeDivStart2); + Map(x => x.TimeDivStart3); + Map(x => x.TimeDivStart4); + Map(x => x.TimeDivStart5); + Map(x => x.TimeDivEnd0); + Map(x => x.TimeDivEnd1); + Map(x => x.TimeDivEnd2); + Map(x => x.TimeDivEnd3); + Map(x => x.TimeDivEnd4); + Map(x => x.TimeDivEnd5); + } + } +} diff --git a/ResultsBrowser/Mappings/TransitionSequenceMap.cs b/ResultsBrowser/Mappings/TransitionSequenceMap.cs new file mode 100644 index 000000000..4b326cb28 --- /dev/null +++ b/ResultsBrowser/Mappings/TransitionSequenceMap.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class TransitionSequenceMap : ClassMap + { + public TransitionSequenceMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Description); + HasMany(x => x.TransitionSteps) + .OrderBy("ItemNr") + .Cascade.All(); + } + } +} diff --git a/ResultsBrowser/Mappings/TransitionStepMap.cs b/ResultsBrowser/Mappings/TransitionStepMap.cs new file mode 100644 index 000000000..fc15b9e2c --- /dev/null +++ b/ResultsBrowser/Mappings/TransitionStepMap.cs @@ -0,0 +1,26 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class TransitionStepMap : ClassMap + { + public TransitionStepMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Duration); + Map(x => x.Message); + Map(x => x.ValvesOpen) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.ValvesClose) + .CustomType("StringClob") + .CustomSqlType("varchar(8000)"); + Map(x => x.RegulValvesPct); + Map(x => x.PumpWithFMPcts); + + References(x => x.TransitionSequence); + } + } +} diff --git a/ResultsBrowser/Mappings/UserMap.cs b/ResultsBrowser/Mappings/UserMap.cs new file mode 100644 index 000000000..0e4ee9bc8 --- /dev/null +++ b/ResultsBrowser/Mappings/UserMap.cs @@ -0,0 +1,18 @@ +using FluentNHibernate.Mapping; + +namespace ResultsBrowser.Mappings +{ + class UserMap : ClassMap + { + public UserMap() + { + Id(x => x.Id); + Map(x => x.Name); + Map(x => x.Password); + Map(x => x.Description); + Map(x => x.LastPwChange); + HasMany(x => x.Groups) + .Cascade.All(); + } + } +} diff --git a/ResultsBrowser/Mappings/VirtualBenchSequenceMap.cs b/ResultsBrowser/Mappings/VirtualBenchSequenceMap.cs new file mode 100644 index 000000000..4e71ef99d --- /dev/null +++ b/ResultsBrowser/Mappings/VirtualBenchSequenceMap.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class VirtualBenchSequenceMap : ClassMap + { + public VirtualBenchSequenceMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Name); + Map(x => x.Description); + HasMany(x => x.VirtualBenchSteps) + .OrderBy("ItemNr") + .Cascade.All(); + } + } +} diff --git a/ResultsBrowser/Mappings/VirtualBenchStepMap.cs b/ResultsBrowser/Mappings/VirtualBenchStepMap.cs new file mode 100644 index 000000000..a3fae516f --- /dev/null +++ b/ResultsBrowser/Mappings/VirtualBenchStepMap.cs @@ -0,0 +1,17 @@ +using FluentNHibernate.Mapping; +using ResultsBrowser.Entities; + +namespace ResultsBrowser.Mappings +{ + class VirtualBenchStepMap : ClassMap + { + public VirtualBenchStepMap() + { + Id(x => x.Id); + Map(x => x.ItemNr); + Map(x => x.Duration); + + References(x => x.VirtualBenchSequence); + } + } +} diff --git a/ResultsBrowser/Mappings/WMTypeMap.cs b/ResultsBrowser/Mappings/WMTypeMap.cs new file mode 100644 index 000000000..2da440717 --- /dev/null +++ b/ResultsBrowser/Mappings/WMTypeMap.cs @@ -0,0 +1,17 @@ +using FluentNHibernate.Mapping; + +namespace ResultsBrowser.Mappings +{ + class WMTypeMap : ClassMap + { + public WMTypeMap() + { + Id(x => x.Id); + Map(x => x.CreateTime); + Map(x => x.CreateUserName); + Map(x => x.CreateDescription); + Map(x => x.Name); + Map(x => x.PulseRate); + } + } +} diff --git a/ResultsBrowser/Mappings/WatermeterMap.cs b/ResultsBrowser/Mappings/WatermeterMap.cs new file mode 100644 index 000000000..e71b78ae3 --- /dev/null +++ b/ResultsBrowser/Mappings/WatermeterMap.cs @@ -0,0 +1,16 @@ +using FluentNHibernate.Mapping; + +namespace ResultsBrowser.Mappings +{ + class WatermeterMap : ClassMap + { + public WatermeterMap() + { + Id(x => x.Id); + Map(x => x.Serial); + // HasOne(x => x.WMType) + // .Cascade.All(); + References(x => x.WMType); + } + } +} diff --git a/ResultsBrowser/Program.cs b/ResultsBrowser/Program.cs new file mode 100644 index 000000000..d3e4ed232 --- /dev/null +++ b/ResultsBrowser/Program.cs @@ -0,0 +1,259 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using ResultsBrowser.Forms; +using ResultsBrowser.Entities; + +using NHibernate; + +namespace ResultsBrowser +{ + public class Program + { + public const string AdminUsername = "admin"; + public const string AdminPassword = "staratura"; + + public const string HomeDir = "C:\\Tbf\\"; /// Contains subdirectories Results, Logs, Images, ... + + /// log4net + static readonly ILog log = LogManager.GetLogger(typeof(Program)); + const string log4netConfigFName = "log4netConfig.xml"; + + /// Local settings + public static LocalSettings LocalSettings = new LocalSettings(); + public const string LocalSettingsFileName = "config.xml"; + + /// Database related: This object reference is set after a successful user login + public static DatabaseSettings CurrentBench; + const string SQLiteDbFName = "SQLite.db"; + +#if (DN100 || MUNICH) + public const int WMsCount = 3; +#elif FUZHOU300 + public const int WMsCount = 6; +#else // if FUZHOU150 + public const int WMsCount = 6; +#endif + + /// + /// Selected procedure data + /// - before the main program window is open, objects referenced by this variable + /// are loaded from the database. + /// - user interface displays data stored in objects referenced by this variable. + /// When user modifies procedure settings and confirms changes (choses to save them), + /// data referenced by this variable are updated and written to the database. + /// - when users starts a test procedure, state machine creates its own copy + /// of procedure data and uses them for the test. Changes of 'SelectedProcedure' + /// done during the test do not have any influence on the currently running test. + /// + public static Entities.Procedure SelectedProcedure = null; + + /// + /// Main window object. + /// + public static MainWnd MainWnd; + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + log.Fatal("--------------------------------------------------------------------------------"); + + /// Local program configuration directory including the trailing backslash + string locAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + + Path.DirectorySeparatorChar + "TestBenchFramework" + Path.DirectorySeparatorChar; + + /// Check whether local application data directory exists. + /// If not, create it and copy the initial configuration to this directory. + /// This is done only once after a clean program installation on the first program start-up + try + { + if (!Directory.Exists(locAppDataDir)) + { + Directory.CreateDirectory(locAppDataDir); + Environment.CurrentDirectory = locAppDataDir; + + string sampleConfig = Application.StartupPath + Path.DirectorySeparatorChar + "SampleConfig" + Path.DirectorySeparatorChar; + if (File.Exists(sampleConfig + LocalSettingsFileName)) { File.Copy(sampleConfig + LocalSettingsFileName, LocalSettingsFileName); } + if (File.Exists(sampleConfig + log4netConfigFName)) { File.Copy(sampleConfig + log4netConfigFName, log4netConfigFName); } + if (File.Exists(sampleConfig + SQLiteDbFName)) { File.Copy(sampleConfig + SQLiteDbFName, SQLiteDbFName); } + + File.SetAttributes(LocalSettingsFileName, FileAttributes.Normal); + File.SetAttributes(log4netConfigFName, FileAttributes.Normal); + File.SetAttributes(SQLiteDbFName, FileAttributes.Normal); + } + else + { + Environment.CurrentDirectory = locAppDataDir; + } + } + catch (Exception e) + { + log.Error("A problem when creating the local application data directory and preparing the initial configuration", e); + return; + } + + /// Configue and start logging + log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(locAppDataDir + log4netConfigFName)); + log.Info("Entering application."); + + /// Load the local settings + if (Program.LocalSettings == null) return; /// Fatal error + LocalSettings.Load(); + + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(LocalSettings.Language); + + /// This belongs to Application.Run(new MainWnd()) ... + /// and should be executed before opening 'loginDlg' + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + /// Ensure that there is at least one bench in the configuration + while (Program.LocalSettings.testBenches.GetLength(0) == 0) + { + log.Warn("No test benches in the local configuration -> display an appropriate dialog."); + + /// Ask what to do, ask for the password, open 'DatabaseSetingsDlg' and continue on OK + if ((new Forms.NoBenchOrDatabaseDlg { Message = "No test bench in the program configuration." }.ShowDialog() != DialogResult.OK) || + (new LoginDlg(true).ShowDialog() == DialogResult.Cancel) || + (new BenchesDlg().ShowDialog() == DialogResult.Cancel)) + { + return; /// Exit program + } + + log.Warn("Loading the local settings again."); + LocalSettings.Load(); + } + + /// User login + bool retryLogin = true; /// true = stay in a login loop + do { + LoginDlgWithBenchSelection loginDlgBench; + if (LocalSettings.LastBenchName != null) + { + loginDlgBench = new LoginDlgWithBenchSelection(LocalSettings.LastBenchName); + } + else + { + loginDlgBench = new LoginDlgWithBenchSelection(); + } + DialogResult dr = loginDlgBench.ShowDialog(); + + if (dr == DialogResult.Cancel) + { + return; /// Login canceled --> Exit application + } + else + { + + for (int i = 0; i < LocalSettings.BenchesCount; i++) + { + if (LocalSettings.TestBenches[i].BenchName == loginDlgBench.BenchName) + { + Entities.User loadedUser = null; + try + { + bool authorized = false; + + if (Entities.User.IsPowerUser(loginDlgBench.User, loginDlgBench.Password)) + { + loadedUser = new Entities.User(loginDlgBench.User); + authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password); + } + + if (!authorized) + { + /// Load user from the UsersAndGroupsDB database + loadedUser = Entities.User.LoadUserByName(loginDlgBench.User, + LocalSettings.TestBenches[i].UsersDBSettings); + if (loadedUser != null) + { + authorized = loadedUser.Authorize(loginDlgBench.User, loginDlgBench.Password); + } + } + + if (authorized) + { + log.InfoFormat("Password accepted, bench '{0}' parameters loaded.", LocalSettings.TestBenches[i].BenchName); + + /// Copy the selected bench settings to CurrentBench. + /// Clone() guarantees that current bench settings wont be modified + /// when user modifies the database settings in DatabaseSettingsDlg. + CurrentBench = (DatabaseSettings)LocalSettings.TestBenches[i].Clone(); + + /// Save the selection to local settings + LocalSettings.LastBenchName = CurrentBench.BenchName; + + retryLogin = false; + break; + } + + if (retryLogin) + { + /// Close Fluent NHibernate + MessageBox.Show("Invalid user, password, or bench", "Error", MessageBoxButtons.OK); + } + } + catch (Exception) + { + /// Database connect failed, ask what to do + switch ((new Forms.NoBenchOrDatabaseDlg { Message = "Cannot connect to the database.", ShowRetry = true }).ShowDialog()) + { + case DialogResult.Abort: return; /// Exit program + case DialogResult.Retry: break; /// Retry the loop + default: + /// Open 'DatabaseSetingsDlg' and retry DB connect on OK + if (new LoginDlg(true).ShowDialog() == DialogResult.Cancel || + new BenchesDlg().ShowDialog() == DialogResult.Cancel) + { + return; /// Exit program + } + LocalSettings.Load(); + break; /// Retry the loop + } + } + } // if benchname is OK + } // for all benches in local settings loop + } // not Canceled + } //do + while (retryLogin); + + /// + /// Load the last procedure or create a new, default one + /// + if (LocalSettings.LastProcedureName != null) + { + IList listOfProcedures = FluentCommon.CreateSession(Database.Procedures) + .CreateQuery("FROM Procedure WHERE Name = :procName") + .SetParameter("procName", LocalSettings.LastProcedureName) + .List(); + + if (listOfProcedures.Count == 1) + { + log.InfoFormat("Pre-selecting the procedure {0}", LocalSettings.LastProcedureName); + SelectedProcedure = listOfProcedures[0]; + } + } + + /// Open the main application window + log.Info("Creating the main window"); + MainWnd = new MainWnd(); + log.Info("Opening the main window"); + Application.Run(MainWnd); + + /// Save local settings + log.Info("The main window was closed, saving the local parameters"); + LocalSettings.Save(); + + /// Close Fluent NHibernate + /// Todo + + log.Info("Exiting application."); + } + } +} \ No newline at end of file diff --git a/ResultsBrowser/Properties/AssemblyInfo.cs b/ResultsBrowser/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1ccd09c5e --- /dev/null +++ b/ResultsBrowser/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ResultsBrowser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ResultsBrowser")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("52c39793-b492-49c6-aa6a-1820ebef1d6e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ResultsBrowser/Properties/Resources.Designer.cs b/ResultsBrowser/Properties/Resources.Designer.cs new file mode 100644 index 000000000..84922c9c2 --- /dev/null +++ b/ResultsBrowser/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ResultsBrowser.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ResultsBrowser.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ResultsBrowser/Properties/Resources.resx b/ResultsBrowser/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/ResultsBrowser/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ResultsBrowser/Properties/Settings.Designer.cs b/ResultsBrowser/Properties/Settings.Designer.cs new file mode 100644 index 000000000..e78e8179c --- /dev/null +++ b/ResultsBrowser/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ResultsBrowser.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ResultsBrowser/Properties/Settings.settings b/ResultsBrowser/Properties/Settings.settings new file mode 100644 index 000000000..39645652a --- /dev/null +++ b/ResultsBrowser/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ResultsBrowser/ResultsBrowser.csproj b/ResultsBrowser/ResultsBrowser.csproj new file mode 100644 index 000000000..77561aae9 --- /dev/null +++ b/ResultsBrowser/ResultsBrowser.csproj @@ -0,0 +1,196 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {890D8E75-F745-407D-9A49-00CBC791D686} + WinExe + Properties + ResultsBrowser + ResultsBrowser + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll + + + ..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll + + + ..\packages\log4net.2.0.2\lib\net40-full\log4net.dll + + + ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll + + + ..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll + + + + + + + + + + + + + + + Form + + + BenchesDlg.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + LoginDlg.cs + + + Form + + + LoginDlgWithBenchSelection.cs + + + Form + + + NoBenchOrDatabaseDlg.cs + + + + Form + + + MainWnd.cs + + + + + + + + + + + + + + + + + + + + + + + + + BenchesDlg.cs + + + BenchesDlg.cs + + + LoginDlg.cs + + + LoginDlg.cs + + + LoginDlgWithBenchSelection.cs + + + LoginDlgWithBenchSelection.cs + + + NoBenchOrDatabaseDlg.cs + + + MainWnd.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + \ No newline at end of file diff --git a/TestBenchFramework.sln b/TestBenchFramework.sln index 71d82d668..5cdbd3f5a 100644 --- a/TestBenchFramework.sln +++ b/TestBenchFramework.sln @@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TestBenchFramework\T EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "TBFSetup", "TBFSetup\TBFSetup.vdproj", "{4890DE5C-9F68-40D7-B075-92C8EAB79833}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResultsBrowser", "ResultsBrowser\ResultsBrowser.csproj", "{890D8E75-F745-407D-9A49-00CBC791D686}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,12 @@ Global {4890DE5C-9F68-40D7-B075-92C8EAB79833}.Release|Any CPU.ActiveCfg = Release {4890DE5C-9F68-40D7-B075-92C8EAB79833}.Release|Any CPU.Build.0 = Release {4890DE5C-9F68-40D7-B075-92C8EAB79833}.Release|x86.ActiveCfg = Release + {890D8E75-F745-407D-9A49-00CBC791D686}.Debug|Any CPU.ActiveCfg = Debug|x86 + {890D8E75-F745-407D-9A49-00CBC791D686}.Debug|x86.ActiveCfg = Debug|x86 + {890D8E75-F745-407D-9A49-00CBC791D686}.Debug|x86.Build.0 = Debug|x86 + {890D8E75-F745-407D-9A49-00CBC791D686}.Release|Any CPU.ActiveCfg = Release|x86 + {890D8E75-F745-407D-9A49-00CBC791D686}.Release|x86.ActiveCfg = Release|x86 + {890D8E75-F745-407D-9A49-00CBC791D686}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE