C20240-005 - Deleting Folder additions

This commit is contained in:
Kevin Laskey 2024-07-29 15:57:54 -04:00
parent 6e6abbd759
commit 4644699df0
7 changed files with 416 additions and 323 deletions

View File

@ -23519,6 +23519,90 @@ GO
========================================================================================================== ==========================================================================================================
*/ */
/*
==========================================================================================================
Start: C2024-005: 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: C2024-005: SQL to delete folders using admin tool
==========================================================================================================
*/
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
| ADD New Code Before this Block | | ADD New Code Before this Block |
@ -23552,8 +23636,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255) DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255) DECLARE @RevDescription varchar(255)
set @RevDate = '07/18/2024 11:24' set @RevDate = '07/29/2024 11:24'
set @RevDescription = 'C2024-005 Add an Admin tool that can delete a group of annotations.' set @RevDescription = 'C2024-005 Add SQL for Admin tool delete folders.'
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

View File

@ -530,7 +530,6 @@
this.superTooltip1.SetSuperTooltip(this.labelX13, new DevComponents.DotNetBar.SuperTooltipInfo("Check RO Links", "", resources.GetString("labelX13.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(350, 175))); this.superTooltip1.SetSuperTooltip(this.labelX13, new DevComponents.DotNetBar.SuperTooltipInfo("Check RO Links", "", resources.GetString("labelX13.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(350, 175)));
this.labelX13.TabIndex = 38; this.labelX13.TabIndex = 38;
this.labelX13.Text = "Delete Folders"; this.labelX13.Text = "Delete Folders";
this.labelX13.Visible = false;
// //
// swDeleteAnnotations // swDeleteAnnotations
// //

View File

@ -24,10 +24,14 @@ namespace VEPROMS
private bool IsAdministratorUser = false; //C2020-035 used to control what Set Amins can do private bool IsAdministratorUser = false; //C2020-035 used to control what Set Amins can do
// C2017-030 - new Admin Tools user interface // C2017-030 - new Admin Tools user interface
// pass in session info to constructor // pass in session info to constructor
public frmBatchRefresh(SessionInfo sessionInfo)
private frmVEPROMS _veProms;
public frmBatchRefresh(SessionInfo sessionInfo, frmVEPROMS veProms)
{ {
InitializeComponent(); InitializeComponent();
_MySessionInfo = sessionInfo; _MySessionInfo = sessionInfo;
_veProms = veProms;
if (sideNavItmDelete.Checked) if (sideNavItmDelete.Checked)
{ {
@ -156,44 +160,16 @@ namespace VEPROMS
if (fi.ChildFolderCount > 0) if (fi.ChildFolderCount > 0)
{ {
if (noProcs) TreeNode tn = new TreeNode(fi.Name);
{ tn.Tag = fi;
LoadFolders(fi, myTVdel, null); tn.StateImageIndex = -1; // Hide the checkbox for the root node
} LoadChildFolders(fi, tn, noProcs);
else myTVdel.Nodes.Add(tn);
{
TreeNode tn = new TreeNode(fi.Name);
tn.Tag = fi;
tn.StateImageIndex = -1; // Hide the checkbox for the root node
LoadChildFolders(fi, tn, noProcs);
myTVdel.Nodes.Add(tn);
}
} }
if (myTVdel.SelectedNode != null) if (myTVdel.SelectedNode != null)
myTVdel.SelectedNode.Expand(); myTVdel.SelectedNode.Expand();
this.Cursor = Cursors.Default; 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 // B2021-060 Higher level folders where being removed from the tree even if there was a child folder that containe a working draft set
@ -222,100 +198,6 @@ namespace VEPROMS
tn.Remove(); tn.Remove();
return loadedWorkingDraft; return loadedWorkingDraft;
} }
/// <summary>
/// Load only folders into treeview
/// </summary>
private void LoadFolders(FolderInfo fi, TreeView treeView, TreeNode parentNode)
{
foreach (FolderInfo fic in fi.SortedChildFolders)
{
TreeNode tnc = treeView.Nodes.Add(fic.Name);
tnc.Tag = fic;
if (fic.ChildFolderCount > 0)
{
// Recursively call for child folders
LoadFolders(fic, treeView, tnc);
}
else
{
if (fic.Name != "PROMS")
{
// If the folder is a bottom-level folder (no child folders), add it directly to the TreeView
//Working
//foreach (DocVersionInfo dvi in fic.FolderDocVersions)
//{
// myDocVersions.Add(tnc, dvi);
//}
// If parentNode is null, add to the root of the tree
if (parentNode == null)
{
// If the folder is a bottom-level folder (no child folders), add it directly to the TreeView
treeView.Nodes.Add(tnc);
foreach (DocVersionInfo dvi in fic.FolderDocVersions)
{
myDocVersions.Add(tnc, dvi);
}
}
else
{
// Otherwise, add to the parent node
parentNode.Nodes.Add(fic.Name);
foreach (DocVersionInfo dvi in fic.FolderDocVersions)
{
myDocVersions.Add(tnc, dvi);
}
}
}
}
}
//foreach (FolderInfo fic in fi.SortedChildFolders)
//{
// // Skip "PROMS" folder
// if (fic.Name == "PROMS")
// {
// continue;
// }
// //// Create a new tree node for the current folder
// TreeNode tnc = new TreeNode(fic.Name) { Tag = fic };
// // If parentNode is null, add to the root of the tree
// if (parentNode == null)
// {
// // If the folder is a bottom-level folder (no child folders), add it directly to the TreeView
// treeView.Nodes.Add(tnc);
// foreach (DocVersionInfo dvi in fic.FolderDocVersions)
// {
// myDocVersions.Add(tnc, dvi);
// }
// }
// else
// {
// // Otherwise, add to the parent node
// //parentNode.Nodes.Add(tnc);
// // If the folder is a bottom-level folder (no child folders), add it directly to the TreeView
// parentNode.Nodes.Add(fic.Name);
// foreach (DocVersionInfo dvi in fic.FolderDocVersions)
// {
// myDocVersions.Add(tnc, dvi);
// }
// }
// // Recursively call for child folders
// if (fic.ChildFolderCount > 0)
// {
// LoadFolders(fic, treeView, tnc);
// }
//}
}
private bool LoadDocVersions(FolderInfo fic, TreeNode tnc, bool noProcs) private bool LoadDocVersions(FolderInfo fic, TreeNode tnc, bool noProcs)
{ {
bool rtnval = false; bool rtnval = false;
@ -1750,21 +1632,27 @@ namespace VEPROMS
if (swDeleteFolder.Value) if (swDeleteFolder.Value)
{ {
//TODO process deletions of folders
txtProcess.AppendText("Deleting Folders...");
//List<ProcedureInfo> pil = new List<ProcedureInfo>(); if (FlexibleMessageBox.Show(this, "You sure you want to remove the selected folders and their contents?", "Confirm Folder Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
//foreach (TreeNode tn in myProcedures.Keys) {
// if (tn.Checked)
// pil.Add(myProcedures[tn]);
////Load Selected Folders
List<DocVersionInfo> dvil = new List<DocVersionInfo>();
foreach (TreeNode tn in myDocVersions.Keys)
if (tn.Checked)
dvil.Add(myDocVersions[tn]);
ProcessDelete(dvil); //TODO process deletions of folders
txtProcess.AppendText("Deleting Folders...");
//List<ProcedureInfo> pil = new List<ProcedureInfo>();
//foreach (TreeNode tn in myProcedures.Keys)
// if (tn.Checked)
// pil.Add(myProcedures[tn]);
////Load Selected Folders
List<DocVersionInfo> dvil = new List<DocVersionInfo>();
foreach (TreeNode tn in myDocVersions.Keys)
if (tn.Checked)
dvil.Add(myDocVersions[tn]);
ProcessDelete(dvil);
}
} }
else else
{ {
@ -1800,11 +1688,13 @@ namespace VEPROMS
foreach (var kvp in foldersToDelete) foreach (var kvp in foldersToDelete)
{ {
int itemID = (int)kvp.ItemID; //Gather folder information
string folderName = kvp.Name;
FolderInfo fi = (FolderInfo)kvp.ActiveParent;
int itemID = (int)fi.FolderID;
string folderName = fi.Name;
// Perform the deletion operation // Perform the deletion operation
// Assume DeleteFolderByID is a method that deletes the folder by its ItemID
bool deletionSuccessful = DeleteFolderByID(itemID); bool deletionSuccessful = DeleteFolderByID(itemID);
// Update txtProcess with the progress // Update txtProcess with the progress
@ -1818,13 +1708,29 @@ namespace VEPROMS
} }
txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);
} }
//Run Repair
PurgeDisconnectedItems(); // Orphan Items
//rebuild
ResetDelTV(true);
} }
// Example deletion method private bool DeleteFolderByID(int folderID)
private bool DeleteFolderByID(int itemID)
{ {
// Implement your folder deletion logic here try
// Return true if deletion was successful, false otherwise {
return true; // Placeholder //Delete
Folder.DeleteFolderAdmin(folderID);
//update treeview UI via veProms
_veProms.tv_FolderDelete(folderID);
return true;
}
catch
{
return false;
}
} }
public List<ProcedureInfo> RetrieveChkAnnotations() public List<ProcedureInfo> RetrieveChkAnnotations()

