Update gestione + flessibile (con JSON) dei QR code...

This commit is contained in:
Samuele E. Locatelli
2019-07-29 18:52:12 +02:00
parent cf24b4da7a
commit 443db0342a
4 changed files with 25 additions and 10 deletions
+22
View File
@@ -4,6 +4,8 @@ using System.Web;
using System.Web.Mvc;
using ZXing;
using ZXing.QrCode;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace QR_GEN.Controllers
{
@@ -16,6 +18,14 @@ namespace QR_GEN.Controllers
{
public string valore;
}
/// <summary>
/// Payload da deserializzare json
/// </summary>
public struct qrPayload
{
public string baseUrl { get; set; }
public string[] parameters { get; set; }
}
public ActionResult Index()
{
@@ -91,6 +101,8 @@ namespace QR_GEN.Controllers
id = richiesta.valore;
}
#endif
#if false
// url decode...
id = HttpUtility.UrlDecode(id);
@@ -99,6 +111,8 @@ namespace QR_GEN.Controllers
// valutare se usare file web.config, file .ini, file conf generico...
string tgtUrl = "";
// se l'
// in base a richiesta compongo stringa ...
switch (id)
{
@@ -111,6 +125,14 @@ namespace QR_GEN.Controllers
case "CTRACK_COLCOM":
tgtUrl = @"http://192.168.0.113/MP/CTRACK/jumper?USER_NAME=opr_mon&UserAuthkey=AK_sdurb4930r2d&CodOpr=";
break;
case "JSON":
// devo DESERIALIZZARE...
var obj = JsonConvert.DeserializeObject<qrPayload>(val);
// metto tutto in tgtUrl...
tgtUrl = string.Format(obj.baseUrl, obj.parameters);
// svuoto val...
val = "";
break;
default:
break;
}
+1 -4
View File
@@ -47,15 +47,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNet.TelemetryCorrelation, Version=1.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.TelemetryCorrelation.1.0.4\lib\net45\Microsoft.AspNet.TelemetryCorrelation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
+1 -4
View File
@@ -14,7 +14,6 @@
<compilation debug="true" targetFramework="4.6.2" />
<httpRuntime targetFramework="4.6.2" />
<httpModules>
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" />
</httpModules>
</system.web>
<runtime>
@@ -54,9 +53,7 @@
</assemblyBinding>
</runtime>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="TelemetryCorrelationHttpModule" />
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="managedHandler" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
+1 -2
View File
@@ -8,7 +8,6 @@
<package id="Microsoft.AspNet.Mvc.it" version="5.2.7" targetFramework="net462" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net462" />
<package id="Microsoft.AspNet.Razor.it" version="3.2.7" targetFramework="net462" />
<package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.4" targetFramework="net462" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net462" />
<package id="Microsoft.AspNet.Web.Optimization.it" version="1.1.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net462" />
@@ -17,7 +16,7 @@
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.11" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="Modernizr" version="2.8.3" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net462" />
<package id="popper.js" version="1.14.3" targetFramework="net462" />
<package id="System.Diagnostics.DiagnosticSource" version="4.5.1" targetFramework="net462" />
<package id="WebGrease" version="1.6.0" targetFramework="net462" />