Compare commits

..

No commits in common. "7713f0cd635106b0831dc70bd68f8ae8a2c570ec" and "3ec7c11797667a5fd9c33d372fe66c765aa074d9" have entirely different histories.

19 changed files with 411 additions and 987 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -97,12 +97,12 @@ namespace VEPROMS
this.expandableSplitter1 = new DevComponents.DotNetBar.ExpandableSplitter();
this.panelEx2 = new DevComponents.DotNetBar.PanelEx();
this.groupPag = new DevComponents.DotNetBar.Controls.GroupPanel();
this.cbxGenerateTimeCritActSum = new System.Windows.Forms.CheckBox();
this.expPrnSetting = new DevComponents.DotNetBar.ExpandablePanel();
this.ppGpDuplex = new DevComponents.DotNetBar.Controls.GroupPanel();
this.tbBlankPage = new DevComponents.DotNetBar.Controls.TextBoxX();
this.lblBlPg = new DevComponents.DotNetBar.LabelX();
this.swtbtnPDFdtPrefixSuffix = new DevComponents.DotNetBar.Controls.SwitchButton();
this.cbxGenerateTimeCritActSum = new System.Windows.Forms.CheckBox();
this.gpnlDebug.SuspendLayout();
this.grpDateSelector.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.docVersionConfigBindingSource)).BeginInit();
@ -1285,23 +1285,6 @@ namespace VEPROMS
this.groupPag.TabIndex = 111;
this.groupPag.Text = "Print using standard PROMS pagination rules by:";
//
// cbxGenerateTimeCritActSum
//
this.cbxGenerateTimeCritActSum.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbxGenerateTimeCritActSum.AutoSize = true;
this.cbxGenerateTimeCritActSum.BackColor = System.Drawing.Color.Transparent;
this.cbxGenerateTimeCritActSum.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cbxGenerateTimeCritActSum.ForeColor = System.Drawing.SystemColors.ControlText;
this.cbxGenerateTimeCritActSum.Location = new System.Drawing.Point(240, 273);
this.cbxGenerateTimeCritActSum.Margin = new System.Windows.Forms.Padding(2);
this.cbxGenerateTimeCritActSum.Name = "cbxGenerateTimeCritActSum";
this.cbxGenerateTimeCritActSum.Size = new System.Drawing.Size(294, 17);
this.cbxGenerateTimeCritActSum.TabIndex = 102;
this.cbxGenerateTimeCritActSum.Text = "Generate Time Critical Action Summary (hidden but used)";
this.cbxGenerateTimeCritActSum.UseVisualStyleBackColor = false;
this.cbxGenerateTimeCritActSum.Visible = false;
//
// expPrnSetting
//
this.expPrnSetting.CanvasColor = System.Drawing.SystemColors.Control;
@ -1438,6 +1421,23 @@ namespace VEPROMS
this.swtbtnPDFdtPrefixSuffix.TabIndex = 111;
this.swtbtnPDFdtPrefixSuffix.ValueChanged += new System.EventHandler(this.swtbtnPDFdtPrefixSuffix_ValueChanged);
//
// cbxGenerateTimeCritActSum
//
this.cbxGenerateTimeCritActSum.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbxGenerateTimeCritActSum.AutoSize = true;
this.cbxGenerateTimeCritActSum.BackColor = System.Drawing.Color.Transparent;
this.cbxGenerateTimeCritActSum.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cbxGenerateTimeCritActSum.ForeColor = System.Drawing.SystemColors.ControlText;
this.cbxGenerateTimeCritActSum.Location = new System.Drawing.Point(240, 273);
this.cbxGenerateTimeCritActSum.Margin = new System.Windows.Forms.Padding(2);
this.cbxGenerateTimeCritActSum.Name = "cbxGenerateTimeCritActSum";
this.cbxGenerateTimeCritActSum.Size = new System.Drawing.Size(294, 17);
this.cbxGenerateTimeCritActSum.TabIndex = 102;
this.cbxGenerateTimeCritActSum.Text = "Generate Time Critical Action Summary (hidden but used)";
this.cbxGenerateTimeCritActSum.UseVisualStyleBackColor = false;
this.cbxGenerateTimeCritActSum.Visible = false;
//
// DlgPrintProcedure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -1096,15 +1096,6 @@ namespace VEPROMS
}
private void btnCreatePDF_Click(object sender, EventArgs e)
{
// B2024-058 Add validation for Revision Date field of the Print dialog
if (txbRevDate.Visible)
{
if (!validateDate(txbRevDate))
{
//txbRevDate.Focus();
return;
}
}
DoCreatePDF();
}
@ -1202,42 +1193,16 @@ namespace VEPROMS
if (_Initializing) return;
ppGpbxUserSpecTxt.Enabled = ppCmbxChgBarTxtType.SelectedIndex == (int)PrintChangeBarText.UserDef;
}
// B2024-058 Add validation for Revision Date field of the Print dialog
private bool validateDate(TextBox txtDate)
{
DateTime dDate;
if (DateTime.TryParse(txtDate.Text, out dDate))
{
return true;
}
else
{
string txtDate2 = txtDate.Text;
string message = String.Format("Date {0} in wrong format" + System.Environment.NewLine + "Correct the revision date.", txtDate2);
string txtTitle = "Invalid Format";
MessageBox.Show(message, txtTitle);
return false;
}
}
private void txbRevDate_Enter(object sender, EventArgs e)
{
txbDate = txbRevDate;
grpDateSelector.Text = "Select Revision Date";
grpDateSelector.Visible = calDateSelector.Visible = true;
//C2021-007 position the calendar to the current RevDate or if no RevDate, position to today's date
DateTime dDate;
// B2024-058 Add validation for Revision Date field of the Print dialog
if (!validateDate(txbDate))
{
txbRevDate.Focus();
}
else
{
DateTime initSelDate = (txbDate.Text != null && txbDate.Text.Length != 0) ? Convert.ToDateTime(txbDate.Text) : DateTime.Today;
DateTime initSelDate =(txbDate.Text != null && txbDate.Text.Length != 0)? Convert.ToDateTime(txbDate.Text) : DateTime.Today;
calDateSelector.DisplayMonth = calDateSelector.SelectedDate = initSelDate;
}
}
private void txbRevDate_Leave(object sender, EventArgs e)
{
if (_Initializing) return;
@ -1410,7 +1375,6 @@ namespace VEPROMS
_NewRevForAllProcs = null;
}
//private void cbxDebug_CheckedChanged(object sender, EventArgs e)
//{
// cbxCmpPRMSpfd.Visible = cbxDebug.Checked;