View File

@ -216,6 +216,8 @@ namespace VEPROMS
set { _MyDocVersion = value; } set { _MyDocVersion = value; }
} }
// C2015-022 setup the child PROMS window // C2015-022 setup the child PROMS window
public frmVEPROMS(frmVEPROMS myParent, DocVersionInfo myDocVersion) public frmVEPROMS(frmVEPROMS myParent, DocVersionInfo myDocVersion)
{ {
@ -254,6 +256,22 @@ namespace VEPROMS
tc.RefreshItem(myItemInfo); 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; private E_UCFImportOptions _UCFImportOptionsFromSettings;
public frmVEPROMS() public frmVEPROMS()
@ -475,6 +493,7 @@ namespace VEPROMS
tv.OpenItem += new vlnTreeViewItemInfoEvent(tv_OpenItem); tv.OpenItem += new vlnTreeViewItemInfoEvent(tv_OpenItem);
tv.TabDisplay += new StepPanelTabDisplayEvent(tc_PanelTabDisplay); tv.TabDisplay += new StepPanelTabDisplayEvent(tc_PanelTabDisplay);
tv.DeleteItemInfo += new vlnTreeViewItemInfoDeleteEvent(tv_DeleteItemInfo); tv.DeleteItemInfo += new vlnTreeViewItemInfoDeleteEvent(tv_DeleteItemInfo);
tv.DeleteFolder += new vlnTreeViewItemInfoDeleteFolderEvent(Tv_DeleteFolder);
tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo); tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo);
tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert); tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert);
tv.PasteItemInfo += new vlnTreeViewItemInfoPasteEvent(tv_PasteItemInfo); tv.PasteItemInfo += new vlnTreeViewItemInfoPasteEvent(tv_PasteItemInfo);
@ -1603,6 +1622,11 @@ namespace VEPROMS
return rtval; return rtval;
} }
private bool tv_DeleteFolder(object sender, vlnTreeItemInfoEventArgs args)
{
return true;
}
private bool tv_PasteItemInfo(object sender, vlnTreeItemInfoPasteEventArgs args) private bool tv_PasteItemInfo(object sender, vlnTreeItemInfoPasteEventArgs args)
{ {
return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type); return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type);
@ -2741,7 +2765,7 @@ namespace VEPROMS
void btnAdministrativeTools_Click(object sender, EventArgs e) void btnAdministrativeTools_Click(object sender, EventArgs e)
{ {
frmBatchRefresh frm = new frmBatchRefresh(MySessionInfo); frmBatchRefresh frm = new frmBatchRefresh(MySessionInfo, this);
frm.ProgressBar = bottomProgBar; frm.ProgressBar = bottomProgBar;
frm.ShowDialog(this); frm.ShowDialog(this);
} }

View File

@ -1433,6 +1433,31 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Folder.Remove", ex); 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 #endregion
#region Exists #region Exists
public static bool Exists(int folderID) public static bool Exists(int folderID)
@ -1536,6 +1561,8 @@ namespace VEPROMS.CSLA.Library
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
} }
#endregion #endregion
} // Class } // Class
#region Converter #region Converter

View File

@ -167,7 +167,9 @@ namespace VEPROMS.CSLA.Library
tn.ResetNode("Dummy GetFolder"); tn.ResetNode("Dummy GetFolder");
return tn; return tn;
} }
// public abstract void LoadChildren();
// public abstract void LoadChildren();
//private long _Start; //private long _Start;
//private Dictionary<string, long> _Timings=new Dictionary<string,long>(); //private Dictionary<string, long> _Timings=new Dictionary<string,long>();
//private void tReset() //private void tReset()

View File

