Change Manager
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@@ -10,6 +15,37 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
return _SearchText;
|
||||
}
|
||||
#region JCB Annotation Status
|
||||
private bool _IsAnnotationNew = false;
|
||||
|
||||
public bool IsAnnotationNew
|
||||
{
|
||||
get
|
||||
{
|
||||
ProcedureInfo pi = this.MyItem.MyProcedure;
|
||||
if (pi != null)
|
||||
//todo figure out audit count
|
||||
_IsAnnotationNew = (this.DTS > pi.DTS);
|
||||
return _IsAnnotationNew;
|
||||
}
|
||||
}
|
||||
private bool _IsAnnotationChanged;
|
||||
|
||||
public bool IsAnnotationChanged
|
||||
{
|
||||
get
|
||||
{
|
||||
ProcedureInfo pi = this.MyItem.MyProcedure;
|
||||
if (pi != null)
|
||||
{
|
||||
//todo figure out audit count
|
||||
_IsAnnotationChanged = (this.DTS > pi.DTS);
|
||||
}
|
||||
return _IsAnnotationChanged;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
public partial class AnnotationType
|
||||
{
|
||||
@@ -52,6 +88,100 @@ namespace VEPROMS.CSLA.Library
|
||||
Save(true);
|
||||
//Update();
|
||||
}
|
||||
|
||||
public static void DeleteAnnotation(AnnotationInfo obj)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
// ItemInfo nextItem = item.NextItem;
|
||||
// ItemInfo prevItem = item.MyPrevious;
|
||||
// item.OnBeforeDelete();
|
||||
DataPortal.Delete(new DeleteCriteria(obj.AnnotationID, Volian.Base.Library.VlnSettings.UserID));
|
||||
// if (nextItem != null) // Adjust PreviousID for NextItem
|
||||
// {
|
||||
// ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
|
||||
// // The order of the next two methods was required to fix a null reference
|
||||
// // when getting myparent. This bug was found when deleting a node from the
|
||||
// // tree when the RTBItem was not open (i.e. in the step editor window).
|
||||
// nextItem.RefreshItemParts();
|
||||
// //nextItem.ResetOrdinal(); - UpdateTransitionText calls ResetOrdinal
|
||||
// nextItem.UpdateTransitionText();
|
||||
// }
|
||||
// else if (prevItem != null)
|
||||
// {
|
||||
// prevItem.RefreshNextItems();
|
||||
// if (prevItem.IsCaution || prevItem.IsNote) prevItem.ResetOrdinal();
|
||||
// prevItem.UpdateTransitionText();
|
||||
// }
|
||||
// ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("AnnotationExt: Stacktrace = {0}", ex.StackTrace);
|
||||
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 Annotation.Delete", 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 _AnnotationID;
|
||||
public int AnnotationID
|
||||
{ get { return _AnnotationID; } }
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
set { _UserID = value; }
|
||||
}
|
||||
public DeleteCriteria(int annotationID, String userID)
|
||||
{
|
||||
_AnnotationID = annotationID;
|
||||
_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 = "deleteAnnotationWithUserID";
|
||||
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
//public partial class AnnotationTypeAnnotations
|
||||
//{
|
||||
|
Reference in New Issue
Block a user