diff --git a/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs b/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs index 7fec8262..ed682b0e 100644 --- a/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs +++ b/EnvelopeGenerator.Application/SQL/DocumentCreateReadSQL.cs @@ -14,11 +14,11 @@ public class DocumentCreateReadSQL : ISQL /// public string Raw => @" DECLARE @BYTE_DATA1 as VARBINARY(MAX) - SET @BYTE_DATA1 = CONVERT(VARBINARY(MAX),{0}) + SET @BYTE_DATA1 = @ByteData DECLARE @OUT_DOCID int EXEC [dbo].[PRSIG_API_ADD_DOC] - {1}, + {0}, @BYTE_DATA1, @OUT_DOCID OUTPUT @@ -31,13 +31,12 @@ public class DocumentCreateReadSQL : ISQL /// /// /// - /// /// - public static DynamicParameters CreateParmas(string base64, string envelope_uuid) + public static DynamicParameters CreateParmas(string base64) { var parameters = new DynamicParameters(); - parameters.Add("@Base64", base64); - parameters.Add("@OUT_UID", envelope_uuid); + byte[] byteData = Convert.FromBase64String(base64); + parameters.Add("ByteData", byteData, System.Data.DbType.Binary); return parameters; } } diff --git a/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs b/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs index 0b42a766..11088c63 100644 --- a/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs +++ b/EnvelopeGenerator.Infrastructure/Executor/DocumentExecutor.cs @@ -18,9 +18,10 @@ public class DocumentExecutor : SQLExecutor, IDocumentExecutor { using var connection = new SqlConnection(Params.ConnectionString); var sql = Provider.GetRequiredService(); - var formattedSql = string.Format(sql.Raw, base64.ToSqlParam(), envelope_uuid.ToSqlParam()); + var formattedSql = string.Format(sql.Raw, envelope_uuid.ToSqlParam()); + var param = DocumentCreateReadSQL.CreateParmas(base64); await connection.OpenAsync(cancellation); - var documents = await connection.QueryAsync(formattedSql); + var documents = await connection.QueryAsync(formattedSql, param); return documents.FirstOrDefault() ?? throw new InvalidOperationException($"Document creation failed. Parameters:" + $"base64={base64}, envelope_uuid='{envelope_uuid}'.");