Aggiunta progetto MP-IOC

- MP-IO versione dotNet Core
- inserito metodo x gestione recupero ricetta
- da verificare condivisione file conf ricetta (in SPEC e in IOC...)
This commit is contained in:
Samuele Locatelli
2023-02-14 17:16:51 +01:00
parent c2577ddfe4
commit 897ef574ca
17 changed files with 2134 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.IOC", "MP.IOC\MP.IOC.csproj", "{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Release|Any CPU.Build.0 = Release|Any CPU
{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8030DF52-992F-46A3-A9F1-5FF64A9D5D9D}
EndGlobalSection
EndGlobal
+73
View File
@@ -0,0 +1,73 @@
using Microsoft.AspNetCore.Mvc;
using MP.IOC.Data;
using Newtonsoft.Json;
using NLog;
using System.Xml;
namespace MP.IOC.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RecipeController : ControllerBase
{
#region Public Constructors
public RecipeController(IConfiguration configuration, MpDataService DataService)
{
Log.Info("Starting MpDataService INIT");
_configuration = configuration;
DService = DataService;
Log.Info("Avviata classe Recipe");
}
#endregion Public Constructors
#region Public Methods
[HttpGet("GetRecipe")]
public async Task<string> GetRecipe(int idxPODL)
{
string answ = "";
var reqRecipe = await DService.RecipeGetByPODL(idxPODL);
if (reqRecipe != null)
{
answ = DService.CalcRecipe(reqRecipe);
}
return answ;
}
[HttpGet("GetRecipeXML")]
public async Task<string> GetRecipeXML(int idxPODL)
{
// aggiungo root node?
string answ = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
// recupero versione json
string rawData = await GetRecipe(idxPODL);
if (!string.IsNullOrEmpty(rawData))
{
XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(rawData);
answ += doc.InnerXml;
}
return answ;
}
#endregion Public Methods
#region Protected Properties
/// <summary>
/// Dataservice x accesso DB
/// </summary>
protected MpDataService DService { get; set; }
#endregion Protected Properties
#region Private Fields
private static IConfiguration _configuration = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="StackExchange.Redis" Version="2.6.90" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MP.Data\MP.Data.csproj" />
</ItemGroup>
</Project>
+38
View File
@@ -0,0 +1,38 @@
using Microsoft.Extensions.Configuration;
using MP.IOC.Data;
using StackExchange.Redis;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
ConfigurationManager configuration = builder.Configuration;
// REDIS setup
string connStringRedis = configuration.GetConnectionString("Redis");
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
// avvio oggetto shared x redis...
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
builder.Services.AddSingleton<MpDataService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
+31
View File
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57791",
"sslPort": 44362
}
},
"profiles": {
"MP.IOC": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7050;http://localhost:5264",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
+80
View File
@@ -0,0 +1,80 @@
{
"TemplateFile": "Fimat/TemplateOutput.tpl",
"NumRow": 2,
"HeadConf": {
"ListKeys": {
"CustDrumCode": "F:",
"Taglio-N": "F:1",
"Taglio-D": "F:4",
"ServiceType": "F:N",
"RecipeType": "F:C",
"ViscoName": "F:",
"ViscoValue": "F:0",
"LotID": "C:IdxPODL",
"OrderCode": "C:CodePODL",
"Article": "C:CodArticolo",
"Info1": "C:DescArticolo",
"Prio": "E:Priority",
"DrumType": "E:DrumType",
"Customer": "Tenditalia",
"Design": "DESIGN",
"Screen": "SCREEN",
"Variant": "VARIANT",
"RecName": "CODE000",
"Series": "E:Series",
"UM": "E:UM",
"DosType": "E:DosType",
"Note1": "",
"Note2": "",
"Sequence": "1",
"SequenceTot": "8",
"Quantity-kg": "1.00"
},
"EnumVal": {
"Priority": {
"N": "Normal",
"H": "Hight"
},
"DrumType": {
"1": "Small",
"2": "Medium",
"3": "Big"
},
"Series": {
"1": "Series 1",
"2": "Series 2"
},
"UM": {
"0": "Percentage",
"1": "g/kg",
"2": "parts for colour and g/kg for thickener",
"3": "gr and parts for thickener",
"4": "g/kg for colour and parts for thickener",
"5": "parts for colour and parts for thickener"
},
"DosType": {
"P": "Production",
"S": "Sampling"
}
}
},
"RowsConf": {
"ListKeys": {
"Weight-gr-prev": "F:0.00",
"CompNumber": "C:RowNum",
"ColourCode": "C001",
"Description": "COLOR1",
"TypComp": "E:ColType",
"PartsWeight": "1.00",
"PartsPerc": "0.10",
"Weight-gr": "30.00"
},
"EnumVal": {
"ColType": {
"C": "Color",
"A": "Thickener",
"X": "Auxiliaries"
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"A_Recipe": {
"DesRecipe": {
"DesData": {
||PlaceholderHeader||
}
},
"ColRecipe": [
||SROW:{"ColData":{||
||PlaceholderRows||
||EROW:}}||
]
}
}
+60
View File
@@ -0,0 +1,60 @@
{
"A_Recipe": {
"DesRecipe": {
"DesData": {
"Prio": "N",
"DrumType": "1",
"CustDrumCode": "123456789012",
"OrderCode": "ORDERCODE",
"Customer": "CUSTOMER",
"Design": "DESIGN",
"Screen": "SCREEN",
"Variant": "VARIANT",
"RecName": "RECNAME",
"Article": "ARTICLE",
"LotID": "LOTID",
"Info1": "INFO1",
"ViscoName": "",
"Taglio-N": "1",
"Taglio-D": "4",
"Sequence": "1",
"SequenceTot": "8",
"Series": "2",
"ViscoValue": "0",
"UM": "1",
"DosType": "P",
"ServiceType": "N",
"RecipeType": "C",
"Note1": "NOTE1",
"Note2": "NOTE2",
"Quantity-kg": "10.00"
}
},
"ColRecipe": [
{
"ColData": {
"CompNumber": "1",
"ColourCode": "C001",
"Description": "COLOR1",
"TypComp": "C",
"PartsWeight": "1.00",
"PartsPerc": "0.10",
"Weight-gr": "30.00",
"Weight-gr-prev": "0.00"
}
},
{
"ColData": {
"CompNumber": "2",
"ColourCode": "THICK1",
"Description": "Thickner 1",
"TypComp": "A",
"PartsWeight": "997.00",
"PartsPerc": "99.70",
"Weight-gr": "9970.00",
"Weight-gr-prev": "0.00"
}
}
]
}
}
+134
View File
@@ -0,0 +1,134 @@
# Ricette
- [Ricette](#ricette)
- [Gestione formati e tag x ricette](#gestione-formati-e-tag-x-ricette)
- [Definizione tag ricette](#definizione-tag-ricette)
- [Esempio tracciato Template](#esempio-tracciato-template)
- [Esempio tracciato configurazione complessivo](#esempio-tracciato-configurazione-complessivo)
- [Campi Calcolati](#campi-calcolati)
# Gestione formati e tag x ricette
Nelle ricette ci possono essere campi liberi, campi da enum (da configurare nel json) e campi calcolati.
E' utile riportare un esempio di tracciato finale desiderato insieme ad un file template tpl da cui attingere x la realizzazione insieme ai campi definiti x testata e corpo.
In particolare sia per testata che corpo sono indicati casi di dati enumerativi (in modo che sia usato uno tra i valori ammessi)
## Definizione tag ricette
I tag ammessi x le ricette sono di seguito riassunti e definiti:
| Cod | Significato | Definizione |
|-----|-------------|--------------------------------------------|
| C | Calcolato | Campo calcolato (NON modificabile) |
| E | Enum | IdxODL numerico |
| F | Fixed | IdxODL numerico |
| S | Suggested | Campo calcolato e suggerito (modificabile) |
IN particolare gli Enum sono poi da riportare nella struttura degli EnumVal che deve completare i valori di testata o di corpo.
## Esempio tracciato Template
Ecco un esempio di template
```csharp
{
"A_Recipe": {
"DesRecipe": {
"DesData": {
||PlaceholderHeader||
},
"ColRecipe": [
||SROW:{"ColData":{||
||PlaceholderRows||
||EROW":}}||
]
}
}
```
il blocco <code>||PlaceholderHeader||</code> verrà sostituito per intero dai valori di testata.
Il blocco delel righe è invece più complesso e composto da 3 parti:
* nel primo blocco, <code>||SROW:{"ColData":{||</code>, si cerca start riga e si prende il valore compreso tra ||SROW:: e || come testata riga da ripetere
* nel secondo blocco si sostituiscono tutti i valori della riga i-esima
* nel terzo blocco <code>||EROW":}}||</code> si sistema la chiusura della riga (end row)
## Esempio tracciato configurazione complessivo
```json
{
"TemplateFile": "TemplateOutput.tpl",
"NumRow": 2,
"HeadConf": {
"ListKeys": {
"CustDrumCode": "F:",
"Taglio-N": "F:1",
"LotID": "C:IdxPODL",
"OrderCode": "C:CodePODL",
"Prio": "E:Priority",
"DrumType": "E:DrumType",
"Customer": "Tenditalia",
"Design": "DESIGN",
"Quantity-kg": "1.00"
},
"EnumVal": {
"Priority": {
"N": "Normal",
"H": "Hight"
},
"DrumType": {
"1": "Small",
"2": "Medium",
"3": "Big"
}
}
},
"RowsConf": {
"ListKeys": {
"Weight-gr-prev": "F:0.00",
"CompNumber": "C:RowNum",
"ColourCode": "C001",
"Description": "COLOR1",
"TypComp": "E:ColType",
"PartsWeight": "1.00",
"PartsPerc": "0.10",
"Weight-gr": "30.00"
},
"EnumVal": {
"ColType": {
"C": "Color",
"A": "Thickener",
"X": "Auxiliaries"
}
}
}
}
```
Come si può notare, il tracciato di configurazione comprende i seguenti blocchi:
| Blocco | descrizione |
|-------------------|--------------------------------------|
| HeadConf | Configurazione campi testata |
| HeadConf:ListKeys | Elenco chiavi/valori x testata |
| HeadConf:EnumVal | Elenco enumerativi ammessi x testata |
| RowsConf | Configurazione campi riga |
| RowsConf:ListKeys | Elenco chiavi/valori x righe |
| RowsConf:EnumVal | Elenco enumerativi ammessi x righe |
## Campi Calcolati
I tag noti x decodifica riguardano i campi calcolati; hard coded, e riconosciuti, sono i seguenti:
| ID | Note | Format | Esempio |
|--------------|-----------------------------------------|------------------|-----------------|
| IdxPODL | IdxODL numerico | - | 123 |
| CodePODL | Codice alfanumerico partendo da IdxPODL | PODL{0:00000000} | PODL00000123 |
| CodArticolo | Campo CodArticolo | - | Art000123 |
| DescArticolo | Campo DescArticolo | - | Articol 123 blu |
| RowNum | Numero riga | - | 1 |
| RowTot | Totale righe | - | 10 |
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"CodApp": "MP.IOC",
"ConnectionStrings": {
"Mp.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
"Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
"RedisAdmin": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
"MongoConnect": "mongodb://W2019-MONGODB:27017"
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2302.1313</Version>
<Version>6.16.2302.1415</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2302.1313</h4>
<h4>Versione: 6.16.2302.1415</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2302.1313
6.16.2302.1415
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2302.1313</version>
<version>6.16.2302.1415</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>