C2026-058 Check all Tables for if Acc Page Id Prefix is Used More than Once

This commit is contained in:
mschill committed 2026-10-15 11:27:45 -04:00
1 parent ae9fb0eb67
commit 82f11fa696
10 files changed
+717 -133

No files matched your search

+227 -56
View File
@@ -441,69 +441,240 @@ namespace VEPROMS
txtResults.Clear();
txtResults.AppendText("Generating User Access Control Report");
using (DataTable dt = UserReports.GetUserAccessControlData())
{
// Start Excel and get Application object.
xls.Application excel = new xls.Application
{
// Make Excel invisible and disable alerts.
Visible = false,
DisplayAlerts = false
};
//Get data and Create excel file from it
Create_ExcelFile(UserReports.GetUserAccessControlData(), "UAC Report", filename);
// Create a new Workbook.
xls.Workbook excelworkBook = excel.Workbooks.Add();
// Create a Worksheet.
var workSheet = (xls.Worksheet)excelworkBook.ActiveSheet;
workSheet.Name = "UAC Report";
// column headings
for (var i = 0; i < dt.Columns.Count; i++)
{
workSheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
}
// rows
for (var i = 0; i < dt.Rows.Count; i++)
{
for (var j = 0; j < dt.Columns.Count; j++)
{
workSheet.Cells[i + 2, j + 1] = dt.Rows[i][j];
}
}
//resize the columns to match the data
workSheet.Columns.AutoFit();
//freeze the top row, and highlight those cells
workSheet.Application.ActiveWindow.SplitRow = 1;
workSheet.Application.ActiveWindow.FreezePanes = true;
workSheet.Cells.Range[workSheet.Cells[1, 1], workSheet.Cells[1, dt.Columns.Count]].Interior.Color = xls.XlRgbColor.rgbLightBlue;
//save the excel file
excelworkBook.SaveAs(filename);
excelworkBook.Close();
excel.Quit();
//release any in use com objects
releaseObject(workSheet);
releaseObject(excelworkBook);
releaseObject(excel);
}
DateTime pEnd = DateTime.Now;
DateTime pEnd = DateTime.Now;
txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}");
Application.DoEvents();
Cursor = Cursors.Default;
MessageBox.Show("Generate User Access Control Report Completed", "User Access Control Report");
}
//C2025-009 Report for tracking PROMS Users / security
//for releasing any Excel com objects still in memory
private void releaseObject(object obj)
#region Duplicate Accessory Page IDs
//C2026-058 Report for tracking Duplicate Accessory Page IDs in ROs in PROMS
//hold the filename for cases when scheduled for later
private string DupAccIDsfilename;
private void btnDupAccIDs_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(DupAccIDsfilename))
{
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Excel XLS (*.xlsx)|*.xlsx",
FileName = "DupAccIDsReport.xlsx"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
DupAccIDsfilename = sfd.FileName;
}
}
if (!CheckProcessLater()) return; // delay processing if set//B2017-221 Allow the batch dialog to close when waiting to process.
txtProcess.Clear();
txtResults.Clear();
if (!string.IsNullOrEmpty(DupAccIDsfilename))
{
Generate_DupAccIDs_Report(DupAccIDsfilename);
}
DupAccIDsfilename = null;
}
private void Generate_DupAccIDs_Report(string filename)
{
Cursor = Cursors.WaitCursor;
DateTime pStart = DateTime.Now;
txtProcess.AppendText("Generate Duplicate Accessory Page IDs Report in PROMS");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText($"Started: {pStart:MM/dd/yyyy @ HH:mm}");
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
txtResults.Clear();
txtResults.AppendText("Generating Duplicate Accessory Page IDs Report");
//Get data and Create excel file from it
Create_ExcelFile(UserReports.GetDupAccIDsData(), "Dup Acc IDs", filename);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}");
Application.DoEvents();
Cursor = Cursors.Default;
MessageBox.Show("Generate Duplicate Accessory Page IDs Report Completed", "Duplicate Accessory Page IDs Report");
}
//C2026-058 Report for tracking Duplicate Accessory Page Prefixes in ROs in PROMS
//hold the filename for cases when scheduled for later
private string DupAccPrefixesfilename;
private void btnDupAccPrefixes_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(DupAccPrefixesfilename))
{
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Excel XLS (*.xlsx)|*.xlsx",
FileName = "DupAccPrefixesReport.xlsx"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
DupAccPrefixesfilename = sfd.FileName;
}
}
if (!CheckProcessLater()) return; // delay processing if set//B2017-221 Allow the batch dialog to close when waiting to process.
txtProcess.Clear();
txtResults.Clear();
if (!string.IsNullOrEmpty(DupAccPrefixesfilename))
{
Generate_DupAccPrefixes_Report(DupAccPrefixesfilename);
}
DupAccPrefixesfilename = null;
}
private void Generate_DupAccPrefixes_Report(string filename)
{
Cursor = Cursors.WaitCursor;
DateTime pStart = DateTime.Now;
txtProcess.AppendText("Generate Duplicate Accessory Page Prefixes Report in PROMS");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText($"Started: {pStart:MM/dd/yyyy @ HH:mm}");
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
txtResults.Clear();
txtResults.AppendText("Generating Duplicate Accessory Page Prefixes Report");
//Get data and Create excel file from it
Create_ExcelFile(UserReports.GetDupAccPrefixesData(), "Dup Acc Prefixes", filename);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}");
Application.DoEvents();
Cursor = Cursors.Default;
MessageBox.Show("Generate Duplicate Accessory Page Prefixes Report Completed", "Duplicate Accessory Page Prefixes Report");
}
//C2026-058 Report for tracking Word Sections/Documents containing Duplicate Accessory Page IDs
//hold the filename for cases when scheduled for later
private string WordDocsDupAccIDsfilename;
private void btnWordDocsDupAccIDs_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(WordDocsDupAccIDsfilename))
{
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Excel XLS (*.xlsx)|*.xlsx",
FileName = "WordDocsDupAccIDsReport.xlsx"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
WordDocsDupAccIDsfilename = sfd.FileName;
}
}
if (!CheckProcessLater()) return; // delay processing if set//B2017-221 Allow the batch dialog to close when waiting to process.
txtProcess.Clear();
txtResults.Clear();
if (!string.IsNullOrEmpty(WordDocsDupAccIDsfilename))
{
Generate_WordDocsDupAccIDs_Report(WordDocsDupAccIDsfilename);
}
WordDocsDupAccIDsfilename = null;
}
private void Generate_WordDocsDupAccIDs_Report(string filename)
{
Cursor = Cursors.WaitCursor;
DateTime pStart = DateTime.Now;
txtProcess.AppendText("Generate Word Sections Containing Duplicate Accessory Page IDs Report in PROMS");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText($"Started: {pStart:MM/dd/yyyy @ HH:mm}");
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
txtResults.Clear();
txtResults.AppendText("Generating Word Sections Containing Duplicate Accessory Page IDs Report");
//Get data and Create excel file from it
Create_ExcelFile(UserReports.GetDocsDupAccIDsData(), "Word Dup AccIDs", filename);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}");
Application.DoEvents();
Cursor = Cursors.Default;
MessageBox.Show("Generate Word Sections Containing Duplicate Accessory Page IDs Report Completed", "Word Sections Containing Duplicate Accessory Page IDs Report");
}
#endregion
//C2026-058 Check all Tables for if Acc Page Id Prefix is Used More than Once
//Create an excel file made up of data table dt,
//with worksheet named (name) and file name (filename)
private void Create_ExcelFile(DataTable dt, string name, string filename)
{
// Start Excel and get Application object.
xls.Application excel = new xls.Application
{
// Make Excel invisible and disable alerts.
Visible = false,
DisplayAlerts = false
};
// Create a new Workbook.
xls.Workbook excelworkBook = excel.Workbooks.Add();
// Create a Worksheet.
var workSheet = (xls.Worksheet)excelworkBook.ActiveSheet;
workSheet.Name = name;
// column headings
for (var i = 0; i < dt.Columns.Count; i++)
{
workSheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
}
// rows
for (var i = 0; i < dt.Rows.Count; i++)
{
for (var j = 0; j < dt.Columns.Count; j++)
{
workSheet.Cells[i + 2, j + 1] = dt.Rows[i][j];
}
}
//resize the columns to match the data
workSheet.Columns.AutoFit();
//freeze the top row, and highlight those cells
workSheet.Application.ActiveWindow.SplitRow = 1;
workSheet.Application.ActiveWindow.FreezePanes = true;
workSheet.Cells.Range[workSheet.Cells[1, 1], workSheet.Cells[1, dt.Columns.Count]].Interior.Color = xls.XlRgbColor.rgbLightBlue;
//save the excel file
excelworkBook.SaveAs(filename);
excelworkBook.Close();
excel.Quit();
//release any in use com objects
releaseObject(workSheet);
releaseObject(excelworkBook);
releaseObject(excel);
}
//C2025-009 Report for tracking PROMS Users / security
//for releasing any Excel com objects still in memory
private void releaseObject(object obj)
{
try
{