Support import without printing documents
This commit is contained in:
parent
5f335b4fee
commit
a8ca303f5e
@ -35,6 +35,19 @@ Namespace Templates
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property PrintDocument As Boolean
|
||||
Get
|
||||
Dim oPrintDocument = GetParameter("PRINT")
|
||||
Dim oDefaultValue = True
|
||||
|
||||
If oPrintDocument IsNot Nothing Then
|
||||
oDefaultValue = IIf(oPrintDocument = "0", False, True)
|
||||
End If
|
||||
|
||||
Return oDefaultValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property DocTypeCategory As DocumentTypeCategory
|
||||
Get
|
||||
Select Case DocType
|
||||
@ -80,8 +93,8 @@ Namespace Templates
|
||||
Dim oParam1 As String = Utils.NotNull(Parameter1, String.Empty)
|
||||
Dim oParam2 As String = Utils.NotNull(Parameter2, String.Empty)
|
||||
|
||||
Dim oParamValue1 = TryGetParameter(oParam1)
|
||||
Dim oParamValue2 = TryGetParameter(oParam2)
|
||||
Dim oParamValue1 = TryGetParameter(oParam1, pName)
|
||||
Dim oParamValue2 = TryGetParameter(oParam2, pName)
|
||||
|
||||
If oParamValue1 IsNot Nothing AndAlso oParamValue1.Item1 = pName Then
|
||||
Return oParamValue1.Item2
|
||||
@ -94,15 +107,17 @@ Namespace Templates
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Private Function TryGetParameter(pParameterString As String) As Tuple(Of String, String)
|
||||
Private Function TryGetParameter(pParameterString As String, pName As String) As Tuple(Of String, String)
|
||||
If pParameterString <> String.Empty Then
|
||||
Dim oSplit = pParameterString.Split("=").ToList()
|
||||
For Each oParameter In pParameterString.Split(",")
|
||||
Dim oSplit = oParameter.Split("=").ToList()
|
||||
|
||||
If oSplit.Count = 2 Then
|
||||
Return New Tuple(Of String, String)(oSplit.First, oSplit.Last)
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
If oSplit.Count = 2 AndAlso oSplit.First = pName Then
|
||||
Return New Tuple(Of String, String)(oSplit.First, oSplit.Last)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return Nothing
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports System.Net.Http
|
||||
Imports System.Collections.Specialized
|
||||
Imports System.Net.Http
|
||||
Imports System.Text
|
||||
Imports System.Xml
|
||||
Imports DigitalData.Modules.Database
|
||||
@ -48,7 +49,6 @@ Namespace Winline
|
||||
''' <exception cref="TaskCanceledException"></exception>
|
||||
''' <returns>True if request was successful.</returns>
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Documents.Document, pTemplate As Template, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
|
||||
Dim oWS = Config
|
||||
|
||||
RaiseEvent WebServiceProgress(Me, "Einstellungen laden")
|
||||
@ -75,7 +75,13 @@ Namespace Winline
|
||||
RaiseEvent WebServiceProgress(Me, "Dateien schreiben")
|
||||
Logger.Debug("Writing request file to [{oOutputFilePath}]")
|
||||
|
||||
' If configured, prevent printing the document and instead create it as a draft in the "Nicht gedruckt" section
|
||||
If pTemplate.PrintDocument = False Then
|
||||
pDocument.PrintVoucher = 0
|
||||
End If
|
||||
|
||||
' --- Serialize Data into XML string
|
||||
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
|
||||
IO.File.WriteAllBytes(oOutputFilePath, oBytes)
|
||||
|
||||
' --- Copy file to Winline Import Directory
|
||||
@ -106,7 +112,19 @@ Namespace Winline
|
||||
' 1 = As File (relative to Winline Server directory)
|
||||
Dim oByref = 1
|
||||
|
||||
Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pMandator.Id}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
|
||||
Dim oParams As New NameValueCollection() From {
|
||||
{"User", oWS.Username},
|
||||
{"Password", oWS.Password},
|
||||
{"Company", pMandator.Id},
|
||||
{"Type", oTemplateType},
|
||||
{"Vorlage", oTemplateName},
|
||||
{"ActionCode", oActionCode},
|
||||
{"Byref", oByref},
|
||||
{"Data", oImportRelativeFilePath}
|
||||
}
|
||||
|
||||
Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import{ToQueryString(oParams)}"
|
||||
'Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pMandator.Id}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
|
||||
Dim oClient As New HttpClient With {
|
||||
.Timeout = TimeSpan.FromSeconds(Constants.HTTP_REQUEST_TIMEOUT_IN_SECONDS)
|
||||
}
|
||||
@ -436,6 +454,27 @@ Namespace Winline
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function ToQueryString(ByVal nvc As NameValueCollection) As String
|
||||
Dim sb As StringBuilder = New StringBuilder("?")
|
||||
Dim first As Boolean = True
|
||||
|
||||
For Each key As String In nvc.AllKeys
|
||||
|
||||
For Each value As String In nvc.GetValues(key)
|
||||
|
||||
If Not first Then
|
||||
sb.Append("&")
|
||||
End If
|
||||
|
||||
sb.AppendFormat("{0}={1}", Uri.EscapeDataString(key), Uri.EscapeDataString(value))
|
||||
first = False
|
||||
Next
|
||||
Next
|
||||
|
||||
Return sb.ToString()
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
End Namespace
|
||||
Loading…
x
Reference in New Issue
Block a user