- Introduced a new module for managing user groups (`usrgrp`) in the administration interface. - Implemented CRUD operations for user groups: list, create, rename, and delete. - Added authorization checks to ensure only users with appropriate permissions can manage groups. - Created corresponding frontend JavaScript and SCSS files for the new module. - Updated documentation to reflect the new group management functionality and its authorization model. - Added SQL stored procedures for group management operations. - Established a new login script for database access, ensuring proper security practices.
93 lines
2.5 KiB
Transact-SQL
93 lines
2.5 KiB
Transact-SQL
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[mfr__updt__documents]
|
|
@tblname as nvarchar(50)
|
|
, @referencetable nvarchar(50)
|
|
, @tgtid bigint
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
SET XACT_ABORT ON;
|
|
|
|
BEGIN TRY
|
|
|
|
DECLARE @tmp [dbo].[mfr__tt__documents];
|
|
|
|
DECLARE @tmp_cmd nvarchar(1000) = N'SELECT DISTINCT * FROM ' + @tblname
|
|
INSERT INTO @tmp EXECUTE [sp_executesql] @tmp_cmd;
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
MERGE [dbo].[mfr__documents] as TARGET
|
|
USING @tmp as SOURCE ON TARGET.[Id] = SOURCE.[Id]
|
|
WHEN MATCHED AND (TARGET.[Version] <= SOURCE.[Version] OR TARGET.[DateModified] <= SOURCE.[DateModified] ) THEN
|
|
UPDATE
|
|
SET [Id] = SOURCE.[Id]
|
|
,[CustomValues] = SOURCE.[CustomValues]
|
|
,[Version] = SOURCE.[Version]
|
|
,[State] = SOURCE.[State]
|
|
,[ExternalId] = SOURCE.[ExternalId]
|
|
,[URI] = SOURCE.[URI]
|
|
,[IsGlobal] = SOURCE.[IsGlobal]
|
|
,[StartDateTime] = SOURCE.[StartDateTime]
|
|
,[EndDateTime] = SOURCE.[EndDateTime]
|
|
,[FileName] = SOURCE.[FileName]
|
|
,[DateModified] = SOURCE.[DateModified]
|
|
,[UploadDate] = SOURCE.[UploadDate]
|
|
,[IsLink] = SOURCE.[IsLink]
|
|
,[ContentType] = SOURCE.[ContentType]
|
|
,[HTMLCode] = SOURCE.[HTMLCode]
|
|
,[ServiceRequestId] = SOURCE.[ServiceRequestId]
|
|
,[Note] = SOURCE.[Note]
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT
|
|
([Id]
|
|
,[CustomValues]
|
|
,[Version]
|
|
,[State]
|
|
,[ExternalId]
|
|
,[URI]
|
|
,[IsGlobal]
|
|
,[StartDateTime]
|
|
,[EndDateTime]
|
|
,[FileName]
|
|
,[DateModified]
|
|
,[UploadDate]
|
|
,[IsLink]
|
|
,[ContentType]
|
|
,[HTMLCode]
|
|
,[ServiceRequestId]
|
|
,[Note])
|
|
VALUES
|
|
(SOURCE.[Id]
|
|
,SOURCE.[CustomValues]
|
|
,SOURCE.[Version]
|
|
,SOURCE.[State]
|
|
,SOURCE.[ExternalId]
|
|
,SOURCE.[URI]
|
|
,SOURCE.[IsGlobal]
|
|
,SOURCE.[StartDateTime]
|
|
,SOURCE.[EndDateTime]
|
|
,SOURCE.[FileName]
|
|
,SOURCE.[DateModified]
|
|
,SOURCE.[UploadDate]
|
|
,SOURCE.[IsLink]
|
|
,SOURCE.[ContentType]
|
|
,SOURCE.[HTMLCode]
|
|
,SOURCE.[ServiceRequestId]
|
|
,SOURCE.[Note]);
|
|
|
|
COMMIT TRANSACTION;
|
|
END TRY
|
|
BEGIN CATCH
|
|
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;
|
|
|
|
INSERT INTO dbo.[fds__admin_dberrors] ([UserName], [ErrorNumber], [ErrorState], [ErrorSeverity], [ErrorLine], [ErrorProcedure], [ErrorMessage], [ErrorDateTime])
|
|
VALUES (SUSER_SNAME(), ERROR_NUMBER(), ERROR_STATE(), ERROR_SEVERITY(), ERROR_LINE(), ERROR_PROCEDURE(), ERROR_MESSAGE(), GETDATE());
|
|
|
|
THROW;
|
|
END CATCH;
|
|
END |