C2025-027-AnnotationsTypeSelect #574

Merged
jjenko merged 10 commits from C2025-027-AnnotationsTypeSelect into Development 2025-07-30 08:23:07 -04:00
34 changed files with 2363 additions and 1348 deletions
Showing only changes of commit 6f04d0bf07 - Show all commits

View File

@@ -101,14 +101,17 @@ namespace VEPROMS
// dltFlg flag is used to notify SQL SP to deleted all the entries for the user before entering the annotation type selections. // dltFlg flag is used to notify SQL SP to deleted all the entries for the user before entering the annotation type selections.
int dltFlg = 1; int dltFlg = 1;
foreach (AnnotataionItem item in lstSelected.Items.OfType<AnnotataionItem>()) //foreach (AnnotataionItem item in lstSelected.Items.OfType<AnnotataionItem>())
{ //{
AnnotationTypeID = item.TypeID; // AnnotationTypeID = item.TypeID;
AnnotationNameStr = item.NameStr; // AnnotationNameStr = item.NameStr;
DataTable dt2 = coverToTable(UserID);
VEPROMS.CSLA.Library.AnnotationstypeSelections.Update2(dt2);
// dltFlg = 0;
//}
VEPROMS.CSLA.Library.AnnotationstypeSelections.Update(UserID, AnnotationTypeID, dltFlg, AnnotationNameStr);
dltFlg = 0;
}
} }
public class AnnotataionItem public class AnnotataionItem
{ {
@@ -172,6 +175,20 @@ namespace VEPROMS
{ {
this.Close(); this.Close();
} }
private DataTable coverToTable(string userid)
{
DataTable dt = new DataTable();
dt.Columns.Add("TypeID", typeof(Int32));
dt.Columns.Add("NameStr", typeof(string));
dt.Columns.Add("UserID", typeof(string));
foreach (AnnotataionItem item in lstSelected.Items.OfType<AnnotataionItem>())
{
dt.Rows.Add(item.TypeID, item.NameStr, userid);
}
return dt;
}
} }
} }

View File

