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

Merged
jjenko merged 1 commits from C2026-058 into Development 2026-10-15 13:08:25 -04:00
10 changed files with 717 additions and 133 deletions

No files matched your search

@@ -659,7 +659,16 @@ namespace ROEditor
{ {
elem.SetAttribute("AccPageIDPrefix",this.tbPrefix.Text); elem.SetAttribute("AccPageIDPrefix",this.tbPrefix.Text);
modified=true; modified=true;
}
if (myrodb.IsDuplicateAccPagePrefix(elem, tbPrefix.Text))
{
tbPrefix.Text = origPrefix;
elem.SetAttribute("AccPageIDPrefix", origPrefix);
modified = false;
MessageBox.Show($"The Prefix field used for the \"Accessory Pages Access\" values should be unique. The fields used in these values can be found under \"Properties\" of an RO Group. If these are not unique, you may have trouble utilizing these ROs within Word Sections in PROMS. Cannot save.", "Problem saving data");
return;
}
}
bool success=true; bool success=true;
if (modified==true) success = myrodb.RODB_WriteRO(elem); if (modified==true) success = myrodb.RODB_WriteRO(elem);
if (modified == true && success == true && modaccpageid==true) if (modified == true && success == true && modaccpageid==true)
@@ -336,7 +336,8 @@ namespace RODBInterface
public abstract bool RODB_GetGroupAndSubgroups(VlnXmlElement node, StringBuilder sb); public abstract bool RODB_GetGroupAndSubgroups(VlnXmlElement node, StringBuilder sb);
public abstract bool RODB_GetChildData(VlnXmlElement node, bool CheckChildCount); public abstract bool RODB_GetChildData(VlnXmlElement node, bool CheckChildCount);
public abstract bool IsDuplicateAccPageID(VlnXmlElement ro, string newacc); public abstract bool IsDuplicateAccPageID(VlnXmlElement ro, string newacc);
public abstract VlnXmlElement RODB_ReadRO(string tbl, string recid); public abstract bool IsDuplicateAccPagePrefix(VlnXmlElement ro, string pfix);
public abstract VlnXmlElement RODB_ReadRO(string tbl, string recid);
public abstract bool RODB_WriteRO(VlnXmlElement ro, bool movedRO = false); public abstract bool RODB_WriteRO(VlnXmlElement ro, bool movedRO = false);
public abstract bool RODB_InsertRO(VlnXmlElement ro); public abstract bool RODB_InsertRO(VlnXmlElement ro);
public abstract ushort RODB_GetFieldType(VlnXmlElement elem, string TableName, string Fld); public abstract ushort RODB_GetFieldType(VlnXmlElement elem, string TableName, string Fld);
@@ -2026,23 +2027,23 @@ namespace RODBInterface
return true; return true;
} }
public override bool IsDuplicateAccPageID(VlnXmlElement ro, string newacc) public override bool IsDuplicateAccPageID(VlnXmlElement ro, string newacc)
{ {
string strcheck, inacc = null; string strcheck, inacc = null;
bool isdup = false; bool isdup = false;
int indx = newacc.IndexOf("'"); int indx = newacc.IndexOf("'");
if (indx >= 0) if (indx >= 0)
inacc = newacc.Insert(indx, "'"); inacc = newacc.Insert(indx, "'");
else else
inacc = newacc; inacc = newacc;
strcheck = "SELECT Count(RecID) AS CNT FROM " + ro.GetAttribute("Table") + " WHERE AccPageID = '" + inacc + "'"; strcheck = "SELECT Count(RecID) AS CNT FROM " + ro.GetAttribute("Table") + " WHERE AccPageID = '" + inacc + "'";
if (ro.HasAttribute("RecID")) // new ro's don't have recid defined yet before this test. if (ro.HasAttribute("RecID")) // new ro's don't have recid defined yet before this test.
strcheck = strcheck + " AND (NOT RecID = '" + ro.GetAttribute("RecID") + "')"; strcheck = strcheck + " AND (NOT RecID = '" + ro.GetAttribute("RecID") + "')";
try try
{ {
DBE.Command(strcheck); DBE.Command(strcheck);
DBE.Reader(); DBE.Reader();
} }
catch (Exception e) catch (Exception e)
{ {
@@ -2062,7 +2063,69 @@ namespace RODBInterface
return isdup; return isdup;
} }
public override VlnXmlElement RODB_ReadRO(string tbl, string recid) //C2026-058 Check all Tables for if Acc Page Id Prefix is Used More than Once
public override bool IsDuplicateAccPagePrefix(VlnXmlElement ro, string pfix)
{
// Loop through and build sql
StringBuilder strGetData = new StringBuilder();
List<string> all_tables = RODB_GetAllTables();
if (all_tables.Count == 0) return false;
foreach (string table in all_tables)
{
//if not the first item, add a union all
if (strGetData.Length > 0)
{ strGetData.Append(" UNION ALL "); }
//All info's containing AccPageIDPrefix should be RecType 3 (Group)
//Note if you use LIKE or ALIKE
// WHERE Info ALIKE '%AccPageIDPrefix%'"
// WHERE Info LIKE '*AccPageIDPrefix*'
//Then it truncates Info only pulling back the 1st 255 characters
strGetData.Append($"SELECT Info, '{table}' AS TBL FROM {table} WHERE RecType = 3");
}
try
{
DBE.Command(strGetData.ToString());
DBE.Reader();
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error getting Acc Page ID Prefix Data");
return true;
}
while (DBE.Read())
{
string Info = DBE.GetString(0);
string tbl = DBE.GetString(1);
using (XmlTextReader rdr = new XmlTextReader(Info, XmlNodeType.Element, null))
{
VlnXmlElement retele = null;
try
{
XmlNode nd = ROXml.ReadNode(rdr);
retele = (VlnXmlElement)nd;
}
catch
{
//do nothing not a valid item to check
}
if (retele != null && tbl != ro.GetAttribute("Table") && retele.GetAttribute("AccPageIDPrefix").ToLower() == pfix.ToLower())
{
return true; //another table contains the prefix - return true
}
}
}
DBE.CommandDispose();
DBE.ReaderClose();
return false;
}
public override VlnXmlElement RODB_ReadRO(string tbl, string recid)
{ {
ShowCount.ReadRo++; ShowCount.ReadRo++;
VlnXmlElement retele = null; VlnXmlElement retele = null;
@@ -3104,6 +3167,33 @@ namespace RODBInterface
} }
} }
} }
//C2026-058 Check all Tables for if Acc Page Id Prefix is Used More than Once
//Get all Tables in the MS Access DB
public List<string> RODB_GetAllTables()
{
List<string> tables = new List<string>();
using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(strDatabaseConnectionCommand))
{
connection.Open();
using (System.Data.OleDb.OleDbCommand command = connection.CreateCommand())
{
using (DataTable schema = connection.GetSchema("Tables"))
{
foreach (DataRow row in schema.Rows)
{
if (row["TABLE_TYPE"].ToString() == "TABLE")
{
tables.Add(row["TABLE_NAME"].ToString());
}
}
}
}
}
return tables;
}
} }
} }
@@ -1357,13 +1357,13 @@ namespace RODBInterface
{ {
command.CommandText = "getCountRecidByAccidNotRecid"; command.CommandText = "getCountRecidByAccidNotRecid";
command.Parameters.AddWithValue("RecID", ro.GetAttribute("RecID")); command.Parameters.AddWithValue("RecID", ro.GetAttribute("RecID"));
} }
else else
command.CommandText = "getCountRecidByAccid"; command.CommandText = "getCountRecidByAccid";
command.Parameters.AddWithValue("@AccPageID", inacc); command.Parameters.AddWithValue("@AccPageID", inacc);
command.Parameters.AddWithValue("@ROTable", ro.GetAttribute("Table")); command.Parameters.AddWithValue("@ROTable", ro.GetAttribute("Table"));
using (SqlDataReader reader = command.ExecuteReader()) using (SqlDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
{ {
@@ -1383,7 +1383,38 @@ namespace RODBInterface
} }
return isdup; return isdup;
} }
public override VlnXmlElement RODB_ReadRO(string tbl, string recid) public override bool IsDuplicateAccPagePrefix(VlnXmlElement ro, string pfix)
{
try
{
using (SqlConnection cn = ROAPP_SqlConnection)
{
SqlCommand command = new SqlCommand();
command.Connection = cn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "checkAccPagePrefixUsed";
command.Parameters.AddWithValue("@Prefix", pfix);
command.Parameters.AddWithValue("@ROTable", ro.GetAttribute("Table"));
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
int cnt = reader.GetInt32(0);
if (cnt > 0)
return true;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error on IsDuplicateAccPagePrefix");
return true;
}
return false;
}
public override VlnXmlElement RODB_ReadRO(string tbl, string recid)
{ {
ShowCount.ReadRo++; ShowCount.ReadRo++;
VlnXmlElement retele = null; VlnXmlElement retele = null;
+158 -2
View File
@@ -25035,6 +25035,162 @@ IF (@@Error = 0) PRINT 'Trigger Alteration: tr_Contents_Delete Succeeded'
ELSE PRINT 'Trigger Alteration: tr_Contents_Delete Error on Creation' ELSE PRINT 'Trigger Alteration: tr_Contents_Delete Error on Creation'
GO GO
/****** Object: View [dbo].[vwDupAccIDs] ***********************/
If Exists(SELECT * FROM sys.objects Where name = 'vwDupAccIDs' AND type in (N'V'))
DROP VIEW [dbo].[vwDupAccIDs]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
==========================================================================================================
Author: Matthew Schill
Create Date: 10/7/2026
Description: View for Duplicate Accessory Page IDs in ROs in PROMS
Usage: Select * FROM dbo.vwDupAccIDs Order by RofstID, AccPageID, GroupTitle
==========================================================================================================
*/
CREATE View [dbo].[vwDupAccIDs]
AS
SELECT rochild.AccPageID, NUMAccPageIDs,
AccPageIDPrefix = dbiAP, GroupTitle = dbiTitle,
title, value, roid, rochild.RofstID
FROM
vwRofstData_RofstChildren rochild
INNER JOIN
(SELECT ROFstID = Max(ROFstID)
FROM ROFsts
Group by RODbID) latestfsts
ON latestfsts.ROFstID = rochild.RofstID
INNER JOIN
(SELECT NUMAccPageIDs=COunt(*), RoFstID, AccPageID FROM
vwRofstData_RofstChildren
WHERE AccPageID IS NOT NULL
Group by RoFstID, AccPageID
Having Count(*) > 1
) dupAcc
ON latestfsts.ROFstID = dupAcc.RofstID
AND dupAcc.AccPageID = rochild.AccPageID
go
IF (@@Error = 0) PRINT 'View [vwDupAccIDs] Succeeded'
ELSE PRINT 'View [vwDupAccIDs] Error on Creation'
go
/****** Object: StoredProcedure [getDupAccIDs] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDupAccIDs]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getDupAccIDs];
GO
/*
==========================================================================================================
Author: Matthew Schill
Create Date: 10/7/2026
Description: Procedure for Duplicate Accessory Page IDs in ROs in PROMS
==========================================================================================================
*/
CREATE PROCEDURE [dbo].[getDupAccIDs]
AS
BEGIN
Select * FROM dbo.vwDupAccIDs Order by RofstID, AccPageID, GroupTitle
RETURN
END
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getDupAccIDs Succeeded'
ELSE PRINT 'Procedure Creation: getDupAccIDs Error on Creation'
GO
/****** Object: StoredProcedure [getDupAccPrefixes] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDupAccPrefixes]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getDupAccPrefixes];
GO
/*
==========================================================================================================
Author: Matthew Schill
Create Date: 10/7/2026
Description: Procedure for Duplicate Accessory Page Prefixes in ROs in PROMS
==========================================================================================================
*/
CREATE PROCEDURE [dbo].[getDupAccPrefixes]
AS
BEGIN
SELECT AccPageIDPrefix = dbiAP, GroupTitle = dbiTitle
FROM
RofstDatabase
INNER JOIN
(SELECT ROFstID = Max(ROFstID)
FROM ROFsts
Group by RODbID) latestfsts
ON latestfsts.ROFstID = RofstDatabase.RofstID
INNER JOIN
(SELECT RoFstID, APPrefix = dbiAP FROM
RofstDatabase
Group by RoFstID, dbiAP
Having Count(*) > 1
) dupAcc
ON latestfsts.ROFstID = dupAcc.RofstID AND APPrefix = dbiAP
Order by dbiAP, dbiTitle
RETURN
END
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getDupAccPrefixes Succeeded'
ELSE PRINT 'Procedure Creation: getDupAccPrefixes Error on Creation'
GO
/****** Object: StoredProcedure [getDocsDupAccIDs] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDocsDupAccIDs]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getDocsDupAccIDs];
GO
/*
==========================================================================================================
Author: Matthew Schill
Create Date: 10/7/2026
Description: Get PROMS Documents containing Duplicate Accessory Page IDs
==========================================================================================================
*/
CREATE PROCEDURE [dbo].[getDocsDupAccIDs]
AS
BEGIN
Select Path = CASE WHEN VN.ParentName = VN.GrandParentName THEN ''
ELSE VN.GrandParentName + '->' END +
VN.ParentName + '->' + VN.FolderName + '->' + Pth.Path + '`' + Text,
AccPageID, DupAcc.roid, Contents.ContentID
FROM dbo.vwDupAccIDs DupAcc
INNER JOIN DROUsages with (NoLock) ON LEFT(DROUsages.ROID,12) = LEFT(DupAcc.roid,12)
INNER JOIN Entries with (NoLock) on DROUsages.DocID = Entries.DocID
INNER JOIN Contents with (NoLock) on Contents.ContentID = Entries.ContentID
INNER JOIN Items with (NoLock) on Contents.ContentID = Items.ContentID
INNER JOIN vefn_getversionItems('') vi on Contents.contentID = vi.contentID
INNER JOIN VEFN_GetVersionNames() VN ON vi.VersionID = VN.VersionID
OUTER APPLY
(Select Path = REPLACE(dbo.ve_GetPath(Items.ItemID), '\u8209?', '-')) Pth
Order by GrandParentName, ParentName, FolderName, Path, Text, AccPageID
RETURN
END
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getDocsDupAccIDs Succeeded'
ELSE PRINT 'Procedure Creation: getDocsDupAccIDs Error on Creation'
GO
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
| ADD New Code Before this Block | | ADD New Code Before this Block |
@@ -25068,8 +25224,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255) DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255) DECLARE @RevDescription varchar(255)
set @RevDate = '07/16/2026 8:30 AM' set @RevDate = '10/7/2026 9:30 AM'
set @RevDescription = 'Reworked ve_GetParentItem for Performance improvement' set @RevDescription = 'Added Reports for Duplicate Acc Page IDs in ROs'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
+31 -1
View File
@@ -263,7 +263,7 @@ WITH EXECUTE AS OWNER
AS AS
SELECT COUNT (RecID) SELECT COUNT (RecID)
FROM [ROALL] FROM [ROALL]
WHERE [ROTable]=@ROTable AND AccPageID=@AccPageID WHERE [ROTable]=@ROTable AND AccPageID=@AccPageID
GO GO
-- Display the status of Proc creation -- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountRecidByAccid Succeeded' IF (@@Error = 0) PRINT 'Procedure Creation: getCountRecidByAccid Succeeded'
@@ -827,4 +827,34 @@ IF (@@Error = 0) PRINT 'Table Creation: ROALL Succeeded'
ELSE PRINT 'Table Creation: DeleteLog ROALL on Creation' ELSE PRINT 'Table Creation: DeleteLog ROALL on Creation'
GO GO
/****** Object: StoredProcedure [dbo].[checkAccPagePrefixUsed] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[checkAccPagePrefixUsed]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [checkAccPagePrefixUsed];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2026 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[checkAccPagePrefixUsed]
(
@Prefix char(32),
@ROTable char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT(*)
FROM
(
SELECT ROTable, cast(info as xml) xinfo
FROM [ROALL]
WHERE Info LIKE '%AccPageIDPrefix%' AND ROTable <> @ROTable
) TBL
cross apply
xinfo.nodes('vlnGroup') t1(r1)
WHERE r1.value('@AccPageIDPrefix','varchar(max)') = @Prefix
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: checkAccPagePrefixUsed Succeeded'
ELSE PRINT 'Procedure Creation: checkAccPagePrefixUsed Error on Creation'
GO
@@ -380,6 +380,7 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmGenTools.resx"> <EmbeddedResource Include="frmGenTools.resx">
<DependentUpon>frmGenTools.cs</DependentUpon> <DependentUpon>frmGenTools.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmPDFStatusForm.resx"> <EmbeddedResource Include="frmPDFStatusForm.resx">
<DependentUpon>frmPDFStatusForm.cs</DependentUpon> <DependentUpon>frmPDFStatusForm.cs</DependentUpon>
+227 -56
View File
@@ -441,69 +441,240 @@ namespace VEPROMS
txtResults.Clear(); txtResults.Clear();
txtResults.AppendText("Generating User Access Control Report"); txtResults.AppendText("Generating User Access Control Report");
using (DataTable dt = UserReports.GetUserAccessControlData()) //Get data and Create excel file from it
{ Create_ExcelFile(UserReports.GetUserAccessControlData(), "UAC Report", 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. DateTime pEnd = DateTime.Now;
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;
txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}"); txtProcess.AppendText($"Completed: {pEnd:MM/dd/yyyy @ HH:mm}");
Application.DoEvents(); Application.DoEvents();
Cursor = Cursors.Default; Cursor = Cursors.Default;
MessageBox.Show("Generate User Access Control Report Completed", "User Access Control Report"); MessageBox.Show("Generate User Access Control Report Completed", "User Access Control Report");
} }
//C2025-009 Report for tracking PROMS Users / security #region Duplicate Accessory Page IDs
//for releasing any Excel com objects still in memory
private void releaseObject(object obj) //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 try
{ {
+77 -13
View File
@@ -52,6 +52,9 @@
this.panelEx1 = new DevComponents.DotNetBar.PanelEx(); this.panelEx1 = new DevComponents.DotNetBar.PanelEx();
this.sideNav1 = new DevComponents.DotNetBar.Controls.SideNav(); this.sideNav1 = new DevComponents.DotNetBar.Controls.SideNav();
this.sideNavPanel6 = new DevComponents.DotNetBar.Controls.SideNavPanel(); this.sideNavPanel6 = new DevComponents.DotNetBar.Controls.SideNavPanel();
this.btnWrdDupAcc = new DevComponents.DotNetBar.ButtonX();
this.line2 = new DevComponents.DotNetBar.Controls.Line();
this.btnUAC = new DevComponents.DotNetBar.ButtonX();
this.sideNavPanel5 = new DevComponents.DotNetBar.Controls.SideNavPanel(); this.sideNavPanel5 = new DevComponents.DotNetBar.Controls.SideNavPanel();
this.btn_ShowUsers = new DevComponents.DotNetBar.ButtonX(); this.btn_ShowUsers = new DevComponents.DotNetBar.ButtonX();
this.sideNavPanel1 = new DevComponents.DotNetBar.Controls.SideNavPanel(); this.sideNavPanel1 = new DevComponents.DotNetBar.Controls.SideNavPanel();
@@ -80,7 +83,8 @@
this.lblAdmToolProgressType = new DevComponents.DotNetBar.LabelX(); this.lblAdmToolProgressType = new DevComponents.DotNetBar.LabelX();
this.buttonItem1 = new DevComponents.DotNetBar.ButtonItem(); this.buttonItem1 = new DevComponents.DotNetBar.ButtonItem();
this.superTooltip1 = new DevComponents.DotNetBar.SuperTooltip(); this.superTooltip1 = new DevComponents.DotNetBar.SuperTooltip();
this.btnUAC = new DevComponents.DotNetBar.ButtonX(); this.btnDupAccPrefix = new DevComponents.DotNetBar.ButtonX();
this.btnDupAccIDs = new DevComponents.DotNetBar.ButtonX();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout(); this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.Panel2.SuspendLayout();
@@ -442,6 +446,10 @@
// //
// sideNavPanel6 // sideNavPanel6
// //
this.sideNavPanel6.Controls.Add(this.btnDupAccIDs);
this.sideNavPanel6.Controls.Add(this.btnDupAccPrefix);
this.sideNavPanel6.Controls.Add(this.btnWrdDupAcc);
this.sideNavPanel6.Controls.Add(this.line2);
this.sideNavPanel6.Controls.Add(this.btnUAC); this.sideNavPanel6.Controls.Add(this.btnUAC);
this.sideNavPanel6.Dock = System.Windows.Forms.DockStyle.Fill; this.sideNavPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.sideNavPanel6.Location = new System.Drawing.Point(88, 31); this.sideNavPanel6.Location = new System.Drawing.Point(88, 31);
@@ -449,6 +457,44 @@
this.sideNavPanel6.Size = new System.Drawing.Size(292, 493); this.sideNavPanel6.Size = new System.Drawing.Size(292, 493);
this.sideNavPanel6.TabIndex = 14; this.sideNavPanel6.TabIndex = 14;
// //
// btnWrdDupAcc
//
this.btnWrdDupAcc.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnWrdDupAcc.Checked = true;
this.btnWrdDupAcc.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnWrdDupAcc.Location = new System.Drawing.Point(26, 94);
this.btnWrdDupAcc.Name = "btnWrdDupAcc";
this.btnWrdDupAcc.Size = new System.Drawing.Size(211, 39);
this.btnWrdDupAcc.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.superTooltip1.SetSuperTooltip(this.btnWrdDupAcc, new DevComponents.DotNetBar.SuperTooltipInfo("Word Sections Containing Duplicate Accessory Page IDs Report", "", resources.GetString("btnWrdDupAcc.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.btnWrdDupAcc.TabIndex = 31;
this.btnWrdDupAcc.Text = "Run Word Sections Containing Duplicate Accessory Page IDs Report";
this.btnWrdDupAcc.Click += new System.EventHandler(this.btnWordDocsDupAccIDs_Click);
//
// line2
//
this.line2.BackColor = System.Drawing.Color.Transparent;
this.line2.Location = new System.Drawing.Point(5, 71);
this.line2.Name = "line2";
this.line2.Size = new System.Drawing.Size(285, 12);
this.line2.TabIndex = 30;
this.line2.Text = "line2";
//
// btnUAC
//
this.btnUAC.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnUAC.Checked = true;
this.btnUAC.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnUAC.Location = new System.Drawing.Point(35, 30);
this.btnUAC.Name = "btnUAC";
this.btnUAC.Size = new System.Drawing.Size(187, 23);
this.btnUAC.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.superTooltip1.SetSuperTooltip(this.btnUAC, new DevComponents.DotNetBar.SuperTooltipInfo("UAC Report", "", "This will return a report containing info on when users were added to PROMS and w" +
"hen users were added to specific PROMS security groups.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.btnUAC.TabIndex = 0;
this.btnUAC.Text = "Run User Access Control Report";
this.btnUAC.Click += new System.EventHandler(this.btnUAC_Click);
//
// sideNavPanel5 // sideNavPanel5
// //
this.sideNavPanel5.Controls.Add(this.btn_ShowUsers); this.sideNavPanel5.Controls.Add(this.btn_ShowUsers);
@@ -785,19 +831,33 @@
this.superTooltip1.DefaultTooltipSettings = new DevComponents.DotNetBar.SuperTooltipInfo("", "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Gray); this.superTooltip1.DefaultTooltipSettings = new DevComponents.DotNetBar.SuperTooltipInfo("", "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Gray);
this.superTooltip1.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F"; this.superTooltip1.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
// //
// btnUAC // btnDupAccPrefix
// //
this.btnUAC.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnDupAccPrefix.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnUAC.Checked = true; this.btnDupAccPrefix.Checked = true;
this.btnUAC.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; this.btnDupAccPrefix.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnUAC.Location = new System.Drawing.Point(35, 30); this.btnDupAccPrefix.Location = new System.Drawing.Point(26, 156);
this.btnUAC.Name = "btnUAC"; this.btnDupAccPrefix.Name = "btnDupAccPrefix";
this.btnUAC.Size = new System.Drawing.Size(187, 23); this.btnDupAccPrefix.Size = new System.Drawing.Size(211, 39);
this.btnUAC.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnDupAccPrefix.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnUAC.TabIndex = 0; this.superTooltip1.SetSuperTooltip(this.btnDupAccPrefix, new DevComponents.DotNetBar.SuperTooltipInfo("Word Sections Containing Duplicate Accessory Page IDs Report", "", resources.GetString("btnDupAccPrefix.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.btnUAC.Text = "Run User Access Control Report"; this.btnDupAccPrefix.TabIndex = 32;
this.superTooltip1.SetSuperTooltip(this.btnUAC, new DevComponents.DotNetBar.SuperTooltipInfo("UAC Report", "", "This will return a report containing info on when users were added to PROMS and when users were added to specific PROMS security groups.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray)); this.btnDupAccPrefix.Text = "Run Duplicate Accessory Page Prefixes Report";
this.btnUAC.Click += new System.EventHandler(this.btnUAC_Click); this.btnDupAccPrefix.Click += new System.EventHandler(this.btnDupAccPrefixes_Click);
//
// btnDupAccIDs
//
this.btnDupAccIDs.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnDupAccIDs.Checked = true;
this.btnDupAccIDs.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnDupAccIDs.Location = new System.Drawing.Point(26, 220);
this.btnDupAccIDs.Name = "btnDupAccIDs";
this.btnDupAccIDs.Size = new System.Drawing.Size(211, 39);
this.btnDupAccIDs.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.superTooltip1.SetSuperTooltip(this.btnDupAccIDs, new DevComponents.DotNetBar.SuperTooltipInfo("Word Sections Containing Duplicate Accessory Page IDs Report", "", resources.GetString("btnDupAccIDs.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.btnDupAccIDs.TabIndex = 33;
this.btnDupAccIDs.Text = "Run Duplicate Accessory Page IDs Report";
this.btnDupAccIDs.Click += new System.EventHandler(this.btnDupAccIDs_Click);
// //
// frmGenTools // frmGenTools
// //
@@ -889,6 +949,10 @@
private DevComponents.DotNetBar.Controls.WarningBox warningBox3; private DevComponents.DotNetBar.Controls.WarningBox warningBox3;
private DevComponents.DotNetBar.ButtonItem buttonItem1; private DevComponents.DotNetBar.ButtonItem buttonItem1;
private DevComponents.DotNetBar.ButtonX btnUAC; private DevComponents.DotNetBar.ButtonX btnUAC;
private DevComponents.DotNetBar.ButtonX btnWrdDupAcc;
private DevComponents.DotNetBar.Controls.Line line2;
private DevComponents.DotNetBar.ButtonX btnDupAccIDs;
private DevComponents.DotNetBar.ButtonX btnDupAccPrefix;
} }
} }
+22 -9
View File
@@ -117,10 +117,25 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="superTooltip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="superTooltip1.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value>
</data>
<data name="btnDupAccIDs.SuperTooltip" xml:space="preserve">
<value>If multiple ROs contain the same Accessory Page IDs, then users could inadvertently use the wrong RO in word documents since those print and save by Accessory Page ID).
This will return a report containing info on ROs that have Duplicate Accessory Page IDs. This can be reviewed and used in conjunction with the other Supplicate Accessory Page ID/Prefix Reports to ensure that ROs and RO Groups are properly set up. Common reasons for Duplicate Accessory Page IDs Include: RO Groups unintentionally set up with duplicate prefixes, fields in ROs that Accessory Page Access uses that have the same text but are upper vs lower case, and some duplicates may be RO Groups that were never intended to be used in PROMS (these may be only used as a group heading).</value>
</data>
<data name="btnDupAccPrefix.SuperTooltip" xml:space="preserve">
<value>If multiple ROs contain the same Accessory Page IDs, then users could inadvertently use the wrong RO in word documents since those print and save by Accessory Page ID.
This will return a report containing info on which RO Groups have duplicate Accessory Page Prefixes. This can be run and used to clean up RO Groups so that they have unique Accessory Page Prefixes.</value>
</data>
<data name="btnWrdDupAcc.SuperTooltip" xml:space="preserve">
<value>If multiple ROs contain the same Accessory Page IDs, then users could inadvertently use the wrong RO in word documents since those print and save by Accessory Page ID.
This will return a report containing info on which Word Sections Contain ROs that have Duplicate Accessory Page IDs. This can be run before cleaning up Duplicates and then utilized after to identify which Word Sections may need edited to the newly updated Accessory Page IDs.</value>
</data>
<data name="warningBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="warningBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAp5JREFUOE+F iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAp5JREFUOE+F
@@ -138,9 +153,6 @@
ud8AKwnMnBpmYFAAAAAASUVORK5CYII= ud8AKwnMnBpmYFAAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<metadata name="superTooltip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="swCkObsoleteROData.SuperTooltip" xml:space="preserve"> <data name="swCkObsoleteROData.SuperTooltip" xml:space="preserve">
<value>Referenced Objects databases are associated with a procedure set (such as Working Draft). <value>Referenced Objects databases are associated with a procedure set (such as Working Draft).
@@ -189,7 +201,8 @@ Should an item become orphaned (disconnected) from the rest of the data, it will
This tool may take an extended period of time to execute. This tool may take an extended period of time to execute.
</value> </value>
</data> </data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<value>46</value> <data name="$this.TrayHeight" type="System.Int32, mscorlib">
</metadata> <value>49</value>
</data>
</root> </root>
@@ -8,34 +8,53 @@ namespace VEPROMS.CSLA.Library
public static class UserReports public static class UserReports
{ {
#region Get User Reports #region Get User Reports
//CSM - C2025-009 Report for tracking PROMS Users / security //CSM - C2025-009 Report for tracking PROMS Users / security
public static DataTable GetUserAccessControlData() public static DataTable GetUserAccessControlData() => GetDataTable("getUserAcessControl");
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getUserAcessControl";
cm.CommandTimeout = Database.DefaultTimeout;
using (SqlDataAdapter da = new SqlDataAdapter(cm))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error in getUserAcessControl Report: retrieving data failed", ex);
}
}
#endregion
} #endregion
#region Get Duplicate Accessory Page Reports
//CSM - C2026-058 Reports for if Acc Page Id Prefix is Used More than Once
// Procedure for Duplicate Accessory Page IDs in ROs in PROMS
public static DataTable GetDupAccIDsData() => GetDataTable("getDupAccIDs");
//CSM - C2026-058 Reports for if Acc Page Id Prefix is Used More than Once
// Procedure for Duplicate Accessory Page Prefixes in ROs in PROMS
public static DataTable GetDupAccPrefixesData() => GetDataTable("getDupAccPrefixes");
//CSM - C2026-058 Reports for if Acc Page Id Prefix is Used More than Once
// Get PROMS Documents containing Duplicate Accessory Page IDs
public static DataTable GetDocsDupAccIDsData() => GetDataTable("getDocsDupAccIDs");
#endregion
#region Generic Get Data Table
private static DataTable GetDataTable(string spname)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = spname;
cm.CommandTimeout = Database.DefaultTimeout;
using (SqlDataAdapter da = new SqlDataAdapter(cm))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
}
catch (Exception ex)
{
throw new DbCslaException($"Error in {spname} Report: retrieving data failed", ex);
}
}
#endregion
}
} }