public bool DeviceBlobAdd( Guid userId, Guid deviceId, string langCode, DbDefines.DocumentType docTypeId, string fileName, string fileExt, byte[] blobData, out string errorMessage) { const string cmdText = "cli.BlobAdd4CustomerDevice"; using var db = new SqlConnection(m_connStr); var cmd = db.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = cmdText; cmd.AddCustomerIdParam(userId); cmd.Parameters.AddWithValue(PrmDeviceId, deviceId); cmd.Parameters.AddWithValue(PrmDocTypeId, (int)docTypeId); cmd.Parameters.AddWithNullableValue(PrmFileName, fileName ?? SqlString.Null); cmd.Parameters.AddWithNullableValue(PrmFileExt, fileExt ?? SqlString.Null); cmd.Parameters.AddWithValue(PrmBlobData, blobData); var prmErrMsg = cmd.AddErrorMessageParam(); var prmRc = cmd.AddRetvalParam(); db.Open(); cmd.ExecuteNonQuery(); var rc = (int)prmRc.Value; if (rc != 0) { var errMsg = (SqlString)prmErrMsg.Value; errorMessage = !errMsg.IsNull ? errMsg.Value : string.Empty; return(false); } errorMessage = null; return(true); }
public bool TicketBlobAdd( Guid userId, Guid ticketId, DbDefines.DocumentType docTypeId, string fileName, string fileExt, byte[] fileData, out string errorMessage) { const string cmdText = "cli.BlobAdd4Ticket"; using var db = new SqlConnection(m_connStr); var cmd = db.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = cmdText; cmd.AddUserIdParam(userId); cmd.Parameters.AddWithValue(PrmTicketId, ticketId); cmd.Parameters.AddWithValue(PrmDocTypeId, (int)docTypeId); cmd.Parameters.AddWithValue(PrmFileName, fileName ?? SqlString.Null); cmd.Parameters.AddWithValue(PrmFileExt, fileExt ?? SqlString.Null); cmd.Parameters.AddWithValue(PrmBlobData, fileData); var prmErrMsg = cmd.AddErrorMessageParam(); var prmRc = cmd.AddRetvalParam(); db.Open(); cmd.ExecuteNonQuery(); var rc = (int)prmRc.Value; if (rc != 0) { var errMsg = (SqlString)prmErrMsg.Value; errorMessage = $"{DbRes.T("FileUploadError", ResourceSet)}: {(!errMsg.IsNull ? errMsg.Value : string.Empty)}"; return(false); } errorMessage = null; return(true); }