C2025-027-AnnotationsTypeSelect

This commit is contained in:
Paul Larsen 2025-07-15 23:14:26 -04:00
parent e08b5cde69
commit f6e25fd966
7 changed files with 66 additions and 371 deletions

View File

@ -24135,7 +24135,7 @@ CREATE PROC [dbo].[getAnnotationstypeSelections]
)
AS
BEGIN
IF((SELECT TypeID FROM AnnotationTypeSelections WHERE UsrID = @UsrID) > 0)
IF((SELECT count(TypeID) FROM AnnotationTypeSelections WHERE UsrID = @UsrID) > 0)
BEGIN
SELECT [ASTypeID]
,[TypeID]
@ -24164,6 +24164,56 @@ BEGIN
END
GO
-- C2025-027 Annotation Type Filtering
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAnnotationstypeFiltered]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getAnnotationstypeFiltered];
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Paul Larsen
-- Create date: 07/10/2025
-- Description: Retrieve Current Annotation Types
-- =============================================
CREATE PROC [dbo].[getAnnotationstypeFiltered]
(
@UsrID varchar(50)
)
AS
BEGIN
IF((SELECT count(TypeID) FROM AnnotationTypeSelections WHERE UsrID = @UsrID) > 0)
BEGIN
SELECT [ASTypeID]
,[TypeID]
,[UsrID]
,[Name]
,[Config]
,[DTS]
,[UserID]
,[IsEPAnnotationType]
FROM [dbo].[AnnotationTypeSelections]
WHERE UsrID = @UsrID
END
ELSE
BEGIN
SELECT
[TypeID],
[Name],
[Config],
[DTS],
[UserID],
[LastChanged],
(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[TypeID]=[AnnotationTypes].[TypeID]) [AnnotationCount],
[IsEPAnnotationType]
FROM [AnnotationTypes]
END
END
-- C2025-027 Annotation Type Filtering
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AnnotationTypeSelections]') AND type in (N'U'))
DROP TABLE [dbo].[AnnotationTypeSelections]

View File

@ -1663,7 +1663,7 @@ namespace VEPROMS
private DevComponents.DotNetBar.QatCustomizeItem qatCustomizeItem1;
private DevComponents.DotNetBar.Bar bottomBar;
private DevComponents.DotNetBar.ProgressBarItem bottomProgBar;
private DevComponents.DotNetBar.ExpandablePanel epAnnotations;
public DevComponents.DotNetBar.ExpandablePanel epAnnotations;
private DevComponents.DotNetBar.ExpandablePanel epProcedures;
private DevComponents.DotNetBar.ExpandablePanel infoPanel;
private Volian.Controls.Library.vlnTreeView tv;

View File

@ -1296,37 +1296,10 @@ namespace VEPROMS
pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0;
}
//void tv_SelectAnnotations(object sender, vlnTreeEventArgs args)
//{
// ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo;
// if (pi == null) return;
// tc.SaveCurrentEditItem(pi);
// //pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex;
// DlgAnnotationsSelect sannoDlg = new DlgAnnotationsSelect(pi, MyUserInfo.UserID);
// //sannoDlg.SelectedSlave = args.UnitIndex;
// //sannoDlg.MySessionInfo = MySessionInfo;
// sannoDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window
// //pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0;
//}
public static void tv_SelectAnnotations()
{
//ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo;
//if (pi == null) return;
//tc.SaveCurrentEditItem(pi);
//pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex;
DlgAnnotationsSelect sannoDlg = new DlgAnnotationsSelect(VlnSettings.UserID);
//sannoDlg.SelectedSlave = args.UnitIndex;
//sannoDlg.MySessionInfo = MySessionInfo;
sannoDlg.ShowDialog(); // RHM 20120925 - Center dialog over PROMS window
//pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0;
}
void tv_CreateTimeCriticalActionSummary(object sender, vlnTreeEventArgs args)
{

View File

@ -1,226 +0,0 @@
// ========================================================================
// 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

@ -16,13 +16,13 @@ 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.
// C2025-027 this new file is used to support (data retrival) for selecting Annotation types to display on the Annotation screen. This is related to Annotation type filtering through V->Options.
namespace VEPROMS.CSLA.Library
{
public class AnnotationstypeSelections
{
public static DataTable Get(string UserID, int ItemID)
public static DataTable Get(string UserID)
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
@ -31,7 +31,7 @@ namespace VEPROMS.CSLA.Library
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationstypeSelections";
cm.CommandText = "getAnnotationstypeFiltered";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@UsrID", UserID);
SqlDataAdapter da = new SqlDataAdapter(cm);
@ -58,7 +58,6 @@ namespace VEPROMS.CSLA.Library
{
row = dt.NewRow();
row["TypeID"] = annosel.TypeID;
row["ItemID"] = ItemID;
row["Name"] = annosel.Name;
row["Config"] = annosel.Config;
row["DTS"] = annosel.DTS;
@ -67,18 +66,7 @@ namespace VEPROMS.CSLA.Library
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;
@ -183,27 +171,7 @@ namespace VEPROMS.CSLA.Library
}
}
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
@ -361,80 +329,6 @@ namespace VEPROMS.CSLA.Library
}
}
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());

View File

@ -119,13 +119,11 @@ namespace Volian.Controls.Library
if (CurrentItem.MyDocVersion != null)
if (CurrentItem.MyDocVersion.DocVersionAssociationCount > 0)
_ROPath = CurrentItem.MyDocVersion.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath;
ProcItem = CurrentItem.MyProcedure;
// C2025-027
//cbGridAnnoType.DataSource = VEPROMS.CSLA.Library.AnnotationstypeSelections.Get(ProcItem.ItemID);
cbGridAnnoType.DataSource = VEPROMS.CSLA.Library.AnnotationstypeSelections.Get(MyUserInfo.UserID, ProcItem.ItemID);
cbGridAnnoType.WatermarkText = "Select Annotation Type";
//ProcItem = CurrentItem.MyProcedure;
// C2025-027 Annotation Type Filtering
//cbGridAnnoType.WatermarkText = "Select Annotation Type";
//cbGridAnnoType.DataSource = VEPROMS.CSLA.Library.AnnotationstypeSelections.Get(MyUserInfo.UserID);
}
public AnnotationInfo FirstExeAnnotation(ItemInfo ii)
@ -372,6 +370,12 @@ namespace Volian.Controls.Library
cbGridAnnoType.DisplayMember = "Name";
cbGridAnnoType.ValueMember = "TypeId";
cbGridAnnoType.DataSource = AnnotationTypeInfoList.Get().Clone();
//ProcItem = CurrentItem.MyProcedure;
//C2025 - 027 Annotation Type Filtering
cbGridAnnoType.WatermarkText = "Select Annotation Type";
cbGridAnnoType.DataSource = VEPROMS.CSLA.Library.AnnotationstypeSelections.Get(MyUserInfo.UserID);
// If there are no annotatons, then selected index is -1 (not defined), otherwise select the first.
// This was done so that it could be saved if there was text entered but user moves to another steprtb without selecting save button
// so that annotation gets saved.