C2025-027-Develop-a-way-to-filter-annotations-so-the-user-can-view-only-the-types-they-want-to-see-EP

This commit is contained in:
2025-04-25 14:33:40 -04:00
parent 6fd84e2f2a
commit 7c1d2b8aa5
13 changed files with 1186 additions and 89 deletions

View File

@@ -105,6 +105,33 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
}
}
//AnnotationTypeInfoList AnnotationTypeInfoList2 = new AnnotationTypeInfoList();
public static AnnotationTypeInfoList AnnotationSelectByItem(int itemID)
{
try
{ // C2025-027 This method needs to be refreshed everytime.
//if (_AnnotationTypeInfoList != null)
// return _AnnotationTypeInfoList;
AnnotationTypeInfoList tmp = (AnnotationTypeInfoList)DataPortal.Fetch(new AnnotationSelectByItemIDCriteria(itemID));
if (tmp.Count < 1)
{
tmp = DataPortal.Fetch<AnnotationTypeInfoList>();
}
AnnotationTypeInfo.AddList(tmp);
tmp.AddEvents();
_AnnotationTypeInfoList = tmp;
OnListChanged();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all AnnotationTypeInfo.
/// </summary>
@@ -157,6 +184,50 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
protected class AnnotationSelectByItemIDCriteria
{
private int _itemID;
public int ItemID
{ get { return _itemID; } }
public AnnotationSelectByItemIDCriteria(int itemID)
{
_itemID = itemID;
}
}
private void DataPortal_Fetch(AnnotationSelectByItemIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationTypes2";
cm.Parameters.AddWithValue("@itemID", criteria.ItemID);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new AnnotationTypeInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationTypeInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()