CSLA - Extension
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -11,12 +9,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class AnnotationInfo
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return _SearchText;
|
||||
}
|
||||
#region JCB Annotation Status
|
||||
private bool _IsAnnotationNew = false;
|
||||
public override string ToString() => _SearchText;
|
||||
#region JCB Annotation Status
|
||||
private bool _IsAnnotationNew = false;
|
||||
|
||||
public bool IsAnnotationNew
|
||||
{
|
||||
@@ -49,11 +44,8 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public partial class AnnotationType
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
[NonSerialized]
|
||||
public override string ToString() => _Name;
|
||||
[NonSerialized]
|
||||
private AnnotationTypeConfig _AnnotationTypeConfig;
|
||||
public AnnotationTypeConfig AnnotationTypeConfig
|
||||
{
|
||||
@@ -83,79 +75,69 @@ namespace VEPROMS.CSLA.Library
|
||||
return _AnnotationTypeConfig;
|
||||
}
|
||||
}
|
||||
public static List<AnnotationTypeInfo> AllList()
|
||||
public static List<AnnotationTypeInfo> AllList() => AnnotationTypeInfo._CacheList;
|
||||
public override string ToString() => _Name;
|
||||
public static AnnotationTypeInfo GetByName(string name)
|
||||
{
|
||||
//return _AllList;
|
||||
return AnnotationTypeInfo._CacheList;
|
||||
try
|
||||
{
|
||||
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationTypeInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
[Serializable()]
|
||||
protected class GetByNameCriteria
|
||||
{
|
||||
return _Name;
|
||||
private readonly string _Name;
|
||||
public string Name => _Name;
|
||||
public GetByNameCriteria(string name) => _Name = name;
|
||||
}
|
||||
public static AnnotationTypeInfo GetByName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationTypeInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetByNameCriteria
|
||||
{
|
||||
private string _Name;
|
||||
public string Name { get { return _Name; } }
|
||||
public GetByNameCriteria(string name)
|
||||
{
|
||||
_Name = name;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByNameCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationTypeByName";
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.Parameters.AddWithValue("@Name", criteria.Name);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
|
||||
ApplicationContext.LocalContext.Remove("cn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByNameCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getAnnotationTypeByName";
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.Parameters.AddWithValue("@Name", criteria.Name);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
|
||||
ApplicationContext.LocalContext.Remove("cn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial class AnnotationTypeInfoList
|
||||
{
|
||||
public static void Refresh()
|
||||
@@ -177,44 +159,20 @@ namespace VEPROMS.CSLA.Library
|
||||
_TypeID = anotypeid;
|
||||
MarkDirty(); // force the record update
|
||||
Save();
|
||||
//Update(); // commit record to database
|
||||
}
|
||||
}
|
||||
public void CommitChanges()
|
||||
{
|
||||
MarkDirty(); // force the record update
|
||||
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));
|
||||
AnnotationInfo.StaticOnInfoChanged();
|
||||
// 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)
|
||||
{
|
||||
@@ -228,8 +186,6 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public static void DeleteAnnotationProcByType(int typID, string procList)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
DataPortal.Delete(new DeleteAnnotationProcByTypeCriteria(typID, procList));
|
||||
@@ -247,8 +203,6 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public static void DeleteAnnotationDocvByType(int typID, string versionID)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
DataPortal.Delete(new DeleteAnnotationDocvByTypeCriteria(typID, versionID));
|
||||
@@ -266,8 +220,6 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public static int getAnnotationProcCnt(int typID, string procList)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
Annotation ProcCnt = DataPortal.Fetch<Annotation>(new getAnnotationCountProcCriteria(typID, procList));
|
||||
@@ -287,8 +239,6 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public static int getAnnotationCountDocv(int typID, string procList)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
Annotation DocvCnt = DataPortal.Fetch<Annotation>(new getAnnotationCountDocvCriteria(typID, procList));
|
||||
@@ -319,10 +269,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class DeleteCriteria
|
||||
{
|
||||
private int _AnnotationID;
|
||||
public int AnnotationID
|
||||
{ get { return _AnnotationID; } }
|
||||
private string _UserID;
|
||||
private readonly int _AnnotationID;
|
||||
public int AnnotationID => _AnnotationID;
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
@@ -364,14 +313,12 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class DeleteAnnotationProcByTypeCriteria
|
||||
{
|
||||
private int _typeID;
|
||||
public int TypeID
|
||||
{ get { return _typeID; } }
|
||||
private readonly int _typeID;
|
||||
public int TypeID => _typeID;
|
||||
|
||||
private string _procList;
|
||||
public string ProcList
|
||||
{ get { return _procList; } }
|
||||
public DeleteAnnotationProcByTypeCriteria(int typeID, string procList)
|
||||
private readonly string _procList;
|
||||
public string ProcList => _procList;
|
||||
public DeleteAnnotationProcByTypeCriteria(int typeID, string procList)
|
||||
{
|
||||
_typeID = typeID;
|
||||
_procList = procList;
|
||||
@@ -407,14 +354,12 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class DeleteAnnotationDocvByTypeCriteria
|
||||
{
|
||||
private int _typeID;
|
||||
public int TypeID
|
||||
{ get { return _typeID; } }
|
||||
private readonly int _typeID;
|
||||
public int TypeID => _typeID;
|
||||
|
||||
private string _versionID;
|
||||
public string VersionID
|
||||
{ get { return _versionID; } }
|
||||
public DeleteAnnotationDocvByTypeCriteria(int typeID, string versionID)
|
||||
private readonly string _versionID;
|
||||
public string VersionID => _versionID;
|
||||
public DeleteAnnotationDocvByTypeCriteria(int typeID, string versionID)
|
||||
{
|
||||
_typeID = typeID;
|
||||
_versionID = versionID;
|
||||
@@ -459,16 +404,15 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
private int _procCnt;
|
||||
public int ProcCnt
|
||||
{ get { return _procCnt; }
|
||||
set { _procCnt = value; }
|
||||
{
|
||||
get { return _procCnt; }
|
||||
set { _procCnt = value; }
|
||||
}
|
||||
private int _typeID;
|
||||
public int TypeID
|
||||
{ get { return _typeID; } }
|
||||
private string _procList;
|
||||
public string ProcList
|
||||
{ get { return _procList; } }
|
||||
public getAnnotationCountProcCriteria(int typeID, string procList, int procCnt = 0)
|
||||
private readonly int _typeID;
|
||||
public int TypeID => _typeID;
|
||||
private readonly string _procList;
|
||||
public string ProcList => _procList;
|
||||
public getAnnotationCountProcCriteria(int typeID, string procList, int procCnt = 0)
|
||||
{
|
||||
_typeID = typeID;
|
||||
_procList = procList;
|
||||
@@ -517,16 +461,15 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
private int _docvCnt;
|
||||
public int DocvCnt
|
||||
{ get { return _docvCnt; }
|
||||
set { _docvCnt = value; }
|
||||
{
|
||||
get { return _docvCnt; }
|
||||
set { _docvCnt = value; }
|
||||
}
|
||||
private int _TypeID;
|
||||
public int TypeID
|
||||
{ get { return _TypeID; } }
|
||||
private string _docvList;
|
||||
public string DocvList
|
||||
{ get { return _docvList; } }
|
||||
public getAnnotationCountDocvCriteria(int typeID, string docvList, int docvCnt = 0)
|
||||
private readonly int _TypeID;
|
||||
public int TypeID => _TypeID;
|
||||
private readonly string _docvList;
|
||||
public string DocvList => _docvList;
|
||||
public getAnnotationCountDocvCriteria(int typeID, string docvList, int docvCnt = 0)
|
||||
{
|
||||
_TypeID = typeID;
|
||||
_docvList = docvList;
|
||||
|
||||
Reference in New Issue
Block a user