Migliorata scrittura codice per stampa
This commit is contained in:
+9
-11
@@ -73,9 +73,7 @@ Class ZebraPrinter
|
||||
End Function
|
||||
|
||||
' creo e stampo l'etichetta (ricevo il nome del template da usare)
|
||||
Public Async Sub Print(FilePath As String)
|
||||
Await Task.Run(Async Function()
|
||||
|
||||
Public Sub Print(FilePath As String)
|
||||
Try
|
||||
' Connecting...
|
||||
m_printerConnection.Open()
|
||||
@@ -86,7 +84,7 @@ Class ZebraPrinter
|
||||
LabelFile = LabelFile.Replace(Variable.Key, Variable.Value)
|
||||
Next
|
||||
Dim LabelBytes As Byte() = Encoding.UTF8.GetBytes(LabelFile)
|
||||
Await Task.Delay(200)
|
||||
Task.Delay(200)
|
||||
' stampo etichetta
|
||||
m_printerConnection.Write(LabelBytes)
|
||||
m_Waiting = False
|
||||
@@ -96,6 +94,8 @@ Class ZebraPrinter
|
||||
' Communications Error
|
||||
Catch __unusedZebraPrinterLanguageUnknownException2__ As ZebraPrinterLanguageUnknownException
|
||||
EmitLog(__unusedZebraPrinterLanguageUnknownException2__.ToString)
|
||||
Catch ex As Exception
|
||||
EmitLog(ex.ToString)
|
||||
End Try
|
||||
|
||||
' Chiudo la connessione
|
||||
@@ -103,7 +103,7 @@ Class ZebraPrinter
|
||||
'Threading.Thread.Sleep(500)
|
||||
Threading.Thread.Sleep(200)
|
||||
' Disconnecting...
|
||||
If m_printerConnection IsNot Nothing Then
|
||||
If Not IsNothing(m_printerConnection) Then
|
||||
m_printerConnection.Close()
|
||||
EmitLog("Connessione stampante: CHIUSA")
|
||||
Threading.Thread.Sleep(1000)
|
||||
@@ -111,9 +111,9 @@ Class ZebraPrinter
|
||||
' Not Connected
|
||||
Catch __unusedConnectionException1__ As ConnectionException
|
||||
EmitLog(__unusedConnectionException1__.ToString)
|
||||
Catch ex As Exception
|
||||
EmitLog(ex.ToString)
|
||||
End Try
|
||||
|
||||
End Function)
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -183,16 +183,14 @@ Class ZebraPrinter
|
||||
Print(args(0))
|
||||
|
||||
' metto il programmma in attesa
|
||||
Dim nCiclo As Integer = 0
|
||||
While m_Waiting And nCiclo < 6
|
||||
Threading.Thread.Sleep(1000)
|
||||
nCiclo += 1
|
||||
End While
|
||||
|
||||
' elimino il file dei dati
|
||||
Try
|
||||
File.Delete(args(1))
|
||||
EmitLog("Eliminato file " & args(1))
|
||||
Catch ex As Exception
|
||||
EmitLog(ex.ToString)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<StartAction>Project</StartAction>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>C:\EgtProg\OmagVIEW\ZebraPrinterUtilitiesD32.exe</StartProgram>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
|
||||
Reference in New Issue
Block a user