Я использую библиотеку C# DocuSign и отправляю 2 документа в конверте.
Я добавляю 2 получателей.
Первый получатель должен подписать документ 1, чтобы класс SignHere имел DocumentId значение 1. Второй получатель должен подписать документ 2, поэтому для класса SignHere для DocumentId установлено значение 2.
В этом случае обоим получателям предлагается подписать документ 1 и документ 2, а подписи перезаписывают друг друга.
Таким образом, DocumentId в классе SignHere игнорируется. Это похоже на ошибку.
Кажется, что строка привязки - это единственное, что действительно контролирует, кто подписывает, какой документ и оба документа будут иметь одинаковые строки привязки. Это потому, что документы были предварительно собраны с якорными строками, такими как <<<signhere:1>>>
Я отредактировал это, чтобы показать мой код:
public string SendDocument(
DocuSignDocument[] Documents,
DocuSignRecipient[] Recipients,
DocuSignSignature[] Signatures,
string EmailSubject = null)
{
string AccessToken = GetAccessToken();
List<Document> EnvelopeDocuments = new List<Document>();
int Index = 0;
foreach (DocuSignDocument Doc in Documents)
{
Document Document = new Document
{
DocumentBase64 = Convert.ToBase64String(FileToBytes(Doc.FileName)),
Name = Doc.DocumentName,
FileExtension = Path.GetExtension(Doc.FileName).TrimStart('.'),
DocumentId = (Index + 1).ToString()
};
EnvelopeDocuments.Add(Document);
Index++;
}
List<Signer> Signers = new List<Signer>();
List<SignHere> SignTabs;
Index = 0;
foreach (DocuSignRecipient Recipient in Recipients)
{
Signer Signer = new Signer()
{
Email = Recipient.EmailAddress,
Name = Recipient.Name,
RecipientId = (Index + 1).ToString(),
RoutingOrder = (Index + 1).ToString()
//RoutingOrder = "1"
};
SignTabs = new List<SignHere>();
// Set the signatures needed for this recipient
foreach (DocuSignSignature Sig in Signatures)
{
if (Sig.DocumentIndex < 0 || Sig.DocumentIndex > Documents.Length - 1)
throw new Exception("Invalid signature DocumentIndex");
if (Sig.RecipientIndex < 0 || Sig.RecipientIndex > Recipients.Length - 1)
throw new Exception("Invalid signature RecipientIndex");
if (Sig.RecipientIndex == Index)
{
// Signature is for this recipient
SignHere SignHere = new SignHere()
{
// It seems DocumentId here is ignored because this recipient still gets asked to sign both documents
DocumentId = (Sig.DocumentIndex + 1).ToString(),
RecipientId = (Sig.RecipientIndex + 1).ToString(),
TabLabel = "Sign here for " + Recipient.Name,
AnchorString = "<<<signhere:" + (Sig.DocumentSignatureIndex + 1) + ">>>"
};
SignTabs.Add(SignHere);
}
}
Signer.Tabs = new Tabs() { SignHereTabs = SignTabs };
Signers.Add(Signer);
Index++;
}
if (EmailSubject == null)
EmailSubject = "Please sign the document";
EnvelopeDefinition Envelope = new EnvelopeDefinition
{
EmailSubject = EmailSubject,
Documents = EnvelopeDocuments,
Recipients = new Recipients { Signers = Signers },
Status = "sent"
};
ApiClient Client = new ApiClient(ApiAddress);
Client.Configuration.AddDefaultHeader("Authorization", "Bearer " + AccessToken);
EnvelopesApi EnvelopesApi = new EnvelopesApi(Client.Configuration);
EnvelopeSummary Results = EnvelopesApi.CreateEnvelope(_AccountId, Envelope);
return Results.EnvelopeId;