Vb.net का उपयोग करके एक बार सभी के द्वारा हस्ताक्षरित फ़ाइलें कैसे डाउनलोड करें। मैं टेम्पलेट आईडी के साथ लिफाफा भेजने के लिए तैयार हूं। इसलिए मैं लिफाफा आईडी का उपयोग करके उस फ़ाइल को वापस प्राप्त करना चाहता हूं, कृपया vb.net का उपयोग कर फ़ाइलों को पुनर्प्राप्त करने के लिए कुछ नमूना कोड प्रदान करें।

यहां कोड जो मैंने vb.net में उपयोग किया था

Private Function DoWnload(ByVal accessToken As String, ByVal basePath As String, ByVal accountId As String, ByVal envelopeId As String, ByVal documents As List(Of EnvelopeDocItem), ByVal docSelect As String) As String
    Dim config = New Configuration(New ApiClient(basePath))
    config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
    Dim envelopesApi As EnvelopesApi = New EnvelopesApi(config)
    Dim results As System.IO.Stream = envelopesApi.GetDocument(accountId, envelopeId, docSelect)
    Dim docItem As EnvelopeDocItem = documents.FirstOrDefault(Function(d) docSelect.Equals(d.DocumentId))
    Dim docName As String = docItem.Name
    Dim hasPDFsuffix As Boolean = docName.ToUpper().EndsWith(".PDF")
    Dim pdfFile As Boolean = hasPDFsuffix
    Dim docType As String = docItem.Type

    If ("content".Equals(docType) OrElse "summary".Equals(docType)) AndAlso Not hasPDFsuffix Then
        docName += ".pdf"
        pdfFile = True
    End If

    If "zip".Equals(docType) Then
        docName += ".zip"
    End If

    Dim mimetype As String

    If pdfFile Then
        mimetype = "application/pdf"
    ElseIf "zip".Equals(docType) Then
        mimetype = "application/zip"
    Else
        mimetype = "application/octet-stream"
    End If
    ''Dim f1 As FileStream = New FileStream("sample.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
    '  Return File(results, mimetype, docName)

    Dim bytesRead As Integer
    Dim buffer(4096) As Byte

    Using outFile As New System.IO.FileStream("C:\File.pdf", IO.FileMode.Create, IO.FileAccess.Write)
        Do
            bytesRead = results.Read(buffer, 0, buffer.Length)
            If bytesRead > 0 Then
                outFile.Write(buffer, 0, bytesRead)
            End If
        Loop While bytesRead > 0
    End Using
    Return ""

End Function



   Dim envelopeDocItems As List(Of EnvelopeDocItem) = New List(Of EnvelopeDocItem) From {
New EnvelopeDocItem With {
    .Name = "Combined",
    .Type = "content",
    .DocumentId = "combined"
},
New EnvelopeDocItem With {
    .Name = "Zip archive",
    .Type = "zip",
    .DocumentId = "archive"
}

उस दस्तावेज़ में चुनें कि क्या पास करना है? मैंने डॉक्यूमेटिड पास किया, त्रुटि हो रही है।

सादर, अरविंद

0
aravindb 8 सितंबर 2020, 16:31

1 उत्तर

सबसे बढ़िया उत्तर
Private Function DoWork(ByVal accessToken As String, ByVal basePath As String, ByVal accountId As String, ByVal envelopeId As String, ByVal documents As List(Of EnvelopeDocItem), ByVal docSelect As String) As FileStreamResult
    Dim config = New Configuration(New ApiClient(basePath))
    config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
    Dim envelopesApi As EnvelopesApi = New EnvelopesApi(config)
    Dim results As System.IO.Stream = envelopesApi.GetDocument(accountId, envelopeId, docSelect)
    Dim docItem As EnvelopeDocItem = documents.FirstOrDefault(Function(d) docSelect.Equals(d.DocumentId))
    Dim docName As String = docItem.Name
    Dim hasPDFsuffix As Boolean = docName.ToUpper().EndsWith(".PDF")
    Dim pdfFile As Boolean = hasPDFsuffix
    Dim docType As String = docItem.Type

    If ("content".Equals(docType) OrElse "summary".Equals(docType)) AndAlso Not hasPDFsuffix Then
        docName += ".pdf"
        pdfFile = True
    End If

    If "zip".Equals(docType) Then
        docName += ".zip"
    End If

    Dim mimetype As String

    If pdfFile Then
        mimetype = "application/pdf"
    ElseIf "zip".Equals(docType) Then
        mimetype = "application/zip"
    Else
        mimetype = "application/octet-stream"
    End If

    Return File(results, mimetype, docName)
End Function

आपको यहां से नगेट प्राप्त करना होगा - https://www.nuget.org /packages/DocuSign.eSign.dll/ लेकिन संस्करण 5.0.0 उपरोक्त कोड के साथ काम नहीं करेगा, संस्करण 4.3 का उपयोग करें

अद्यतन: इस अतिरिक्त वर्ग को जोड़ना:

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks

Namespace Models
    Public Class EnvelopeDocItem
        Public Property Name As String
        Public Property Type As String
        Public Property DocumentId As String
    End Class
End Namespace
1
Inbar Gazit 10 सितंबर 2020, 20:20