@ -22,10 +22,11 @@ namespace Volian.Controls.Library
public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args); public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args);
public delegate void vlnTreeViewTimeEvent(object sender, vlnTreeTimeEventArgs args); public delegate void vlnTreeViewTimeEvent(object sender, vlnTreeTimeEventArgs args);
public delegate void vlnTreeViewStatusEvent(object sender, vlnTreeStatusEventArgs args); public delegate void vlnTreeViewStatusEvent(object sender, vlnTreeStatusEventArgs args);
public delegate ItemInfo vlnTreeViewClipboardStatusEvent(object sender, vlnTreeEventArgs args); public delegate ItemInfo vlnTreeViewClipboardStatusEvent(object sender, vlnTreeEventArgs args);
public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args); public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args);
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args); public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args); public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args);
public delegate bool vlnTreeViewItemInfoDeleteFolderEvent(object sender, vlnTreeFolderDeleteEventArgs args);
public delegate bool vlnTreeViewItemInfoInsertEvent(object sender, vlnTreeItemInfoInsertEventArgs args); public delegate bool vlnTreeViewItemInfoInsertEvent(object sender, vlnTreeItemInfoInsertEventArgs args);
public delegate bool vlnTreeViewItemInfoPasteEvent(object sender, vlnTreeItemInfoPasteEventArgs args); public delegate bool vlnTreeViewItemInfoPasteEvent(object sender, vlnTreeItemInfoPasteEventArgs args);
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args); public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
@ -220,6 +221,15 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
} }
public class vlnTreeFolderDeleteEventArgs : EventArgs
{
public int FolderId { get; }
public vlnTreeFolderDeleteEventArgs(int folderId)
{
FolderId = folderId;
}
}
public enum E_InsertType {Before, After, Child}; public enum E_InsertType {Before, After, Child};
public partial class vlnTreeItemInfoInsertEventArgs public partial class vlnTreeItemInfoInsertEventArgs
{ {
@ -427,6 +437,12 @@ namespace Volian.Controls.Library
if (DeleteItemInfo != null) return DeleteItemInfo(sender, args); if (DeleteItemInfo != null) return DeleteItemInfo(sender, args);
return false; 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; public event vlnTreeViewItemInfoInsertEvent InsertItemInfo;
private bool OnInsertItemInfo(object sender, vlnTreeItemInfoInsertEventArgs args) private bool OnInsertItemInfo(object sender, vlnTreeItemInfoInsertEventArgs args)
{ {
@ -551,11 +567,11 @@ namespace Volian.Controls.Library
{ {
if (ProcedureCheckedOutTo != null) ProcedureCheckedOutTo(sender, args); if (ProcedureCheckedOutTo != null) ProcedureCheckedOutTo(sender, args);
} }
public event vlnTreeViewEvent ExportImportProcedureSets; public event vlnTreeViewEvent ExportImportProcedureSets;
private void OnExportImportProcedureSets(object sender, vlnTreeEventArgs args) private void OnExportImportProcedureSets(object sender, vlnTreeEventArgs args)
{ {
if (ExportImportProcedureSets != null) ExportImportProcedureSets(sender, args); if (ExportImportProcedureSets != null) ExportImportProcedureSets(sender, args);
} }
public event vlnTreeViewEvent PrintTransitionReport; public event vlnTreeViewEvent PrintTransitionReport;
private void OnPrintTransitionReport(object sender, vlnTreeEventArgs args) private void OnPrintTransitionReport(object sender, vlnTreeEventArgs args)
{ {
@ -693,11 +709,11 @@ namespace Volian.Controls.Library
//_MyLog.WarnFormat("Context Menu 1b - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1b - {0}", GC.GetTotalMemory(true));
if (ui.IsAdministrator() || ui.IsSetAdministrator(fi)) if (ui.IsAdministrator() || ui.IsSetAdministrator(fi))
{ {
if (fi.MyParent != null) // don't allow insert before/after if at top node if (fi.MyParent != null) // don't allow insert before/after if at top node
{ {
if (!ui.IsAdministrator() && DoSpecificInfo) cm.MenuItems.Add("Procedure Set Specific Information", new EventHandler(mi_Click)); if (!ui.IsAdministrator() && DoSpecificInfo) cm.MenuItems.Add("Procedure Set Specific Information", new EventHandler(mi_Click));
// B2020-111 only allow Set Administrator to add new folders inside folders they admininstrate // B2020-111 only allow Set Administrator to add new folders inside folders they admininstrate
if (ui.IsAdministrator()||ui.IsSetAdministrator(fi.MyParent)) if (ui.IsAdministrator() || ui.IsSetAdministrator(fi.MyParent))
{ {
cm.MenuItems.Add("Insert Folder Before", new EventHandler(mi_Click)); cm.MenuItems.Add("Insert Folder Before", new EventHandler(mi_Click));
cm.MenuItems.Add("Insert Folder After", new EventHandler(mi_Click)); cm.MenuItems.Add("Insert Folder After", new EventHandler(mi_Click));
@ -712,16 +728,16 @@ namespace Volian.Controls.Library
if (fi.HasWorkingDraft) if (fi.HasWorkingDraft)
cm.MenuItems.Add("Print Transition Report", new EventHandler(mi_Click)); cm.MenuItems.Add("Print Transition Report", new EventHandler(mi_Click));
} }
else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs
{ {
isWrkDftNode = true; isWrkDftNode = true;
//_MyLog.WarnFormat("Context Menu 1c - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1c - {0}", GC.GetTotalMemory(true));
DocVersionInfo dvi = tn.VEObject as DocVersionInfo; DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi)) if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi))
{ {
cm.MenuItems.Add("Import Procedure", mi_Click); cm.MenuItems.Add("Import Procedure", mi_Click);
} }
if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi) || ui.IsWriter(dvi)) if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi) || ui.IsWriter(dvi))
{ {
OwnerInfoList.Reset(); OwnerInfoList.Reset();
oil = OwnerInfoList.GetByVersionID(dvi.VersionID); oil = OwnerInfoList.GetByVersionID(dvi.VersionID);
@ -812,15 +828,15 @@ namespace Volian.Controls.Library
urv.Enabled = !dvi.ROfstLastCompleted || dvi.NewerRoFst; urv.Enabled = !dvi.ROfstLastCompleted || dvi.NewerRoFst;
} }
} }
else if (tn.VEObject as ProcedureInfo != null) // Procs can only contain sections else if (tn.VEObject as ProcedureInfo != null) // Procs can only contain sections
{ {
isProcNode = true; isProcNode = true;
ProcedureInfo pri = tn.VEObject as ProcedureInfo; ProcedureInfo pri = tn.VEObject as ProcedureInfo;
oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure); oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure);
if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion)) if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion))
{ {
cm.MenuItems.Add("Export Procedure", mi_Click); cm.MenuItems.Add("Export Procedure", mi_Click);
} }
if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion) || ui.IsWriter(pri.MyDocVersion)) if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion) || ui.IsWriter(pri.MyDocVersion))
{ {
if (oi != null && oi.SessionID != MySessionInfo.SessionID) if (oi != null && oi.SessionID != MySessionInfo.SessionID)
@ -1052,36 +1068,36 @@ namespace Volian.Controls.Library
ok = true; ok = true;
else if (tn.VEObject is ItemInfo && (ui.IsAdministrator() || ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion) || ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion))) else if (tn.VEObject is ItemInfo && (ui.IsAdministrator() || ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion) || ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion)))
ok = true; ok = true;
if(ok) if (ok)
Menu_Paste(tn, cm); Menu_Paste(tn, cm);
#endregion #endregion
//_MyLog.WarnFormat("Context Menu 5 - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 5 - {0}", GC.GetTotalMemory(true));
#region Menu_Delete #region Menu_Delete
if (ok) 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.
PartInfo pi = tn.VEObject as PartInfo;
if (pi == null && tn.Parent != null) // it's not a part and it's not the top....
{ {
// Add delete to the menu unless at the very 'top' node, on a grouping (partinfo) fi = tn.VEObject as FolderInfo;
// node (RNOs, Steps, Cautions, Notes) or Folder/DocVersion that contains any items. if (fi == null || tn.Nodes.Count == 0) // it's not a folder or it has no children
PartInfo pi = tn.VEObject as PartInfo;
if (pi == null && tn.Parent != null) // it's not a part and it's not the top....
{ {
fi = tn.VEObject as FolderInfo; DocVersionInfo di = tn.VEObject as DocVersionInfo;
if (fi == null || tn.Nodes.Count == 0) // it's not a folder or it has no children if (di == null || tn.Nodes.Count == 0) // it's not a docversion or it has no children
{ {
DocVersionInfo di = tn.VEObject as DocVersionInfo; // if it's an enhanced step that was linked from a source, don't allow delete
if (di == null || tn.Nodes.Count == 0) // it's not a docversion or it has no children bool canDoDel = true;
{ ItemInfo iienh = tn.VEObject as ItemInfo;
// if it's an enhanced step that was linked from a source, don't allow delete if (iienh != null && iienh.IsProcedure && iienh.IsEnhancedProcedure) canDoDel = false;
bool canDoDel = true; if (iienh != null && iienh.IsSection && iienh.IsEnhancedSection && !iienh.IsEnhancedSectionTitleOnly) canDoDel = false;
ItemInfo iienh = tn.VEObject as ItemInfo; if (iienh != null && iienh.IsEnhancedStep) canDoDel = false;
if (iienh != null && iienh.IsProcedure && iienh.IsEnhancedProcedure) canDoDel = false; if (canDoDel) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
if (iienh != null && iienh.IsSection && iienh.IsEnhancedSection && !iienh.IsEnhancedSectionTitleOnly) canDoDel = false;
if (iienh != null && iienh.IsEnhancedStep) canDoDel = false;
if (canDoDel) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
}
} }
} }
} }
}
#endregion #endregion
//_MyLog.WarnFormat("Context Menu 6 - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 6 - {0}", GC.GetTotalMemory(true));
#region Menu_ExternalTransitions #region Menu_ExternalTransitions
@ -1117,13 +1133,13 @@ namespace Volian.Controls.Library
} }
doclink = string.Format("Unlink Source and {0} Procedure", doclink); doclink = string.Format("Unlink Source and {0} Procedure", doclink);
MenuItem mix = cm.MenuItems.Add(doclink, new EventHandler(miEnhanced_Click)); MenuItem mix = cm.MenuItems.Add(doclink, new EventHandler(miEnhanced_Click));
mix.Tag = -1; // NOTE this is what flags what gets processed on menu click, i.e. -1 mix.Tag = -1; // NOTE this is what flags what gets processed on menu click, i.e. -1
} }
// if this is a source procedure that has enhanced, for example Background and/or deviation, ask which should be unlinked including all // if this is a source procedure that has enhanced, for example Background and/or deviation, ask which should be unlinked including all
else if (eds != null && eds.Count > 1) else if (eds != null && eds.Count > 1)
{ {
MenuItem miu = new MenuItem("Unlink Enhanced Procedure(s) from Source"); MenuItem miu = new MenuItem("Unlink Enhanced Procedure(s) from Source");
miu.Tag = -2; // this menu item doesn't get used. miu.Tag = -2; // this menu item doesn't get used.
int k = 0; int k = 0;
foreach (EnhancedDocument ed in eds) foreach (EnhancedDocument ed in eds)
{ {
@ -1134,7 +1150,7 @@ namespace Volian.Controls.Library
} }
// add all submenu item // add all submenu item
MenuItem mp1 = miu.MenuItems.Add("All", new EventHandler(miEnhanced_Click)); MenuItem mp1 = miu.MenuItems.Add("All", new EventHandler(miEnhanced_Click));
mp1.Tag = 0; // Tag of 0 flags All mp1.Tag = 0; // Tag of 0 flags All
cm.MenuItems.Add(miu); cm.MenuItems.Add(miu);
} }
} }
@ -1144,8 +1160,8 @@ namespace Volian.Controls.Library
// Add Properties to the menu unless at the very 'top' node or on a grouping (partinfo) // Add Properties to the menu unless at the very 'top' node or on a grouping (partinfo)
// node (RNOs, Steps, Cautions, Notes) or at the step level. // node (RNOs, Steps, Cautions, Notes) or at the step level.
// B2020-105 Allow Set Administrators to rename folder's (sets of procedures) to which they have been given access. // B2020-105 Allow Set Administrators to rename folder's (sets of procedures) to which they have been given access.
if ( tn.VEObject is FolderInfo) ok = (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as FolderInfo)); if (tn.VEObject is FolderInfo) ok = (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as FolderInfo));
else ok = (tn.VEObject is DocVersionInfo) ? (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as DocVersionInfo)) else ok = (tn.VEObject is DocVersionInfo) ? (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as DocVersionInfo))
: (ui.IsAdministrator() || (tn.VEObject is ItemInfo) && (ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion) : (ui.IsAdministrator() || (tn.VEObject is ItemInfo) && (ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion)
|| ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion))); || ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion)));
PartInfo pia = tn.VEObject as PartInfo; PartInfo pia = tn.VEObject as PartInfo;
@ -1256,7 +1272,7 @@ namespace Volian.Controls.Library
// F2022-024 added Time Critical Action Summary option // F2022-024 added Time Critical Action Summary option
foreach (MenuItem itm in cm.MenuItems) foreach (MenuItem itm in cm.MenuItems)
{ {
if(itm.Text == "Procedure Specific Information" || itm.Text == "New Section" || itm.Text == "Approve" || itm.Text == "Open" || if (itm.Text == "Procedure Specific Information" || itm.Text == "New Section" || itm.Text == "Approve" || itm.Text == "Open" ||
itm.Text == "Copy" || itm.Text == "Delete" || itm.Text == "Properties..." || itm.Text == "Replace Existing Procedure" || itm.Text == "Copy" || itm.Text == "Delete" || itm.Text == "Properties..." || itm.Text == "Replace Existing Procedure" ||
itm.Text.StartsWith("Showing Change Bars Starting") || itm.Text == "Create Continuous Action Summary" || itm.Text.StartsWith("Showing Change Bars Starting") || itm.Text == "Create Continuous Action Summary" ||
itm.Text == "Create Time Critical Action Summary" || itm.Text == "Export Procedure") itm.Text == "Create Time Critical Action Summary" || itm.Text == "Export Procedure")
@ -1267,7 +1283,7 @@ namespace Volian.Controls.Library
{ {
foreach (MenuItem itm in cm.MenuItems) foreach (MenuItem itm in cm.MenuItems)
{ {
if(!itm.Text.StartsWith("Document Checked Out")) if (!itm.Text.StartsWith("Document Checked Out"))
itm.Enabled = false; itm.Enabled = false;
} }
} }
@ -1284,7 +1300,7 @@ namespace Volian.Controls.Library
{ {
_currentPri = pri; _currentPri = pri;
RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID); RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID);
if (ril.Count == 0) return; // no versions to list if (ril.Count == 0) return; // no versions to list
MenuItem mi = menuItemCollection.Add("Versions"); MenuItem mi = menuItemCollection.Add("Versions");
int k = 0; int k = 0;
int lastApprovedRevisionID = 0; int lastApprovedRevisionID = 0;
@ -1331,11 +1347,11 @@ namespace Volian.Controls.Library
ril = null; ril = null;
} }
} }
public void AddNewNode(IVEDrillDownReadOnly o) public void AddNewNode(IVEDrillDownReadOnly o)
{ {
VETreeNode tn = new VETreeNode(o); VETreeNode tn = new VETreeNode(o);
SelectedNode.Nodes.Add(tn); SelectedNode.Nodes.Add(tn);
} }
private void AddApprovedRevisions(Menu.MenuItemCollection menuItemCollection, ProcedureInfo pri) private void AddApprovedRevisions(Menu.MenuItemCollection menuItemCollection, ProcedureInfo pri)
{ {
try try
@ -1344,7 +1360,7 @@ namespace Volian.Controls.Library
_currentPri = pri; _currentPri = pri;
using (RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID)) using (RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID))
{ {
//_MyLog.WarnFormat("Context Menu 1 After GET - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1 After GET - {0}", GC.GetTotalMemory(true));
if (ril.Count == 0) return; // no versions to list if (ril.Count == 0) return; // no versions to list
MenuItem mi = menuItemCollection.Add("Versions"); MenuItem mi = menuItemCollection.Add("Versions");
int lastApprovedRevisionID = 0; int lastApprovedRevisionID = 0;
@ -1425,7 +1441,7 @@ namespace Volian.Controls.Library
RevisionConfig rc = ri.MyConfig as RevisionConfig; RevisionConfig rc = ri.MyConfig as RevisionConfig;
// bug fix: B2016-183 - add the child's name (ex Unit 1) to the export file name for Parent/Child procedures. // bug fix: B2016-183 - add the child's name (ex Unit 1) to the export file name for Parent/Child procedures.
int applIdx = rc.Applicability_Index; int applIdx = rc.Applicability_Index;
string str = (applIdx > 0)?_currentPri.MyDocVersion.UnitNames[applIdx-1] +"_":""; // if parent/child get the defined child name to inlcude the export filename string str = (applIdx > 0) ? _currentPri.MyDocVersion.UnitNames[applIdx - 1] + "_" : ""; // if parent/child get the defined child name to inlcude the export filename
System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(ri.LatestVersion.ApprovedXML); xd.LoadXml(ri.LatestVersion.ApprovedXML);
string PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; string PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database;
@ -1473,12 +1489,12 @@ namespace Volian.Controls.Library
{ {
MenuItem mip = mi.Parent as MenuItem; MenuItem mip = mi.Parent as MenuItem;
//B2021-086 Added the check for the last revision stage is an Approved stage //B2021-086 Added the check for the last revision stage is an Approved stage
if ((ri.RevisionID < int.Parse(mip.Parent.Tag.ToString())) && ri.LatestVersion.MyStage.IsApproved!=0) if ((ri.RevisionID < int.Parse(mip.Parent.Tag.ToString())) && ri.LatestVersion.MyStage.IsApproved != 0)
superceded = true; superceded = true;
} }
vlnTreeViewPdfArgs args = new vlnTreeViewPdfArgs(Volian.Base.Library.TmpFile.CreateFileName(ProcedureInfo.Get(ri.ItemID).PDFNumber), ri.LatestVersion.PDF, superceded ? "Superceded" : ""); vlnTreeViewPdfArgs args = new vlnTreeViewPdfArgs(Volian.Base.Library.TmpFile.CreateFileName(ProcedureInfo.Get(ri.ItemID).PDFNumber), ri.LatestVersion.PDF, superceded ? "Superceded" : "");
OnViewPDF(sender, args); OnViewPDF(sender, args);
// System.Diagnostics.Process pp = System.Diagnostics.Process.Start(GetDocPdf(ri, superceded)); // System.Diagnostics.Process pp = System.Diagnostics.Process.Start(GetDocPdf(ri, superceded));
} }
void MultiUnitApprovedRevision_Click(object sender, EventArgs e) void MultiUnitApprovedRevision_Click(object sender, EventArgs e)
{ {
@ -1591,7 +1607,7 @@ namespace Volian.Controls.Library
// 'from' is object copied // 'from' is object copied
// 'to' is object where paste was selected from // 'to' is object where paste was selected from
#region Menu_Paste_ToDocVersion #region Menu_Paste_ToDocVersion
if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc
{ {
if (iiClipboard.IsProcedure) if (iiClipboard.IsProcedure)
{ {
@ -1622,7 +1638,7 @@ namespace Volian.Controls.Library
if (iiClipboard.IsRtfRaw) canPaste = false; // never paste an equation. if (iiClipboard.IsRtfRaw) canPaste = false; // never paste an equation.
if (canPaste) cm.MenuItems.Add("Paste Procedure", new EventHandler(mi_Click)); if (canPaste) cm.MenuItems.Add("Paste Procedure", new EventHandler(mi_Click));
} }
#endregion #endregion
} }
else else
{ {
@ -1633,7 +1649,7 @@ namespace Volian.Controls.Library
{ {
SectionInfo si = (tn.VEObject as SectionInfo != null) ? tn.VEObject as SectionInfo : null; SectionInfo si = (tn.VEObject as SectionInfo != null) ? tn.VEObject as SectionInfo : null;
#region Menu_Paste_ToFromProcedure #region Menu_Paste_ToFromProcedure
if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after
{ {
// Enhanced considerations, in order to paste a procedure around another procedure: NOTE that an 'enhanced' procedure cannot be in paste buffer! // Enhanced considerations, in order to paste a procedure around another procedure: NOTE that an 'enhanced' procedure cannot be in paste buffer!
// 1) 'to' & 'from' both 'non', i.e. Neither can have enhanced config data (be source or enhanced) // 1) 'to' & 'from' both 'non', i.e. Neither can have enhanced config data (be source or enhanced)
@ -1657,16 +1673,16 @@ namespace Volian.Controls.Library
bool prFromIsEnhanced = iiClipboard.IsEnhancedProcedure; bool prFromIsEnhanced = iiClipboard.IsEnhancedProcedure;
bool prFromIsSource = pcFromCfg.MyEnhancedDocuments != null && pcFromCfg.MyEnhancedDocuments.Count > 0 && pcFromCfg.MyEnhancedDocuments[0].Type != 0; bool prFromIsSource = pcFromCfg.MyEnhancedDocuments != null && pcFromCfg.MyEnhancedDocuments.Count > 0 && pcFromCfg.MyEnhancedDocuments[0].Type != 0;
bool prCanPaste = false; bool prCanPaste = false;
if (!prToIsEnhanced && !prToIsSource && !prFromIsEnhanced && !prFromIsSource) prCanPaste = true; // 1) if (!prToIsEnhanced && !prToIsSource && !prFromIsEnhanced && !prFromIsSource) prCanPaste = true; // 1)
// else if ((!prToIsEnhanced && !prToIsSource) && prFromIsSource) prCanPaste = false; // 2) commented out because already set to false // else if ((!prToIsEnhanced && !prToIsSource) && prFromIsSource) prCanPaste = false; // 2) commented out because already set to false
else if (prToIsSource && !prFromIsEnhanced && !prFromIsSource) // 3) else if (prToIsSource && !prFromIsEnhanced && !prFromIsSource) // 3)
{ {
prCanPaste = true; prCanPaste = true;
okToReplace = false; okToReplace = false;
} }
else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) prCanPaste = true; // 4) else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) prCanPaste = true; // 4)
//else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID != iiClipboard.MyDocVersion.VersionID) prCanPaste = false; // 5) commented out because already set to false //else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID != iiClipboard.MyDocVersion.VersionID) prCanPaste = false; // 5) commented out because already set to false
//else if (prToIsEnhanced && prFromIsSource) prCanPaste = false; // 6)commented out because already set to false //else if (prToIsEnhanced && prFromIsSource) prCanPaste = false; // 6)commented out because already set to false
if (iiClipboard.IsRtfRaw) prCanPaste = okToReplace = prCanPaste = false; // never paste an equation. if (iiClipboard.IsRtfRaw) prCanPaste = okToReplace = prCanPaste = false; // never paste an equation.
if (prCanPaste) cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click)); if (prCanPaste) cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click));
if (okToReplace && prCanPaste) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click)); if (okToReplace && prCanPaste) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
@ -1698,9 +1714,9 @@ namespace Volian.Controls.Library
bool scFromIsEnhanced = iiClipboard.IsEnhancedSection; bool scFromIsEnhanced = iiClipboard.IsEnhancedSection;
bool scFromIsSource = scFromCfg.MyEnhancedDocuments != null && scFromCfg.MyEnhancedDocuments.Count > 0 && scFromCfg.MyEnhancedDocuments[0].Type != 0; bool scFromIsSource = scFromCfg.MyEnhancedDocuments != null && scFromCfg.MyEnhancedDocuments.Count > 0 && scFromCfg.MyEnhancedDocuments[0].Type != 0;
bool scCanPaste = false; bool scCanPaste = false;
if (!prToIsEnhanced && !prToIsSource && !scFromIsEnhanced && !scFromIsSource) scCanPaste = true; // 1) if (!prToIsEnhanced && !prToIsSource && !scFromIsEnhanced && !scFromIsSource) scCanPaste = true; // 1)
else if (prToIsSource && !scFromIsEnhanced && !scFromIsSource) scCanPaste = true; else if (prToIsSource && !scFromIsEnhanced && !scFromIsSource) scCanPaste = true;
else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) scCanPaste = true; // 3) else if (prToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) scCanPaste = true; // 3)
if (iiClipboard.IsRtfRaw) scCanPaste = false; // never paste an equation. if (iiClipboard.IsRtfRaw) scCanPaste = false; // never paste an equation.
if (scCanPaste) cm.MenuItems.Add("Paste Section", new EventHandler(mi_Click)); if (scCanPaste) cm.MenuItems.Add("Paste Section", new EventHandler(mi_Click));
} }
@ -1724,13 +1740,13 @@ namespace Volian.Controls.Library
bool secFromIsEnhanced = iiClipboard.IsEnhancedSection; bool secFromIsEnhanced = iiClipboard.IsEnhancedSection;
bool secFromIsSource = secFromCfg.MyEnhancedDocuments != null && secFromCfg.MyEnhancedDocuments.Count > 0 && secFromCfg.MyEnhancedDocuments[0].Type != 0; bool secFromIsSource = secFromCfg.MyEnhancedDocuments != null && secFromCfg.MyEnhancedDocuments.Count > 0 && secFromCfg.MyEnhancedDocuments[0].Type != 0;
bool secCanPaste = false; bool secCanPaste = false;
if (!secToIsEnhanced && !secToIsSource && !secFromIsEnhanced && !secFromIsSource) secCanPaste = true; // 1) if (!secToIsEnhanced && !secToIsSource && !secFromIsEnhanced && !secFromIsSource) secCanPaste = true; // 1)
else if (secToIsSource && !secFromIsEnhanced && !secFromIsSource) // 2) else if (secToIsSource && !secFromIsEnhanced && !secFromIsSource) // 2)
{ {
secCanPaste = true; secCanPaste = true;
okToReplace = false; okToReplace = false;
} }
else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) secCanPaste = true; // 3) else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) secCanPaste = true; // 3)
if (iiClipboard.IsRtfRaw) secCanPaste = okToReplace = false; // never paste an equation. if (iiClipboard.IsRtfRaw) secCanPaste = okToReplace = false; // never paste an equation.
if (secCanPaste) cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click)); 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)); if (okToReplace && secCanPaste) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
@ -1760,9 +1776,9 @@ namespace Volian.Controls.Library
bool stpFromIsEnhanced = iiClipboard.IsEnhancedStep; bool stpFromIsEnhanced = iiClipboard.IsEnhancedStep;
bool stpFromIsSource = stpFromCfg.MyEnhancedDocuments != null && stpFromCfg.MyEnhancedDocuments.Count > 0 && stpFromCfg.MyEnhancedDocuments[0].Type != 0; bool stpFromIsSource = stpFromCfg.MyEnhancedDocuments != null && stpFromCfg.MyEnhancedDocuments.Count > 0 && stpFromCfg.MyEnhancedDocuments[0].Type != 0;
bool stpCanPaste = false; bool stpCanPaste = false;
if (!secToIsEnhanced && !secToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 1) if (!secToIsEnhanced && !secToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 1)
else if (secToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 2) else if (secToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 2)
else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) stpCanPaste = true; // 3) else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) stpCanPaste = true; // 3)
if (iiClipboard.IsRtfRaw) stpCanPaste = false; // never paste an equation. if (iiClipboard.IsRtfRaw) stpCanPaste = false; // never paste an equation.
if (stpCanPaste) cm.MenuItems.Add("Paste Step", new EventHandler(mi_Click)); if (stpCanPaste) cm.MenuItems.Add("Paste Step", new EventHandler(mi_Click));
} }
@ -1786,8 +1802,8 @@ namespace Volian.Controls.Library
bool stpFromIsEnhanced = iiClipboard.IsEnhancedStep; bool stpFromIsEnhanced = iiClipboard.IsEnhancedStep;
bool stpFromIsSource = stpFromCfg.MyEnhancedDocuments != null && stpFromCfg.MyEnhancedDocuments.Count > 0 && stpFromCfg.MyEnhancedDocuments[0].Type != 0; bool stpFromIsSource = stpFromCfg.MyEnhancedDocuments != null && stpFromCfg.MyEnhancedDocuments.Count > 0 && stpFromCfg.MyEnhancedDocuments[0].Type != 0;
bool stpCanPaste = false; bool stpCanPaste = false;
if (!stpToIsEnhanced && !stpToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 1) if (!stpToIsEnhanced && !stpToIsSource && !stpFromIsEnhanced && !stpFromIsSource) stpCanPaste = true; // 1)
else if (stpToIsSource && !stpFromIsEnhanced && !stpFromIsSource) // 2) else if (stpToIsSource && !stpFromIsEnhanced && !stpFromIsSource) // 2)
{ {
stpCanPaste = true; stpCanPaste = true;
okToReplace = false; okToReplace = false;
@ -1795,7 +1811,7 @@ namespace Volian.Controls.Library
else if (stpToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) // 3 else if (stpToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) // 3
{ {
stpCanPaste = true; stpCanPaste = true;
if (stpFromIsSource) okToReplace = false; // B2017-183: don't allow a replace to source steps if (stpFromIsSource) okToReplace = false; // B2017-183: don't allow a replace to source steps
} }
if (iiClipboard.IsRtfRaw) stpCanPaste = false; // never paste an equation. if (iiClipboard.IsRtfRaw) stpCanPaste = false; // never paste an equation.
if (stpCanPaste && AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click)); if (stpCanPaste && AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
@ -1825,7 +1841,7 @@ namespace Volian.Controls.Library
OnPrintSection(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag)); OnPrintSection(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
break; break;
case "Print All Procedures for": case "Print All Procedures for":
OnPrintAllProcedures(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0,mi.Text,(int)mi.Tag)); OnPrintAllProcedures(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
break; break;
case "Approve": case "Approve":
OnApproveProcedure(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag)); OnApproveProcedure(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
@ -1837,10 +1853,10 @@ namespace Volian.Controls.Library
OnApproveSomeProcedures(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag)); OnApproveSomeProcedures(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
break; break;
case "Create Continuous Action Summary": case "Create Continuous Action Summary":
OnCreateContinuousActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null,0,mi.Text,(int)mi.Tag)); OnCreateContinuousActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
break; break;
case "Create Time Critical Action Summary": case "Create Time Critical Action Summary":
OnCreateTimeCriticalActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null,0,mi.Text,(int)mi.Tag)); OnCreateTimeCriticalActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag));
break; break;
default: default:
if (mip.Text.StartsWith("Showing Change Bars Starting")) if (mip.Text.StartsWith("Showing Change Bars Starting"))
@ -1878,7 +1894,7 @@ namespace Volian.Controls.Library
{ {
if (selprc.IsEnhancedProcedure) if (selprc.IsEnhancedProcedure)
{ {
selprc.DoUnlinkEnhanced(selprc, 0, !hasValidConnectingProc); // if no valid linked: enhtype = 0 since this an enhanced doc is getting unlinked selprc.DoUnlinkEnhanced(selprc, 0, !hasValidConnectingProc); // if no valid linked: enhtype = 0 since this an enhanced doc is getting unlinked
} }
else // from source else // from source
{ {
@ -1906,7 +1922,7 @@ namespace Volian.Controls.Library
{ {
ItemInfo lprc = ItemInfo.Get(ed.ItemID); ItemInfo lprc = ItemInfo.Get(ed.ItemID);
bool hasValidConnectingProc = CheckForValidEnhLink(lprc); bool hasValidConnectingProc = CheckForValidEnhLink(lprc);
// if there is a valid connection, unlink both. Otherwise, just unlink this selected procedure. // if there is a valid connection, unlink both. Otherwise, just unlink this selected procedure.
if (hasValidConnectingProc) if (hasValidConnectingProc)
lprc.DoUnlinkEnhanced(lprc, ed.Type, !hasValidConnectingProc); lprc.DoUnlinkEnhanced(lprc, ed.Type, !hasValidConnectingProc);
else else
@ -1930,27 +1946,27 @@ namespace Volian.Controls.Library
OnNodeSI(this, new vlnTreeEventArgs(tn, null, 0)); OnNodeSI(this, new vlnTreeEventArgs(tn, null, 0));
return; return;
} }
if (mi.Text.StartsWith("Collapse")) if (mi.Text.StartsWith("Collapse"))
{ {
CollapseProcedures(); CollapseProcedures();
return; return;
} }
if (mi.Text == "Print Transition Report") if (mi.Text == "Print Transition Report")
{ {
OnPrintTransitionReport(this, new vlnTreeEventArgs(SelectedNode as VETreeNode)); OnPrintTransitionReport(this, new vlnTreeEventArgs(SelectedNode as VETreeNode));
return; return;
} }
if (mi.Text == "Export Procedure Set" || mi.Text == "Export Procedure") if (mi.Text == "Export Procedure Set" || mi.Text == "Export Procedure")
{ {
OnExportImportProcedureSets(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0)); OnExportImportProcedureSets(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0));
return; return;
} }
if (mi.Text == "Import Procedure Set" || mi.Text == "Import Procedure") if (mi.Text == "Import Procedure Set" || mi.Text == "Import Procedure")
{ {
OnExportImportProcedureSets(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 1)); OnExportImportProcedureSets(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 1));
return; return;
} }
if (mi.Text.StartsWith("Procedure Checked Out to") || mi.Text.StartsWith("Document Checked Out to")) if (mi.Text.StartsWith("Procedure Checked Out to") || mi.Text.StartsWith("Document Checked Out to"))
{ {
OnProcedureCheckedOutTo(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0)); OnProcedureCheckedOutTo(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0));
return; return;
@ -2016,7 +2032,7 @@ namespace Volian.Controls.Library
tv_NodeCopy(); tv_NodeCopy();
break; break;
// lots of paste options: // lots of paste options:
case "Paste Procedure": case "Paste Procedure":
case "Paste Procedure Before": case "Paste Procedure Before":
case "Paste Procedure After": case "Paste Procedure After":
case "Paste Section": case "Paste Section":
@ -2107,14 +2123,14 @@ namespace Volian.Controls.Library
UpdateROValues(SelectedNode as VETreeNode); UpdateROValues(SelectedNode as VETreeNode);
break; break;
case "Create Continuous Action Summary": case "Create Continuous Action Summary":
OnCreateContinuousActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null,0)); OnCreateContinuousActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0));
break; break;
// F2022-024 Time Critical Action Summary // F2022-024 Time Critical Action Summary
case "Create Time Critical Action Summary": case "Create Time Critical Action Summary":
OnCreateTimeCriticalActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null,0)); OnCreateTimeCriticalActionSummary(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0));
break; break;
// B2017-243 added the following two Cannot Paste items when dealing with enhanced documents // B2017-243 added the following two Cannot Paste items when dealing with enhanced documents
// when then user selects these menu items a message box will appear giving more information as to why it cannot be pasted // when then user selects these menu items a message box will appear giving more information as to why it cannot be pasted
case "CANNOT PASTE HERE. Click for more information...": case "CANNOT PASTE HERE. Click for more information...":
FlexibleMessageBox.Show("You have copied a document that is linked to an Enhanced Document.\n\n" + FlexibleMessageBox.Show("You have copied a document that is linked to an Enhanced Document.\n\n" +
"It can only be pasted before or after another document, within the set, that is linked to an Enhanced Document.", "Cannot Paste Here"); "It can only be pasted before or after another document, within the set, that is linked to an Enhanced Document.", "Cannot Paste Here");
@ -2156,7 +2172,7 @@ namespace Volian.Controls.Library
foreach (VETreeNode tnc in tn.Nodes) foreach (VETreeNode tnc in tn.Nodes)
CollapseProcedures(tnc); CollapseProcedures(tnc);
if (tn.VEObject as DocVersionInfo == null && tn.VEObject as FolderInfo == null) if (tn.VEObject as DocVersionInfo == null && tn.VEObject as FolderInfo == null)
tn.Collapse(); tn.Collapse();
_doingCollapseNode = true; // B2016-058 this will prevent a Drag Node error when collapsing an RNOs, Cautions, or Notes tree node _doingCollapseNode = true; // B2016-058 this will prevent a Drag Node error when collapsing an RNOs, Cautions, or Notes tree node
} }
private void tv_RemoveChgIds() private void tv_RemoveChgIds()
@ -2211,12 +2227,12 @@ namespace Volian.Controls.Library
FinalProgressBarMessage = "Cannot check-out Working Draft"; FinalProgressBarMessage = "Cannot check-out Working Draft";
return; return;
} }
Cursor = Cursors.WaitCursor; // C2023-002: move wait cursor after check out error Cursor = Cursors.WaitCursor; // C2023-002: move wait cursor after check out error
int ownerid = MySessionInfo.CheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion); int ownerid = MySessionInfo.CheckOutItem(MyDVI.VersionID, CheckOutType.DocVersion);
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID)) using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
{ {
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(MyDVI)); // RO changes placed in file in the Documents\VEPROMS folder swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(MyDVI)); // RO changes placed in file in the Documents\VEPROMS folder
// B2022-026 RO Memory Reduction code - first load the new ro.fst so that we can assign the ROTableUpdate event to the correct roFstInfo // B2022-026 RO Memory Reduction code - first load the new ro.fst so that we can assign the ROTableUpdate event to the correct roFstInfo
if (dv.ROfstLoadingFigures || dv.NewerRoFst) // B2017-125 see if loading figures was completed if (dv.ROfstLoadingFigures || dv.NewerRoFst) // B2017-125 see if loading figures was completed
{ {
// only load the RO.fst // only load the RO.fst
@ -2244,7 +2260,7 @@ namespace Volian.Controls.Library
swROUpdate.Write(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID)); swROUpdate.Write(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
} }
private ProgressBarItem _ProgressBar=null; private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar public ProgressBarItem ProgressBar
{ {
get { return _ProgressBar; } get { return _ProgressBar; }
@ -2422,7 +2438,7 @@ namespace Volian.Controls.Library
// assume that item to paste is a procedure, otherwise the menuing would not have // assume that item to paste is a procedure, otherwise the menuing would not have
// included the paste options // included the paste options
tn = (VETreeNode) tn.Nodes[tn.Nodes.Count - 1]; tn = (VETreeNode)tn.Nodes[tn.Nodes.Count - 1];
p = "After"; p = "After";
} }
else // this is an empty docversion: else // this is an empty docversion:
@ -2451,7 +2467,7 @@ namespace Volian.Controls.Library
PasteAsChild(tn, iiClipboard.ItemID); PasteAsChild(tn, iiClipboard.ItemID);
//if (p.IndexOf("Replace") <= -1) //if (p.IndexOf("Replace") <= -1)
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
} }
public void PasteAsDocVersionChild(VETreeNode tn, int copyStartID) public void PasteAsDocVersionChild(VETreeNode tn, int copyStartID)
@ -2468,7 +2484,7 @@ namespace Volian.Controls.Library
} }
ItemInfo newProc = dvi.PasteChild(copyStartID); ItemInfo newProc = dvi.PasteChild(copyStartID);
VETreeNode tn1 = new VETreeNode(newProc); VETreeNode tn1 = new VETreeNode(newProc);
SelectedNode.Nodes.Add(tn1); // add tree node to end of list. SelectedNode.Nodes.Add(tn1); // add tree node to end of list.
SelectedNode = tn1; SelectedNode = tn1;
} }
@ -2505,7 +2521,7 @@ namespace Volian.Controls.Library
} }
if (pasteSectIntoEmptySect) if (pasteSectIntoEmptySect)
{ {
tn.ChildrenLoaded = false; // force a reload of treenode tn.ChildrenLoaded = false; // force a reload of treenode
tn.LoadChildren(true); tn.LoadChildren(true);
} }
SelectedNode = tn; SelectedNode = tn;
@ -2543,8 +2559,8 @@ namespace Volian.Controls.Library
} }
private void PasteReplace(VETreeNode tn, int copyStartID, TreeNode treeNodeReplace) private void PasteReplace(VETreeNode tn, int copyStartID, TreeNode treeNodeReplace)
{ {
VETreeNode prevtn = (VETreeNode) tn.PrevNode; VETreeNode prevtn = (VETreeNode)tn.PrevNode;
VETreeNode partn = (VETreeNode) tn.Parent; VETreeNode partn = (VETreeNode)tn.Parent;
ItemInfo ii = tn.VEObject as ItemInfo; 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 // 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.PasteStepIsWithinDefinedSubStepLevels(copyStartID, ii, true);
@ -2582,7 +2598,7 @@ namespace Volian.Controls.Library
SelectedNode.Nodes.Add(tn1); // add tree node to end of list. SelectedNode.Nodes.Add(tn1); // add tree node to end of list.
SelectedNode = tn1; SelectedNode = tn1;
} }
private void tv_NodeCopy() private void tv_NodeCopy()
{ {
if (SelectedNode == null) return; if (SelectedNode == null) return;
VETreeNode tn = SelectedNode as VETreeNode; VETreeNode tn = SelectedNode as VETreeNode;
@ -2594,7 +2610,7 @@ namespace Volian.Controls.Library
private void SetupNodeProperties() private void SetupNodeProperties()
{ {
VETreeNode tn = SelectedNode as VETreeNode; VETreeNode tn = SelectedNode as VETreeNode;
if (tn==null)return; if (tn == null) return;
if ((tn.VEObject as FolderInfo) != null) if ((tn.VEObject as FolderInfo) != null)
OpenProperties(tn.VEObject as FolderInfo); OpenProperties(tn.VEObject as FolderInfo);
@ -2606,7 +2622,7 @@ namespace Volian.Controls.Library
if (dvi != null && dvi.DocVersionAssociations != null && dvi.DocVersionAssociations.Count > 0) rofstid = dvi.DocVersionAssociations[0].MyROFst.ROFstID; if (dvi != null && dvi.DocVersionAssociations != null && dvi.DocVersionAssociations.Count > 0) rofstid = dvi.DocVersionAssociations[0].MyROFst.ROFstID;
OpenProperties(tn.VEObject as DocVersionInfo); OpenProperties(tn.VEObject as DocVersionInfo);
if (dvi != null && dvi.DocVersionAssociations != null && dvi.DocVersionAssociations.Count > 0 && rofstid != dvi.DocVersionAssociations[0].MyROFst.ROFstID) if (dvi != null && dvi.DocVersionAssociations != null && dvi.DocVersionAssociations.Count > 0 && rofstid != dvi.DocVersionAssociations[0].MyROFst.ROFstID)
OnTabDisplay(this,new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST")); OnTabDisplay(this, new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST"));
} }
else if ((tn.VEObject as ProcedureInfo) != null) else if ((tn.VEObject as ProcedureInfo) != null)
OpenProperties(tn.VEObject as ProcedureInfo); OpenProperties(tn.VEObject as ProcedureInfo);
@ -2620,7 +2636,7 @@ namespace Volian.Controls.Library
{ {
using (Folder folder = folderInfo.Get()) using (Folder folder = folderInfo.Get())
{ {
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(string.Format("{0} Properties", folder.FolderConfig.Name), folder.FolderConfig)); OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(string.Format("{0} Properties", folder.FolderConfig.Name), folder.FolderConfig));
} }
} }
private void OpenProperties(DocVersionInfo dvInfo) private void OpenProperties(DocVersionInfo dvInfo)
@ -2634,7 +2650,7 @@ namespace Volian.Controls.Library
{ {
using (Procedure proc = procInfo.Get()) using (Procedure proc = procInfo.Get())
{ {
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(string.Format("{0} {1} Properties", proc.ProcedureConfig.Number, proc.ProcedureConfig.Title), proc.ProcedureConfig)); OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(string.Format("{0} {1} Properties", proc.ProcedureConfig.Number, proc.ProcedureConfig.Title), proc.ProcedureConfig));
} }
} }
private void OpenProperties(SectionInfo sectInfo) private void OpenProperties(SectionInfo sectInfo)
@ -2647,7 +2663,7 @@ namespace Volian.Controls.Library
title = string.Format("{0} {1} Properties", sectInfo.SectionConfig.Number, sectInfo.SectionConfig.Title); title = string.Format("{0} {1} Properties", sectInfo.SectionConfig.Number, sectInfo.SectionConfig.Title);
else else
title = string.Format("{0} Properties", sectInfo.SectionConfig.Title); title = string.Format("{0} Properties", sectInfo.SectionConfig.Title);
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig)); OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig));
} }
} }
private void OpenProperties(StepInfo stpinfo) private void OpenProperties(StepInfo stpinfo)
@ -2701,7 +2717,7 @@ namespace Volian.Controls.Library
{ {
if (newtype == MenuSelections.DocVersion) if (newtype == MenuSelections.DocVersion)
{ {
int dvid = -1; // flag to allow user to cancel from dialog & then we remove it. int dvid = -1; // flag to allow user to cancel from dialog & then we remove it.
using (DocVersion docversion = DocVersion.MakeDocVersion(parentfolder, "Working Draft", "Title", null, null, null)) using (DocVersion docversion = DocVersion.MakeDocVersion(parentfolder, "Working Draft", "Title", null, null, null))
{ {
ShowBrokenRules(docversion.BrokenRulesCollection); ShowBrokenRules(docversion.BrokenRulesCollection);
@ -2710,7 +2726,7 @@ namespace Volian.Controls.Library
{ {
docversion.Save(); docversion.Save();
tn = new VETreeNode(_LastDocVersionInfo); tn = new VETreeNode(_LastDocVersionInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. SelectedNode.Nodes.Add(tn); // add tree node to end of list.
parentfolder.Reset_ChildFolders(); parentfolder.Reset_ChildFolders();
parentfolder.Reset_FolderDocVersions(); parentfolder.Reset_FolderDocVersions();
} }
@ -2721,7 +2737,7 @@ namespace Volian.Controls.Library
} }
else if (newtype == MenuSelections.Folder) else if (newtype == MenuSelections.Folder)
{ {
int f1 = -1; // flag to allow user to cancel from dialog & then we remove it. int f1 = -1; // flag to allow user to cancel from dialog & then we remove it.
string uniquename = _LastFolderInfo.UniqueChildName("New Folder"); string uniquename = _LastFolderInfo.UniqueChildName("New Folder");
using (Folder folder = Folder.MakeFolder(parentfolder, parentfolder.MyConnection, uniquename, string.Empty, "Short Name", null, string.Empty, DateTime.Now, VlnSettings.UserID)) using (Folder folder = Folder.MakeFolder(parentfolder, parentfolder.MyConnection, uniquename, string.Empty, "Short Name", null, string.Empty, DateTime.Now, VlnSettings.UserID))
{ {
@ -2733,14 +2749,14 @@ namespace Volian.Controls.Library
{ {
folder.Save(); folder.Save();
tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo); tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
SelectedNode.Nodes.Add(tn); // add new tree node to end of childlist. SelectedNode.Nodes.Add(tn); // add new tree node to end of childlist.
} }
else else
f1 = folder.FolderID; f1 = folder.FolderID;
} }
if (f1 != -1) Folder.Delete(f1); if (f1 != -1) Folder.Delete(f1);
} }
else if (newtype == MenuSelections.FolderAfter||newtype == MenuSelections.FolderBefore) else if (newtype == MenuSelections.FolderAfter || newtype == MenuSelections.FolderBefore)
{ {
int f2 = -1; int f2 = -1;
string uniquename = _LastFolderInfo.MyParent.UniqueChildName("New Folder"); string uniquename = _LastFolderInfo.MyParent.UniqueChildName("New Folder");
@ -2770,7 +2786,7 @@ namespace Volian.Controls.Library
else if (newtype == MenuSelections.Procedure) else if (newtype == MenuSelections.Procedure)
{ {
int p1 = -1; int p1 = -1;
using (Procedure procedure = Procedure.MakeProcedure(_LastDocVersionInfo, _LastDocVersionInfo.Procedures.Count!=0?_LastDocVersionInfo.Procedures[_LastDocVersionInfo.Procedures.Count-1]:null, null, "New Procedure", 0)) using (Procedure procedure = Procedure.MakeProcedure(_LastDocVersionInfo, _LastDocVersionInfo.Procedures.Count != 0 ? _LastDocVersionInfo.Procedures[_LastDocVersionInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
{ {
ShowBrokenRules(procedure.BrokenRulesCollection); ShowBrokenRules(procedure.BrokenRulesCollection);
SetLastValues(ProcedureInfo.Get(procedure.ItemID)); SetLastValues(ProcedureInfo.Get(procedure.ItemID));
@ -2779,8 +2795,8 @@ namespace Volian.Controls.Library
{ {
procedure.Save(); procedure.Save();
tn = new VETreeNode(_LastProcedureInfo); tn = new VETreeNode(_LastProcedureInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. SelectedNode.Nodes.Add(tn); // add tree node to end of list.
// The following line will allow for a refresh of the procedure list on the Working Draft's treenodes docversion (B2016-034) // The following line will allow for a refresh of the procedure list on the Working Draft's treenodes docversion (B2016-034)
if (((SelectedNode as VETreeNode).VEObject as DocVersionInfo) != null) ((SelectedNode as VETreeNode).VEObject as DocVersionInfo).ResetProcedures(); if (((SelectedNode as VETreeNode).VEObject as DocVersionInfo) != null) ((SelectedNode as VETreeNode).VEObject as DocVersionInfo).ResetProcedures();
if (procedure.MyProcedureInfo.CreateEnhanced) if (procedure.MyProcedureInfo.CreateEnhanced)
{ {
@ -2827,16 +2843,16 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region InsertSection #region InsertSection
else if (newtype == MenuSelections.Section) // Insert subsection at end of parents section list else if (newtype == MenuSelections.Section) // Insert subsection at end of parents section list
{ {
string message = string.Empty; string message = string.Empty;
if (_LastProcedureInfo != null) if (_LastProcedureInfo != null)
if (!MySessionInfo.CanCheckOutItem(_LastProcedureInfo.ItemID, CheckOutType.Procedure, ref message)) if (!MySessionInfo.CanCheckOutItem(_LastProcedureInfo.ItemID, CheckOutType.Procedure, ref message))
{ {
FlexibleMessageBox.Show(this, message, "Item Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); FlexibleMessageBox.Show(this, message, "Item Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
OnUnPauseRefresh(this, null); OnUnPauseRefresh(this, null);
return; return;
} }
int s1 = -1; int s1 = -1;
if (!(_LastProcedureInfo == null) || !(_LastSectionInfo == null)) if (!(_LastProcedureInfo == null) || !(_LastSectionInfo == null))
{ {
@ -2866,7 +2882,7 @@ namespace Volian.Controls.Library
"If you would like to view or copy these hidden steps you will need to go\n" + "If you would like to view or copy these hidden steps you will need to go\n" +
"into the properties of this section and check the Editable Data checkbox.\n" + "into the properties of this section and check the Editable Data checkbox.\n" +
"You will then be able to view and copy those steps. When finished, open\n" + "You will then be able to view and copy those steps. When finished, open\n" +
"the properties page again and uncheck the Editable Data checkbox.\n\n"+ "the properties page again and uncheck the Editable Data checkbox.\n\n" +
"Do you want to continue creating the subsection?"; "Do you want to continue creating the subsection?";
if (FlexibleMessageBox.Show(this, msgstr, "Subsection Insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) if (FlexibleMessageBox.Show(this, msgstr, "Subsection Insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{ {
@ -2878,7 +2894,7 @@ namespace Volian.Controls.Library
if (!hasMetaSubs) doPseudo = true; if (!hasMetaSubs) doPseudo = true;
} }
} }
using(Section section = CreateNewSection()) using (Section section = CreateNewSection())
{ {
ShowBrokenRules(section.BrokenRulesCollection); ShowBrokenRules(section.BrokenRulesCollection);
SectionInfo savLastSectionInfo = _LastSectionInfo; SectionInfo savLastSectionInfo = _LastSectionInfo;
@ -2888,10 +2904,10 @@ namespace Volian.Controls.Library
if (!doPseudo) if (!doPseudo)
{ {
tn = new VETreeNode(_LastSectionInfo); tn = new VETreeNode(_LastSectionInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. SelectedNode.Nodes.Add(tn); // add tree node to end of list.
// if the new section was flagged as either having an enhanced link for Title or Contents, create the // if the new section was flagged as either having an enhanced link for Title or Contents, create the
// Enhanced section: // Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text); CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
sectiontmp.Dispose(); sectiontmp.Dispose();
@ -2902,7 +2918,7 @@ namespace Volian.Controls.Library
// may have to add a 'steps' node if a step(s) already exist... // may have to add a 'steps' node if a step(s) already exist...
ItemInfo ii = (SelectedNode as VETreeNode).VEObject as ItemInfo; ItemInfo ii = (SelectedNode as VETreeNode).VEObject as ItemInfo;
int cpindx = 0; int cpindx = 0;
if (SelectedNode.Nodes.Count>0) if (SelectedNode.Nodes.Count > 0)
{ {
VETreeNode vtn = SelectedNode.Nodes[0] as VETreeNode; VETreeNode vtn = SelectedNode.Nodes[0] as VETreeNode;
// B2017-014: removed code that was adding a 2nd section part node. and also select node to // B2017-014: removed code that was adding a 2nd section part node. and also select node to
@ -2912,13 +2928,13 @@ namespace Volian.Controls.Library
// B2017-014: removed code that was adding a 2nd section part node. // B2017-014: removed code that was adding a 2nd section part node.
} }
} }
else // Properties was canceled out of: else // Properties was canceled out of:
s1 = section.ItemID; s1 = section.ItemID;
} }
if (s1 != -1) if (s1 != -1)
{ {
DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next
// B2020-087 refresh the tree node after canceling the creation of the subsection // B2020-087 refresh the tree node after canceling the creation of the subsection
_LastTreeNode.ChildrenLoaded = false; _LastTreeNode.ChildrenLoaded = false;
_LastTreeNode.RefreshNode(); _LastTreeNode.RefreshNode();
_LastTreeNode.Collapse(); _LastTreeNode.Collapse();
@ -2946,14 +2962,14 @@ namespace Volian.Controls.Library
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{ {
int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1); int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1);
int itemido = (indx >= par.Nodes.Count)?-1:(((par.Nodes[indx] as VETreeNode).VEObject) as ItemInfo).ItemID; int itemido = (indx >= par.Nodes.Count) ? -1 : (((par.Nodes[indx] as VETreeNode).VEObject) as ItemInfo).ItemID;
if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString() || itemido !=section.ItemID) if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString() || itemido != section.ItemID)
{ {
tn = new VETreeNode(_LastSectionInfo); tn = new VETreeNode(_LastSectionInfo);
par.Nodes.Insert(indx, tn); par.Nodes.Insert(indx, tn);
// if the new section was flagged as either having an enhanced link for Title or Contents, create the // if the new section was flagged as either having an enhanced link for Title or Contents, create the
// Enhanced section: // Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text); CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
sectiontmp.Dispose(); sectiontmp.Dispose();
@ -2965,7 +2981,7 @@ namespace Volian.Controls.Library
if (s2 != -1) if (s2 != -1)
{ {
DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next
// B2020-087 refresh the tree node after canceling the creation of the subsection // B2020-087 refresh the tree node after canceling the creation of the subsection
_LastTreeNode.ChildrenLoaded = false; _LastTreeNode.ChildrenLoaded = false;
_LastTreeNode.RefreshNode(); _LastTreeNode.RefreshNode();
_LastTreeNode.Collapse(); _LastTreeNode.Collapse();
@ -2973,7 +2989,7 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region InsertStep #region InsertStep
else if (newtype == MenuSelections.Step) // insert step from section - no substeps from tree. else if (newtype == MenuSelections.Step) // insert step from section - no substeps from tree.
{ {
string message = string.Empty; string message = string.Empty;
if (!MySessionInfo.CanCheckOutItem(_LastSectionInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message)) if (!MySessionInfo.CanCheckOutItem(_LastSectionInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
@ -3050,7 +3066,7 @@ namespace Volian.Controls.Library
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0)) using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
{ {
SaveEnhancedForProcedure(sourceProc, newenhProcedure, ded.Type); SaveEnhancedForProcedure(sourceProc, newenhProcedure, ded.Type);
RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID)); // this updates the treeview to include the new enhanced procedure RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID)); // this updates the treeview to include the new enhanced procedure
} }
} }
} }
@ -3148,7 +3164,7 @@ namespace Volian.Controls.Library
{ {
SectionConfig newenhcfg = new SectionConfig(newenhSection); SectionConfig newenhcfg = new SectionConfig(newenhSection);
newenhcfg.AddEnhancedDocument(0, sourceSect.ItemID); newenhcfg.AddEnhancedDocument(0, sourceSect.ItemID);
newenhcfg.SaveEnhancedDocuments(); // does this save data? newenhcfg.SaveEnhancedDocuments(); // does this save data?
using (Content c1 = Content.Get(newenhSection.ContentID)) using (Content c1 = Content.Get(newenhSection.ContentID))
{ {
c1.Config = newenhcfg.ToString(); c1.Config = newenhcfg.ToString();
@ -3229,12 +3245,12 @@ namespace Volian.Controls.Library
// see if enhanced related steps need created: // see if enhanced related steps need created:
SectionConfig scfgE = _LastItemInfo.ActiveSection.MyConfig as SectionConfig; // C2018-003 fixed use of getting the active section SectionConfig scfgE = _LastItemInfo.ActiveSection.MyConfig as SectionConfig; // C2018-003 fixed use of getting the active section
if (scfgE != null && scfgE.Section_LnkEnh=="Y") if (scfgE != null && scfgE.Section_LnkEnh == "Y")
{ {
// set up which item to insert from based on whether editor was open (see comment from 11/17 above). // set up which item to insert from based on whether editor was open (see comment from 11/17 above).
EnhancedDocuments enhdocs = null; EnhancedDocuments enhdocs = null;
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child; ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child;
if (_LastItemInfo.MyPrevious != null) // the code above will do the MakeStep regardless of whether editor is up if this is the only step. if (_LastItemInfo.MyPrevious != null) // the code above will do the MakeStep regardless of whether editor is up if this is the only step.
{ {
addpart = ItemInfo.EAddpingPart.After; addpart = ItemInfo.EAddpingPart.After;
ItemInfo lstSrc = _LastItemInfo.MyPrevious; ItemInfo lstSrc = _LastItemInfo.MyPrevious;
@ -3406,7 +3422,7 @@ namespace Volian.Controls.Library
result = FlexibleMessageBox.Show("Are you sure you want to delete this " + typeDescription + "?", "Verify Delete", result = FlexibleMessageBox.Show("Are you sure you want to delete this " + typeDescription + "?", "Verify Delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Question); MessageBoxButtons.YesNo, MessageBoxIcon.Question);
} }
if (_LastProcedureInfo != null || result == DialogResult.Yes) if (_LastProcedureInfo != null || result == DialogResult.Yes)
{ {
if (_LastFolderInfo != null) if (_LastFolderInfo != null)
{ {
@ -3512,7 +3528,7 @@ namespace Volian.Controls.Library
// just clear enhanced links back // just clear enhanced links back
_LastSectionInfo.ClearEnhancedSectionLink(); _LastSectionInfo.ClearEnhancedSectionLink();
} }
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo,true)); OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo, true));
// always return false because an event gets fired to delete tree nodes. // always return false because an event gets fired to delete tree nodes.
if (!DeleteItemInfoAndChildren(_LastSectionInfo)) if (!DeleteItemInfoAndChildren(_LastSectionInfo))
{ {
@ -3567,6 +3583,41 @@ namespace Volian.Controls.Library
} }
return false; 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) private bool DeleteItemInfoAndChildren(ItemInfo ii)
{ {
DateTime dtStart = DateTime.Now; DateTime dtStart = DateTime.Now;