C2025-027-AnnotationsTypeSelect

This commit is contained in:
2025-07-11 16:08:14 -04:00
parent 5f59543a14
commit e08b5cde69
15 changed files with 2717 additions and 1273 deletions

View File

@@ -206,7 +206,7 @@ namespace VEPROMS.CSLA.Library
public partial class AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private AnnotationAuditInfo Item { get { return (AnnotationAuditInfo)_Item; } }
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) {; }
}
#endregion
#region Converter

View File

@@ -0,0 +1,226 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoListConverter))]
public partial class AnnotationAuditInfoList : ReadOnlyListBase<AnnotationAuditInfoList, AnnotationAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<AnnotationAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (AnnotationAuditInfo tmp in this)
{
tmp.Changed += new AnnotationAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~AnnotationAuditInfoList()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
foreach (AnnotationAuditInfo tmp in this)
{
tmp.Changed -= new AnnotationAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static AnnotationAuditInfoList _AnnotationAuditInfoList = null;
/// <summary>
/// Return a list of all AnnotationAuditInfo.
/// </summary>
public static AnnotationAuditInfoList Get()
{
try
{
if (_AnnotationAuditInfoList != null)
return _AnnotationAuditInfoList;
AnnotationAuditInfoList tmp = DataPortal.Fetch<AnnotationAuditInfoList>();
AnnotationAuditInfo.AddList(tmp);
tmp.AddEvents();
_AnnotationAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all AnnotationAuditInfo.
/// </summary>
public static void Reset()
{
_AnnotationAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static AnnotationAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<AnnotationAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
// }
//}
private AnnotationAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationAudits";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new AnnotationAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
AnnotationAuditInfoListPropertyDescriptor pd = new AnnotationAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private AnnotationAuditInfo Item { get { return (AnnotationAuditInfo)_Item; } }
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class AnnotationAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfoList)
{
// Return department and department role separated by comma.
return ((AnnotationAuditInfoList)value).Items.Count.ToString() + " AnnotationAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,463 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
//namespace VEPROMS.CSLA.Library;
// C2025-027 this new file is used to support (data retrival) for selecting Annotation types to display on the Annotation screen.
namespace VEPROMS.CSLA.Library
{
public class AnnotationstypeSelections
{
public static DataTable Get(string UserID, int ItemID)
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationstypeSelections";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@UsrID", UserID);
SqlDataAdapter da = new SqlDataAdapter(cm);
SqlDataReader reader = cm.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
// if the user has not created a annotation sub-set list saved to AnnotationTypeSelections table.
if (dt.Rows.Count < 1)
{
//dt.Rows.Add(DataPortal.Fetch<AnnotationTypeInfoList>());
//DataPortal.Fetch<AnnotationTypeInfoList>();
DataRow row;
int rowflg = 0;
foreach (AnnotationTypeInfo annosel in DataPortal.Fetch<AnnotationTypeInfoList>())
{
// C2025-027 need to use a datatable instead of AnnotationTypeInfoList so the global search Annotations will not be effected by the Annotation select list selections
if (rowflg == 0)
{
row = dt.NewRow();
dt.Rows.Add(row);
rowflg = 1;
}
else
{
row = dt.NewRow();
row["TypeID"] = annosel.TypeID;
row["ItemID"] = ItemID;
row["Name"] = annosel.Name;
row["Config"] = annosel.Config;
row["DTS"] = annosel.DTS;
row["UserID"] = annosel.UserID;
row["IsEPAnnotationType"] = annosel.IsEPAnnotationType;
dt.Rows.Add(row);
}
//row = dt.NewRow();
//row["TypeID"] = annosel.TypeID;
//row["ItemID"] = ItemID;
//row["Name"] = annosel.Name;
//row["Config"] = annosel.Config;
//row["DTS"] = annosel.DTS;
//row["UserID"] = annosel.UserID;
//row["IsEPAnnotationType"] = annosel.IsEPAnnotationType;
//dt.Rows.Add(row);
//dt.Rows.Add(0,annosel.TypeID, ItemID, annosel.Name, annosel.Config, annosel.DTS, annosel.UserID, 0x0000000000000000, annosel.IsEPAnnotationType);
};
}
return dt;
}
catch (Exception ex)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
//instead of crashing
return new DataTable();
}
}
}
}
public static DataTable Retrieve(string UserID)
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationstypeSelections";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@UsrID", UserID);
SqlDataAdapter da = new SqlDataAdapter(cm);
SqlDataReader reader = cm.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
return dt;
}
catch (Exception ex)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
//instead of crashing
return new DataTable();
}
}
}
}
public static DataTable GetAnnoTypes(string UserID)
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationSelectListTypes";
cm.CommandTimeout = Database.DefaultTimeout;
SqlDataAdapter da = new SqlDataAdapter(cm);
cm.Parameters.AddWithValue("@UserID", UserID);
SqlDataReader reader = cm.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
return dt;
}
catch (Exception ex)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
//instead of crashing
return new DataTable();
}
}
}
}
public static void Update(string UserID, int TypeID, int dltFlg, string Name = "")
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "UpdateAnnotationstypeSelections";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@UserID", UserID);
cm.Parameters.AddWithValue("@TypeID", TypeID);
cm.Parameters.AddWithValue("@dltFlg", dltFlg);
cm.Parameters.AddWithValue("@Name", Name);
cm.ExecuteNonQuery();
}
catch (Exception ex)
{
}
}
}
}
public static AnnotationTypeInfoList AnnotationSelectByItem(int itemID)
{
try
{
//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();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
}
}
private int _TypeID;
[System.ComponentModel.DataObjectField(true, true)]
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _TypeID;
}
}
private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ItemID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Name;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _AnnotationTypeAnnotationCount = 0;
public int AnnotationTypeAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationTypeAnnotationCount;
}
}
//C2025-023 - Electronic Procedures - Modifications to PROMS
// Is Annotation Type an EP Annotation?
private bool _IsEPAnnotationType = false;
public bool IsEPAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _IsEPAnnotationType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_IsEPAnnotationType != value)
{
_IsEPAnnotationType = value;
//PropertyHasChanged();
}
}
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
[Serializable()]
protected class retrieveAnnotSelections
{
private int _itemID;
public int itemID { get { return _itemID; } }
public retrieveAnnotSelections(int itemID)
{
_itemID = itemID;
}
}
[Serializable()]
public class retrieveAnnotSelectionsList
{
private int _TypeID;
public int TypeID
{
get { return _TypeID; }
set { _TypeID = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
private string _Config;
public string Config
{
get { return _Config; }
set { _Config = 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; }
}
private bool _IsEPAnnotationType;
public bool IsEPAnnotationType
{
get { return _IsEPAnnotationType; }
set { _IsEPAnnotationType = value; }
}
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
}
private void DataPortal_Fetch(retrieveAnnotSelections criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationstypeSelections";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@itemID", criteria.itemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("retrieveAnnotSelectionsList.DataPortal_Fetch", ex);
throw new DbCslaException("retrieveAnnotSelectionsList.DataPortal_Fetch", ex);
}
//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;
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] retrieveAnnotSelectionsList.ReadData", GetHashCode());
try
{
_TypeID = dr.GetInt32("TypeID");
_ItemID = dr.GetInt32("ItemID");
_Name = dr.GetString("Name");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
if (dr.GetSchemaTable().Rows.OfType<DataRow>().Any(row => row["ColumnName"].ToString() == "IsEPAnnotationType"))
_IsEPAnnotationType = (bool)dr.GetValue("IsEPAnnotationType");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("retrieveAnnotSelectionsList.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("retrieveAnnotSelectionsList.ReadData", ex);
}
}
}
}

View File

@@ -387,6 +387,7 @@
<Compile Include="Generated\ZContentInfo.cs" />
<Compile Include="Generated\ZTransition.cs" />
<Compile Include="Generated\ZTransitionInfo.cs" />
<Compile Include="Minimal\AnnotationstypeSections.cs" />
<Compile Include="Minimal\UserSettings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VEObjects\VEDrillDown.cs" />