View File

@ -23519,90 +23519,6 @@ GO
==========================================================================================================
*/
/*
==========================================================================================================
Start: C2021-059: SQL to delete folders using admin tool
==========================================================================================================
*/
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'deleteFolderAdmin')
DROP PROCEDURE [dbo].[deleteFolderAdmin]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[deleteFolderAdmin]
(
@FolderID int
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DELETE From Assignments WHERE [FolderID]=@FolderID
DELETE From Associations where VersionID in (select versionid from DocVersions where folderid = @FolderID)
DELETE From DocVersions where VersionID in (select versionid from DocVersions where folderid= @FolderID)
DELETE From DocVersions where [FolderID]=@FolderID
-- Delete from items where ItemID matches
DELETE FROM tblitems
WHERE ItemID IN (
SELECT DISTINCT ItemID
FROM docversions
WHERE folderID = @folderID
);
-- Delete from items where ItemID matches
DELETE FROM tblitems
WHERE ItemID IN (
SELECT DISTINCT ItemID
FROM docversions
WHERE folderID = @folderID
);
-- Delete from tblContents where ContentID matches
DELETE FROM tblContents
WHERE ContentID IN (
SELECT DISTINCT c.ContentID
FROM tblContents c
JOIN items i ON c.ContentID = i.ItemID
WHERE i.ItemID IN (
SELECT DISTINCT ItemID
FROM docversions
WHERE folderID = @folderID
)
);
DELETE From Folders WHERE [ParentID] = @FolderID
DELETE From Folders WHERE [FolderID] = @FolderID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
/*
==========================================================================================================
End: C2021-059: SQL to delete folders using admin tool
==========================================================================================================
*/
/*
---------------------------------------------------------------------------
| ADD New Code Before this Block |
@ -23636,8 +23552,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '07/29/2024 11:24'
set @RevDescription = 'C2021-059 Add SQL for Admin tool delete folders.'
set @RevDate = '07/18/2024 11:24'
set @RevDescription = 'C2024-005 Add an Admin tool that can delete a group of annotations.'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription

View File

@ -22,8 +22,6 @@ namespace VEPROMS
string procList = "";
string docvList = "";
int AnnotationTyp;
string AnnotationName = "";
string totalDeleteCnt = "";
List<ProcedureInfo> pil2 = new List<ProcedureInfo>();
List<DocVersionInfo> dvil2 = new List<DocVersionInfo>();
private frmBatchRefresh mainForm = null;
@ -54,7 +52,6 @@ namespace VEPROMS
lbAnnotationTypes.DisplayMember = "Value";
lbAnnotationTypes.ValueMember = "Key";
lbAnnotationTypes.SelectedIndexChanged += lbAnnotationTypes_SelectedIndexChanged;
lbAnnotationTypes.ClearSelected();
}
// create comma delimited string of procedures selected by user.
@ -105,28 +102,13 @@ namespace VEPROMS
// Process used to cleanup annotations "(Proceed?" button)
private void button1_Click(object sender, EventArgs e)
{
if (lbAnnotationTypes.SelectedIndex > -1)
{
TextBox frm2 = mainForm.GettxtProcess();
TextBox frm3 = mainForm.GettxtResults();
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
AnnotationName = System.Convert.ToString(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Value);
frm3.AppendText("Deleting Annotations: Annotation Type: " + '"' + AnnotationName + '"');
frm3.AppendText(Environment.NewLine + "P = Procedure, F = Folder" + Environment.NewLine);
int deletecountProc = 0;
int deletecountDocv = 0;
foreach (var p in pil2)
{
if (p.IsProcedure)
{
//AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
//AnnotationName = System.Convert.ToString(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Value);
//deletecountProc = Annotation.getAnnotationProcCnt(AnnotationTyp, getAnnotationProcItems(p));
deletecountProc = Annotation.getAnnotationProcCnt(AnnotationTyp, p.ItemID.ToString());
frm2.AppendText(Environment.NewLine + p.DisplayNumber + ' ' + p.DisplayText);
//frm3.AppendText(Environment.NewLine + "P: " + p.DisplayNumber + '"' + p.DisplayText + '"' + " Type: " + '"' + AnnotationName + '"' + " count: " + deletecountProc);
frm3.AppendText(Environment.NewLine + "P: " + p.DisplayNumber + '"' + p.DisplayText + '"' + " Delete count: " + deletecountProc);
TextBox frm2 = mainForm.GettxtProcess();
frm2.AppendText(p.DisplayNumber + ' ' + p.DisplayText);
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
Annotation.DeleteAnnotationProcByType(AnnotationTyp, p.ItemID.ToString());
lblCountNumber.Text = "0";
}
@ -136,26 +118,16 @@ namespace VEPROMS
{
if (d.IsDocVersion)
{
//AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
//AnnotationName = System.Convert.ToString(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Value);
deletecountDocv = Annotation.getAnnotationCountDocv(AnnotationTyp, d.VersionID.ToString());
frm2.AppendText(Environment.NewLine + d.ActiveParent.ToString());
frm3.AppendText(Environment.NewLine + "F: " + '"' + d.ActiveParent.ToString() + '"' + " Delete count: " + deletecountDocv);
TextBox frm2 = mainForm.GettxtProcess();
frm2.AppendText(d.ActiveParent.ToString());
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
Annotation.DeleteAnnotationDocvByType(AnnotationTyp, d.VersionID.ToString());
lblCountNumber.Text = "0";
}
}
frm3.AppendText(Environment.NewLine + Environment.NewLine + "Total Annotations Deleted: " + totalDeleteCnt + Environment.NewLine + Environment.NewLine);
}
}
// Retrieve number of annotations that will be deleted.
private void lbAnnotationTypes_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbAnnotationTypes.SelectedIndex > -1)
{
btnClean.Enabled = false;
lblCountNumber.Text = "";
@ -173,9 +145,7 @@ namespace VEPROMS
deletecountDocv = Annotation.getAnnotationCountDocv(AnnotationTyp, getAnnotationDocvItems(dvil2));
}
lblCountNumber.Text = (deletecountProc + deletecountDocv).ToString();
totalDeleteCnt = (deletecountProc + deletecountDocv).ToString();
btnClean.Enabled = true;
}
}
// Close form.
@ -186,5 +156,3 @@ namespace VEPROMS
}
}

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@ using System.IO;
using Volian.Controls.Library;
using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms;
using Volian.Controls.Library;
namespace VEPROMS
{
@ -25,17 +24,11 @@ namespace VEPROMS
private bool IsAdministratorUser = false; //C2020-035 used to control what Set Amins can do
// C2017-030 - new Admin Tools user interface
// pass in session info to constructor
private frmVEPROMS _veProms;
public frmBatchRefresh(SessionInfo sessionInfo, frmVEPROMS veProms)
public frmBatchRefresh(SessionInfo sessionInfo)
{
InitializeComponent();
_MySessionInfo = sessionInfo;
_veProms = veProms;
// When opening Admin tools Check tab will be default.
this.sideNavItmCheck.Checked = true;
@ -43,10 +36,7 @@ namespace VEPROMS
{
AdminToolType = (E_AdminToolType)4;
if (swDeleteFolder.Value)
{
ResetDelTV(true);
setupProgessSteps1();
}
else
ResetDelTV(false);
}
@ -71,13 +61,6 @@ namespace VEPROMS
{
return txtProcess;
}
// Make txtResults text box available to frmAnnotationsClean form.
internal TextBox GettxtResults()
{
return txtResults;
}
// NOTE: removed the Refresh ROs and Refresh Transitions and ROs options (now only Transitions can be refreshed)
// the Update ROs and Refresh ROs logic was merged together. The Update ROs will functionally do both
// also annotations will be placed on step elements that have RO changes
@ -111,8 +94,6 @@ namespace VEPROMS
private Dictionary<TreeNode, ProcedureInfo> myProcedures = new Dictionary<TreeNode, ProcedureInfo>();
private Dictionary<TreeNode, DocVersionInfo> myDocVersions = new Dictionary<TreeNode, DocVersionInfo>();
private Dictionary<TreeNode, FolderInfo> myFolders = new Dictionary<TreeNode, FolderInfo>();
private void frmBatchRefresh_Load(object sender, EventArgs e)
{
IsClosing = false;//B2017-221 Allow the batch dialog to close when waiting to process.
@ -155,7 +136,6 @@ namespace VEPROMS
//myTreeNodePath = new List<string>();
myTV.Nodes.Clear();
myDocVersions.Clear();
myFolders.Clear();
FolderInfo fi = FolderInfo.GetTop();
TreeNode tn = myTV.Nodes.Add(fi.Name);
tn.Tag = fi;
@ -178,6 +158,12 @@ namespace VEPROMS
FolderInfo fi = FolderInfo.GetTop();
if (fi.ChildFolderCount > 0)
{
if (noProcs)
{
LoadBottomLevelFolders(fi, myTVdel);
}
else
{
TreeNode tn = new TreeNode(fi.Name);
tn.Tag = fi;
@ -185,15 +171,32 @@ namespace VEPROMS
LoadChildFolders(fi, tn, noProcs);
myTVdel.Nodes.Add(tn);
}
}
if (myTVdel.SelectedNode != null)
myTVdel.SelectedNode.Expand();
//Expand if folders
if (noProcs)
myTVdel.ExpandAll();
this.Cursor = Cursors.Default;
//btnFixLinks.Enabled = false;
//this.Cursor = Cursors.WaitCursor;
////myTreeNodePath = new List<string>();
//myTVdel.Nodes.Clear();
//myDocVersions.Clear();
//FolderInfo fi = FolderInfo.GetTop();
//TreeNode tn = myTVdel.Nodes.Add(fi.Name );
//tn.Tag = fi;
//if (fi.ChildFolderCount > 0)
//{
// if (noProcs)
// {
// LoadBottomLevelFolders(fi, myTVdel);
// }
// else
// LoadChildFolders(fi, tn, noProcs);
//}
//if (myTVdel.SelectedNode != null)
// myTVdel.SelectedNode.Expand();
//this.Cursor = Cursors.Default;
}
// B2021-060 Higher level folders where being removed from the tree even if there was a child folder that containe a working draft set
@ -205,13 +208,10 @@ namespace VEPROMS
{
TreeNode tnc = tn.Nodes.Add(fic.Name);
tnc.Tag = fic;
if (fic.ChildFolderCount > 0)
{
if (LoadChildFolders(fic, tnc, noProcs))
loadedChildWorkingDraft = true;
}
// B2020-114 and C2020-035 only show folders the Set Admin can access
if (fic.FolderDocVersionCount > 0)
{
if (!LoadDocVersions(fic, tnc, noProcs))
@ -219,27 +219,40 @@ namespace VEPROMS
else
loadedWorkingDraft = true;
}
else
{
// Add the folder to the dictionary
if (!myFolders.ContainsKey(tnc))
myFolders.Add(tnc, fic);
}
}
if (loadedChildWorkingDraft)
{
loadedWorkingDraft = true;
}
if (loadedChildWorkingDraft) loadedWorkingDraft = true; // B2021-060 if child folder working draft loaded set loadedWorkingDraft
if (tn.Parent != null && !loadedWorkingDraft)
{
tn.Remove();
}
return loadedWorkingDraft;
}
/// <summary>
/// Load only bottom layer of folders into treenode.
/// </summary>
/// <param name="fi"></param>
/// <param name="tn"></param>
private void LoadBottomLevelFolders(FolderInfo fi, TreeView treeView)
{
foreach (FolderInfo fic in fi.SortedChildFolders)
{
if (fic.ChildFolderCount > 0)
{
// Recursively call for child folders
LoadBottomLevelFolders(fic, treeView);
}
else
{
if (fic.Name != "PROMS")
{
// If the folder is a bottom-level folder (no child folders), add it directly to the TreeView
TreeNode tnc = treeView.Nodes.Add(fic.Name);
tnc.Tag = fic;
}
}
}
}
private bool LoadDocVersions(FolderInfo fic, TreeNode tnc, bool noProcs)
{
bool rtnval = false;
@ -1256,76 +1269,6 @@ namespace VEPROMS
}
}
}
//After check model to select and deselect nodes on the delete and annotation tree.
private void myTV_AfterCheck_DelAnn(object sender, TreeViewEventArgs e)
{
if (e.Action != TreeViewAction.Unknown)
{
if (e.Node.Nodes.Count > 0)
{
CheckChildNodes_DelAnn(e.Node, e.Node.Checked);
}
}
if (e.Node.Checked)
{
// Ensure child nodes follow the parent node's state
CheckChildNodes_DelAnn(e.Node, e.Node.Checked);
}
else
{
// Automatically deselect parent nodes if current node is unchecked
if (swDeleteFolder.Value)
DiselectParentNodes_DelAnn(e.Node);
}
btnFixLinks.Enabled = AtLeastOneNodeChecked_DelAnn(); // Ensure button is enabled based on custom logic
}
private void DiselectParentNodes_DelAnn(TreeNode node)
{
TreeNode parent = node.Parent;
while (parent != null)
{
parent.Checked = false;
parent = parent.Parent;
}
}
private void DiselectChildNodes_DelAnn(TreeNodeCollection children)
{
foreach (TreeNode child in children)
{
child.Checked = false;
DiselectChildNodes_DelAnn(child.Nodes);
}
}
private void CheckChildNodes_DelAnn(TreeNode treeNode, bool isChecked)
{
foreach (TreeNode tn in treeNode.Nodes)
{
tn.Checked = isChecked;
if (tn.Nodes.Count > 0)
CheckChildNodes_DelAnn(tn, isChecked);
}
}
private bool AtLeastOneNodeChecked_DelAnn()
{
foreach (TreeNode node in myTV.Nodes)
{
if (node.Checked || AnyChildNodeChecked_DelAnn(node))
return true;
}
return false;
}
private bool AnyChildNodeChecked_DelAnn(TreeNode node)
{
foreach (TreeNode childNode in node.Nodes)
{
if (childNode.Checked || AnyChildNodeChecked_DelAnn(childNode))
return true;
}
return false;
}
private ProgressBarItem _ProgressBar = null;
@ -1516,20 +1459,8 @@ namespace VEPROMS
break;
case E_AdminToolType.Delete:
if (swDeleteFolder.Value)
{
splitContainer3.Panel2Collapsed = false;
progressSteps1.Items.Add(siOrphDatRecs);
lblAdmToolProgressType.Text = "Deleting: ";
progressSteps1.Visible = true;
progressSteps1.Refresh();
}
else
{
lblAdmToolProgressType.Text = "";
splitContainer3.Panel2Collapsed = true;
progressSteps1.Visible = false;
}
break;
}
}
@ -1731,7 +1662,6 @@ namespace VEPROMS
//C2024-005 Delete Annotations, Delete Folders
private void swDeleteAnnotations_ValueChanged(object sender, EventArgs e)
{
setupProgessSteps1();
swDeleteFolder.Value = !swDeleteAnnotations.Value;
if (swDeleteFolder.Value)
ResetDelTV(true);
@ -1741,7 +1671,6 @@ namespace VEPROMS
private void swDeleteFolder_ValueChanged(object sender, EventArgs e)
{
setupProgessSteps1();
swDeleteAnnotations.Value = !swDeleteFolder.Value;
if (swDeleteFolder.Value)
ResetDelTV(true);
@ -1755,105 +1684,68 @@ namespace VEPROMS
txtResults.Clear();
txtProcess.Clear();
this.Cursor = Cursors.WaitCursor;
//Create checked proce and doc info lists.
List<ProcedureInfo> pil = new List<ProcedureInfo>();
List<DocVersionInfo> dvil = new List<DocVersionInfo>();
// Create a list of procedures the user selected
foreach (TreeNode tn in myProcedures.Keys)
if (tn.Checked)
pil.Add(myProcedures[tn]);
// Create a list of doc versions the user selected
foreach (TreeNode tn in myDocVersions.Keys)
if (tn.Checked)
dvil.Add(myDocVersions[tn]);
bool cancelledOut = false; // Flag to indicate if the process should be cancelled
StringBuilder sbDocVersions = new StringBuilder();
foreach (DocVersionInfo dq in dvil)
{
string msg = string.Empty;
if (!MySessionInfo.CanCheckOutItem(dq.VersionID, CheckOutType.DocVersion, ref msg))
{
string msgp = string.Empty;
foreach (ProcedureInfo pi in dq.Procedures)
{
if (!MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref msgp))
{
FolderInfo fi = (FolderInfo)dq.ActiveParent;
int itemID = (int)fi.FolderID;
string folderName = fi.Name;
if (swDeleteFolder.Value)
sbDocVersions.AppendLine($"{folderName} - {msgp}");
else
sbDocVersions.AppendLine(msgp);
cancelledOut = true;
}
}
}
}
if (cancelledOut)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The batch update process was not successful for all working drafts selected.");
sb.AppendLine("The following procedures are currently checked out...");
sb.AppendLine();
sb.AppendLine(sbDocVersions.ToString());
sb.AppendLine();
if (swDeleteFolder.Value)
sb.AppendLine("If you want to delete these folders, please contact the respective users and have them close any procedures in the working draft.");
else
sb.AppendLine("If you want to delete annotations from these working drafts, please contact the respective users and have them close any procedures in the working draft.");
sb.AppendLine();
txtProcess.AppendText(sb.ToString());
this.Cursor = Cursors.Default;
return;
}
if (swDeleteFolder.Value)
{
if (FlexibleMessageBox.Show(this, "Are you sure you want to remove the selected folders and their contents?", "Confirm Folder Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//TODO process deletions of folders
txtProcess.AppendText("Deleting Folders...");
//Load Selected Folders
List<FolderInfo> ef = new List<FolderInfo>();
foreach (TreeNode tn in myFolders.Keys)
//List<ProcedureInfo> pil = new List<ProcedureInfo>();
//foreach (TreeNode tn in myProcedures.Keys)
// if (tn.Checked)
// pil.Add(myProcedures[tn]);
if (tn.Checked)
ef.Add(myFolders[tn]);
////Load Selected Folders
Dictionary<int, string> folderData = new Dictionary<int, string>();
ProcessDelete(dvil, ef);
}
//List<FolderInfo> Flist = new List<FolderInfo>();
//foreach (TreeNode tn in myDocVersions.Keys)
// if (tn.Checked)
// Flist.Add();
//List<DocVersionInfo> dvil = new List<DocVersionInfo>();
//foreach (TreeNode tn in myDocVersions.Keys)
// if (tn.Checked)
// dvil.Add(myDocVersions[tn]);
//foreach (TreeNode tn in myTVdel.Nodes)
//{
// if (tn.Checked)
// {
// var itemInfo = myProcedures[tn];
// folderData.Add(itemInfo.ItemID, itemInfo.DisplayText);
// }
//}
//ProcessDelete(dvil);
}
else
{
// Write progress status
txtProcess.AppendText("Deleting Annotations...");
// Create a list of procedures the user selected
List<ProcedureInfo> pil = new List<ProcedureInfo>();
foreach (TreeNode tn in myProcedures.Keys)
if (tn.Checked)
pil.Add(myProcedures[tn]);
// Create a list of doc versions the user selected
List<DocVersionInfo> dvil = new List<DocVersionInfo>();
foreach (TreeNode tn in myDocVersions.Keys)
if (tn.Checked)
dvil.Add(myDocVersions[tn]);
frmAnnotationsCleanup frmAnnoDel = new frmAnnotationsCleanup(this, pil, dvil);
frmAnnoDel.ShowDialog();
}
this.Cursor = Cursors.Default;
}
private void ProcessDelete(List<DocVersionInfo> foldersToDelete, List<FolderInfo> emptyFoldersToDelete)
private void ProcessDelete(List<DocVersionInfo> foldersToDelete)
{
int foldersDeleted = 0;
DateTime pStart = DateTime.Now;
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(pStart.ToString("MM/dd/yyyy @ HH:mm"));
@ -1861,19 +1753,17 @@ namespace VEPROMS
foreach (var kvp in foldersToDelete)
{
//Gather folder information
FolderInfo fi = (FolderInfo)kvp.ActiveParent;
int itemID = (int)fi.FolderID;
string folderName = fi.Name;
int itemID = (int)kvp.ItemID;
string folderName = kvp.Name;
// Perform the deletion operation
// Assume DeleteFolderByID is a method that deletes the folder by its ItemID
bool deletionSuccessful = DeleteFolderByID(itemID);
// Update txtProcess with the progress
if (deletionSuccessful)
{
txtProcess.AppendText($"Successfully deleted folder: {folderName} (ID: {itemID})");
foldersDeleted += 1;
}
else
{
@ -1881,69 +1771,13 @@ namespace VEPROMS
}
txtProcess.AppendText(Environment.NewLine);
}
//Delete non working info folders.
foreach (var kvp in emptyFoldersToDelete)
{
//Gather folder information
FolderInfo fi = (FolderInfo)kvp;
int itemID = (int)fi.FolderID;
string folderName = fi.Name;
// Perform the deletion operation
bool deletionSuccessful = DeleteFolderByID(itemID);
// Update txtProcess with the progress
if (deletionSuccessful)
{
txtProcess.AppendText($"Successfully deleted folder: {folderName} (ID: {itemID})");
foldersDeleted += 1;
}
else
// Example deletion method
private bool DeleteFolderByID(int itemID)
{
txtProcess.AppendText($"Failed to delete folder: {folderName} (ID: {itemID})");
}
txtProcess.AppendText(Environment.NewLine);
}
//Run Repair
int prgStpIdx = -1;
StepProgress(++prgStpIdx, 50);
PurgeDisconnectedItems(); // Orphan Items
StepProgress(prgStpIdx, 100);
//rebuild
ResetDelTV(true);
MessageBox.Show($"Folder deletion completed, {foldersDeleted} folders have been deleted.", "Delete Folders");
ClearStepProgress();
txtResults.AppendText($"Folder deletion process completed, {foldersDeleted} folders have been deleted.");
txtResults.AppendText(Environment.NewLine);
}
private bool DeleteFolderByID(int folderID)
{
try
{
//Delete
Folder.DeleteFolderAdmin(folderID);
//update treeview UI via veProms
_veProms.tv_FolderDelete(folderID);
return true;
}
catch (Exception ex)
{
string err = ex.ToString();
return false;
}
// Implement your folder deletion logic here
// Return true if deletion was successful, false otherwise
return true; // Placeholder
}
public List<ProcedureInfo> RetrieveChkAnnotations()
@ -1958,5 +1792,3 @@ namespace VEPROMS
}

View File

@ -121,7 +121,9 @@
<value>17, 17</value>
</metadata>
<data name="swDeleteFolder.SuperTooltip" xml:space="preserve">
<value>This allows the user to remove folders and sub folders as well as their contents.
<value>This allows the user to check referenced objects links in procedure step data for multiple working drafts in a batch mode.
Bad referenced bject links will be identified with an Bad RO Link annotation. Use the PROMS Search tool to list all of the steps that have this annotation.
Be sure a current backup of the database exists prior performing this function.
@ -130,34 +132,28 @@ It is recommended that this be done during off hours.
</value>
</data>
<data name="labelX13.SuperTooltip" xml:space="preserve">
<value>This allows the user to remove folders and sub folders as well as their contents.
<value>This allows the user to check referenced objects links in procedure step data for multiple working drafts in a batch mode.
Bad referenced bject links will be identified with an Bad RO Link annotation. Use the PROMS Search tool to list all of the steps that have this annotation.
Be sure a current backup of the database exists prior performing this function.
It is recommended that this be done during off hours.
</value>
</data>
<data name="swDeleteAnnotations.SuperTooltip" xml:space="preserve">
<value>This function will allow the user to remove annotations from the selected working drafts.
<value>This function will refresh transitions in all procedures selected below, whether they were selected individually or as a group via a procedure set.
Be sure a current backup of the database exists prior to running this function.
If more than one working draft is selected, it is recommended that this be performed during off hours.</value>
If more than one procedure is selected, it is recommended that this be performed during off hours.</value>
</data>
<data name="labelX14.SuperTooltip" xml:space="preserve">
<value>This function will allow the user to remove annotations from the selected working drafts.
<value>This function will refresh transitions in all procedures selected below, whether they were selected individually or as a group via a procedure set.
Be sure a current backup of the database exists prior to running this function.
If more than one working draft is selected, it is recommended that this be performed during off hours.</value>
</data>
<data name="btnDeleteItems.SuperTooltip" xml:space="preserve">
<value>This will allow for the deletion of groups of annotations and allow for deleting entire folders within PROMS. Use the tree nodes to select which items to delete.
Click on the on/off switches to turn on/off each tool.
Note that only one of these tools can be run at a time.</value>
If more than one procedure is selected, it is recommended that this be performed during off hours.</value>
</data>
<data name="swCheckROLinks.SuperTooltip" xml:space="preserve">
<value>This allows the user to check referenced objects links in procedure step data for multiple working drafts in a batch mode.

View File

@ -254,21 +254,6 @@ namespace VEPROMS
tc.RefreshItem(myItemInfo);
}
public void tv_FolderDelete(int folderId)
{
// Create an instance of the event args if needed
var args = new vlnTreeFolderDeleteEventArgs(folderId);
// Trigger the deletion using the event arguments
tv.RemoveFolder(args.FolderId);
}
private bool Tv_DeleteFolder(object sender, vlnTreeFolderDeleteEventArgs args)
{
tv.RemoveFolder(args.FolderId);
return true;
}
private E_UCFImportOptions _UCFImportOptionsFromSettings;
public frmVEPROMS()
@ -489,7 +474,6 @@ namespace VEPROMS
tv.NodeNew += new vlnTreeViewEvent(tv_NodeNew);
tv.OpenItem += new vlnTreeViewItemInfoEvent(tv_OpenItem);
tv.TabDisplay += new StepPanelTabDisplayEvent(tc_PanelTabDisplay);
tv.DeleteFolder += new vlnTreeViewItemInfoDeleteFolderEvent(Tv_DeleteFolder);
tv.DeleteItemInfo += new vlnTreeViewItemInfoDeleteEvent(tv_DeleteItemInfo);
tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo);
tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert);
@ -2757,7 +2741,7 @@ namespace VEPROMS
void btnAdministrativeTools_Click(object sender, EventArgs e)
{
frmBatchRefresh frm = new frmBatchRefresh(MySessionInfo, this);
frmBatchRefresh frm = new frmBatchRefresh(MySessionInfo);
frm.ProgressBar = bottomProgBar;
frm.ShowDialog(this);
}

View File

@ -951,10 +951,7 @@ namespace VEPROMS.CSLA.Library
// it is pasted into a section without enhanced data, then clear it.
// config data can only be on hls/notes/cautions for pasted steps.
// B2024-059: clear links on a source section. When a paste occurs, the section is copied with the links but not
// new section is created in the enhanced document, so the links point to the original section (copied). These
// need to be removed.
if (!pasteItem.IsHigh && !pasteItem.IsCaution && !pasteItem.IsNote && !pasteItem.IsSection) return;
if (!pasteItem.IsHigh && !pasteItem.IsCaution && !pasteItem.IsNote) return;
// See if the pasted step's section is enhanced with enhanced steps, and if not, clear it
// Also, if pasting into a source section, don't clear (B2017-225), the 'isSourceSection' portion of the code.
@ -977,12 +974,6 @@ namespace VEPROMS.CSLA.Library
// of the pasted step.
if (pasteItem.HasEnhancedLinkedStep) pasteItem.RemoveEnhancedFromConfig();
}
// B2024-059: clear links on a source section
if (isSourceSection)
{
EnhancedDocuments seleds = pasteItem.GetMyEnhancedDocuments();
foreach (EnhancedDocument ed in seleds) pasteItem.DoUnlinkEnhanced(pasteItem, ed.Type, true);
}
}
#endregion
#region Insert Child
@ -1318,7 +1309,8 @@ namespace VEPROMS.CSLA.Library
else if (addType == EAddpingPart.Replace) // what about user interface for enhanced pasted steps?
{
ItemInfo enhReplaceItem = ItemInfo.Get(edSource.ItemID);
newEnhancedItemInfo = Item.PasteReplace(enhReplaceItem, tmpCopyEnhancedID, chgid);
TreeNode trn = null;
newEnhancedItemInfo = Item.PasteReplace(enhReplaceItem, tmpCopyEnhancedID, chgid, trn);
}
// update the config data for the new enhanced item (procedure, section or step) to point back to the correct source
@ -2506,15 +2498,16 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region PasteReplace
// B2024-045, 049 and 050: remove the treenode that was passed in - adjust tree from user interface code, not in item extension
// code (the 2 PasteReplace methods here had a treenode passed in)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace)
{
bool tmp = false;
return PasteReplace(itemInfo, copyStartID, chgid, ref tmp);
return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp);
}
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, ref bool firstTrans)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans)
{
firstTrans = false;
if (!CanDeleteObject())
@ -2572,11 +2565,10 @@ namespace VEPROMS.CSLA.Library
}
else
{
// B2024-045, 049 and 050: if not a single procedure replace, update user interface by using the 'OnNewChild'. Single
// procedure's MyParent is null because its parent is a working draft (docversion) since MyParent's type is iteminfo.
// For the single procedure case, the user interface code in vlntreeview will update the tree.
if (newItemInfo.MyParent != null)
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
//Create tree node for copied procedure when no other procedures exist in the working draft (treeNodeReplace)
VETreeNode tn = null;
tn = new VETreeNode(newItemInfo);
treeNodeReplace.Nodes.Add(tn);
}
return newItemInfo;
}

View File

@ -1107,7 +1107,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
@ -1129,7 +1129,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
//FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
@ -1157,7 +1157,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
@ -1184,7 +1184,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
@ -1211,7 +1211,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
@ -1238,7 +1238,7 @@ namespace VEPROMS.CSLA.Library
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);

View File

@ -1433,31 +1433,6 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Folder.Remove", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void DeleteFolderAdmin(int folderID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Remove", 0);
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "deleteFolderAdmin";
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Remove", ex);
throw new DbCslaException("Folder.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int folderID)

View File

@ -672,10 +672,8 @@ namespace Volian.Controls.Library
if (_MyDisplayTabItems.ContainsKey(key) && pasteType != ItemInfo.EAddpingPart.Replace) // If procedure page open use it unless replace
{
DisplayTabItem pg = _MyDisplayTabItems[key];
// B2024-038: if section, refresh the editor even if the section is not expanded.
bool isSec = myItemInfo.IsSection;
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID) &&
(pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID].Expanded || isSec))
pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID].Expanded)
{
EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID];
switch (pasteType)
@ -712,8 +710,7 @@ namespace Volian.Controls.Library
}
else if (_MyDisplayTabItems.ContainsKey(key) && pasteType == ItemInfo.EAddpingPart.Replace)
{
// B2024-038: changed tab key to procedure (was item, which caused crash if section)
CloseTabItem(_MyDisplayTabItems["Item - " + proc.ItemID.ToString()]); //Grab itemID and set to close open tab.
CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted
}
return false;

View File

@ -1844,8 +1844,8 @@ namespace Volian.Controls.Library
bool gotoFirstTrans = false;
try
{
// B2024-045, 049 and 050: do not pass in a tree node to Item.PasteReplace
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo), ref gotoFirstTrans);
TreeNode treeNodeReplace = null;
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo), treeNodeReplace, ref gotoFirstTrans);
if (gotoFirstTrans) //B2017-179 could not replace step, we are positioning onto the first transition that needs resolved
{
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo);

View File

@ -26,9 +26,7 @@ namespace Volian.Controls.Library
public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args);
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args);
public delegate bool vlnTreeViewItemInfoInsertEvent(object sender, vlnTreeItemInfoInsertEventArgs args);
public delegate bool vlnTreeViewItemInfoDeleteFolderEvent(object sender, vlnTreeFolderDeleteEventArgs args);
public delegate bool vlnTreeViewItemInfoPasteEvent(object sender, vlnTreeItemInfoPasteEventArgs args);
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
public delegate DialogResult vlnTreeViewPropertyEvent(object sender, vlnTreePropertyEventArgs args);
@ -222,15 +220,6 @@ namespace Volian.Controls.Library
}
#endregion
}
public class vlnTreeFolderDeleteEventArgs : EventArgs
{
public int FolderId { get; }
public vlnTreeFolderDeleteEventArgs(int folderId)
{
FolderId = folderId;
}
}
public enum E_InsertType {Before, After, Child};
public partial class vlnTreeItemInfoInsertEventArgs
{
@ -438,12 +427,6 @@ namespace Volian.Controls.Library
if (DeleteItemInfo != null) return DeleteItemInfo(sender, args);
return false;
}
public event vlnTreeViewItemInfoDeleteFolderEvent DeleteFolder;
private bool OnDeleteFolder(object sender, vlnTreeFolderDeleteEventArgs args)
{
if (DeleteItemInfo != null) return DeleteFolder(sender, args);
return false;
}
public event vlnTreeViewItemInfoInsertEvent InsertItemInfo;
private bool OnInsertItemInfo(object sender, vlnTreeItemInfoInsertEventArgs args)
{
@ -568,11 +551,6 @@ namespace Volian.Controls.Library
{
if (ProcedureCheckedOutTo != null) ProcedureCheckedOutTo(sender, args);
}
public event vlnTreeViewEvent ExportImportProcedureSets;
private void OnExportImportProcedureSets(object sender, vlnTreeEventArgs args)
{
@ -1081,11 +1059,6 @@ namespace Volian.Controls.Library
#region Menu_Delete
if (ok)
{
// Add delete to the menu unless at the very 'top' node, on a grouping (partinfo)
// node (RNOs, Steps, Cautions, Notes) or Folder/DocVersion that contains any items.
@ -1109,7 +1082,6 @@ namespace Volian.Controls.Library
}
}
}
#endregion
//_MyLog.WarnFormat("Context Menu 6 - {0}", GC.GetTotalMemory(true));
#region Menu_ExternalTransitions
@ -1740,13 +1712,10 @@ namespace Volian.Controls.Library
// 1) 'to' & 'from' both 'non', i.e. Neither can have enhanced config data (be source or enhanced)
// can do Before/After/Replace
// 2) 'to' section is 'source' and 'from' section is 'non' (has no MyEnhancedDocuments)
// can do Before/After - no links exist in pasted section so cannot do Replace
// can do Before/After - no links exist in pasted section.
// cannot do Replace
// 3) 'to' section is 'source' and 'from' section is same docversion 'source'
// can do Before/After (B2024-038 removes replace)
// 4) 'to' section is not 'source' and 'from' section is source
// can do Before/After but not replace - would have to manage
// links for 'from' section (B2024-038 added this case)
// can do Before/After/Replace
SectionConfig secToCfg = iiPasteHere.MyConfig as SectionConfig;
SectionConfig secFromCfg = iiClipboard.MyConfig as SectionConfig;
@ -1761,16 +1730,7 @@ namespace Volian.Controls.Library
secCanPaste = true;
okToReplace = false;
}
else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID)
{
secCanPaste = true; // 3)
okToReplace = false;
}
else if (!secToIsSource && secFromIsSource)
{
secCanPaste = true; // 4
okToReplace = false;
}
else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) secCanPaste = true; // 3)
if (iiClipboard.IsRtfRaw) secCanPaste = okToReplace = false; // never paste an equation.
if (secCanPaste) cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click));
if (okToReplace && secCanPaste) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
@ -1980,16 +1940,6 @@ namespace Volian.Controls.Library
OnPrintTransitionReport(this, new vlnTreeEventArgs(SelectedNode as VETreeNode));
return;
}
if (mi.Text == "Export Procedure Set" || mi.Text == "Export Procedure")
{
OnExportImportProcedureSets(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0));
@ -2458,7 +2408,7 @@ namespace Volian.Controls.Library
}
}
VETreeNode tn = SelectedNode as VETreeNode;
TreeNode treeNodeReplace = SelectedNode.Parent; //Get Tree Node of Parent we are proc we are placing into.
DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
// Check for paste into a docversion - queries/code is different than paste related to an item (into a proc or section)
if (dvi != null)
@ -2495,27 +2445,11 @@ namespace Volian.Controls.Library
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
else if (p.IndexOf("Replace") > -1)
{
bool OnlyProc = iiPaste.IsProcedure && iiPaste.MyPrevious == null && (iiPaste.NextItems == null || iiPaste.NextItems.Count == 0);
VETreeNode tmp = null;
if (OnlyProc)
{
VETreeNode tnp = SelectedNode as VETreeNode;
tmp = tnp == null ? null : tnp.Parent as VETreeNode;
}
ItemInfo repitem = PasteReplace(tn, iiClipboard.ItemID);
// B2024-045, 049 and 050: The treenode was passed into the business object's replace but sometimes it was null. And this
// wasn't working if it was a single procedure in a working Draft. Adjust the tree here if single procedure in working draft.
if (OnlyProc && repitem != null && tmp != null)
{
VETreeNode tn1 = new VETreeNode(repitem);
tmp.Nodes.Add(tn1);
SelectedNode = tn1;
}
PasteReplace(tn, iiClipboard.ItemID, treeNodeReplace);
}
else // paste as child
PasteAsChild(tn, iiClipboard.ItemID);
//if (p.IndexOf("Replace") <= -1)
this.Cursor = Cursors.Default;
}
@ -2607,19 +2541,18 @@ namespace Volian.Controls.Library
}
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
}
private ItemInfo PasteReplace(VETreeNode tn, int copyStartID)
private void PasteReplace(VETreeNode tn, int copyStartID, TreeNode treeNodeReplace)
{
VETreeNode prevtn = (VETreeNode) tn.PrevNode;
VETreeNode partn = (VETreeNode) tn.Parent;
ItemInfo ii = tn.VEObject as ItemInfo;
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(copyStartID, ii, true);
ItemInfo replItemInfo = null;
if (!OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, ItemInfo.EAddpingPart.Replace, ii.MyContent.Type)))
{
// first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId, treeNodeReplace);
StepConfig replItemConfig = ii.MyConfig as StepConfig;
if (replItemInfo != null)
@ -2629,7 +2562,7 @@ namespace Volian.Controls.Library
}
// B2018-047: was crashing on the following line (before change it was casting the result to a VETreeNote when the partn.FirstNode was just a TreeNode)
SelectedNode = prevtn != null ? prevtn.NextNode : partn.FirstNode;
return replItemInfo;
}
public void PasteRepalceEmpty(VETreeNode tn, int copyStartID)
@ -3634,41 +3567,6 @@ namespace Volian.Controls.Library
}
return false;
}
public void RemoveFolder(int folderId)
{
TreeNode nodeToRemove = FindNodeById(folderId, this.Nodes);
if (nodeToRemove != null)
{
// Perform the removal logic
nodeToRemove.Remove(); // This removes the node from its parent
}
}
private TreeNode FindNodeById(int folderId, TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
VETreeNode vetNode = node as VETreeNode;
if (vetNode != null)
{
FolderInfo folderInfo = vetNode.VEObject as FolderInfo;
if (folderInfo != null && folderInfo.FolderID == folderId)
{
return node;
}
else
{
TreeNode foundNode = FindNodeById(folderId, node.Nodes);
if (foundNode != null)
{
return foundNode;
}
}
}
}
return null;
}
private bool DeleteItemInfoAndChildren(ItemInfo ii)
{
DateTime dtStart = DateTime.Now;