@@ -1,5 +1,3 @@
Set NoCount On; Set NoCount On;
If (db_name() in('master','model','msdn','tempdb')) If (db_name() in('master','model','msdn','tempdb'))
@@ -24076,16 +24074,72 @@ ELSE
GO GO
-- 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]
GO
/****** Object: Table [dbo].[AnnotationTypeSelections] Script Date: 7/10/2025 2:38:23 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Paul Larsen
-- Create date: 07/10/2025
-- Description: Store user Annotation selections for annotation filter.
-- =============================================
CREATE TABLE [dbo].[AnnotationTypeSelections](
[ASTypeID] [int] IDENTITY(1,1) NOT NULL,
[TypeID] [int] NULL,
[UsrID] [varchar](50) NULL,
[Name] [nvarchar](100) NULL,
[Config] [nvarchar](max) NULL,
[DTS] [datetime] NULL,
[UserID] [nvarchar](100) NULL,
mschill marked this conversation as resolved
Review

Would suggest not having columns named both UserID and UserID in the same table as it is confusing which is the function of each,
Would suggest renaming UserID as something like CreatedBy.

Would suggest not having columns named both UserID and UserID in the same table as it is confusing which is the function of each, Would suggest renaming UserID as something like CreatedBy.
[LastChanged] [timestamp] NULL,
[IsEPAnnotationType] [bit] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
--CREATE UNIQUE INDEX idx_AnnotationTypeSelections_Usrid
--ON AnnotationTypeSelections (TypeID, Name, UsrID);
--GO
IF EXISTS (SELECT * FROM sys.indexes WHERE name='idx_AnnotationTypeSelections_UsrID'
AND object_id = OBJECT_ID('[dbo].[AnnotationTypeSelections]'))
begin
DROP INDEX [idx_AnnotationTypeSelections_UsrID] ON [dbo].[AnnotationTypeSelections];
end
CREATE NONCLUSTERED INDEX idx_AnnotationTypeSelections_UsrID
ON [dbo].[AnnotationTypeSelections] (UsrID)
INCLUDE (TypeID, Name)
GO
--CREATE NONCLUSTERED INDEX [idx_AnnotationTypeSelections_Usrid] ON [dbo].[AnnotationTypeSelections]
mschill marked this conversation as resolved
Review

if commented out, should be removed or reason given why commented out?

if commented out, should be removed or reason given why commented out?
--(
-- [UsrID] ASC
--)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
--GO
--CREATE NONCLUSTERED INDEX [idx_AnnotationTypeSelections_TypeID] ON [dbo].[AnnotationTypeSelections]
--(
mschill marked this conversation as resolved
Review

If commented out, would remove or give reason why commented out?

If commented out, would remove or give reason why commented out?
Review

Comment removed.

Comment removed.
-- [TypeID] ASC
--)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
--GO
-- C2025-027 Annotation Type Filtering -- C2025-027 Annotation Type Filtering
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAnnotationSelectListTypes]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAnnotationSelectListTypes]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getAnnotationSelectListTypes]; DROP PROCEDURE [getAnnotationSelectListTypes];
GO GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ============================================= -- =============================================
-- Author: Paul Larsen -- Author: Paul Larsen
-- Create date: 7/10/2025 -- Create date: 7/10/2025
@@ -24104,13 +24158,10 @@ AS
[DTS], [DTS],
[UserID], [UserID],
[LastChanged], [LastChanged],
(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[TypeID]= [TypeID]) [AnnotationCount] (SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[TypeID]= [TypeID]) [AnnotationCount],
--[IsEPAnnotationType] [IsEPAnnotationType]
FROM [AnnotationTypes] --A FROM [AnnotationTypes] --A
--JOIN AnnotationTypeSelections S ON S.TypeID = A.TypeID WHERE TypeID NOT IN (SELECT TypeID FROM AnnotationTypeSelections WHERE UsrID = @UserID)
WHERE TypeID NOT IN (SELECT TypeID FROM AnnotationTypeSelections WHERE UsrID = @UserID) --S.ItemID = @ItemID AND S.TypeID != A.TypeID
RETURN
GO GO
@@ -24154,7 +24205,6 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAnnotationsty
GO GO
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
@@ -24198,12 +24248,42 @@ BEGIN
END END
END END
GO
-- C2025-027 Annotation Type Filtering -- C2025-027 Annotation Type Filtering
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AnnotationTypeSelections]') AND type in (N'U')) --IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[TableValAnnotTypeSelections]') AND OBJECTPROPERTY(id,N'IsType') = 1)
DROP TABLE [dbo].[AnnotationTypeSelections]
-- Type --
--IF NOT EXISTS (SELECT * FROM sys.types WHERE is_table_type = 1 AND name ='TableValAnnotTypeSelections')
-- DROP PROCEDURE [TableValAnnotTypeSelections];
--GO
--/****** Object: UserDefinedTableType [dbo].[TableValAnnotTypeSelections] Script Date: 7/21/2025 8:06:11 PM ******/
--CREATE TYPE [dbo].[TableValAnnotTypeSelections] AS TABLE(
-- [TypeID] [int] NOT NULL,
-- [NameStr] [varchar](200) NULL,
-- [UserID] [varchar](50) NULL
--)
--GO
-- C2025-027 Annotation Type Filtering
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[UpdateAnnotationstypeSelections2]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [UpdateAnnotationstypeSelections2];
-- Need to drop UpdateAnnotationstypeSelections2 SP first so script can drop and recreate the TableValAnnotTypeSelections table type
IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.DOMAINS WHERE Domain_Name = 'TableValAnnotTypeSelections' )
DROP TYPE [dbo].[TableValAnnotTypeSelections]
CREATE TYPE [dbo].[TableValAnnotTypeSelections] AS TABLE(
[TypeID] [int] NOT NULL,
[NameStr] [varchar](200) NULL,
[UserID] [varchar](50) NULL
)
GO GO
/****** Object: Table [dbo].[AnnotationTypeSelections] Script Date: 7/10/2025 2:38:23 PM ******/
/****** Object: StoredProcedure [dbo].[UpdateAnnotationstypeSelections2] Script Date: 7/21/2025 8:51:42 PM ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
@@ -24212,33 +24292,51 @@ GO
-- ============================================= -- =============================================
-- Author: Paul Larsen -- Author: Paul Larsen
-- Create date: 07/10/2025 -- Create date: 07/21/2025
-- Description: Store user Annotation selections for annotation filter. -- Description: Manage user choice annotation types
-- ============================================= -- =============================================
CREATE PROC [dbo].[UpdateAnnotationstypeSelections2]
CREATE TABLE [dbo].[AnnotationTypeSelections](
[ASTypeID] [int] IDENTITY(1,1) NOT NULL,
[TypeID] [int] NULL,
[UsrID] [varchar](50) NULL,
[Name] [nvarchar](100) NOT NULL,
[Config] [nvarchar](max) NULL,
[DTS] [datetime] NOT NULL,
[UserID] [nvarchar](100) NOT NULL,
[LastChanged] [timestamp] NOT NULL,
[IsEPAnnotationType] [bit] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [idx_AnnotationTypeSelections_Usrid] ON [dbo].[AnnotationTypeSelections]
( (
[UsrID] ASC @TempTable AS dbo.TableValAnnotTypeSelections READONLY
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] )
GO AS
CREATE NONCLUSTERED INDEX [idx_AnnotationTypeSelections_TypeID] ON [dbo].[AnnotationTypeSelections] BEGIN
(
[TypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
--INSERT INTO CUSTOMER (CustomerId,CustomerName ,Isdeleted )
--SELECT CustomerId, CustomerName, 0 AS Isdeleted FROM @TempTable
MERGE AnnotationTypeSelections AS TARGET
USING @TempTable AS SOURCE
/* 1. Performing the UPDATE operation */
/* If the P_ID is same,
check for change in P_NAME or P_PRICE */
ON (TARGET.TypeID = SOURCE.TypeID)
WHEN MATCHED
AND TARGET.Name <> SOURCE.NameStr
/* Update the records in TARGET */
THEN UPDATE
SET TARGET.Name = SOURCE.NameStr,
TARGET.UsrID = SOURCE.UserID
/* 2. Performing the INSERT operation */
/* When no records are matched with TARGET table
Then insert the records in the target table */
WHEN NOT MATCHED BY TARGET
THEN INSERT (TypeID, Name, UsrID)
VALUES (SOURCE.TypeID, SOURCE.NameStr,SOURCE.UserID)
/* 3. Performing the DELETE operation */
/* When no records are matched with SOURCE table
Then delete the records from the target table */
WHEN NOT MATCHED BY SOURCE
THEN DELETE;
END
GO
IF (@@Error = 0) PRINT 'Running vesp_UpdateEPFormat Succeeded' IF (@@Error = 0) PRINT 'Running vesp_UpdateEPFormat Succeeded'
ELSE PRINT 'Running vesp_UpdateEPFormat Failed to Execute' ELSE PRINT 'Running vesp_UpdateEPFormat Failed to Execute'

View File

@@ -166,6 +166,31 @@ namespace VEPROMS.CSLA.Library
catch (Exception ex) catch (Exception ex)
{ {
}
}
}
}
public static void Update2(DataTable dt)
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
try
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "UpdateAnnotationstypeSelections2";
cm.CommandTimeout = Database.DefaultTimeout;
//Pass table Valued parameter to Store Procedure
SqlParameter sqlParam = cm.Parameters.AddWithValue("@TempTable", dt);
sqlParam.SqlDbType = SqlDbType.Structured;
cm.ExecuteNonQuery();
}
catch (Exception ex)
{
} }
} }
} }