Attempted fixes for enhanced tests
This commit is contained in:
parent
96e85e8c5c
commit
09d0f73396
@ -1944,6 +1944,54 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#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)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
|
||||
@ -2066,6 +2114,68 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
#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
|
||||
[Serializable()]
|
||||
public class PastingPartCriteria
|
||||
@ -2356,6 +2466,17 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyPrevious = null; // Reset list so that the next line gets a new list
|
||||
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)
|
||||
{
|
||||
ItemInfo tmp = null;
|
||||
@ -2503,10 +2624,18 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
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;
|
||||
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
|
||||
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans)
|
||||
{
|
||||
firstTrans = false;
|
||||
@ -2518,8 +2647,17 @@ namespace VEPROMS.CSLA.Library
|
||||
ItemInfo newItemInfo = null;
|
||||
try
|
||||
{
|
||||
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
|
||||
if (newItemInfo == null) return null;
|
||||
// if this item is an enhanced item, do a pastereplace specific to it:
|
||||
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)
|
||||
{
|
||||
@ -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
|
||||
return iii;
|
||||
}
|
||||
if (!HandleSqlExceptionOnCopy(ex))
|
||||
{
|
||||
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 it's children")
|
||||
|| ex.Message.Contains("This step has been deleted")
|
||||
)
|
||||
throw ex;
|
||||
if (!HandleSqlExceptionOnCopy(ex))
|
||||
{
|
||||
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 it's children")
|
||||
|| ex.Message.Contains("This step has been deleted")
|
||||
)
|
||||
throw ex;
|
||||
FlexibleMessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
|
||||
return itemInfo;
|
||||
}
|
||||
else
|
||||
return itemInfo;
|
||||
return itemInfo;
|
||||
}
|
||||
else
|
||||
return itemInfo;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
private static bool HandleSqlExceptionOnCopy(Exception ex)
|
||||
private static bool HandleSqlExceptionOnCopy(Exception ex)
|
||||
{
|
||||
if (ex.Message.Contains("This step has been deleted"))
|
||||
{
|
||||
|
@ -1936,7 +1936,7 @@ namespace Volian.Controls.Library
|
||||
sia.IdentifyChildren(highlight);
|
||||
}
|
||||
}
|
||||
if (MyBeforeEditItems != null)
|
||||
if (MyBeforeEditItems != null && !MyItemInfo.IsEnhancedStep)
|
||||
{
|
||||
foreach (EditItem sib in MyBeforeEditItems)
|
||||
{
|
||||
|
@ -1749,9 +1749,9 @@ namespace Volian.Controls.Library
|
||||
EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments();
|
||||
// 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
|
||||
allowDel = true; // allow delete if not linked
|
||||
btnCpyStp.Enabled = setting;
|
||||
//B20170-158 Allow a Unlinked Step to be pasted before or after a linked step.
|
||||
allowDel = true; // allow delete if not linked
|
||||
btnCpyStp.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi); // setting;
|
||||
//B20170-158 Allow a Unlinked Step to be pasted before or after a linked step.
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
//B2020-058: crash on null reference
|
||||
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;
|
||||
}
|
||||
else if (tmp.MyDisplayTabControl.MyCopyStep.IsEnhancedStep && tmp.MyDisplayTabControl.MyCopyStep.MyDocVersion.VersionID == MyItemInfo.MyDocVersion.VersionID)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi);
|
||||
}
|
||||
}
|
||||
else
|
||||
btnStepPaste.Enabled = setting;
|
||||
|
Loading…
x
Reference in New Issue
Block a user