This Commit contains all the changes for the new feature for S.L in regards to ExcelStats of the GUI
This commit is contained in:
@@ -66,28 +66,22 @@ namespace AiQ_GUI
|
||||
return "Spreadsheet not found";
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(FilePath);
|
||||
using XLWorkbook workbook = new(FilePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
// Start from row 1 and check downwards to find next empty row in column B
|
||||
int row = 1;
|
||||
while (!worksheet.Cell(row, 2).IsEmpty()) // Column B = Serial numbers
|
||||
{
|
||||
row++;
|
||||
}
|
||||
|
||||
// Safety check to avoid invalid index
|
||||
if (row <= 1)
|
||||
{
|
||||
return "Last serial number not found";
|
||||
}
|
||||
|
||||
// Generate new serial number from previous
|
||||
string lastSerialNumber = worksheet.Cell(row - 1, 2).GetString(); // Column B
|
||||
if (string.IsNullOrWhiteSpace(lastSerialNumber) || !lastSerialNumber.StartsWith("K"))
|
||||
{
|
||||
return "Invalid last serial number format";
|
||||
}
|
||||
|
||||
int NewSerialNumberInt = Convert.ToInt32(lastSerialNumber.Substring(1)) + 1;
|
||||
string newSerialNumber = "K" + NewSerialNumberInt;
|
||||
@@ -124,7 +118,7 @@ namespace AiQ_GUI
|
||||
return "Spreadsheet not found";
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(filePath);
|
||||
using XLWorkbook workbook = new(filePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
// Find the row with the matching serial number in column B
|
||||
@@ -136,8 +130,7 @@ namespace AiQ_GUI
|
||||
{
|
||||
// Update columns D-E
|
||||
worksheet.Cell(row, 4).Value = "Pre Test: " + DateTime.Now.ToString("dd/MM/yyyy");
|
||||
worksheet.Cell(row, 5).Value = Vers.version + " - " + Vers.revision + Environment.NewLine +
|
||||
Vers.buildtime + Environment.NewLine + Vers.proquint;
|
||||
worksheet.Cell(row, 5).Value = $"{Vers.version} - {Vers.revision}" + Environment.NewLine + Vers.buildtime + Environment.NewLine + Vers.proquint;
|
||||
// Update MAC to column H
|
||||
worksheet.Cell(row, 8).Value = Vers.MAC;
|
||||
|
||||
@@ -172,7 +165,7 @@ namespace AiQ_GUI
|
||||
return "Spreadsheet not found";
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(FilePath);
|
||||
using XLWorkbook workbook = new(FilePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
// Find the row with the matching serial number in column B
|
||||
@@ -224,15 +217,13 @@ namespace AiQ_GUI
|
||||
return "Spreadsheet not found";
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(FilePath);
|
||||
using XLWorkbook workbook = new(FilePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
// Find next free row by checking column C
|
||||
int row = 2;
|
||||
while (!worksheet.Cell(row, 3).IsEmpty()) // Column C
|
||||
{
|
||||
row++;
|
||||
}
|
||||
|
||||
// Write model, serial, date, and protectionKeyId to columns C–F
|
||||
worksheet.Cell(row, 3).Value = model; // Column C
|
||||
@@ -263,7 +254,7 @@ namespace AiQ_GUI
|
||||
return 0;
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(filePath);
|
||||
using XLWorkbook workbook = new(filePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
int row = 2; // Start from row 2
|
||||
@@ -277,10 +268,9 @@ namespace AiQ_GUI
|
||||
if (sheetSerial.Contains(serial) && sheetModel.Contains(model))
|
||||
{
|
||||
string rmaStr = worksheet.Cell(row, 1).GetString(); // Column A
|
||||
|
||||
if (int.TryParse(rmaStr, out int rmaNumber))
|
||||
{
|
||||
return rmaNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* Safe to ignore bad row */ }
|
||||
@@ -306,7 +296,7 @@ namespace AiQ_GUI
|
||||
return 0;
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(filePath);
|
||||
using XLWorkbook workbook = new(filePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
int row = 1;
|
||||
@@ -315,10 +305,9 @@ namespace AiQ_GUI
|
||||
try
|
||||
{
|
||||
string cellSerial = worksheet.Cell(row, 2).GetString();
|
||||
|
||||
if (cellSerial.Contains(serial))
|
||||
{
|
||||
return row;
|
||||
}
|
||||
}
|
||||
catch { /* Ignore malformed rows */ }
|
||||
|
||||
@@ -343,14 +332,12 @@ namespace AiQ_GUI
|
||||
return -1;
|
||||
}
|
||||
|
||||
using XLWorkbook workbook = new XLWorkbook(filePath);
|
||||
using XLWorkbook workbook = new(filePath);
|
||||
IXLWorksheet worksheet = workbook.Worksheets.First();
|
||||
|
||||
int row = 2; // Start from C2
|
||||
while (!worksheet.Cell(row, 3).IsEmpty()) // Column C = 3
|
||||
{
|
||||
row++;
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
@@ -368,7 +355,7 @@ namespace AiQ_GUI
|
||||
// 1. Ensure spreadsheet exists and has valid starting data
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
XLWorkbook workbook = new XLWorkbook();
|
||||
XLWorkbook workbook = new();
|
||||
IXLWorksheet ws = workbook.Worksheets.Add("Sheet1");
|
||||
|
||||
// Pre-fill first row with dummy data for serial
|
||||
@@ -379,7 +366,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
|
||||
// 2. Run Pre-Test update
|
||||
Versions fakeVersion = new Versions
|
||||
Versions fakeVersion = new()
|
||||
{
|
||||
version = "1.6.4",
|
||||
revision = "bf16134",
|
||||
@@ -388,11 +375,11 @@ namespace AiQ_GUI
|
||||
MAC = "00:1A:2B:3C:4D:5E"
|
||||
};
|
||||
|
||||
string preTestResult = Excel.UpdateSpreadSheetPreTest(filePath, fakeVersion, "Fake Cam", "TestModel");
|
||||
string preTestResult = UpdateSpreadSheetPreTest(filePath, fakeVersion, "Fake Cam", "TestModel");
|
||||
Debug.WriteLine("Pre-Test Result: " + preTestResult);
|
||||
|
||||
// 3. Run Final Test update
|
||||
Diags fakeDiags = new Diags
|
||||
Diags fakeDiags = new()
|
||||
{
|
||||
serialNumber = preTestResult, // Newly generated serial
|
||||
licenses = new Licenses
|
||||
@@ -404,13 +391,13 @@ namespace AiQ_GUI
|
||||
}
|
||||
};
|
||||
|
||||
SSHData fakeSSH = new SSHData
|
||||
SSHData fakeSSH = new()
|
||||
{
|
||||
packages = "\r\nlibvaxtorocr10 - 8.4.20-1\r\nvaxtorocrdatacpu3 - 8.4.20-1",
|
||||
tailscale = true
|
||||
};
|
||||
|
||||
string finalTestResult = Excel.UpdateSpreadSheetFinalTest(filePath, fakeDiags, fakeSSH, 0);
|
||||
string finalTestResult = UpdateSpreadSheetFinalTest(filePath, fakeDiags, fakeSSH, 0);
|
||||
Debug.WriteLine("Final-Test Result: " + finalTestResult);
|
||||
|
||||
// // 4. Run Vaxtor update
|
||||
|
||||
Reference in New Issue
Block a user