B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced

This commit is contained in:
Kathy Ruffing 2022-08-03 15:03:40 +00:00
parent f234174a51
commit b6d69fbd4c
8 changed files with 347 additions and 22 deletions

View File

@ -20952,6 +20952,80 @@ GO
========================================================================================================== ==========================================================================================================
*/ */
/*
==========================================================================================================
Start: B2022-049 Unlink single procedure for enhanced (if data got corrupted)
==========================================================================================================
*/
If Exists(SELECT * FROM sys.objects Where name = 'vesp_PurgeProcLinkedItemsAndChildren' AND type in (N'P'))
DROP PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2022 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
Create PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren](@EnhanceID int, @EnhType int)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
-- Only unlink for the input procedure number & its children. Do not follow the links, i.e. source or enhanced. This
-- can be used for removing link information if the links between the 2, source & enhanced, get corrupted.
declare @Enh1 TABLE
(
ID int,
xConfig xml
)
insert into @Enh1
select CC.ContentID, CC.xConfig from (select *, cast(config as xml) xConfig from Contents) CC
JOIN vefn_ChildItems(@EnhanceID) VCI ON VCI.ContentID = CC.ContentID
cross apply VEFN_GetNewEnhancedData(VCI.itemid,@EnhType) VEN
Update @Enh1 Set xConfig.modify('delete //Enhanced[@Type=sql:variable("@EnhType")]') From @Enh1
Update CC Set Config = cast(xconfig as varchar(max)) From Contents CC
Join @Enh1 EE ON EE.ID = CC.ContentID
SELECT [ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[LastChanged],
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
FROM [Contents] where ContentID in (Select ID From @Enh1)
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
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Succeeded'
ELSE PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Error on Creation'
GO
/*
==========================================================================================================
End: B2022-049 Unlink single procedure for enhanced (if data got corrupted) [Version 2.xx]
==========================================================================================================
*/
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@ -20986,8 +21060,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255) DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255) DECLARE @RevDescription varchar(255)
set @RevDate = '07/29/2022 9:00 AM' set @RevDate = '08/03/2022 9:00 AM'
set @RevDescription = 'B2022-082: Search not finding occurrences that use bold and underline' set @RevDescription = 'B2022-049 Unlink single procedure for enhanced (if data got corrupted) '
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

@ -20952,6 +20952,80 @@ GO
========================================================================================================== ==========================================================================================================
*/ */
/*
==========================================================================================================
Start: B2022-049 Unlink single procedure for enhanced (if data got corrupted)
==========================================================================================================
*/
If Exists(SELECT * FROM sys.objects Where name = 'vesp_PurgeProcLinkedItemsAndChildren' AND type in (N'P'))
DROP PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2022 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
Create PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren](@EnhanceID int, @EnhType int)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
-- Only unlink for the input procedure number & its children. Do not follow the links, i.e. source or enhanced. This
-- can be used for removing link information if the links between the 2, source & enhanced, get corrupted.
declare @Enh1 TABLE
(
ID int,
xConfig xml
)
insert into @Enh1
select CC.ContentID, CC.xConfig from (select *, cast(config as xml) xConfig from Contents) CC
JOIN vefn_ChildItems(@EnhanceID) VCI ON VCI.ContentID = CC.ContentID
cross apply VEFN_GetNewEnhancedData(VCI.itemid,@EnhType) VEN
Update @Enh1 Set xConfig.modify('delete //Enhanced[@Type=sql:variable("@EnhType")]') From @Enh1
Update CC Set Config = cast(xconfig as varchar(max)) From Contents CC
Join @Enh1 EE ON EE.ID = CC.ContentID
SELECT [ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[LastChanged],
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
FROM [Contents] where ContentID in (Select ID From @Enh1)
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
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Succeeded'
ELSE PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Error on Creation'
GO
/*
==========================================================================================================
End: B2022-049 Unlink single procedure for enhanced (if data got corrupted) [Version 2.xx]
==========================================================================================================
*/
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@ -20986,8 +21060,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255) DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255) DECLARE @RevDescription varchar(255)
set @RevDate = '07/29/2022 9:00 AM' set @RevDate = '08/03/2022 9:00 AM'
set @RevDescription = 'B2022-082: Search not finding occurrences that use bold and underline' set @RevDescription = 'B2022-049 Unlink single procedure for enhanced (if data got corrupted) '
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

