From 7508b118fe0994ee883bdac62e2b1054e5bdb6ab Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 Apr 2023 20:01:10 +0200 Subject: [PATCH] refresh webAPI --- DemoServer/MainForm.Designer.cs | 77 +++++++++++++++++-- DemoServer/MainForm.cs | 18 +++++ .../Controllers/QueueController.cs | 55 +++++++++++++ WebDoorCreator.API/Program.cs | 3 + WebDoorCreator.API/WebDoorCreator.API.csproj | 1 + 5 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 WebDoorCreator.API/Controllers/QueueController.cs diff --git a/DemoServer/MainForm.Designer.cs b/DemoServer/MainForm.Designer.cs index dc1aef4..9fccf68 100644 --- a/DemoServer/MainForm.Designer.cs +++ b/DemoServer/MainForm.Designer.cs @@ -32,6 +32,11 @@ this.txtServAddr = new System.Windows.Forms.TextBox(); this.txtUrlAddr = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.btnOpenSwagger = new System.Windows.Forms.Button(); + this.btnPing = new System.Windows.Forms.Button(); + this.lblOut = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -47,37 +52,92 @@ // this.txtServAddr.Location = new System.Drawing.Point(99, 13); this.txtServAddr.Name = "txtServAddr"; - this.txtServAddr.Size = new System.Drawing.Size(287, 20); + this.txtServAddr.Size = new System.Drawing.Size(342, 20); this.txtServAddr.TabIndex = 1; this.txtServAddr.Text = "iis01.egalware.com"; // // txtUrlAddr // - this.txtUrlAddr.Location = new System.Drawing.Point(99, 50); + this.txtUrlAddr.Location = new System.Drawing.Point(99, 84); this.txtUrlAddr.Name = "txtUrlAddr"; - this.txtUrlAddr.Size = new System.Drawing.Size(287, 20); + this.txtUrlAddr.Size = new System.Drawing.Size(342, 20); this.txtUrlAddr.TabIndex = 3; this.txtUrlAddr.Text = "https://iis01.egalware.com//WDC/SRV/api"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(14, 53); + this.label2.Location = new System.Drawing.Point(14, 87); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(49, 13); this.label2.TabIndex = 2; this.label2.Text = "API URL"; // - // Form1 + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(99, 40); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(342, 20); + this.textBox1.TabIndex = 5; + this.textBox1.Text = "https://iis01.egalware.com/WDC/SRV/swagger/index.html"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(14, 43); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(49, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Swagger"; + // + // btnOpenSwagger + // + this.btnOpenSwagger.Location = new System.Drawing.Point(447, 38); + this.btnOpenSwagger.Name = "btnOpenSwagger"; + this.btnOpenSwagger.Size = new System.Drawing.Size(75, 23); + this.btnOpenSwagger.TabIndex = 6; + this.btnOpenSwagger.Text = "Open"; + this.btnOpenSwagger.UseVisualStyleBackColor = true; + // + // btnPing + // + this.btnPing.Location = new System.Drawing.Point(447, 13); + this.btnPing.Name = "btnPing"; + this.btnPing.Size = new System.Drawing.Size(75, 23); + this.btnPing.TabIndex = 7; + this.btnPing.Text = "Ping"; + this.btnPing.UseVisualStyleBackColor = true; + this.btnPing.Click += new System.EventHandler(this.btnPing_Click); + // + // lblOut + // + this.lblOut.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblOut.AutoSize = true; + this.lblOut.BackColor = System.Drawing.SystemColors.Desktop; + this.lblOut.ForeColor = System.Drawing.SystemColors.ActiveCaption; + this.lblOut.Location = new System.Drawing.Point(534, 11); + this.lblOut.MinimumSize = new System.Drawing.Size(250, 400); + this.lblOut.Name = "lblOut"; + this.lblOut.Size = new System.Drawing.Size(250, 400); + this.lblOut.TabIndex = 8; + this.lblOut.Text = "---"; + // + // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.lblOut); + this.Controls.Add(this.btnPing); + this.Controls.Add(this.btnOpenSwagger); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.label3); this.Controls.Add(this.txtUrlAddr); this.Controls.Add(this.label2); this.Controls.Add(this.txtServAddr); this.Controls.Add(this.label1); - this.Name = "Form1"; + this.Name = "MainForm"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); @@ -90,6 +150,11 @@ private System.Windows.Forms.TextBox txtServAddr; private System.Windows.Forms.TextBox txtUrlAddr; private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btnOpenSwagger; + private System.Windows.Forms.Button btnPing; + private System.Windows.Forms.Label lblOut; } } diff --git a/DemoServer/MainForm.cs b/DemoServer/MainForm.cs index b7b75a9..b603fc2 100644 --- a/DemoServer/MainForm.cs +++ b/DemoServer/MainForm.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -16,5 +17,22 @@ namespace DemoServer { InitializeComponent(); } + + private void btnPing_Click(object sender, EventArgs e) + { + var pingObj = new Ping(); + try + { + var pingTest = pingObj.Send(txtServAddr.Text.Trim()); + StringBuilder sb = new StringBuilder(); + sb.AppendLine("--- Test PING ---"); + sb.AppendLine($"ping res: {pingTest.Status}"); + sb.AppendLine("----------"); + sb.AppendLine(""); + lblOut.Text = sb.ToString(); + } + catch + { } + } } } diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs new file mode 100644 index 0000000..8ced669 --- /dev/null +++ b/WebDoorCreator.API/Controllers/QueueController.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Mvc; +using NLog; + +namespace WebDoorCreator.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class QueueController : ControllerBase + { + #region Public Constructors + + // da inizializzare con redis x recuperare elenco delle VERE richieste... + + //public QueueController(IConfiguration configuration, MpDataService DataService) + public QueueController(IConfiguration configuration) + { + Log.Info("Starting QueueController"); + _configuration = configuration; + //DService = DataService; + Log.Info("Avviato QueueController"); + } + + #endregion Public Constructors + + #region Public Methods + + [HttpGet("GetQueueLenght")] + public int GetQueueLenght() + { + return rndGen.Next(0, 20); + } + + [HttpGet("GetQueueList")] + public IEnumerable GetQueueList() + { + return Enumerable.Range(1, rndGen.Next(5, 20)).Select(index => $"WDC{rndGen.Next(0, 2000):000000}").ToArray(); + } + + #endregion Public Methods + + #region Protected Fields + + protected Random rndGen = new Random(); + + #endregion Protected Fields + + #region Private Fields + + private static IConfiguration _configuration = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebDoorCreator.API/Program.cs b/WebDoorCreator.API/Program.cs index 755c38e..a78947f 100644 --- a/WebDoorCreator.API/Program.cs +++ b/WebDoorCreator.API/Program.cs @@ -7,6 +7,9 @@ builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +// aggiunta servizi x accesso dati... + + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/WebDoorCreator.API/WebDoorCreator.API.csproj b/WebDoorCreator.API/WebDoorCreator.API.csproj index cbc38d8..0ab645d 100644 --- a/WebDoorCreator.API/WebDoorCreator.API.csproj +++ b/WebDoorCreator.API/WebDoorCreator.API.csproj @@ -11,6 +11,7 @@ +