Files
webdoorcreator/DemoVB/Form1.vb
T
2023-04-19 17:40:32 +02:00

101 lines
3.6 KiB
VB.net

Imports System.IO
Imports System.Net.NetworkInformation
Imports System.Text
Imports WeebDoorCreator.SDK
Public Class Form1
' caricamento del NEXT STACK da redis (come oggetto)
' PROD http : https://iis01.egalware.com/WDC/SRV/
' DEV: https : https://localhost:7043/
Dim baseIp As String = "iis01.steamware.net"
Dim baseUrl As String = "https://iis01.egalware.com/WDC/SRV/"
Dim codPost As String = "WRK001" ' nome macchina calcolo
Dim risultatoPing As PingReply = Nothing
Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
Private Sub btnTestPing_Click(sender As Object, e As EventArgs) Handles btnTestPing.Click
' chiamo test ping...
risultatoPing = currWDC.testPing
lblpingTest.Text = risultatoPing.Status.ToString()
End Sub
Private Sub btnTestAlive_Click(sender As Object, e As EventArgs) Handles btnTestAlive.Click
Dim answ As String = ""
If (currWDC.testAlive) Then
lblTestAlive.Text = "Server Alive!!!"
Else
lblTestAlive.Text = "Alive test failed!"
End If
End Sub
Dim idxSim As Integer = 0
Private Sub btnFullTest_Click(sender As Object, e As EventArgs) Handles btnFullTest.Click
Dim num2proc As Integer
Dim queueStatus As New Dictionary(Of String, Long)
Dim queueList As New Dictionary(Of String, String)
Dim procResults As New List(Of CalcResultDTO)
Dim respDone As Boolean
Dim fileName As String
Dim fileCont As String
queueStatus = currWDC.queueStatus
Dim sb As StringBuilder
sb = New StringBuilder
sb.AppendLine("----------------------------")
For Each item As KeyValuePair(Of String, Long) In queueStatus
sb.AppendLine($"{item.Key} | Found {item.Value} items")
Next
sb.AppendLine("----------------------------")
sb.AppendLine()
lblOut.Text = sb.ToString()
' recupero numero da processare
num2proc = currWDC.numTask2proc
If (num2proc > 0) Then
sb.AppendLine("----------------------------")
' mi prendo la lista dei primi 2 e processo...
queueList = currWDC.queueList(2)
' gestione random se success oppure errore...
For Each item As KeyValuePair(Of String, String) In queueList
fileCont = ""
idxSim = idxSim + 1
If (idxSim > 3) Then
idxSim = 0
End If
fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg")
If (File.Exists(fileName)) Then
fileCont = File.ReadAllText(fileName)
End If
sb.AppendLine($"DoorId.Vers: {item.Key}.{item.Value}")
Dim currRes As New CalcResultDTO
currRes.Validated = True
currRes.DoorIdVers = $"{item.Key}.{item.Value}"
currRes.SvgGen = fileCont
procResults.Add(currRes)
Next
sb.AppendLine("----------------------------")
sb.AppendLine()
' rendo la risposta...
respDone = currWDC.SendProcResults(procResults)
sb.AppendLine()
sb.AppendLine("----------------------------")
If (respDone) Then
sb.AppendLine("Effettuato invio risposta al server")
Else
sb.AppendLine("Errore durante invio risposta al server")
End If
sb.AppendLine("----------------------------")
lblOut.Text = sb.ToString()
End If
End Sub
End Class