From 0ea1c28424a6b413194f7feaa8753756c4aed888 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 20 Apr 2023 09:18:48 +0200 Subject: [PATCH 1/3] update x metodo reset Queue --- WebDoorCreator.API/Controllers/QueueController.cs | 4 +--- WebDoorCreator.Data/Services/QueueDataService.cs | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs index 8cd8b4f..a02d448 100644 --- a/WebDoorCreator.API/Controllers/QueueController.cs +++ b/WebDoorCreator.API/Controllers/QueueController.cs @@ -65,9 +65,7 @@ namespace WebDoorCreator.API.Controllers bool fatto = false; if (passPhrase == "bbbBirdIsTheWord") { - // vera chaimata di reset delle code - fatto = true; - await Task.Delay(10); + fatto = await QDataServ.ResetQueue(); } answ = fatto ? "OK" : "NO"; return answ; diff --git a/WebDoorCreator.Data/Services/QueueDataService.cs b/WebDoorCreator.Data/Services/QueueDataService.cs index 6edf2ab..899505d 100644 --- a/WebDoorCreator.Data/Services/QueueDataService.cs +++ b/WebDoorCreator.Data/Services/QueueDataService.cs @@ -390,6 +390,7 @@ namespace WebDoorCreator.Data.Services { await RequestPendingUpsert(item.Name, item.Value); await RequestProcessingRemove(item.Name); + fatto = true; } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; From be3ff6e8612bac6b68b77a1a9b2b90b09b5b6caf Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 20 Apr 2023 10:23:08 +0200 Subject: [PATCH 2/3] Fix reset coda processing --- DemoVB/Form1.Designer.vb | 34 ++++++++++++++++-------------- DemoVB/Form1.vb | 8 +++---- WeebDoorCreator.SDK/WDC.cs | 43 +++++++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/DemoVB/Form1.Designer.vb b/DemoVB/Form1.Designer.vb index 4d4604b..086cfb9 100644 --- a/DemoVB/Form1.Designer.vb +++ b/DemoVB/Form1.Designer.vb @@ -27,8 +27,8 @@ Partial Class Form1 Me.lblTestAlive = New System.Windows.Forms.Label() Me.btnTestAlive = New System.Windows.Forms.Button() Me.btnFullTest = New System.Windows.Forms.Button() - Me.lblOut = New System.Windows.Forms.Label() Me.btnResetQueue = New System.Windows.Forms.Button() + Me.txtOut = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'btnTestPing @@ -76,19 +76,6 @@ Partial Class Form1 Me.btnFullTest.Text = "Full Test" Me.btnFullTest.UseVisualStyleBackColor = True ' - 'lblOut - ' - Me.lblOut.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.lblOut.AutoSize = True - Me.lblOut.BackColor = System.Drawing.SystemColors.ControlDarkDark - Me.lblOut.ForeColor = System.Drawing.Color.Gold - Me.lblOut.Location = New System.Drawing.Point(106, 64) - Me.lblOut.MinimumSize = New System.Drawing.Size(650, 400) - Me.lblOut.Name = "lblOut" - Me.lblOut.Size = New System.Drawing.Size(650, 400) - Me.lblOut.TabIndex = 5 - Me.lblOut.Text = "Label1" - ' 'btnResetQueue ' Me.btnResetQueue.Location = New System.Drawing.Point(13, 228) @@ -98,13 +85,28 @@ Partial Class Form1 Me.btnResetQueue.Text = "Reset Queue" Me.btnResetQueue.UseVisualStyleBackColor = True ' + 'txtOut + ' + Me.txtOut.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtOut.BackColor = System.Drawing.SystemColors.ControlDarkDark + Me.txtOut.ForeColor = System.Drawing.Color.Yellow + Me.txtOut.Location = New System.Drawing.Point(109, 64) + Me.txtOut.MinimumSize = New System.Drawing.Size(650, 400) + Me.txtOut.Multiline = True + Me.txtOut.Name = "txtOut" + Me.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtOut.Size = New System.Drawing.Size(650, 400) + Me.txtOut.TabIndex = 7 + Me.txtOut.Text = "---" + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(764, 472) + Me.Controls.Add(Me.txtOut) Me.Controls.Add(Me.btnResetQueue) - Me.Controls.Add(Me.lblOut) Me.Controls.Add(Me.btnFullTest) Me.Controls.Add(Me.lblTestAlive) Me.Controls.Add(Me.btnTestAlive) @@ -122,6 +124,6 @@ Partial Class Form1 Friend WithEvents lblTestAlive As Label Friend WithEvents btnTestAlive As Button Friend WithEvents btnFullTest As Button - Friend WithEvents lblOut As Label Friend WithEvents btnResetQueue As Button + Friend WithEvents txtOut As TextBox End Class diff --git a/DemoVB/Form1.vb b/DemoVB/Form1.vb index 84631cd..67f9183 100644 --- a/DemoVB/Form1.vb +++ b/DemoVB/Form1.vb @@ -52,7 +52,7 @@ Public Class Form1 Next sb.AppendLine("----------------------------") sb.AppendLine() - lblOut.Text = sb.ToString() + txtOut.Text = sb.ToString() ' recupero numero da processare num2proc = currWDC.numTask2proc If (num2proc > 0) Then @@ -73,7 +73,7 @@ Public Class Form1 ' mi limito a mostrare codice + contenuto DDF... dovrebbe processare invero... sb.AppendLine("--------------------------------------------------------") - sb.AppendLine($"DoorId.Vers: {item.Key}.{item.Value}") + sb.AppendLine($"DoorId.Vers: {item.Key}") sb.AppendLine("DDF:") sb.AppendLine("--------") sb.AppendLine(item.Value) @@ -99,13 +99,13 @@ Public Class Form1 sb.AppendLine(respPut) sb.AppendLine("----------------------------") - lblOut.Text = sb.ToString() + txtOut.Text = sb.ToString() End If End Sub Private Sub btnResetQueue_Click(sender As Object, e As EventArgs) Handles btnResetQueue.Click currWDC.ResetQueue() - lblOut.Text = "Queue Resetted!" + txtOut.Text = "Queue Resetted!" End Sub End Class diff --git a/WeebDoorCreator.SDK/WDC.cs b/WeebDoorCreator.SDK/WDC.cs index 81e8c6b..70ceb18 100644 --- a/WeebDoorCreator.SDK/WDC.cs +++ b/WeebDoorCreator.SDK/WDC.cs @@ -121,7 +121,7 @@ namespace WeebDoorCreator.SDK { { "passPhrase", "bbbBirdIsTheWord" } }; - var rawData = callUrlGet(urlTakeNextItems, parList); + var rawData = callUrlPost(urlResetQueue,"", parList); return rawData; } @@ -260,6 +260,47 @@ namespace WeebDoorCreator.SDK // restituisco valore! return answ; } + /// + /// Effettua chiamata URL POST con parametri (opzionali) e payload (opzionale) e restituisce risultato + /// + /// + /// + /// + /// + protected string callUrlPost(string URL, string payload, Dictionary paramsList) + { + string answ = ""; + // cerco online + RestClient client = new RestClient(apiUrl); + var request = new RestRequest(URL); + // compongo + string paramsQuery = ""; + if (paramsList != null && paramsList.Count > 0) + { + foreach (var item in paramsList) + { + paramsQuery += $"{item.Key}={item.Value}"; + } + request = new RestRequest($"{URL}?{paramsQuery}"); + } + if (!string.IsNullOrEmpty(payload)) + { + request.AddJsonBody(payload); + } + var response = client.Post(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 From 55d1dbf6efdfe74c57b3710ea0d384164f9e42e8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 20 Apr 2023 10:24:53 +0200 Subject: [PATCH 3/3] Aggiunto check solo stato code --- DemoVB/Form1.Designer.vb | 14 +++++++++++++- DemoVB/Form1.vb | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/DemoVB/Form1.Designer.vb b/DemoVB/Form1.Designer.vb index 086cfb9..4496fdb 100644 --- a/DemoVB/Form1.Designer.vb +++ b/DemoVB/Form1.Designer.vb @@ -29,6 +29,7 @@ Partial Class Form1 Me.btnFullTest = New System.Windows.Forms.Button() Me.btnResetQueue = New System.Windows.Forms.Button() Me.txtOut = New System.Windows.Forms.TextBox() + Me.btnQueueStatus = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnTestPing @@ -69,7 +70,7 @@ Partial Class Form1 ' 'btnFullTest ' - Me.btnFullTest.Location = New System.Drawing.Point(13, 61) + Me.btnFullTest.Location = New System.Drawing.Point(12, 104) Me.btnFullTest.Name = "btnFullTest" Me.btnFullTest.Size = New System.Drawing.Size(75, 23) Me.btnFullTest.TabIndex = 4 @@ -100,11 +101,21 @@ Partial Class Form1 Me.txtOut.TabIndex = 7 Me.txtOut.Text = "---" ' + 'btnQueueStatus + ' + Me.btnQueueStatus.Location = New System.Drawing.Point(13, 64) + Me.btnQueueStatus.Name = "btnQueueStatus" + Me.btnQueueStatus.Size = New System.Drawing.Size(75, 23) + Me.btnQueueStatus.TabIndex = 8 + Me.btnQueueStatus.Text = "Stato Queue" + Me.btnQueueStatus.UseVisualStyleBackColor = True + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(764, 472) + Me.Controls.Add(Me.btnQueueStatus) Me.Controls.Add(Me.txtOut) Me.Controls.Add(Me.btnResetQueue) Me.Controls.Add(Me.btnFullTest) @@ -126,4 +137,5 @@ Partial Class Form1 Friend WithEvents btnFullTest As Button Friend WithEvents btnResetQueue As Button Friend WithEvents txtOut As TextBox + Friend WithEvents btnQueueStatus As Button End Class diff --git a/DemoVB/Form1.vb b/DemoVB/Form1.vb index 67f9183..bf3ebcf 100644 --- a/DemoVB/Form1.vb +++ b/DemoVB/Form1.vb @@ -108,4 +108,19 @@ Public Class Form1 currWDC.ResetQueue() txtOut.Text = "Queue Resetted!" End Sub + + Private Sub btnQueueStatus_Click(sender As Object, e As EventArgs) Handles btnQueueStatus.Click + + Dim queueStatus As New Dictionary(Of String, Long) + 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() + txtOut.Text = sb.ToString() + End Sub End Class