@ -1718,9 +1718,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()] [Serializable()]
private class EnhancedUnlinkCriteria private class EnhancedUnlinkCriteria
{ {
public EnhancedUnlinkCriteria(int? enhancedID) public EnhancedUnlinkCriteria(int? enhancedID, int? enhType, bool onlyCur)
{ {
_EnhancedID = enhancedID; _EnhancedID = enhancedID;
_EnhType = enhType;
_OnlyCur = onlyCur;
} }
private int? _EnhancedID; private int? _EnhancedID;
public int? EnhancedID public int? EnhancedID
@ -1728,10 +1730,58 @@ namespace VEPROMS.CSLA.Library
get { return _EnhancedID; } get { return _EnhancedID; }
set { _EnhancedID = value; } set { _EnhancedID = value; }
} }
private int? _EnhType;
public int? EnhType
{
get { return _EnhType; }
set { _EnhType = value; }
}
private bool _OnlyCur;
public bool OnlyCur
{
get { return _OnlyCur; }
set { _OnlyCur = value; }
}
} }
private void DataPortal_Fetch(EnhancedUnlinkCriteria criteria) private void DataPortal_Fetch(EnhancedUnlinkCriteria criteria)
{ {
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. To fix this problem,
// a sql script was added 'vesp_PurgeProcLinkedItemsAndChildren' that only removes link information within the
// input procedure, i.e. does not remove them from linked procedure.
if (criteria.OnlyCur)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_PurgeProcLinkedItemsAndChildren";
cm.Parameters.AddWithValue("@EnhanceID", criteria.EnhancedID); // note query had 'EnhanceID', not 'EnhancedID'
cm.Parameters.AddWithValue("@EnhType", criteria.EnhType);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("EnhancedUnlinkCriteria.DataPortal_Fetch", ex);
throw new DbCslaException("EnhancedUnlinkCriteria.DataPortal_Fetch", ex);
}
return;
}
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1762,11 +1812,11 @@ namespace VEPROMS.CSLA.Library
} }
} }
public static ContentInfoList DoEnhancedUnlink(int enhancedID) public static ContentInfoList DoEnhancedUnlink(int enhancedID, int enhType, bool onlyCur)
{ {
try try
{ {
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new EnhancedUnlinkCriteria(enhancedID)); ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new EnhancedUnlinkCriteria(enhancedID, enhType, onlyCur));
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)

View File

@ -2602,11 +2602,13 @@ namespace VEPROMS.CSLA.Library
//} //}
#endregion #endregion
#region UnlinkEnhanced #region UnlinkEnhanced
public void DoUnlinkEnhanced(ItemInfo enhii) // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
// Add parameters to be passed down to query to only remove links from current procedure
public void DoUnlinkEnhanced(ItemInfo enhii, int enhType, bool onlyCur)
{ {
try try
{ {
using (ContentInfoList cil = ContentInfoList.DoEnhancedUnlink(enhii.ItemID)) using (ContentInfoList cil = ContentInfoList.DoEnhancedUnlink(enhii.ItemID, enhType, onlyCur))
{ {
foreach (ContentInfo ci in cil) foreach (ContentInfo ci in cil)
{ {
@ -7373,7 +7375,8 @@ namespace VEPROMS.CSLA.Library
if (seds != null && seds.Count != 0) if (seds != null && seds.Count != 0)
{ {
ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID); ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID);
if (srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars) // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check
if (srcItem != null && srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars)
{ {
if (retiil == null) retiil = new ItemInfoList(ii); if (retiil == null) retiil = new ItemInfoList(ii);
else retiil.AddItem(ii); else retiil.AddItem(ii);

View File

@ -1474,22 +1474,26 @@ namespace VEPROMS.CSLA.Library
// Find hls in enhanced in order to get its notes to set their config to // Find hls in enhanced in order to get its notes to set their config to
// point back to the new source's note itemid. // point back to the new source's note itemid.
ItemInfo enhCtItem = null; ItemInfo enhCtItem = null;
while (enhCtItem == null && enhIndxCt < enhHls.Cautions.Count) // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check
if (enhHls.Cautions != null)
{ {
ItemInfo enhTstCaut = enhHls.Cautions[enhIndxCt]; while (enhCtItem == null && enhIndxCt < enhHls.Cautions.Count)
StepConfig enhTstCautCfg = enhTstCaut.MyConfig as StepConfig;
if (enhTstCautCfg.MyEnhancedDocuments.Count > 0)
{ {
foreach (EnhancedDocument enhCt in enhTstCaut.GetMyEnhancedDocuments()) ItemInfo enhTstCaut = enhHls.Cautions[enhIndxCt];
StepConfig enhTstCautCfg = enhTstCaut.MyConfig as StepConfig;
if (enhTstCautCfg.MyEnhancedDocuments.Count > 0)
{ {
if (enhCt.Type == 0) foreach (EnhancedDocument enhCt in enhTstCaut.GetMyEnhancedDocuments())
{ {
enhCtItem = enhTstCaut; if (enhCt.Type == 0)
break; {
enhCtItem = enhTstCaut;
break;
}
} }
} }
if (enhCtItem == null) enhIndxCt++;
} }
if (enhCtItem == null) enhIndxCt++;
} }
if (enhCtItem != null) if (enhCtItem != null)
{ {

View File

@ -1686,7 +1686,9 @@ namespace Volian.Controls.Library
} }
public void UnlinkEnhanced(ItemInfo enhII) public void UnlinkEnhanced(ItemInfo enhII)
{ {
enhII.DoUnlinkEnhanced(enhII); // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
// Pass in to unlink as before this change
enhII.DoUnlinkEnhanced(enhII, 0, false);
SetFocus(); SetFocus();
} }
public ItemInfo AddMissingEnhancedStep(ItemInfo ii, int EnhType) public ItemInfo AddMissingEnhancedStep(ItemInfo ii, int EnhType)

View File

@ -183,7 +183,9 @@ namespace Volian.Controls.Library
if (bi.Name.StartsWith("btnEnhanced")) if (bi.Name.StartsWith("btnEnhanced"))
existingEnhancedButtons.Add(bi.Name); existingEnhancedButtons.Add(bi.Name);
bool inSource = dveds[0].Type != 0; bool inSource = dveds[0].Type != 0;
int buttonsNeeded = inSource ? dveds.Count : (dveds.Count * 2); // enhanced items need unlink button also. int buttonsNeeded = inSource ? dveds.Count : (dveds.Count * 2); // enhanced items need unlink button also.
// if in view only mode, don't do unlink
if (!inSource && MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.View) buttonsNeeded--;
if (MyItemInfo.IsSection && !MyItemInfo.IsStepSection) buttonsNeeded = 0; // no buttons for word sections if (MyItemInfo.IsSection && !MyItemInfo.IsStepSection) buttonsNeeded = 0; // no buttons for word sections
if (buttonsNeeded > existingEnhancedButtons.Count) // add buttons if (buttonsNeeded > existingEnhancedButtons.Count) // add buttons
{ {
@ -195,7 +197,8 @@ namespace Volian.Controls.Library
biEnhanced.Click += btnEnhancedGoTo_Click; biEnhanced.Click += btnEnhancedGoTo_Click;
myButtonItem.SubItems.Add(biEnhanced); myButtonItem.SubItems.Add(biEnhanced);
existingEnhancedButtons.Add(biEnhanced.Name); existingEnhancedButtons.Add(biEnhanced.Name);
if (!inSource) // if in view only mode, don't do unlink
if (!inSource && MyEditItem != null && MyEditItem.MyStepPanel.VwMode != E_ViewMode.View)
{ {
// add unlink buttons: // add unlink buttons:
buttonName = string.Format("btnEnhancedUnlink{0}", dved.Type); buttonName = string.Format("btnEnhancedUnlink{0}", dved.Type);

View File

@ -1024,6 +1024,54 @@ namespace Volian.Controls.Library
cm.MenuItems.Add("Incoming Transitions", new EventHandler(mi_Click)); cm.MenuItems.Add("Incoming Transitions", new EventHandler(mi_Click));
} }
#endregion #endregion
#region Menu_UnLinkEnhanced
// B2022-049: provide for way to unlink a procedure from the tree view. Also unlinks procedure if no
// connected (linked) procedure.
if (tn.VEObject is ProcedureInfo)
{
ItemInfo prc = (ItemInfo)tn.VEObject;
if (ui.IsAdministrator() || ui.IsSetAdministrator(prc.MyDocVersion) || ui.IsWriter(prc.MyDocVersion))
{
DVEnhancedDocuments dveds = prc.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
EnhancedDocuments eds = prc.GetMyEnhancedDocuments();
// if just one link, add single menu item to unlink. If more than one, need a list with all.
if (eds != null && eds.Count == 1)
{
// Get menu string, must start with 'Unlink Source '
string doclink = null;
doclink = dveds.GetByType(eds[0].Type).Name; // need background/dev if on source
if (eds[0].Type == 0)
{
ItemInfo prl = ItemInfo.Get(eds[0].ItemID);
DVEnhancedDocuments dvedsl = prl.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
foreach (DVEnhancedDocument dvel in dvedsl) if (dvel.VersionID == prc.MyDocVersion.VersionID) doclink = dvel.Name;
}
doclink = string.Format("Unlink Source and {0} Procedure", doclink);
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
}
// 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)
{
MenuItem miu = new MenuItem("Unlink Enhanced Procedure(s) from Source");
miu.Tag = -2; // this menu item doesn't get used.
int k = 0;
foreach (EnhancedDocument ed in eds)
{
// add submenu item for it
k++;
MenuItem mp = miu.MenuItems.Add(dveds.GetByType(ed.Type).Name, new EventHandler(miEnhanced_Click));
mp.Tag = k;
}
// add all submenu item
MenuItem mp1 = miu.MenuItems.Add("All", new EventHandler(miEnhanced_Click));
mp1.Tag = 0; // Tag of 0 flags All
cm.MenuItems.Add(miu);
}
}
}
#endregion
#region Menu_Properties #region Menu_Properties
// 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.
@ -1687,6 +1735,73 @@ namespace Volian.Controls.Library
} }
} }
//end jcb multiunit //end jcb multiunit
private bool CheckForValidEnhLink(ItemInfo prc) // Check if this procedure has valid link
{
EnhancedDocuments eds = prc.GetMyEnhancedDocuments();
foreach (EnhancedDocument ed in eds) // only unlink those that are selected
{
ItemInfo lprc = ItemInfo.Get(ed.ItemID);
EnhancedDocuments edsl = lprc.GetMyEnhancedDocuments();
foreach (EnhancedDocument edl in edsl) if (edl.ItemID == prc.ItemID) return true;
}
return false;
}
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
// Handle menu selection for unlinking the source/enhanced OR if not valid links, just the procedure selected
void miEnhanced_Click(object sender, EventArgs e)
{
MenuItem mi = sender as MenuItem;
VETreeNode tnprc = SelectedNode as VETreeNode;
ItemInfo selprc = tnprc.VEObject as ItemInfo;
EnhancedDocuments seleds = selprc.GetMyEnhancedDocuments();
// if tag on menu = -1, it is a single document, no need to loop. This can be from either the source or enhanced.
if ((int)mi.Tag == -1)
{
bool hasValidConnectingProc = CheckForValidEnhLink(selprc);
if (FlexibleMessageBox.Show(this, "Do you want to unlink the Enhanced procedure from its Source?", "Confirm Procedure Unlink", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
if (selprc.IsEnhancedProcedure)
{
selprc.DoUnlinkEnhanced(selprc, 0, !hasValidConnectingProc); // if no valid linked: enhtype = 0 since this an enhanced doc is getting unlinked
}
else // from source
{
// if valid connection, make call from the linked enhanced, otherwise just unlink the source only
if (hasValidConnectingProc)
{
ItemInfo lprc = ItemInfo.Get(seleds[0].ItemID);
lprc.DoUnlinkEnhanced(lprc, 0, !hasValidConnectingProc);
}
else
selprc.DoUnlinkEnhanced(selprc, seleds[0].Type, !hasValidConnectingProc);
}
}
}
else
{
// The following code is run if selection made from source. There may be moore than one enhanced, for example background
// and deviation
if (FlexibleMessageBox.Show(this, "Do you want to unlink the selected Enhanced procedure(s) from the Source procedure?", "Confirm Procedure Unlink", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int k = 1;
foreach (EnhancedDocument ed in seleds) // only unlink those that are selected
{
if (k == (int)mi.Tag || (int)mi.Tag == 0)
{
ItemInfo lprc = ItemInfo.Get(ed.ItemID);
bool hasValidConnectingProc = CheckForValidEnhLink(lprc);
// if there is a valid connection, unlink both. Otherwise, just unlink this selected procedure.
if (hasValidConnectingProc)
lprc.DoUnlinkEnhanced(lprc, ed.Type, !hasValidConnectingProc);
else
selprc.DoUnlinkEnhanced(selprc, ed.Type, !hasValidConnectingProc);
}
k++;
}
}
}
}
void mi_Click(object sender, EventArgs e) void mi_Click(object sender, EventArgs e)
{ {
MenuItem mi = sender as MenuItem; MenuItem mi = sender as MenuItem;