B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
This commit is contained in:
@@ -1718,9 +1718,11 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
private class EnhancedUnlinkCriteria
|
||||
{
|
||||
public EnhancedUnlinkCriteria(int? enhancedID)
|
||||
public EnhancedUnlinkCriteria(int? enhancedID, int? enhType, bool onlyCur)
|
||||
{
|
||||
_EnhancedID = enhancedID;
|
||||
_EnhType = enhType;
|
||||
_OnlyCur = onlyCur;
|
||||
}
|
||||
private int? _EnhancedID;
|
||||
public int? EnhancedID
|
||||
@@ -1728,10 +1730,58 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return _EnhancedID; }
|
||||
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)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
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
|
||||
{
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new EnhancedUnlinkCriteria(enhancedID));
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new EnhancedUnlinkCriteria(enhancedID, enhType, onlyCur));
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -2602,11 +2602,13 @@ namespace VEPROMS.CSLA.Library
|
||||
//}
|
||||
#endregion
|
||||
#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
|
||||
{
|
||||
using (ContentInfoList cil = ContentInfoList.DoEnhancedUnlink(enhii.ItemID))
|
||||
using (ContentInfoList cil = ContentInfoList.DoEnhancedUnlink(enhii.ItemID, enhType, onlyCur))
|
||||
{
|
||||
foreach (ContentInfo ci in cil)
|
||||
{
|
||||
@@ -7373,7 +7375,8 @@ namespace VEPROMS.CSLA.Library
|
||||
if (seds != null && seds.Count != 0)
|
||||
{
|
||||
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);
|
||||
else retiil.AddItem(ii);
|
||||
|
@@ -1474,22 +1474,26 @@ namespace VEPROMS.CSLA.Library
|
||||
// Find hls in enhanced in order to get its notes to set their config to
|
||||
// point back to the new source's note itemid.
|
||||
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];
|
||||
StepConfig enhTstCautCfg = enhTstCaut.MyConfig as StepConfig;
|
||||
if (enhTstCautCfg.MyEnhancedDocuments.Count > 0)
|
||||
while (enhCtItem == null && enhIndxCt < enhHls.Cautions.Count)
|
||||
{
|
||||
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;
|
||||
break;
|
||||
if (enhCt.Type == 0)
|
||||
{
|
||||
enhCtItem = enhTstCaut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enhCtItem == null) enhIndxCt++;
|
||||
}
|
||||
if (enhCtItem == null) enhIndxCt++;
|
||||
}
|
||||
if (enhCtItem != null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user