V4.1 with excel stats changes
This commit is contained in:
84
AiQ_GUI.cs
84
AiQ_GUI.cs
@@ -1,5 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.Data.OleDb;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -226,7 +227,6 @@ namespace AiQ_GUI
|
||||
|
||||
await TestPassed(PCTime);
|
||||
}
|
||||
|
||||
public void Stats(string TypeOfTest)
|
||||
{
|
||||
Stats([TypeOfTest]);
|
||||
@@ -234,7 +234,7 @@ namespace AiQ_GUI
|
||||
|
||||
public void Stats(string[] TypeOfTest)
|
||||
{
|
||||
using OleDbConnection conn = new(connString); // Opens connection to Access database
|
||||
using OleDbConnection conn = new(Access.connString); // Opens connection to Access database
|
||||
try
|
||||
{
|
||||
conn.Open(); // Opens DB
|
||||
@@ -263,7 +263,7 @@ namespace AiQ_GUI
|
||||
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText, string IsRMA, int RMA)
|
||||
{
|
||||
using OleDbConnection conn = new(connString);
|
||||
using OleDbConnection conn = new(Access.connString);
|
||||
conn.Open();
|
||||
|
||||
// Null checks
|
||||
@@ -288,8 +288,6 @@ namespace AiQ_GUI
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async void BtnPreTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Show user test has started
|
||||
@@ -337,6 +335,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 // No serial or model so allocate one
|
||||
await AllocateSerial();
|
||||
@@ -415,25 +415,23 @@ namespace AiQ_GUI
|
||||
Btn.BackColor = Color.Maroon;
|
||||
Btn.Text = "Test Failed";
|
||||
|
||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||
{
|
||||
Access.Stats(["Final Tests Failed", ErrMssg], CamOnTest.Model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Access.Stats("RMA Final Tests Failed", CamOnTest.Model);
|
||||
}
|
||||
AddToActionsList(ErrMssg);
|
||||
|
||||
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;
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
Access.StatsDiags(RedLbls, RhTxBxActions.Text, CamOnTest.Model); // Log to Access database
|
||||
|
||||
if (await DisplayQuestion("Test failed, appeal?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
{
|
||||
@@ -451,8 +449,6 @@ namespace AiQ_GUI
|
||||
// Joins the actions box to any red labels to use as a full failed text
|
||||
Logging.LogErrorMessage(FullFailureValues);
|
||||
|
||||
|
||||
|
||||
IList<IList<object>> values = GoogleAPI.service.Spreadsheets.Values.Get(GoogleAPI.spreadsheetId_ModelInfo, "'Approval'!A1:A").Execute().Values;
|
||||
|
||||
if (values?.Count > 0)
|
||||
@@ -526,12 +522,23 @@ namespace AiQ_GUI
|
||||
BtnNo.Visible = false;
|
||||
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>()
|
||||
.Where(lbl => lbl.ForeColor == Color.Red) // Only include red labels
|
||||
.Select(lbl => lbl.Text)); // Extract text
|
||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||
|
||||
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]);
|
||||
@@ -543,10 +550,6 @@ namespace AiQ_GUI
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "TRUE", CamOnTest.RMANum);
|
||||
}
|
||||
|
||||
// Log to Access database
|
||||
|
||||
Access.StatsDiags(RedLbls, RhTxBxActions.Text, CamOnTest.Model); // Log to Access database
|
||||
|
||||
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
Helper.RestartApp();
|
||||
}
|
||||
@@ -1127,7 +1130,6 @@ namespace AiQ_GUI
|
||||
PnlInputValue.Visible = true;
|
||||
|
||||
while (Flags.Done == false) // Waiting for user input in RMA Num panel
|
||||
{
|
||||
await Task.Delay(100); // Check every 100ms
|
||||
|
||||
Flags.Done = false; // Reset flag
|
||||
@@ -1786,41 +1788,9 @@ namespace AiQ_GUI
|
||||
{
|
||||
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
||||
|
||||
//StatsExcel excelExporter = new();
|
||||
//excelExporter.ExportDatabaseToExcel();
|
||||
|
||||
|
||||
|
||||
StatsExcel excelExporter = new();
|
||||
excelExporter.ExportDatabaseToExcel();
|
||||
|
||||
// FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
||||
|
||||
// //CamOnTest.IP = CbBxFoundCams.Text;
|
||||
// _ = fakeCamera.StartAsync(CAMTYPE.BAD).ContinueWith(task =>
|
||||
// {
|
||||
// //Network.Initialize("developer", "Pass123");
|
||||
|
||||
// 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
|
||||
|
||||
//BtnPreTest_Click(sender, e);
|
||||
|
||||
|
||||
stopWatchTest.Stop();
|
||||
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"));
|
||||
}
|
||||
|
||||
@@ -8,17 +8,13 @@ namespace AiQ_GUI
|
||||
{
|
||||
private const string exportPath = @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\AiQ_Test_Stats.xlsx";
|
||||
|
||||
private readonly string exportPath =
|
||||
@"C:\Users\BradleyBorn\OneDrive - MAV Systems Ltd\Desktop\AiQ_Test_Stats.xlsx";
|
||||
|
||||
public void ExportDatabaseToExcel()
|
||||
{
|
||||
try
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("=== ExportDatabaseToExcel START ===");
|
||||
|
||||
using (OleDbConnection conn = new(Access.connString))
|
||||
{
|
||||
using OleDbConnection conn = new(Access.connString);
|
||||
conn.Open();
|
||||
MainForm.Instance.AddToActionsList("Connected to Access database.");
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
Reference in New Issue
Block a user