Final Changes to Stats Excel - This has been tested via Fake Cam Test all scenearios and published and tested
This commit is contained in:
132
AiQ_GUI.cs
132
AiQ_GUI.cs
@@ -42,7 +42,7 @@ namespace AiQ_GUI
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
|
||||
Task? closeProcessesTask = Windows.CloseProcesses(); // Fire and forget closing other apps
|
||||
//Windows.UpdateFirewall();
|
||||
Windows.UpdateFirewall();
|
||||
Task UniDataTask = Task.Run(() => Access.ReadUniData()); // Get universal data
|
||||
Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json
|
||||
Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version
|
||||
@@ -108,7 +108,7 @@ namespace AiQ_GUI
|
||||
CbBxIris.SelectedIndex = lds.Iris;
|
||||
CbBxGain.SelectedIndex = lds.Gain;
|
||||
|
||||
if (lds.User == "Bradley")
|
||||
if (lds.User == "Bradley" || lds.User == "Sophie")
|
||||
BtnTest.Visible = true;
|
||||
|
||||
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
|
||||
@@ -151,7 +151,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (!await FlexiAPI.ZoomModules("1F40", CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time.
|
||||
await TestFailed(BtnStartTest, "Could not zoom modules to 8000");
|
||||
|
||||
|
||||
|
||||
if (!await FlexiAPI.SetZoomLockOn(CamOnTest.IP))
|
||||
Helper.RestartApp();
|
||||
@@ -194,7 +194,7 @@ namespace AiQ_GUI
|
||||
await FlexiAPI.SetTrim(CamOnTest.IP, LblTestTubePing.Text); // Auto trims the cameras, some plates should have been captured in the meantime
|
||||
|
||||
if (!await FlexiAPI.ZoomModules("0000", CamOnTest.IP)) // Zoom to full wide
|
||||
{
|
||||
{
|
||||
await TestFailed(BtnStartTest, "Could not zoom modules to full wide");
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace AiQ_GUI
|
||||
LED.CheckLEDs(DiagsAPI.LedCurrent, LblLEDI, "mA", CameraAccessInfo.LED_I); // Current
|
||||
|
||||
this.Refresh(); // Make sure all labels are updated before checking them
|
||||
|
||||
|
||||
// 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)
|
||||
@@ -269,7 +269,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
}
|
||||
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText)
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText, string IsRMA, int RMA)
|
||||
{
|
||||
using OleDbConnection conn = new(connString);
|
||||
conn.Open();
|
||||
@@ -280,26 +280,20 @@ namespace AiQ_GUI
|
||||
string model = string.IsNullOrWhiteSpace(CamOnTest?.Model) ? "-" : CamOnTest.Model;
|
||||
|
||||
string sql = @"
|
||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents])
|
||||
VALUES (?, ?, ?, ?)";
|
||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents],[IsRMA],[RMA])
|
||||
VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
using OleDbCommand cmd = new(sql, conn);
|
||||
|
||||
cmd.Parameters.Add(new OleDbParameter
|
||||
{
|
||||
OleDbType = OleDbType.Date,
|
||||
Value = DateTime.Now
|
||||
});
|
||||
cmd.Parameters.AddWithValue("?", model);
|
||||
cmd.Parameters.AddWithValue("?", redVal);
|
||||
cmd.Parameters.AddWithValue("?", actVal);
|
||||
// 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 });
|
||||
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
|
||||
//if (rows > 0)
|
||||
// AddToActionsList($"DiagsStats inserted ({rows} row) for model '{model}' on {DateTime.Now:yyyy-MM-dd}");
|
||||
//else
|
||||
// AddToActionsList("No rows inserted into DiagsStats (unexpected).");
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -362,8 +356,8 @@ namespace AiQ_GUI
|
||||
{
|
||||
await PreTestFailed("Diagnostic Failure");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ***** Pass/Fails *****
|
||||
@@ -428,15 +422,6 @@ namespace AiQ_GUI
|
||||
// Indicators to the user the test has failed
|
||||
Btn.BackColor = Color.Maroon;
|
||||
Btn.Text = "Test Failed";
|
||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats( ["Final Tests Failed", ErrMssg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Final Tests Failed");
|
||||
}
|
||||
AddToActionsList(ErrMssg);
|
||||
|
||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||
.OfType<Label>()
|
||||
@@ -444,7 +429,18 @@ namespace AiQ_GUI
|
||||
.Select(lbl => lbl.Text)); // Extract text
|
||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text); // Log to Access database
|
||||
|
||||
// Database logging \\
|
||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Final Tests Failed", ErrMssg]);
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "FALSE", CamOnTest.RMANum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Final Tests Failed");
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "TRUE", CamOnTest.RMANum);
|
||||
}
|
||||
|
||||
|
||||
if (await DisplayQuestion("Test failed, appeal?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
@@ -538,22 +534,24 @@ namespace AiQ_GUI
|
||||
BtnNo.Visible = false;
|
||||
Logging.LogMessage("Pre Test Failed");
|
||||
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Pre Tests Failed", ErrMssg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Pre Tests Failed");
|
||||
}
|
||||
|
||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||
.OfType<Label>()
|
||||
.Where(lbl => lbl.ForeColor == Color.Red) // Only include red labels
|
||||
.Select(lbl => lbl.Text)); // Extract text
|
||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text); // 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);
|
||||
}
|
||||
|
||||
// Log to Access database
|
||||
|
||||
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
Helper.RestartApp();
|
||||
@@ -685,7 +683,7 @@ namespace AiQ_GUI
|
||||
CamOnTest.RMANum = Convert.ToInt32(await DisplayInput("What is the RMA number?"));
|
||||
|
||||
if (CamOnTest.RMANum == -1) // Means they chose the 'I don't know' option
|
||||
{
|
||||
{
|
||||
await TestFailed(BtnStartTest, "Please get RMA number from operations team before continuing");
|
||||
}
|
||||
}
|
||||
@@ -752,11 +750,11 @@ namespace AiQ_GUI
|
||||
string ProdcutKeyID = await DisplayInput("What is the Key ID?", false);
|
||||
|
||||
if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose the 'I don't know' option or isn't valid Key ID
|
||||
{
|
||||
{
|
||||
Stats("Please Get A Valid Vaxtor Product Key Before Continuing");
|
||||
await TestFailed(BtnStartTest, "Please get a valid Vaxtor Product Key before continuing");
|
||||
}
|
||||
|
||||
|
||||
|
||||
DiagsAPI.licenses.raptorKeyID = TxBxProductKey.Text;
|
||||
lblVaxtor.Text += DiagsAPI.licenses.raptorKeyID;
|
||||
@@ -1860,31 +1858,31 @@ namespace AiQ_GUI
|
||||
StatsExcel excelExporter = new();
|
||||
excelExporter.ExportDatabaseToExcel();
|
||||
|
||||
// FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
||||
//FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
||||
|
||||
// //CamOnTest.IP = CbBxFoundCams.Text;
|
||||
// _ = fakeCamera.StartAsync(CAMTYPE.BAD).ContinueWith(task =>
|
||||
// {
|
||||
// //Network.Initialize("developer", "Pass123");
|
||||
////CamOnTest.IP = CbBxFoundCams.Text;
|
||||
//_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
|
||||
//{
|
||||
// //Network.Initialize("developer", "Pass123");
|
||||
|
||||
// if (task.IsFaulted)
|
||||
// {
|
||||
// AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}", false);
|
||||
// }
|
||||
// });
|
||||
// if (task.IsFaulted)
|
||||
// {
|
||||
// AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}", false);
|
||||
// }
|
||||
//});
|
||||
|
||||
// await Task.Delay(3000); // Wait for server to start
|
||||
// CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit
|
||||
// CmBoFoundCams_TextChanged(sender, e);
|
||||
// CbBxCameraType.SelectedIndex = CbBxCameraType.Items.Count - 1; // Selects AB12CD as model number
|
||||
//await Task.Delay(3000); // Wait for server to start
|
||||
//CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit
|
||||
//CmBoFoundCams_TextChanged(sender, e);
|
||||
//CbBxCameraType.SelectedIndex = CbBxCameraType.Items.Count - 1; // Selects AB12CD as model number
|
||||
|
||||
// await Task.Delay(3000); // Wait for server to start
|
||||
//await Task.Delay(3000); // Wait for server to start
|
||||
|
||||
//BtnPreTest_Click(sender, e);
|
||||
//BtnStartTest_Click(sender, e);
|
||||
|
||||
|
||||
stopWatchTest.Stop();
|
||||
|
||||
Reference in New Issue
Block a user