Attempted fixes for enhanced tests

This commit is contained in:
Kevin Laskey 2024-07-10 09:25:21 -04:00
parent 96e85e8c5c
commit 09d0f73396
3 changed files with 162 additions and 20 deletions

View File

@ -1944,6 +1944,54 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region DataPortal #region DataPortal
private void DataPortal_Fetch(PastingPartEnhancedCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
Csla.ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@StartItemID", criteria.StartItemID); // copy children
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); //copy to
cm.Parameters.AddWithValue("@Type", criteria.Type);
cm.Parameters.AddWithValue("@DTS", criteria.DTS);
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
SqlParameter param_ItemID = new SqlParameter("@NewItemID", SqlDbType.Int);
param_ItemID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ItemID);
cm.CommandText = "PasteItemEnhancedReplace";
//cm.CommandText = "PasteItemReplace";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
//int newItemID = (int)cm.Parameters["@NewItemID"].Value;
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (Csla.ApplicationContext.ExecutionLocation == Csla.ApplicationContext.ExecutionLocations.Client)
Csla.ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("This step has been deleted") && !ex.Message.Contains("This current step has been deleted in another session"))
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
}
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
private void DataPortal_Fetch(PastingPartCriteria criteria) private void DataPortal_Fetch(PastingPartCriteria criteria)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
@ -2066,6 +2114,68 @@ namespace VEPROMS.CSLA.Library
} }
} }
#endregion #endregion
#region PastingPartEnhancedCriteria
[Serializable()]
public class PastingPartEnhancedCriteria
{
#region Properties
private int _StartItemID;
public int StartItemID
{
get { return _StartItemID; }
set { _StartItemID = value; }
}
private int _ItemID; // paste relative to this itemid
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private EAddpingPart _AddType;
public EAddpingPart AddType
{
get { return _AddType; }
set { _AddType = value; }
}
private int? _FromType = null;
public int? FromType
{
get { return _FromType; }
set { _FromType = value; }
}
private int? _Type = null;
public int? Type
{
get { return _Type; }
set { _Type = value; }
}
private DateTime _DTS;
public DateTime DTS
{
get { return _DTS; }
set { _DTS = value; }
}
private string _UserID;
public string UserID
{
get { return _UserID; }
set { _UserID = value; }
}
#endregion
#region Constructor
public PastingPartEnhancedCriteria(int startItemid, int itemID, EAddpingPart addType, int? type, int? fromType, DateTime dts, string userID)
{
_StartItemID = startItemid;
_ItemID = itemID;
_AddType = addType;
_Type = type;
_FromType = fromType;
_DTS = dts;
_UserID = userID;
}
#endregion
}
#endregion
#region PastingPartCriteria #region PastingPartCriteria
[Serializable()] [Serializable()]
public class PastingPartCriteria public class PastingPartCriteria
@ -2356,6 +2466,17 @@ namespace VEPROMS.CSLA.Library
_MyPrevious = null; // Reset list so that the next line gets a new list _MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
} }
internal static ItemInfo CopyPasteReplaceEnhancedItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
{
ItemInfo tmp = null;
tmp = DataPortal.Fetch<StepInfo>(new ItemInfo.PastingPartEnhancedCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
if (tmp == null)
{
tmp = ItemInfo.Get(copyStartID);
}
AddToCache(tmp);
return tmp;
}
internal static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType) internal static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
{ {
ItemInfo tmp = null; ItemInfo tmp = null;
@ -2503,10 +2624,18 @@ namespace VEPROMS.CSLA.Library
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace) public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace)
{ {
if (itemInfo.IsEnhancedStep)
{
// don't replace the step, just remove current children & add new children:
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Item");
}
bool tmp = false; bool tmp = false;
return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp); return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp);
} }
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved // B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans) public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans)
{ {
firstTrans = false; firstTrans = false;
@ -2518,8 +2647,17 @@ namespace VEPROMS.CSLA.Library
ItemInfo newItemInfo = null; ItemInfo newItemInfo = null;
try try
{ {
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type); // if this item is an enhanced item, do a pastereplace specific to it:
if (newItemInfo == null) return null; if (itemInfo.IsEnhancedStep)
{
newItemInfo = ItemInfo.CopyPasteReplaceEnhancedItemInfoFetch(copyStartID, itemInfo);
if (newItemInfo == null) return null;
}
else
{
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
if (newItemInfo == null) return null;
}
} }
catch (Exception ex1) catch (Exception ex1)
{ {
@ -2567,7 +2705,7 @@ namespace VEPROMS.CSLA.Library
//Create tree node for copied procedure when no other procedures exist in the folder //Create tree node for copied procedure when no other procedures exist in the folder
VETreeNode vtn = treeNodeReplace as VETreeNode; VETreeNode vtn = treeNodeReplace as VETreeNode;
DocVersionInfo dvi = vtn.VEObject as DocVersionInfo; DocVersionInfo dvi = vtn.VEObject as DocVersionInfo;
ItemInfo newProc = dvi.PasteChild(copyStartID); ItemInfo newProc = dvi.PasteChild(copyStartID);
VETreeNode tn1 = new VETreeNode(newProc); VETreeNode tn1 = new VETreeNode(newProc);
treeNodeReplace.Nodes.Add(tn1); // add tree node to end of list. treeNodeReplace.Nodes.Add(tn1); // add tree node to end of list.
@ -2584,23 +2722,23 @@ namespace VEPROMS.CSLA.Library
firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved
return iii; return iii;
} }
if (!HandleSqlExceptionOnCopy(ex)) if (!HandleSqlExceptionOnCopy(ex))
{ {
if (ex.Message.Contains("has External Transitions and has no next step") if (ex.Message.Contains("has External Transitions and has no next step")
|| ex.Message.Contains("has External Transitions to Procedure") || ex.Message.Contains("has External Transitions to Procedure")
|| ex.Message.Contains("has External Transitions to it's children") || ex.Message.Contains("has External Transitions to it's children")
|| ex.Message.Contains("This step has been deleted") || ex.Message.Contains("This step has been deleted")
) )
throw ex; throw ex;
FlexibleMessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); FlexibleMessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return itemInfo; return itemInfo;
} }
else else
return itemInfo; return itemInfo;
} }
} }
#endregion #endregion
private static bool HandleSqlExceptionOnCopy(Exception ex) private static bool HandleSqlExceptionOnCopy(Exception ex)
{ {
if (ex.Message.Contains("This step has been deleted")) if (ex.Message.Contains("This step has been deleted"))
{ {

View File

@ -1936,7 +1936,7 @@ namespace Volian.Controls.Library
sia.IdentifyChildren(highlight); sia.IdentifyChildren(highlight);
} }
} }
if (MyBeforeEditItems != null) if (MyBeforeEditItems != null && !MyItemInfo.IsEnhancedStep)
{ {
foreach (EditItem sib in MyBeforeEditItems) foreach (EditItem sib in MyBeforeEditItems)
{ {

View File

@ -1749,9 +1749,9 @@ namespace Volian.Controls.Library
EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments(); EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments();
// note in follow if statements, 'setting' == false when in enhanced document: // note in follow if statements, 'setting' == false when in enhanced document:
if (setting && MyItemInfo.IsStep && (eds == null || eds.Count == 0)) // this step is in enhanced, but not linked // B2018-112 and is allowed to edit if (setting && MyItemInfo.IsStep && (eds == null || eds.Count == 0)) // this step is in enhanced, but not linked // B2018-112 and is allowed to edit
allowDel = true; // allow delete if not linked allowDel = true; // allow delete if not linked
btnCpyStp.Enabled = setting; btnCpyStp.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi); // setting;
//B20170-158 Allow a Unlinked Step to be pasted before or after a linked step. //B20170-158 Allow a Unlinked Step to be pasted before or after a linked step.
StepTabPanel tmp = Parent as StepTabPanel; StepTabPanel tmp = Parent as StepTabPanel;
//B2020-058: crash on null reference //B2020-058: crash on null reference
if (tmp != null && tmp.MyDisplayTabControl != null && tmp.MyDisplayTabControl.MyCopyStep != null) if (tmp != null && tmp.MyDisplayTabControl != null && tmp.MyDisplayTabControl.MyCopyStep != null)
@ -1761,6 +1761,10 @@ namespace Volian.Controls.Library
{ {
if (MyItemInfo.IsEnhancedStep) btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; if (MyItemInfo.IsEnhancedStep) btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
} }
else if (tmp.MyDisplayTabControl.MyCopyStep.IsEnhancedStep && tmp.MyDisplayTabControl.MyCopyStep.MyDocVersion.VersionID == MyItemInfo.MyDocVersion.VersionID)
{
btnPasteBefore.Enabled = btnPasteAfter.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi);
}
} }
else else
btnStepPaste.Enabled = setting; btnStepPaste.Enabled = setting;