Refactor DocumentCreateReadSQL to remove envelope_uuid
Updated CreateParmas method to accept only base64 string. Converted base64 to byte array and added it as ByteData. Adjusted SQL command and DocumentExecutor to reflect these changes.
This commit is contained in:
parent
126370ebdb
commit
41e0c51055
@ -14,11 +14,11 @@ public class DocumentCreateReadSQL : ISQL<EnvelopeDocument>
|
||||
/// </summary>
|
||||
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<EnvelopeDocument>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="base64"></param>
|
||||
/// <param name="envelope_uuid"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,9 +18,10 @@ public class DocumentExecutor : SQLExecutor, IDocumentExecutor
|
||||
{
|
||||
using var connection = new SqlConnection(Params.ConnectionString);
|
||||
var sql = Provider.GetRequiredService<DocumentCreateReadSQL>();
|
||||
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<EnvelopeDocument>(formattedSql);
|
||||
var documents = await connection.QueryAsync<EnvelopeDocument>(formattedSql, param);
|
||||
return documents.FirstOrDefault()
|
||||
?? throw new InvalidOperationException($"Document creation failed. Parameters:" +
|
||||
$"base64={base64}, envelope_uuid='{envelope_uuid}'.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user