From ad855b77cdd847ea53f68570f42b34c529886be7 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 7 May 2025 13:21:17 +0200 Subject: [PATCH] Refactor SQL execution in DocumentCreateReadSQL Changed namespace for DocumentCreateReadSQL and updated SQL command to use formatted strings for parameters. Simplified DocumentExecutor to directly use the formatted SQL, enhancing clarity and reducing complexity in parameter handling. --- EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs | 6 +++--- .../Executor/DocumentExecutor.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs b/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs index 02b4ec73..f4f1ffb1 100644 --- a/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs +++ b/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs @@ -10,17 +10,17 @@ namespace EnvelopeGenerator.Application.SQL; public class DocumentCreateReadSQL : ISQL { /// - /// + /// Base64, OUT_UID /// public string Raw => @" USE [DD_ECM] DECLARE @BYTE_DATA1 as VARBINARY(MAX) - SET @BYTE_DATA1 = CONVERT(VARBINARY(MAX),'@Base64') + SET @BYTE_DATA1 = CONVERT(VARBINARY(MAX),{0}) DECLARE @OUT_DOCID int EXEC [dbo].[PRSIG_API_ADD_DOC] - @ENV_UID = @OUT_UID, + @ENV_UID = {1}, @BYTE_DATA = @BYTE_DATA1, @OUT_DOCID = @OUT_DOCID OUTPUT diff --git a/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs b/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs index 7143b81e..aec62eed 100644 --- a/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs +++ b/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs @@ -18,9 +18,9 @@ public class DocumentExecutor : SQLExecutor, IDocumentExecutor { using var connection = new SqlConnection(Params.ConnectionString); var sql = Provider.GetRequiredService(); + var formattedSql = string.Format(sql.Raw, base64, envelope_uuid); await connection.OpenAsync(cancellation); - var parameters = DocumentCreateReadSQL.CreateParmas(base64, envelope_uuid); - var documents = await connection.QueryAsync(sql.Raw, parameters); + var documents = await connection.QueryAsync(formattedSql); return documents.FirstOrDefault() ?? throw new InvalidOperationException($"Document creation failed. Parameters:" + $"base64={base64}, envelope_uuid='{envelope_uuid}'.");