Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE [SG_UTNet4_Sprint_11_Tune]
- GO
- /****** Object: StoredProcedure [utbio].[DeleteEnrollmentData] Script Date: 3/24/2017 11:34:26 AM ******/
- DROP PROCEDURE [utbio].[DeleteEnrollmentData]
- GO
- /****** Object: StoredProcedure [utbio].[DeleteEnrollmentData] Script Date: 3/24/2017 11:34:26 AM ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: Boris Kostadinov
- -- Create date: 26.11.2013
- -- Last update author: Ognjan Ognjanoski
- -- Last update date: 28.07.2015
- -- Description: Used to delete the biometrics data from a client file.
- -- Version: 1.3
- -- =============================================
- CREATE PROCEDURE [utbio].[DeleteEnrollmentData]
- @ImplementationID nvarchar(50),
- @UserProfileID bigint,
- @UseDeleteAuthorization bit,
- @UserIPAddress nvarchar(46),
- @ClientFileID bigint,
- @BiometricsDataTypeID nchar(1) = 'P', -- add in 1.3
- @DeleteReason nvarchar(200),
- @Result bigint OUTPUT,
- @ResultMessage nvarchar(max) OUTPUT
- AS
- BEGIN
- SET NOCOUNT ON;
- DECLARE
- @BiometricsDataID bigint,
- @UserCanModify bit,
- @ActivityDetails nvarchar(max)
- IF @ClientFileID != 0 AND EXISTS( SELECT * FROM utbio.tClientFiles WHERE ClientFileID = @ClientFileID AND IsDeleted = 'False' )
- BEGIN
- -- Check the access rights:
- --EXEC utUserManagement.VerifyAccessRight
- -- @UserProfileID = @UserProfileID,
- -- @ImplementationID = @ImplementationID,
- -- @UserIPAddress = @UserIPAddress,
- -- @AccessRightCode = 'BDE',
- -- @ProtectedObjectRef = NULL,
- -- @Result = @UserCanModify OUTPUT;
- --IF @UserCanModify = 'True'
- --BEGIN
- BEGIN TRAN DeleteEnrollmentData
- BEGIN TRY
- SELECT @BiometricsDataID = BiometricsDataID FROM utbio.tBiometricsData WHERE ClientFileID = @ClientFileID AND IsDeleted = 'False' AND BiometricsTypeID = @BiometricsDataTypeID
- IF @BiometricsDataID IS NOT NULL
- BEGIN
- IF @UseDeleteAuthorization = 1 -- Check for is there a Delete Authorization for the implementation
- BEGIN
- Insert into utbio.tDeleteAuthorizations
- values( @BiometricsDataID, GETDATE(), @UserProfileID, @DeleteReason, 0, null, null )
- -- Add log entry:
- SET @ActivityDetails = '<Details><Description>' + CASE
- WHEN @DeleteReason IS NULL OR @DeleteReason = '' THEN 'Biometrics fingerprint data send for delete authorization by user.'
- ELSE 'Biometrics fingerprint data send for delete authorization by user with reason: ' + @DeleteReason END + '</Description></Details>';
- EXEC utbio.InsertBiometricsLogEntry
- @ActivityCodeID = 'BDDL',
- @ActivityOn = NULL,
- @ActivityBy = @UserProfileID,
- @UserIPAddress = @UserIPAddress,
- @ClientFileID = @ClientFileID,
- @BiometricsDataID = @BiometricsDataID,
- @ActivityDetails = @ActivityDetails,
- @IsSystemAction = 'False'
- END
- ELSE -- @UseDeleteAuthorization = 0
- BEGIN
- -- Mark this entry as delted:
- UPDATE utbio.tBiometricsData
- SET
- IsDeleted = 'True',
- DeletedOn = GETDATE(),
- DeletedBy = @UserProfileID
- WHERE BiometricsDataID = @BiometricsDataID
- -- Add log entry:
- SET @ActivityDetails = '<Details><Description>' + CASE
- WHEN @DeleteReason IS NULL OR @DeleteReason = '' THEN 'Biometrics fingerprint data deleted by user.'
- ELSE 'Biometrics fingerprint data deleted by user with reason: ' + @DeleteReason END + '</Description></Details>';
- EXEC utbio.InsertBiometricsLogEntry
- @ActivityCodeID = 'BDDL',
- @ActivityOn = NULL,
- @ActivityBy = @UserProfileID,
- @UserIPAddress = @UserIPAddress,
- @ClientFileID = @ClientFileID,
- @BiometricsDataID = @BiometricsDataID,
- @ActivityDetails = @ActivityDetails,
- @IsSystemAction = 'False'
- END
- END
- SET @Result = 0
- SET @ResultMessage = 'Successfully deleted biometrics data.'
- COMMIT TRAN DeleteEnrollmentData
- END TRY
- BEGIN CATCH
- ROLLBACK TRAN DeleteEnrollmentData
- SET @Result = 1
- SET @ResultMessage = 'SQL error while trying to delete enrollment data!'
- DECLARE
- @Error int,
- @Message nvarchar(max)
- SELECT @Error = ERROR_NUMBER(), @Message = ERROR_MESSAGE()
- RAISERROR( 'UTBio_DeleteEnrollmentData: %d - %s', 16, 1, @Error, @Message );
- END CATCH
- --END
- --ELSE
- --BEGIN
- -- SET @Result = 3
- -- SET @ResultMessage = 'User is not allowed to modify client file biometrics data!'
- --END
- END
- ELSE
- BEGIN
- SET @Result = 2
- SET @ResultMessage = 'Client file with the provided ID does not exist!'
- END
- END
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement