From 075c2654d18fda55c137246e6e150fae633004d0 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 10 Apr 2020 14:54:09 -0700 Subject: [PATCH] Signed-off-by: matt --- .../AuditDb.cs | 19 +- .../Com.QuantAsylum.Tractor.Database/Db.cs | 8 +- .../DlgQuery.cs | 6 +- .../DlgSettings.Designer.cs | 301 +++++++++++------- .../DlgSettings.cs | 79 +++-- .../DlgSettings.resx | 3 + .../DlgTestRun.cs | 81 ++++- .../AppSettings.cs | 12 +- .../ObjectEditorUiBuilder.cs | 4 +- .../Operator/PromptA00.cs | 5 +- Tractor/Constants.cs | 3 +- Tractor/Form1.Designer.cs | 2 +- Tractor/Form1.cs | 20 +- Tractor/Properties/AssemblyInfo.cs | 4 +- Tractor/Releases.txt | 8 +- 15 files changed, 371 insertions(+), 184 deletions(-) diff --git a/Tractor/Com.QuantAsylum.Tractor.Database/AuditDb.cs b/Tractor/Com.QuantAsylum.Tractor.Database/AuditDb.cs index 50c9be9..c253be9 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Database/AuditDb.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Database/AuditDb.cs @@ -125,7 +125,7 @@ static public string CheckService() } catch (Exception ex) { - + Log.WriteLine(LogType.Database, "CheckService() exception: " + ex.Message); } throw new HttpRequestException("CheckService() failed"); @@ -163,7 +163,7 @@ static public List QueryGroupsBySerialNumber(string pid, string sn) } catch (Exception ex) { - + Log.WriteLine(LogType.Database, "QueryGroupsBySerialNumber() exception: " + ex.Message); } return new List { "An error occured in QueryGroupsBySerialNumber()" }; @@ -205,7 +205,7 @@ static public string QueryTestsByGroup(string pid, string group) } catch (Exception ex) { - + Log.WriteLine(LogType.Database, "QueryTestsByGroup() exception: " + ex.Message); } return "An error occurred in QueryTestByGroup()"; @@ -230,7 +230,7 @@ static public List QueryTestNames(string pid) } catch (Exception ex) { - + Log.WriteLine(LogType.Database, "QueryTestNames() exception: " + ex.Message); } return new List { "An error occured in QueryTestNames()" }; @@ -274,7 +274,7 @@ static public string QueryStatsByTest(string pid, string testName, string testSe } catch (Exception ex) { - + Log.WriteLine(LogType.Database, "QueryStatsByTest() exception: " + ex.Message); } return "An error occurred. "; @@ -295,15 +295,6 @@ static public string QueryTestNamesByProductId(string pid) List vals = jsSerializer.Deserialize>(result); StringBuilder sb = new StringBuilder(); - //if (ad.Count > 0) - //{ - // sb.AppendLine("Unit: " + ad[0].SerialNumber); - // sb.AppendLine("Date: " + ad[0].Time.ToString()); - // for (int i = 0; i < ad.Count; i++) - // { - // sb.AppendFormat("{0}[{1}] {2} [{3}] {4}" + Environment.NewLine, ad[i].Name, ad[i].Channel, ad[i].ResultString, ad[i].TestLimits, ad[i].PassFail); - // } - //} return sb.ToString(); } diff --git a/Tractor/Com.QuantAsylum.Tractor.Database/Db.cs b/Tractor/Com.QuantAsylum.Tractor.Database/Db.cs index 4295f0d..66e9594 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Database/Db.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Database/Db.cs @@ -22,7 +22,7 @@ static public bool CreateNew(string connectString) } catch (Exception ex) { - Log.WriteLine(LogType.Database, ex.Message); + Log.WriteLine(LogType.Database, "CreateNew() exception: " + ex.Message); } return false; @@ -38,7 +38,7 @@ static public bool DeleteExisting(string connectString) } catch (Exception ex) { - Log.WriteLine(LogType.Database, ex.Message); + Log.WriteLine(LogType.Database, "DeleteExisting() exception: " + ex.Message); } return false; @@ -58,7 +58,7 @@ static public bool OpenExisting(string connectString) } catch (Exception ex) { - Log.WriteLine(LogType.Database, ex.Message); + Log.WriteLine(LogType.Database, "OpenExisting() exception: " + ex.Message); } return false; @@ -76,7 +76,7 @@ static public bool InsertTest(Test tri) } catch (Exception ex) { - Log.WriteLine(LogType.Error, "Exception submitting changes in InsertTest(): " + ex.Message); + Log.WriteLine(LogType.Error, "InsertTest() exception: " + ex.Message); } return false; diff --git a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgQuery.cs b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgQuery.cs index 30d53a4..b3970af 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgQuery.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgQuery.cs @@ -89,7 +89,9 @@ private void button2_Click(object sender, EventArgs e) } catch (Exception ex) { - MessageBox.Show("Web service call failed: " + ex.Message); + string s = "Web service call failed exception: " + ex.Message; + Log.WriteLine(LogType.Database, s); + MessageBox.Show(s); } } @@ -221,7 +223,7 @@ private void LoadGuid(TextBox tb) } catch (Exception ex) { - Log.WriteLine(LogType.Error, "An exception occured load a PID fron a file: " + ex.Message); + Log.WriteLine(LogType.Error, "An exception occured loading a PID fron a file: " + ex.Message); } } diff --git a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.Designer.cs b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.Designer.cs index 17356bb..33d94ea 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.Designer.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.Designer.cs @@ -40,15 +40,11 @@ private void InitializeComponent() this.checkBox3 = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.textBox3 = new System.Windows.Forms.TextBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button5 = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); this.textBox6 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.button9 = new System.Windows.Forms.Button(); @@ -56,15 +52,25 @@ private void InitializeComponent() this.button7 = new System.Windows.Forms.Button(); this.textBox5 = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); this.button6 = new System.Windows.Forms.Button(); - this.textBox4 = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.groupBox1.SuspendLayout(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.checkBox5 = new System.Windows.Forms.CheckBox(); + this.label10 = new System.Windows.Forms.Label(); + this.textBox7 = new System.Windows.Forms.TextBox(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label12 = new System.Windows.Forms.Label(); + this.textBox9 = new System.Windows.Forms.TextBox(); this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.tabPage3.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // comboBox1 @@ -97,7 +103,7 @@ private void InitializeComponent() // button1 // this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button1.Location = new System.Drawing.Point(140, 632); + this.button1.Location = new System.Drawing.Point(204, 555); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 3; @@ -108,7 +114,7 @@ private void InitializeComponent() // button2 // this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button2.Location = new System.Drawing.Point(261, 632); + this.button2.Location = new System.Drawing.Point(325, 555); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 4; @@ -145,7 +151,7 @@ private void InitializeComponent() // checkBox3 // this.checkBox3.AutoSize = true; - this.checkBox3.Location = new System.Drawing.Point(33, 27); + this.checkBox3.Location = new System.Drawing.Point(53, 22); this.checkBox3.Name = "checkBox3"; this.checkBox3.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.checkBox3.Size = new System.Drawing.Size(94, 17); @@ -156,7 +162,7 @@ private void InitializeComponent() // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(9, 57); + this.label3.Location = new System.Drawing.Point(29, 52); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(98, 13); this.label3.TabIndex = 10; @@ -164,48 +170,14 @@ private void InitializeComponent() // // textBox2 // - this.textBox2.Location = new System.Drawing.Point(113, 50); + this.textBox2.Location = new System.Drawing.Point(133, 45); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(351, 20); this.textBox2.TabIndex = 9; // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(60, 83); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(47, 13); - this.label4.TabIndex = 11; - this.label4.Text = "Session:"; - // - // textBox3 - // - this.textBox3.Location = new System.Drawing.Point(113, 76); - this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(351, 20); - this.textBox3.TabIndex = 12; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.button5); - this.groupBox1.Controls.Add(this.label5); - this.groupBox1.Controls.Add(this.button4); - this.groupBox1.Controls.Add(this.button3); - this.groupBox1.Controls.Add(this.checkBox3); - this.groupBox1.Controls.Add(this.textBox3); - this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Controls.Add(this.textBox2); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Location = new System.Drawing.Point(12, 155); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(477, 205); - this.groupBox1.TabIndex = 13; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Database"; - // // button5 // - this.button5.Location = new System.Drawing.Point(332, 126); + this.button5.Location = new System.Drawing.Point(352, 86); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(101, 23); this.button5.TabIndex = 16; @@ -215,16 +187,16 @@ private void InitializeComponent() // // label5 // - this.label5.Location = new System.Drawing.Point(6, 162); + this.label5.Location = new System.Drawing.Point(15, 460); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(465, 31); + this.label5.Size = new System.Drawing.Size(592, 75); this.label5.TabIndex = 15; this.label5.Text = "label5"; this.label5.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // button4 // - this.button4.Location = new System.Drawing.Point(225, 126); + this.button4.Location = new System.Drawing.Point(245, 86); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(101, 23); this.button4.TabIndex = 14; @@ -234,7 +206,7 @@ private void InitializeComponent() // // button3 // - this.button3.Location = new System.Drawing.Point(33, 126); + this.button3.Location = new System.Drawing.Point(53, 86); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(132, 23); this.button3.TabIndex = 13; @@ -252,35 +224,14 @@ private void InitializeComponent() this.groupBox2.Controls.Add(this.checkBox2); this.groupBox2.Location = new System.Drawing.Point(12, 12); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(477, 137); + this.groupBox2.Size = new System.Drawing.Size(595, 137); this.groupBox2.TabIndex = 14; this.groupBox2.TabStop = false; this.groupBox2.Text = "Setup"; // - // groupBox3 - // - this.groupBox3.Controls.Add(this.textBox6); - this.groupBox3.Controls.Add(this.label9); - this.groupBox3.Controls.Add(this.button9); - this.groupBox3.Controls.Add(this.button8); - this.groupBox3.Controls.Add(this.button7); - this.groupBox3.Controls.Add(this.textBox5); - this.groupBox3.Controls.Add(this.label8); - this.groupBox3.Controls.Add(this.label7); - this.groupBox3.Controls.Add(this.button6); - this.groupBox3.Controls.Add(this.textBox4); - this.groupBox3.Controls.Add(this.label6); - this.groupBox3.Controls.Add(this.checkBox4); - this.groupBox3.Location = new System.Drawing.Point(12, 366); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(477, 246); - this.groupBox3.TabIndex = 15; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Audit Database"; - // // textBox6 // - this.textBox6.Location = new System.Drawing.Point(113, 100); + this.textBox6.Location = new System.Drawing.Point(124, 41); this.textBox6.Name = "textBox6"; this.textBox6.Size = new System.Drawing.Size(351, 20); this.textBox6.TabIndex = 24; @@ -288,7 +239,7 @@ private void InitializeComponent() // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(73, 107); + this.label9.Location = new System.Drawing.Point(84, 48); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(34, 13); this.label9.TabIndex = 25; @@ -296,7 +247,7 @@ private void InitializeComponent() // // button9 // - this.button9.Location = new System.Drawing.Point(372, 150); + this.button9.Location = new System.Drawing.Point(383, 82); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(61, 23); this.button9.TabIndex = 23; @@ -306,7 +257,7 @@ private void InitializeComponent() // // button8 // - this.button8.Location = new System.Drawing.Point(305, 150); + this.button8.Location = new System.Drawing.Point(316, 82); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(61, 23); this.button8.TabIndex = 22; @@ -316,7 +267,7 @@ private void InitializeComponent() // // button7 // - this.button7.Location = new System.Drawing.Point(128, 150); + this.button7.Location = new System.Drawing.Point(93, 82); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(115, 23); this.button7.TabIndex = 21; @@ -326,32 +277,27 @@ private void InitializeComponent() // // textBox5 // - this.textBox5.Location = new System.Drawing.Point(113, 74); + this.textBox5.Location = new System.Drawing.Point(93, 25); this.textBox5.Name = "textBox5"; this.textBox5.Size = new System.Drawing.Size(351, 20); this.textBox5.TabIndex = 19; + this.toolTip1.SetToolTip(this.textBox5, "This is a note to yourself. For example, you might note when production is runnin" + + "g with an alternate supplier for a particular part so you can see how it does co" + + "mpared to the normal supplier."); // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(60, 81); + this.label8.Location = new System.Drawing.Point(44, 32); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(47, 13); this.label8.TabIndex = 20; this.label8.Text = "Session:"; - // - // label7 - // - this.label7.Location = new System.Drawing.Point(6, 191); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(465, 31); - this.label7.TabIndex = 17; - this.label7.Text = "label7"; - this.label7.TextAlign = System.Drawing.ContentAlignment.TopCenter; + this.label8.TextAlign = System.Drawing.ContentAlignment.TopRight; // // button6 // - this.button6.Location = new System.Drawing.Point(6, 150); + this.button6.Location = new System.Drawing.Point(19, 83); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(101, 23); this.button6.TabIndex = 17; @@ -359,26 +305,10 @@ private void InitializeComponent() this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // - // textBox4 - // - this.textBox4.Location = new System.Drawing.Point(113, 48); - this.textBox4.Name = "textBox4"; - this.textBox4.Size = new System.Drawing.Size(351, 20); - this.textBox4.TabIndex = 17; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(51, 55); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(56, 13); - this.label6.TabIndex = 18; - this.label6.Text = "Product Id"; - // // checkBox4 // this.checkBox4.AutoSize = true; - this.checkBox4.Location = new System.Drawing.Point(33, 25); + this.checkBox4.Location = new System.Drawing.Point(46, 18); this.checkBox4.Name = "checkBox4"; this.checkBox4.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.checkBox4.Size = new System.Drawing.Size(94, 17); @@ -387,17 +317,134 @@ private void InitializeComponent() this.checkBox4.UseVisualStyleBackColor = true; this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Location = new System.Drawing.Point(12, 301); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(599, 152); + this.tabControl1.TabIndex = 16; + // + // tabPage1 + // + this.tabPage1.BackColor = System.Drawing.SystemColors.Control; + this.tabPage1.Controls.Add(this.checkBox5); + this.tabPage1.Controls.Add(this.label10); + this.tabPage1.Controls.Add(this.textBox7); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(591, 126); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "CSV Logging"; + // + // checkBox5 + // + this.checkBox5.AutoSize = true; + this.checkBox5.Location = new System.Drawing.Point(47, 26); + this.checkBox5.Name = "checkBox5"; + this.checkBox5.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.checkBox5.Size = new System.Drawing.Size(90, 17); + this.checkBox5.TabIndex = 25; + this.checkBox5.Text = "Use CSV Log"; + this.checkBox5.UseVisualStyleBackColor = true; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(62, 59); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(54, 13); + this.label10.TabIndex = 22; + this.label10.Text = "File Name"; + // + // textBox7 + // + this.textBox7.Location = new System.Drawing.Point(124, 52); + this.textBox7.Name = "textBox7"; + this.textBox7.Size = new System.Drawing.Size(351, 20); + this.textBox7.TabIndex = 21; + this.toolTip1.SetToolTip(this.textBox7, "If you specify a filename only, then .CSV will be appended AND it will be located" + + " in the default CSV directory. But you can specify a full path here if required." + + " "); + // + // tabPage2 + // + this.tabPage2.BackColor = System.Drawing.SystemColors.Control; + this.tabPage2.Controls.Add(this.textBox6); + this.tabPage2.Controls.Add(this.checkBox4); + this.tabPage2.Controls.Add(this.label9); + this.tabPage2.Controls.Add(this.button6); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(591, 126); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Audit DB Logging"; + // + // tabPage3 + // + this.tabPage3.BackColor = System.Drawing.SystemColors.Control; + this.tabPage3.Controls.Add(this.button5); + this.tabPage3.Controls.Add(this.button4); + this.tabPage3.Controls.Add(this.label3); + this.tabPage3.Controls.Add(this.textBox2); + this.tabPage3.Controls.Add(this.button3); + this.tabPage3.Controls.Add(this.checkBox3); + this.tabPage3.Location = new System.Drawing.Point(4, 22); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Size = new System.Drawing.Size(591, 126); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "MS SQL Logging"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.label12); + this.groupBox1.Controls.Add(this.textBox9); + this.groupBox1.Controls.Add(this.button7); + this.groupBox1.Controls.Add(this.button9); + this.groupBox1.Controls.Add(this.button8); + this.groupBox1.Controls.Add(this.textBox5); + this.groupBox1.Controls.Add(this.label8); + this.groupBox1.Location = new System.Drawing.Point(12, 163); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(595, 123); + this.groupBox1.TabIndex = 17; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Common Settings"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(32, 58); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(59, 13); + this.label12.TabIndex = 27; + this.label12.Text = "Product Id:"; + this.label12.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // textBox9 + // + this.textBox9.Location = new System.Drawing.Point(93, 51); + this.textBox9.Name = "textBox9"; + this.textBox9.Size = new System.Drawing.Size(351, 20); + this.textBox9.TabIndex = 26; + // // DlgSettings // this.AcceptButton = this.button1; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button2; - this.ClientSize = new System.Drawing.Size(511, 676); + this.ClientSize = new System.Drawing.Size(625, 600); this.ControlBox = false; - this.Controls.Add(this.groupBox3); - this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.label5); + this.Controls.Add(this.groupBox2); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; @@ -405,12 +452,17 @@ private void InitializeComponent() this.Text = "Settings"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DlgSettings_FormClosing); this.Load += new System.EventHandler(this.DlgSettings_Load); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.tabPage3.ResumeLayout(false); + this.tabPage3.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.ResumeLayout(false); } @@ -428,19 +480,12 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkBox3; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox textBox3; - private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button3; private System.Windows.Forms.Label label5; private System.Windows.Forms.Button button5; private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.Label label7; private System.Windows.Forms.Button button6; - private System.Windows.Forms.TextBox textBox4; - private System.Windows.Forms.Label label6; private System.Windows.Forms.CheckBox checkBox4; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.Button button8; @@ -450,5 +495,15 @@ private void InitializeComponent() private System.Windows.Forms.Button button9; private System.Windows.Forms.TextBox textBox6; private System.Windows.Forms.Label label9; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.CheckBox checkBox5; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox textBox7; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox textBox9; } } \ No newline at end of file diff --git a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.cs b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.cs index 288dcba..a229d37 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.cs @@ -27,7 +27,6 @@ public DlgSettings(AppSettings settings) InitializeComponent(); Settings = settings; label5.Text = ""; - label7.Text = ""; } private void DlgSettings_Load(object sender, EventArgs e) @@ -47,9 +46,11 @@ private void DlgSettings_Load(object sender, EventArgs e) checkBox1.Checked = Settings.AbortOnFailure; checkBox3.Checked = Settings.UseDb; textBox2.Text = Settings.DbConnectString; - textBox3.Text = Settings.DbSessionName; - textBox4.Text = Settings.ProductId.ToString(); - textBox5.Text = Settings.AuditDbSessionName; + textBox5.Text = Settings.SessionName; + textBox9.Text = Settings.ProductId.ToString(); + + checkBox5.Checked = Settings.UseCsvLog; + textBox7.Text = Settings.CsvFileName; checkBox4.CheckedChanged -= checkBox4_CheckedChanged; checkBox4.Checked = Settings.UseAuditDb; @@ -69,18 +70,26 @@ private void DlgSettings_FormClosing(object sender, FormClosingEventArgs e) // OK Button clicked private void button1_Click(object sender, EventArgs e) { - if (Guid.TryParse(textBox4.Text, out Guid guidResult)) + CanClose = true; + + if (Guid.TryParse(textBox9.Text, out Guid guidResult)) { Settings.TestClass = comboBox1.Text; + Settings.SessionName = textBox5.Text; + Settings.ProductId = guidResult; + Settings.AbortOnFailure = checkBox1.Checked; + Settings.UseDb = checkBox3.Checked; Settings.DbConnectString = textBox2.Text; - Settings.DbSessionName = textBox3.Text; - Settings.ProductId = guidResult; - Settings.AuditDbSessionName = textBox5.Text; + + Settings.UseCsvLog = checkBox5.Checked; + Settings.CsvFileName = textBox7.Text.Trim(); + Settings.UseAuditDb = checkBox4.Checked; Settings.AuditDbEmail = textBox6.Text; Settings.Password = textBox1.Text.Trim(); + if (Settings.Password == "") { Settings.LockTestScreen = false; @@ -89,12 +98,42 @@ private void button1_Click(object sender, EventArgs e) { Settings.LockTestScreen = checkBox2.Checked; } + + if (Settings.CsvFileName != "") + { + string f = Path.Combine(Constants.CsvLogsPath, Settings.CsvFileName); + + if (Path.HasExtension(f) == false) + { + f = f + ".csv"; + Settings.CsvFileName = Path.GetFileName(f); + } + + if (File.Exists(f) == false) + { + try + { + File.CreateText(f).Close(); + File.Delete(f); + } + catch (Exception ex) + { + label5.Text = "CSV File Name isn't valid: " + ex.Message; + CanClose = false; + } + } + } + + if (Settings.CsvFileName == "" && Settings.UseCsvLog) + { + label5.Text = "CSV file name not specified"; + CanClose = false; + } return; } CanClose = false; - } // Cancel button clicked @@ -138,8 +177,8 @@ private void button5_Click(object sender, EventArgs e) // Test connection to audit database private void button6_Click(object sender, EventArgs e) { - label7.Text = "Wait..."; - label7.Update(); + label5.Text = "Wait..."; + label5.Update(); try { @@ -147,35 +186,35 @@ private void button6_Click(object sender, EventArgs e) { if (result >= Constants.RequiredWebserviceVersion) { - label7.Text = string.Format("Connection successful. Webservice version: {0:0.00}", result); + label5.Text = string.Format("Connection successful. Webservice version: {0:0.00}", result); } else { - label7.Text = string.Format("Bad version. Needed {0:0.00} but found {1:0.00}", Constants.RequiredWebserviceVersion, result); + label5.Text = string.Format("Bad version. Needed {0:0.00} but found {1:0.00}", Constants.RequiredWebserviceVersion, result); } } else { - label7.Text = "Connection failed. Service or internet connection may be down"; + label5.Text = "Connection failed. Service or internet connection may be down"; } } catch (Exception ex) { - label7.Text = ex.Message.Substring(0, Math.Min(100, ex.Message.Length-1)); + label5.Text = ex.Message.Substring(0, Math.Min(100, ex.Message.Length-1)); } } // Generate new Product ID private void button7_Click(object sender, EventArgs e) { - textBox4.Text = Guid.NewGuid().ToString(); - label7.Text = ""; + textBox9.Text = Guid.NewGuid().ToString(); + label5.Text = ""; } // Save Product ID to file private void button8_Click(object sender, EventArgs e) { - if (Guid.TryParse(textBox4.Text, out Guid guidResult)) + if (Guid.TryParse(textBox9.Text, out Guid guidResult)) { try { @@ -197,7 +236,7 @@ private void button8_Click(object sender, EventArgs e) } else { - label7.Text = "Bad GUID. Please correct and try again"; + label5.Text = "Bad GUID. Please correct and try again"; } } @@ -220,7 +259,7 @@ private void button9_Click(object sender, EventArgs e) if (Guid.TryParse(lines[0], out Guid guidResult)) { - textBox4.Text = guidResult.ToString(); + textBox9.Text = guidResult.ToString(); return; } diff --git a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.resx b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.resx index df8339b..d54ad1e 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.resx +++ b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgSettings.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgTestRun.cs b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgTestRun.cs index a356f74..59fdf5a 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgTestRun.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Dialogs/DlgTestRun.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Data; using System.Drawing; +using System.Globalization; +using System.IO; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Security.Cryptography; @@ -27,6 +29,7 @@ enum ColText { TEST = 0, ENABLED = 1, TARGET = 2, L = 3, R = 4, PASSFAIL = 5 }; bool Pause = false; string ReportDirectory = ""; + string CsvLogDirectory = ""; TestManager Tm; @@ -35,10 +38,11 @@ enum ColText { TEST = 0, ENABLED = 1, TARGET = 2, L = 3, R = 4, PASSFAIL = 5 }; public delegate void TestRunComplete(); public TestRunComplete RunCompleteCallback; - public DlgTestRun(TestManager tm, TestRunComplete runCompleteCallback, string reportDir) + public DlgTestRun(TestManager tm, TestRunComplete runCompleteCallback, string reportDir, string csvLogDir) { InitializeComponent(); ReportDirectory = reportDir; + CsvLogDirectory = csvLogDir; Tm = tm; RunCompleteCallback = runCompleteCallback; } @@ -150,6 +154,7 @@ private void Start() bool allPassed = true; string opMessage = ""; + // Tests that run together (eg left and right channels) are part of the same test group Guid testGroup = Guid.NewGuid(); for (int i = 0; i < Form1.AppSettings.TestList.Count; i++) @@ -255,6 +260,41 @@ private void Start() Form1.AppSettings.TestList[i].TestResultBitmap == null ? "[No Image]" : html.ImageLink("Screen", Form1.AppSettings.TestList[i].TestResultBitmap) )); + if (Form1.AppSettings.UseCsvLog) + { + string fileName = Path.Combine(Constants.CsvLogsPath, Form1.AppSettings.CsvFileName); + + if (File.Exists(fileName) == false) + { + try + { + Log.WriteLine(LogType.General, "CSV Log file created: " + fileName); + File.AppendAllText(fileName, GetCsvHeader()); + } + catch (Exception ex) + { + Log.WriteLine(LogType.Error, "CSV Log File could not be created. CSV logging disabled: " + ex.Message); + Form1.AppSettings.UseCsvLog = false; + } + } + + if (Form1.AppSettings.TestList[i] is AudioTestBase) + { + if (((AudioTestBase)Form1.AppSettings.TestList[i]).LeftChannel) + { + SubmitToCsv(fileName, testGroup, 0, Form1.AppSettings.TestList[i], tr); + } + if (((AudioTestBase)Form1.AppSettings.TestList[i]).RightChannel) + { + SubmitToCsv(fileName, testGroup, 1, Form1.AppSettings.TestList[i], tr); + } + } + else + { + SubmitToCsv(fileName, testGroup, 0, Form1.AppSettings.TestList[i], tr); + } + } + if (Form1.AppSettings.UseAuditDb) { if (Form1.AppSettings.TestList[i] is AudioTestBase) @@ -327,7 +367,7 @@ private void SubmitToDb(Guid testGroup, int channelIndex, TestBase tb, TestResul Test tri = new Test() { SerialNumber = Tm.LocalStash.ContainsKey("SerialNumber") ? Tm.LocalStash["SerialNumber"] : "0", - SessionName = Form1.AppSettings.DbSessionName, + SessionName = Form1.AppSettings.SessionName, Name = tb.Name, Time = DateTime.Now, PassFail = tr.Pass, @@ -348,7 +388,7 @@ private void SubmitToAuditDb(Guid testGroup, int channelIndex, TestBase tb, Test { ProductId = Form1.AppSettings.ProductId.ToString(), SerialNumber = Tm.LocalStash.ContainsKey("SerialNumber") ? Tm.LocalStash["SerialNumber"] : "0", - SessionName = Form1.AppSettings.AuditDbSessionName, + SessionName = Form1.AppSettings.SessionName, Channel = (channelIndex == 0 ? "Left" : "Right"), Name = tb.Name, TestGroup = testGroup.ToString(), @@ -364,6 +404,41 @@ private void SubmitToAuditDb(Guid testGroup, int channelIndex, TestBase tb, Test AuditDb.SubmitAuditData(d); } + private string GetCsvHeader() + { + string s = "ProductId,SerialNumber,SessionName,Channel,Name,TestGroup,TestFile,TestFileMd5,Time,PassFail,ResultString,Result,TestLimits" + Environment.NewLine; + return s; + } + + private void SubmitToCsv(string fileName, Guid testGroup, int channelIndex, TestBase tb, TestResult tr) + { + string s = + Form1.AppSettings.ProductId.ToString() + "," + + (Tm.LocalStash.ContainsKey("SerialNumber") ? Tm.LocalStash["SerialNumber"] : "0") + "," + + Form1.AppSettings.SessionName + "," + + (channelIndex == 0 ? "Left" : "Right") + "," + + tb.Name + "," + + testGroup.ToString() + "," + + Form1.SettingsFile + "," + + ComputeMd5(Form1.AppSettings) + "," + + DateTime.Now + "," + + tr.Pass + "," + + tr.StringValue[channelIndex] + "," + + tr.Value[channelIndex].ToString("0.000", CultureInfo.InvariantCulture) + "," + + tb.GetTestLimits() + "," + + Environment.NewLine; + + try + { + File.AppendAllText(fileName, s); + } + catch (Exception ex) + { + Log.WriteLine(LogType.Error, $"Failed to write line to CSV file. CSV logging has been disabled. Filename: {fileName} Message: {ex.Message}"); + Form1.AppSettings.UseCsvLog = false; + } + } + private string ComputeMd5(AppSettings settings) { byte[] bytes = ASCIIEncoding.ASCII.GetBytes(settings.Serialize()); diff --git a/Tractor/Com.QuantAsylum.Tractor.Settings/AppSettings.cs b/Tractor/Com.QuantAsylum.Tractor.Settings/AppSettings.cs index d5329cf..d134b7e 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Settings/AppSettings.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Settings/AppSettings.cs @@ -17,17 +17,19 @@ public class AppSettings public bool AbortOnFailure = true; - public string DbConnectString = "Server=MyPc\\SQLEXPRESS;Integrated security = SSPI; Initial Catalog = QATestDB; User ID = sa; Password=password"; + public string SessionName = ""; + + public Guid ProductId = Guid.NewGuid(); public bool UseDb = false; - public string DbSessionName = ""; + public string DbConnectString = "Server=MyPc\\SQLEXPRESS;Integrated security = SSPI; Initial Catalog = QATestDB; User ID = sa; Password=password"; - public bool UseAuditDb = false; + public bool UseCsvLog = false; - public Guid ProductId = Guid.NewGuid(); + public string CsvFileName = ""; - public string AuditDbSessionName = ""; + public bool UseAuditDb = false; public string AuditDbEmail = "youremail@yourcompany.com"; diff --git a/Tractor/Com.QuantAsylum.Tractor.Tests/ObjectEditorUiBuilder.cs b/Tractor/Com.QuantAsylum.Tractor.Tests/ObjectEditorUiBuilder.cs index d4b8fe4..d953399 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Tests/ObjectEditorUiBuilder.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Tests/ObjectEditorUiBuilder.cs @@ -488,7 +488,9 @@ public bool VerifyChanges(bool commit = false) } catch (Exception ex) { - MessageBox.Show("Failed to parse attribute in AutobuilUi.cs: " + ex.Message); + string s = "Failed to parse attribute in AutobuilUi.cs: " + ex.Message; + Log.WriteLine(LogType.Error, s); + MessageBox.Show(s); return false; } diff --git a/Tractor/Com.QuantAsylum.Tractor.Tests/Operator/PromptA00.cs b/Tractor/Com.QuantAsylum.Tractor.Tests/Operator/PromptA00.cs index 94222c8..2aa8463 100644 --- a/Tractor/Com.QuantAsylum.Tractor.Tests/Operator/PromptA00.cs +++ b/Tractor/Com.QuantAsylum.Tractor.Tests/Operator/PromptA00.cs @@ -2,6 +2,7 @@ using System; using System.Drawing; using System.Windows.Forms; +using Tractor; using Tractor.Com.QuantAsylum.Tractor.Tests; namespace Com.QuantAsylum.Tractor.Tests @@ -42,7 +43,9 @@ public override void DoTest(string title, out TestResult tr) } catch (Exception ex) { - MessageBox.Show($"Failed to load specified bitmap file {BitmapFile}. Exception: " + ex.Message); + string s = $"Failed to load specified bitmap file {BitmapFile}. Exception: " + ex.Message; + Log.WriteLine(LogType.Error, s); + MessageBox.Show(s); } DlgPrompt dlg = new DlgPrompt(PromptMessage, ShowFailButton, bmp); diff --git a/Tractor/Constants.cs b/Tractor/Constants.cs index 72e2f53..4d3c53f 100644 --- a/Tractor/Constants.cs +++ b/Tractor/Constants.cs @@ -10,7 +10,7 @@ namespace Tractor static class Constants { public static string TitleBarText = "QuantAsylum TRACTOR"; - public static readonly double Version = 0.994; + public static readonly double Version = 0.997; public static string VersionSuffix = ""; public static double RequiredWebserviceVersion = 0.5; @@ -21,6 +21,7 @@ static class Constants public static string MaskFiles = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "QuantAsylum", "QA401", "UserMasks"); static public string DefaultSettingsFile = Path.Combine(DataFilePath, "Default.Settings"); public static string TestLogsPath = Path.Combine(DataFilePath, "TestLogs"); + public static string CsvLogsPath = Path.Combine(DataFilePath, "CsvLogs"); public static string LogFileName = "index.html"; public static string AuditPath = Path.Combine(DataFilePath, "AuditData"); public static string PidPath = Path.Combine(DataFilePath, "ProductIds"); diff --git a/Tractor/Form1.Designer.cs b/Tractor/Form1.Designer.cs index 032acbc..a326150 100644 --- a/Tractor/Form1.Designer.cs +++ b/Tractor/Form1.Designer.cs @@ -185,7 +185,7 @@ private void InitializeComponent() // this.openLogInBrowserToolStripMenuItem.Name = "openLogInBrowserToolStripMenuItem"; this.openLogInBrowserToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.openLogInBrowserToolStripMenuItem.Text = "Open Log in Browser"; + this.openLogInBrowserToolStripMenuItem.Text = "Open Product HTML Log in Browser"; // // queryCloudToolStripMenuItem // diff --git a/Tractor/Form1.cs b/Tractor/Form1.cs index 8c18fe6..44493b6 100644 --- a/Tractor/Form1.cs +++ b/Tractor/Form1.cs @@ -41,7 +41,7 @@ public partial class Form1 : Form public Form1() { - Log.WriteLine("Application started..."); + Log.WriteLine($"Version {Constants.Version:0.000}. Application started..."); This = this; InitializeComponent(); @@ -104,6 +104,7 @@ private void Form1_Load(object sender, EventArgs e) { Directory.CreateDirectory(Constants.DataFilePath); Directory.CreateDirectory(Constants.TestLogsPath); + Directory.CreateDirectory(Constants.CsvLogsPath); Directory.CreateDirectory(Constants.AuditPath); Directory.CreateDirectory(Constants.PidPath); @@ -440,11 +441,11 @@ private void RunTestBtn_Click(object sender, EventArgs e) } } - DlgTestRun dlg = new DlgTestRun(Tm, TestRunCallback, Constants.TestLogsPath); + DlgTestRun dlg = new DlgTestRun(Tm, TestRunCallback, Constants.TestLogsPath, Constants.CsvLogsPath); this.Visible = false; HasRun = true; - if (dlg.ShowDialog() == DialogResult.OK) + if (dlg.ShowDialog() == DialogResult.OK) { } @@ -536,6 +537,7 @@ private void LoadFromFile(string fileName) { try { + Log.WriteLine($"LoadFromFile: {fileName}"); SettingsFile = fileName; AppSettings = AppSettings.Deserialize(File.ReadAllText(fileName)); Type t = Type.GetType(AppSettings.TestClass); @@ -545,7 +547,9 @@ private void LoadFromFile(string fileName) } catch (Exception ex) { - MessageBox.Show("There was an error loading the file: " + ex.Message, "File Load Error"); + string s = $"There was an error loading the file: {ex.Message}"; + Log.WriteLine(s); + MessageBox.Show(s, "File Load Error"); } UpdateTitleBar(); @@ -610,7 +614,9 @@ private void saveTestPlanToolStripMenuItem_Click(object sender, EventArgs e) } catch (Exception ex) { - MessageBox.Show("There was an error saving the file: " + ex.Message, "File Save Error"); + string s = $"There was an error saving the file: {ex.Message}"; + Log.WriteLine(s); + MessageBox.Show(s, "File Save Error"); } UpdateTitleBar(); } @@ -632,7 +638,9 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) } catch (Exception ex) { - MessageBox.Show("There was an error saving the file: " + ex.Message, "File Save Error"); + string s = "There was an error saving the file: " + ex.Message; + Log.WriteLine(LogType.Error, s); + MessageBox.Show(s, "File Save Error"); } } UpdateTitleBar(); diff --git a/Tractor/Properties/AssemblyInfo.cs b/Tractor/Properties/AssemblyInfo.cs index 251f26e..c6b7c9c 100644 --- a/Tractor/Properties/AssemblyInfo.cs +++ b/Tractor/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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("0.9.9.5")] -[assembly: AssemblyFileVersion("0.9.9.5")] +[assembly: AssemblyVersion("0.9.9.7")] +[assembly: AssemblyFileVersion("0.9.9.7")] diff --git a/Tractor/Releases.txt b/Tractor/Releases.txt index 35de32b..833c47b 100644 --- a/Tractor/Releases.txt +++ b/Tractor/Releases.txt @@ -1,5 +1,11 @@ -0.995 +0.997 +- Added ability to log to CSV file. CSV files will be logged to a directory located at C:\Users\\Documents\QuantAsylum\Tractor\CsvLogs +- Consolidated UI on logging +- Verify all database logging options are correct when opening older test files with this version! + +0.995 - Removed old-style deprecated interfaces (old style = pass data back and forth via remoting. new style = don't pull data over, just ask for calc to be done on host) +- Fortified logging of exceptions with some more detail 0.994 - Fixed bug where older-style audit records could get stuck and never upload to server