V4.2 with stats and vaxtor settings changes. Fixed merge problems
This commit is contained in:
88
AiQ_GUI.cs
88
AiQ_GUI.cs
@@ -1,6 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.Data.OleDb;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -220,73 +219,10 @@ namespace AiQ_GUI
|
||||
// If there are any actions identified then fail the test.
|
||||
// If any labels are red then fail. Only labels in panel so can foreach on labels not controls
|
||||
if (RhTxBxActions.Text.Length > 2 || PnlLbls.Controls.OfType<Label>().Any(c => c.ForeColor == Color.Red) == true)
|
||||
await TestFailed(BtnStartTest, "Failed due to action box text and/or red label");// If approved then pass otherwise GUI would have restarted before getting to TestPassed.
|
||||
{
|
||||
await TestFailed(BtnStartTest, "Diagnostic Failure");// If approved then pass otherwise GUI would have restarted before getting to TestPassed.
|
||||
}
|
||||
|
||||
await TestPassed(PCTime);
|
||||
}
|
||||
public void Stats(string TypeOfTest)
|
||||
{
|
||||
Stats([TypeOfTest]);
|
||||
}
|
||||
|
||||
public void Stats(string[] TypeOfTest)
|
||||
{
|
||||
using OleDbConnection conn = new(Access.connString); // Opens connection to Access database
|
||||
try
|
||||
{
|
||||
conn.Open(); // Opens DB
|
||||
string modelNumber = CbBxCameraType.Text.Substring(0, 6); // Get model number from combobox and make sure it is only 6 characters.
|
||||
|
||||
foreach (string type in TypeOfTest)
|
||||
{
|
||||
string query = $"UPDATE AiQ SET [{type}] = [{type}] + 1 WHERE [ModelNumber] = ?"; // Add one for every test ran of this type for this model number
|
||||
using OleDbCommand cmd = new(query, conn); // Create command
|
||||
cmd.Parameters.AddWithValue("?", modelNumber); // Add model number to prevent injection
|
||||
|
||||
int rowsAffected = cmd.ExecuteNonQuery();
|
||||
// Execute the command and get the number of rows affected
|
||||
//if (rowsAffected > 0) // If one or more rows were updated
|
||||
// AddToActionsList($"Updated {TypeOfTest} for {modelNumber}");
|
||||
//else
|
||||
// AddToActionsList($"No rows found for {modelNumber}");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
AddToActionsList("Could not access Access in Google Drive. Is it running?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText, string IsRMA, int RMA)
|
||||
{
|
||||
using OleDbConnection conn = new(Access.connString);
|
||||
conn.Open();
|
||||
|
||||
// Null checks
|
||||
string redVal = string.IsNullOrWhiteSpace(redDiagLabels) ? "-" : redDiagLabels;
|
||||
string actVal = string.IsNullOrWhiteSpace(RhTxBxActionsText) ? "-" : RhTxBxActionsText;
|
||||
string model = string.IsNullOrWhiteSpace(CamOnTest?.Model) ? "-" : CamOnTest.Model;
|
||||
|
||||
string sql = @"
|
||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents],[IsRMA],[RMA])
|
||||
VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
using OleDbCommand cmd = new(sql, conn);
|
||||
|
||||
// OleDb uses positional parameters — order must match the VALUES list above
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = DateTime.Now });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = model });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = redVal });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = actVal });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Boolean, Value = IsRMA });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = RMA });
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private async void BtnPreTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -335,8 +271,8 @@ namespace AiQ_GUI
|
||||
await AllocateSerial();
|
||||
else if (GoogleAPI.UpdateSpreadSheetRePreTest(CameraAccessInfo.SpreadsheetID, Vers) != "OK") // If rerun might be different values so update SS
|
||||
AddToActionsList("Failed to write to spreadsheet, please check manually");
|
||||
// else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK")
|
||||
// AddToActionsList("Failed to write to spreadsheet, please check manually");
|
||||
// else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK")
|
||||
// AddToActionsList("Failed to write to spreadsheet, please check manually");
|
||||
}
|
||||
else // No serial or model so allocate one
|
||||
await AllocateSerial();
|
||||
@@ -501,14 +437,11 @@ namespace AiQ_GUI
|
||||
PnlQuestion.Visible = true;
|
||||
BtnNo.Visible = false;
|
||||
Logging.LogMessage("Pre Test Passed");
|
||||
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Access.Stats("Pre Tests Passed", CamOnTest.Model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Access.Stats("RMA Pre Tests Passed", CamOnTest.Model);
|
||||
}
|
||||
|
||||
if (await DisplayQuestion("Test passed, restart?"))
|
||||
Helper.RestartApp();
|
||||
@@ -523,13 +456,9 @@ namespace AiQ_GUI
|
||||
Logging.LogMessage("Pre Test Failed");
|
||||
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Access.Stats(["Pre Tests Failed", ErrMssg], CamOnTest.Model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Access.Stats("RMA Pre Tests Failed", CamOnTest.Model);
|
||||
}
|
||||
|
||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||
.OfType<Label>()
|
||||
@@ -539,17 +468,6 @@ namespace AiQ_GUI
|
||||
|
||||
Access.StatsDiags(RedLbls, RhTxBxActions.Text, CamOnTest.Model); // Log to Access database
|
||||
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Pre Tests Failed", ErrMssg]);
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "FALSE", CamOnTest.RMANum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Pre Tests Failed");
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "TRUE", CamOnTest.RMANum);
|
||||
}
|
||||
|
||||
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
Helper.RestartApp();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user