- Added RTF command ulnone to StripRtfFormatting
- Fixed ResetParts to also MyContent.RefreshContentParts - Removed a using command because it was causing a cached iteminfo to be disposed. Added DeleteItemAndChildren
This commit is contained in:
parent
8496e3128a
commit
06c622b5eb
@ -981,6 +981,7 @@ namespace VEPROMS.CSLA.Library
|
||||
string retval = rtf;
|
||||
retval = Regex.Replace(retval, @"\\b0 ?", "");
|
||||
retval = Regex.Replace(retval, @"\\b ?", "");
|
||||
retval = Regex.Replace(retval, @"\\ulnone ?", "");
|
||||
retval = Regex.Replace(retval, @"\\ul0 ?", "");
|
||||
retval = Regex.Replace(retval, @"\\ul ?", "");
|
||||
retval = Regex.Replace(retval, @"\\i0 ?", "");
|
||||
@ -1084,8 +1085,19 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string key = itemID.ToString();
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
{
|
||||
bool firstContent = true;
|
||||
foreach (ItemInfo itm in _CacheByPrimaryKey[key])
|
||||
{
|
||||
itm.ResetParts();
|
||||
if (itm._MyContent != null && firstContent)
|
||||
{
|
||||
firstContent = false;// Only need to do this once.
|
||||
//RefreshContentParts looks through ContentInfo objects
|
||||
itm._MyContent.RefreshContentParts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ResetParts()
|
||||
{
|
||||
@ -1289,8 +1301,10 @@ namespace VEPROMS.CSLA.Library
|
||||
_ActiveParent = this.ItemDocVersions[0];
|
||||
else
|
||||
{
|
||||
using (ContentInfo parentContent = ParentContent)
|
||||
{
|
||||
//The following using command caused a cached iteminfo to be disposed.
|
||||
//using (ContentInfo parentContent = ParentContent)
|
||||
//{
|
||||
ContentInfo parentContent = ParentContent;
|
||||
if (parentContent == null || parentContent.ContentItemCount == 0)
|
||||
_ActiveParent = this;
|
||||
else
|
||||
@ -1300,7 +1314,7 @@ namespace VEPROMS.CSLA.Library
|
||||
itemID = list[0].ItemID;
|
||||
_ActiveParent = ItemInfo.Get(itemID);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,9 +361,146 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ResetOrdinal()
|
||||
public void ResetOrdinal()
|
||||
{
|
||||
ResetOrdinal(ItemID);
|
||||
}
|
||||
public static void DeleteItemInfoAndChildren(int itemID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = itemID.ToString();
|
||||
if(_CacheByPrimaryKey.ContainsKey(key))
|
||||
{
|
||||
|
||||
ItemInfo [] items = _CacheByPrimaryKey[key].ToArray();
|
||||
ItemInfo parent = items[0].ActiveParent as ItemInfo;
|
||||
if (parent != null)
|
||||
ItemInfo.ResetParts(parent.ItemID);
|
||||
foreach (ItemInfo item in items)
|
||||
item.DeleteItemInfoAndChildren();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteItemInfoAndChildren()
|
||||
{
|
||||
if (_ItemParts != null)
|
||||
{
|
||||
foreach (PartInfo part in _ItemParts)
|
||||
{
|
||||
if (part._MyItems != null)
|
||||
{
|
||||
foreach (ItemInfo item in part._MyItems)
|
||||
{
|
||||
item.DeleteItemInfoAndChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Dispose();
|
||||
}
|
||||
public static void RefreshPrevious(int? itemID, int? previousID)
|
||||
{
|
||||
if (itemID == null) return;
|
||||
string key = itemID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_CacheByPrimaryKey.ContainsKey(key))
|
||||
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
|
||||
tmpInfo.RefreshPrevious(previousID);
|
||||
}
|
||||
private void RefreshPrevious(int? previousID)
|
||||
{
|
||||
if (_PreviousID != previousID)
|
||||
{
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
|
||||
_PreviousID = previousID; // Update the value
|
||||
}
|
||||
_MyPrevious = null; // Reset list so that the next line gets a new list
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
|
||||
}
|
||||
}
|
||||
public partial class Item
|
||||
{
|
||||
#region DeleteItemAndChildren
|
||||
public static void DeleteItemAndChildren(ItemInfo item)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Item");
|
||||
try
|
||||
{
|
||||
ItemInfo nextItem = item.NextItem;
|
||||
DataPortal.Delete(new DeleteCriteria(item.ItemID,Environment.UserName));
|
||||
if (nextItem != null) // Adjust PreviousID for NextItem
|
||||
{
|
||||
ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
|
||||
nextItem.ResetOrdinal();
|
||||
nextItem.RefreshItemParts();
|
||||
nextItem.UpdateTransitionText();
|
||||
}
|
||||
ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Data.SqlClient.SqlException exSQL = SqlException(ex);
|
||||
if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###"))
|
||||
//return false;
|
||||
throw exSQL;
|
||||
else
|
||||
throw new DbCslaException("Error on Item.DeleteItemAndChildren", ex);
|
||||
}
|
||||
}
|
||||
private static System.Data.SqlClient.SqlException SqlException(Exception ex)
|
||||
{
|
||||
Type sqlExType = typeof(System.Data.SqlClient.SqlException);
|
||||
while (ex != null)
|
||||
{
|
||||
if (ex.GetType() == sqlExType) return ex as System.Data.SqlClient.SqlException;
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
[Serializable()]
|
||||
protected class DeleteCriteria
|
||||
{
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{ get { return _ItemID; } }
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
set { _UserID = value; }
|
||||
}
|
||||
public DeleteCriteria(int itemID,String userID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
_UserID = userID;
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
private void DataPortal_Delete(DeleteCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "DeleteItemAndChildren";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
|
||||
cm.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Delete", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("Item.DataPortal_Delete", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user