diff --git a/DemoVB/DemoVB.vbproj b/DemoVB/DemoVB.vbproj index fe6ef33..5f70030 100644 --- a/DemoVB/DemoVB.vbproj +++ b/DemoVB/DemoVB.vbproj @@ -155,5 +155,19 @@ WeebDoorCreator.SDK + + + Always + + + Always + + + Always + + + Always + + \ No newline at end of file diff --git a/DemoVB/Form1.vb b/DemoVB/Form1.vb index 5fa6c36..4908666 100644 --- a/DemoVB/Form1.vb +++ b/DemoVB/Form1.vb @@ -1,4 +1,5 @@ -Imports System.Net.NetworkInformation +Imports System.IO +Imports System.Net.NetworkInformation Imports System.Text Imports WeebDoorCreator.SDK @@ -30,28 +31,70 @@ Public Class Form1 End If End Sub + Dim idxSim As Integer = 0 + Private Sub btnFullTest_Click(sender As Object, e As EventArgs) Handles btnFullTest.Click - Dim answ As String = "" + + 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("----------------------------") 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 - answ = sb.ToString() - lblOut.Text = answ - - ' mi prendo la lista dei primi 2 e processo... - - ' gestione random se success oppure errore... + 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 diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs index 4818d43..593157c 100644 --- a/WebDoorCreator.API/Controllers/QueueController.cs +++ b/WebDoorCreator.API/Controllers/QueueController.cs @@ -74,7 +74,7 @@ namespace WebDoorCreator.API.Controllers /// /// [HttpGet("TakeNextItems")] - public async Task> TakeProcessingItems(int numItems) + public async Task> TakeProcessingItems(int numItems = 10) { var actQueue = await QDataServ.TakeProcessingItems(numItems); return actQueue; diff --git a/WebDoorCreator.UI/temp/Conf.yaml b/WebDoorCreator.UI/temp/Conf.yaml index 334932c..c4b0f6d 100644 --- a/WebDoorCreator.UI/temp/Conf.yaml +++ b/WebDoorCreator.UI/temp/Conf.yaml @@ -11,11 +11,8 @@ order: elevation: project: pO: - line: -<<<<<<< HEAD + line: date: 2023-04-19T12:47:14.6842406+02:00 -======= ->>>>>>> 7b61d49767d77faa7513f4f237adadd704a7631d piece: DO_1 produce: false profiles: @@ -35,8 +32,6 @@ profiles: type: BV machining: ON overmaterial: 0.1 -<<<<<<< HEAD -======= secure: UP size: width: 33.8125 @@ -64,6 +59,5 @@ locks: back_set: 2.0 offset_WS: 0.0 side: lock_top ->>>>>>> 7b61d49767d77faa7513f4f237adadd704a7631d --- diff --git a/WeebDoorCreator.SDK/WDC.cs b/WeebDoorCreator.SDK/WDC.cs index eadd7e2..d5db8da 100644 --- a/WeebDoorCreator.SDK/WDC.cs +++ b/WeebDoorCreator.SDK/WDC.cs @@ -78,14 +78,36 @@ namespace WeebDoorCreator.SDK /// /// Status delle code chiamate /// - public Dictionary queueStatus + public Dictionary queueStatus() { - get + var rawData = callUrl(urlActLenght); + var returnData = JsonConvert.DeserializeObject>(rawData); + return returnData; + } + /// + /// Elenco degli item da processare, nel formato DoorId, Vers + /// + public Dictionary queueList(int maxNum) + { + Dictionary parList = new Dictionary { - var rawData = callUrl(urlActLenght); - var returnData = JsonConvert.DeserializeObject>(rawData); - return returnData; - } + { "numItems", $"{maxNum}" } + }; + var rawData = callUrl(urlTakeNextItems, parList); + var returnData = JsonConvert.DeserializeObject>(rawData); + return returnData; + } + + /// + /// Restitusice l'elenco degli esiti di processing + /// + /// + /// + public bool SendProcResults(List calcResults) + { + bool fatto = false; + + return fatto; } #endregion Public Properties @@ -163,6 +185,37 @@ namespace WeebDoorCreator.SDK // restituisco valore! return answ; } + /// + /// Effettua chiamata URL e restituisce risultato + /// + /// + /// + protected string callUrl(string URL, Dictionary paramsList) + { + string answ = ""; + // cerco online + RestClient client = new RestClient(apiUrl); + // compongo + string paramsQuery = ""; + foreach (var item in paramsList) + { + paramsQuery += $"{item.Key}={item.Value}"; + } + var request = new RestRequest($"{URL}?{paramsQuery}"); + var response = client.Get(request); + // controllo status code risposta + if (response.StatusCode == System.Net.HttpStatusCode.OK) + { + // deserializzo risposta + answ = response.Content; + } + else + { + answ = "KO"; + } + // restituisco valore! + return answ; + } #endregion Protected Methods