diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3aad0c7..6939d2c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,8 @@ variables:
NEXUS_PATH: 'MagMan'
APP_NAME: 'MagMan.UI'
SOL_NAME: 'MagMan.UI'
+ NUGET_PATH: 'C:\Tools\nuget.exe'
+ MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe'
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
.nuget-fix: &nuget-fix
@@ -54,15 +56,59 @@ variables:
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html
-
# mCurl -v -u $env:NEXUS_USER:$env:NEXUS_PASSWD --upload-file bin/release/$env:APP_NAME.zip $env:NEXUS_SERVER/utility/$env:NEXUS_PATH/$version/$env:APP_NAME-$version.zip
+# helper x fix version number
+.version-fix: &version-fix
+ - |
+ $env:NEW_REL = $env:VERS_MAIN+"."+(get-date -format yyMM)+"."+(get-date -format ddHH)
+ $env:NUM_REL = $env:VERS_MAIN+"."+(get-date -format yyMM)+"."+(get-date -format dHH)
+ $env:NUM_DEB = $env:VERS_MAIN+"."+(get-date -format yyMM)+"-beta."+(get-date -format dHH)
+ $env:NEW_COPYRIGHT = "EgalWare @ 2021-" + (get-date -format yyyy)
+ $contenuto = Get-Content -path 'VersGen\VersGen.cs' -Raw
+ $newContenuto = $contenuto -replace '0.0.0.0', $env:NEW_REL
+ $newContenuto = $newContenuto -replace 'EgalWare © 2021', $env:NEW_COPYRIGHT
+ $newContenuto | Set-Content -Path 'VersGen\VersGen.cs'
+ # display versioni generate
+ $resoconto = "Effettuato fix file VersGen | release v: " + $env:NUM_REL + " | debug v: " + $env:NUM_DEB;
+ Write-Output $resoconto;
+ echo "Replace completati"
+
+# helper x fix nuspec file
+.nuspec-fix: &nuspec-fix
+ - |
+ echo "Modifica dati file nuspec Release"
+ $currRelease = $env:NUM_REL
+ $currDebug = $env:NUM_DEB
+ $find = "(.|\n)*?";
+ $fileNameRel = "$env:APP_NAME.Release.nuspec";
+ $replRel = "" + $currRelease + "";
+ $nuspDataRel = Get-Content $fileNameRel;
+ $nuspDataRelUpd = $nuspDataRel -replace $find, $replRel;
+ $nuspDataRelUpd = $nuspDataRelUpd -replace "#copyright#", $replCopy;
+ $nuspDataRelUpd = $nuspDataRelUpd -replace "#releaseNotes#", "Build $adesso";
+ Set-Content -Path $fileNameRel -Value $nuspDataRelUpd;
+ echo "Modifica dati file nuspec Debug"
+ $fileNameDeb = "$env:APP_NAME.Debug.nuspec";
+ $replDeb = "" + $currDebug + "";
+ $nuspDataDeb = Get-Content $fileNameDeb;
+ $nuspDataDebUpd = $nuspDataDeb -replace $find, $replDeb;
+ $nuspDataDebUpd = $nuspDataDebUpd -replace "#copyright#", $replCopy;
+ $nuspDataDebUpd = $nuspDataDebUpd -replace "#releaseNotes#", "Build $adesso";
+ Set-Content -Path $fileNameDeb -Value $nuspDataDebUpd;
+ echo "replace completati"
+
+
stages:
- build
+ - staging
- installer
- # - release
+ - release
-build:
+# --------------------------------
+# BUILD
+# --------------------------------
+MagMan.UI:build:
stage: build
tags:
- win
@@ -72,6 +118,49 @@ build:
script:
- echo $CI_COMMIT_BRANCH
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
+
+EgwProxy.MagMan:build:
+ stage: build
+ tags:
+ - win
+ variables:
+ APP_NAME: EgwProxy.MagMan
+ SOL_NAME: EgwProxy.MagMan
+ before_script:
+ - *nuget-fix
+ - '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
+ script:
+ - echo $CI_COMMIT_BRANCH
+ - dotnet build $env:APP_NAME/$env:APP_NAME.csproj
+
+# --------------------------------
+# STAGING (nuget beta)
+# --------------------------------
+EgwProxy.MagMan:staging:
+ stage: staging
+ needs: ["EgwProxy.MagMan:build"]
+ tags:
+ - win
+ variables:
+ CONFIG: Debug
+ APP_NAME: EgwProxy.MagMan
+ SOL_NAME: EgwProxy.MagMan
+ only:
+ refs:
+ - develop
+ before_script:
+ - *nuget-fix
+ - '& "$env:NUGET_PATH" restore "$env:SOL_NAME.sln" -verbosity quiet'
+ - *version-fix
+ - *nuspec-fix
+ script:
+# - '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
+ - dotnet build "$env:APP_NAME\$env:APP_NAME.csproj"
+ - '& Remove-Item *.nupkg'
+ - '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
+ - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
+ - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
+
installer:
stage: installer
@@ -83,7 +172,7 @@ installer:
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
- needs: ["build"]
+ needs: ["MagMan.UI:build"]
script:
# - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MagMan.UI/MagMan.UI.csproj -o:publish
# pubblico solo installer Linux x64: https://docs.microsoft.com/en-us/dotnet/core/deploying/
@@ -92,19 +181,31 @@ installer:
- *hashBuild
- *nexusUpload
-# release:
-# stage: release
-# tags:
-# - win
-# only:
-# #- feature/Deploy_CI_CD
-# # - main
-# - tags
-# except:
-# - branches
-# needs: ["build"]
-# artifacts:
-# paths:
-# - publish/
-# script:
-# - dotnet publish -c Release -o ./publish MagMan.UI/MagMan.UI.csproj
\ No newline at end of file
+# --------------------------------
+# RELEASE
+# --------------------------------
+
+EgwProxy.MagMan:release:
+ stage: release
+ needs: ["EgwProxy.MagMan:build"]
+ tags:
+ - win
+ variables:
+ CONFIG: Release
+ APP_NAME: EgwProxy.MagMan
+ SOL_NAME: EgwProxy.MagMan
+ only:
+ refs:
+ - SDK
+ before_script:
+ - *nuget-fix
+ - '& "$env:NUGET_PATH" restore "$env:SOL_NAME.sln" -verbosity quiet'
+ - *version-fix
+ - *nuspec-fix
+ script:
+ - dotnet build "$env:APP_NAME\$env:APP_NAME.csproj"
+ #- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
+ - '& Remove-Item *.nupkg'
+ - '& $env:NUGET_PATH pack "$env:APP_NAME.Debug.nuspec"'
+ - '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
+ - '& "$env:NUGET_PATH" push *$env:NUM_DEB.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
\ No newline at end of file
diff --git a/EgwProxy.MagMan.Debug.nuspec b/EgwProxy.MagMan.Debug.nuspec
new file mode 100644
index 0000000..2013a5d
--- /dev/null
+++ b/EgwProxy.MagMan.Debug.nuspec
@@ -0,0 +1,24 @@
+
+
+
+ EgwProxy.MagMan
+ #version#
+ EgwProxy.MagMan
+ Samuele E. Locatelli, EgalWare
+ false
+ MIT
+ Libreria per comunicazione REST con server MagMan online/onsite per EgtBW - beta/unstable
+ #releaseNotes#
+ #copyright#
+ EgwProxy.MagMan MagMan Rest
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EgwProxy.MagMan.Release.nuspec b/EgwProxy.MagMan.Release.nuspec
new file mode 100644
index 0000000..ef038dc
--- /dev/null
+++ b/EgwProxy.MagMan.Release.nuspec
@@ -0,0 +1,23 @@
+
+
+
+ EgwProxy.MagMan
+ #version#
+ EgwProxy.MagMan
+ Samuele E. Locatelli, EgalWare
+ false
+ MIT
+ Libreria per comunicazione REST con server MagMan online/onsite per EgtBW
+ #releaseNotes#
+ #copyright#
+ EgwProxy.MagMan MagMan Rest
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EgwProxy.MagMan.sln b/EgwProxy.MagMan.sln
new file mode 100644
index 0000000..96190d3
--- /dev/null
+++ b/EgwProxy.MagMan.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34408.163
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleApp", "TestConsoleApp\TestConsoleApp.csproj", "{57626C9A-AAE0-4A43-A7E9-610320DD9D31}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.MagMan", "EgwProxy.MagMan\EgwProxy.MagMan.csproj", "{1696D7A5-765A-4D25-8D29-CA7345023479}"
+EndProject
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TestWinFormVB", "TestWinFormVB\TestWinFormVB.vbproj", "{665C94F5-27A6-4CD0-9487-036D199CDC47}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {57626C9A-AAE0-4A43-A7E9-610320DD9D31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {57626C9A-AAE0-4A43-A7E9-610320DD9D31}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {57626C9A-AAE0-4A43-A7E9-610320DD9D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {57626C9A-AAE0-4A43-A7E9-610320DD9D31}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1696D7A5-765A-4D25-8D29-CA7345023479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1696D7A5-765A-4D25-8D29-CA7345023479}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1696D7A5-765A-4D25-8D29-CA7345023479}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1696D7A5-765A-4D25-8D29-CA7345023479}.Release|Any CPU.Build.0 = Release|Any CPU
+ {665C94F5-27A6-4CD0-9487-036D199CDC47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {665C94F5-27A6-4CD0-9487-036D199CDC47}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {665C94F5-27A6-4CD0-9487-036D199CDC47}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {665C94F5-27A6-4CD0-9487-036D199CDC47}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1A62D7FE-522B-4154-9525-DD9C529BF49B}
+ EndGlobalSection
+EndGlobal
diff --git a/EgwProxy.MagMan/DTO/ItemDTO.cs b/EgwProxy.MagMan/DTO/ItemDTO.cs
new file mode 100644
index 0000000..4018507
--- /dev/null
+++ b/EgwProxy.MagMan/DTO/ItemDTO.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EgwProxy.MagMan.DTO
+{
+ public class ItemDTO
+ {
+
+ ///
+ /// Codice Univoco (DB)
+ ///
+ public int ItemID { get; set; } = 0;
+ ///
+ /// Codice Materiale di provenienza
+ ///
+ public int MatID { get; set; } = 0;
+
+ ///
+ /// Check if is a Remnant
+ ///
+ public bool IsRemn { get; set; } = false;
+
+ ///
+ /// Location
+ ///
+ public string Location { get; set; } = "";
+ ///
+ /// Qty available on wharehouse
+ ///
+ public int QtyAvail { get; set; } = 0;
+
+ ///
+ /// DateTime last modification
+ ///
+ public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10);
+
+ ///
+ /// Item's Lenght
+ ///
+ public decimal LMm { get; set; } = 0;
+
+ ///
+ /// Item's Width
+ ///
+ public decimal WMm { get; set; } = 0;
+
+ ///
+ /// Item's Thikness
+ ///
+ public decimal TMm { get; set; } = 0;
+ ///
+ /// Note
+ ///
+ public string Note { get; set; } = "";
+
+ ///
+ /// Codice QR/Matrix Item
+ ///
+ public string ItemDtmx { get; set; } = "";
+ }
+}
diff --git a/EgwProxy.MagMan/DTO/MaterialDTO.cs b/EgwProxy.MagMan/DTO/MaterialDTO.cs
new file mode 100644
index 0000000..576b9ca
--- /dev/null
+++ b/EgwProxy.MagMan/DTO/MaterialDTO.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EgwProxy.MagMan.DTO
+{
+ public class MaterialDTO
+ {
+ ///
+ /// Codice Univoco (DB)
+ ///
+ public int MatID { get; set; } = 0;
+ ///
+ /// Codice materiale (esterno)
+ ///
+ public int MatExtCode { get; set; } = 0;
+ ///
+ /// Descrizione materiale
+ ///
+ public string MatDesc { get; set; } = "";
+
+ ///
+ /// Lenght/Lunghezza in mm
+ ///
+ public decimal LMm { get; set; } = 0;
+ ///
+ /// Width/Larghezza in mm
+ ///
+ public decimal WMm { get; set; } = 0;
+ ///
+ /// Thikness/Spessore in mm
+ ///
+ public decimal TMm { get; set; } = 0;
+ ///
+ /// Codice QR/Matrix materiale
+ ///
+ public string MatDtmx { get; set; } = "";
+
+ ///
+ /// Elenco item e giancenze
+ ///
+ public List ItemList { get; set; } = new List();
+ }
+}
diff --git a/EgwProxy.MagMan/DataSyncro.cs b/EgwProxy.MagMan/DataSyncro.cs
new file mode 100644
index 0000000..3da4e60
--- /dev/null
+++ b/EgwProxy.MagMan/DataSyncro.cs
@@ -0,0 +1,190 @@
+using EgwProxy.MagMan.DTO;
+using Newtonsoft.Json;
+using RestSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Net;
+using System.Text;
+using System.Text.Json.Serialization;
+using RestSharp.Serializers.NewtonsoftJson;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace EgwProxy.MagMan
+{
+ public class DataSyncro
+ {
+ #region Public Constructors
+
+ ///
+ /// Inizializza la libreria di comunicazione con il token assegnato
+ ///
+ ///
+ public DataSyncro(string serverUrl, string UserToken)
+ {
+ RestToken = UserToken;
+ servAddr = serverUrl;
+ apiUrl = $"https://{servAddr}/api/";
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+ ///
+ /// Test ping x indirizzo indicato
+ ///
+ ///
+ ///
+ public static IPStatus pingAddress(string tgtAddr)
+ {
+ IPStatus answ = IPStatus.Unknown;
+ IPAddress address;
+ PingReply reply;
+ using (Ping pingSender = new Ping())
+ {
+ address = IPAddress.Loopback;
+ int pingMsTimeout = 500;
+ IPAddress.TryParse(tgtAddr, out address);
+ try
+ {
+ // se != null --> uso tgtAddr...
+ if (address != null)
+ {
+ reply = pingSender.Send(address, pingMsTimeout);
+ }
+ else
+ {
+ reply = pingSender.Send(tgtAddr, pingMsTimeout);
+ }
+ }
+ catch
+ {
+ reply = pingSender.Send(IPAddress.Loopback, pingMsTimeout);
+ }
+ answ = reply.Status;
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua chiamata test sul server (ping)
+ ///
+ ///
+ public bool CheckRemote()
+ {
+ IPAddress address = IPAddress.Loopback;
+ string srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
+ return pingAddress(srvIp) == IPStatus.Success;
+ }
+
+ ///
+ /// Elenco Materiali dato RestToken
+ ///
+ public async Task> MaterialsGet()
+ {
+ List answ = new List();
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(RestToken);
+ var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
+ var response = await client.GetAsync(request);
+ // controllo risposta
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ // contenuto serializzato
+ string rawData = $"{response.Content}";
+ answ = JsonConvert.DeserializeObject>(rawData);
+ }
+ return await Task.FromResult(answ);
+ }
+ ///
+ /// Invia un elenco (anche parziale) di Materiali, il server farà il merge
+ ///
+ public async Task MaterialsSend(List List2Merge)
+ {
+ bool answ = false;
+ // cerco online
+ var client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(RestToken);
+ var jsonBody = JsonConvert.SerializeObject(List2Merge);
+ var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
+ var response = await client.PostAsync(request);
+ // controllo risposta
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ // contenuto serializzato
+ string rawData = $"{response.Content}";
+ answ = rawData == "OK";
+ }
+ return await Task.FromResult(answ);
+ }
+
+ ///
+ /// Inventario per materiale
+ ///
+ /// Se 0 = tutto
+ ///
+ public async Task> InventoryGet(int MatID)
+ {
+ List answ = new List();
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(RestToken);
+ var request = new RestRequest($"Inventory/{MKeyEnc}?MatId={MatID}", Method.Get);
+ var response = await client.GetAsync(request);
+ // controllo risposta
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ // contenuto serializzato
+ string rawData = $"{response.Content}";
+ answ = JsonConvert.DeserializeObject>(rawData);
+ }
+ return await Task.FromResult(answ);
+ }
+ ///
+ /// Invia un elenco di RawItems associati ad un singolo materiale, il server farà il merge
+ ///
+ public async Task InventorySend(MaterialDTO Mat2Merge)
+ {
+ bool answ = false;
+ // cerco online
+ var client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(RestToken);
+ var jsonBody = JsonConvert.SerializeObject(Mat2Merge.ItemList);
+ var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
+ var response = await client.PostAsync(request);
+ // controllo risposta
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ // contenuto serializzato
+ string rawData = $"{response.Content}";
+ answ = rawData == "OK";
+ }
+ return await Task.FromResult(answ);
+ }
+
+ #endregion Public Methods
+
+ #region Private Fields
+
+ ///
+ /// URL dell'API x chiamate gestione licenze
+ ///
+ private string apiUrl = $"";
+
+ ///
+ /// Token di chiamata per l'applicazione
+ ///
+ private string RestToken = "";
+
+ ///
+ /// Indirizzo server (URL con eventuale porta)
+ ///
+ private string servAddr = $"";
+
+ #endregion Private Fields
+ }
+}
\ No newline at end of file
diff --git a/EgwProxy.MagMan/EgwProxy.MagMan.csproj b/EgwProxy.MagMan/EgwProxy.MagMan.csproj
new file mode 100644
index 0000000..25c7dfa
--- /dev/null
+++ b/EgwProxy.MagMan/EgwProxy.MagMan.csproj
@@ -0,0 +1,89 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {1696D7A5-765A-4D25-8D29-CA7345023479}
+ Library
+ Properties
+ EgwProxy.MagMan
+ EgwProxy.MagMan
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll
+
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+
+ ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll
+
+
+ ..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
+ ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EgwProxy.MagMan/Properties/AssemblyInfo.cs b/EgwProxy.MagMan/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2d320c4
--- /dev/null
+++ b/EgwProxy.MagMan/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("EgwProxy.MagMan")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("EgwProxy.MagMan")]
+[assembly: AssemblyCopyright("Copyright © 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1696d7a5-765a-4d25-8d29-ca7345023479")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/EgwProxy.MagMan/app.config b/EgwProxy.MagMan/app.config
new file mode 100644
index 0000000..8922cd8
--- /dev/null
+++ b/EgwProxy.MagMan/app.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EgwProxy.MagMan/packages.config b/EgwProxy.MagMan/packages.config
new file mode 100644
index 0000000..c5ca275
--- /dev/null
+++ b/EgwProxy.MagMan/packages.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MagMan.Core/DTO/ItemDTO.cs b/MagMan.Core/DTO/ItemDTO.cs
new file mode 100644
index 0000000..ab807f2
--- /dev/null
+++ b/MagMan.Core/DTO/ItemDTO.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MagMan.Core.DTO
+{
+ public class ItemDTO
+ {
+ ///
+ /// Ext ref for Material
+ ///
+ public int MatId { get; set; } = 0;
+
+ ///
+ /// Key del RawItem di riferimento (se zero da verificare con quote)
+ ///
+ public int RawItemId { get; set; } = 0;
+
+ ///
+ /// Check if is a Remnant
+ ///
+ public bool IsRemn { get; set; } = false;
+
+ ///
+ /// Location
+ ///
+ public string Location { get; set; } = "";
+
+ ///
+ /// Qty available on wharehouse
+ ///
+ public int QtyAvail { get; set; } = 0;
+
+ ///
+ /// Item's Lenght
+ ///
+ public decimal LMm { get; set; } = 0;
+
+ ///
+ /// Item's Width
+ ///
+ public decimal WMm { get; set; } = 0;
+
+ ///
+ /// Item's Thikness
+ ///
+ public decimal HMm { get; set; } = 0;
+
+ ///
+ /// Note (optional)
+ ///
+ public string Note { get; set; } = "";
+ }
+}
diff --git a/MagMan.Core/DTO/MaterialDTO.cs b/MagMan.Core/DTO/MaterialDTO.cs
index 1c98963..5ab8283 100644
--- a/MagMan.Core/DTO/MaterialDTO.cs
+++ b/MagMan.Core/DTO/MaterialDTO.cs
@@ -8,27 +8,21 @@ namespace MagMan.Core.DTO
{
public class MaterialDTO
{
+ ///
+ /// Primary Key Materiale, 0 se proviente da EgtBeamWall
+ ///
+ public int MatId { get; set; } = 0;
///
- /// Codice materiale (esterno)
+ /// Codice Materiale
///
- public int MatExtCode { get; set; } = 0;
+ public string MatCode { get; set; } = "";
+
///
/// Descrizione materiale
///
public string MatDesc { get; set; } = "";
-#if false
- ///
- /// Data approvazione (se non approvato è nel futuro)
- ///
- public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100);
- ///
- /// Utente approvazione amteriale
- ///
- public string ApprovUser { get; set; } = "";
-#endif
-
///
/// Lenght/Lunghezza in mm
///
@@ -40,6 +34,6 @@ namespace MagMan.Core.DTO
///
/// Thikness/Spessore in mm
///
- public decimal TMm { get; set; } = 0;
+ public decimal HMm { get; set; } = 0;
}
}
diff --git a/MagMan.Core/DTO/ProjectDTO.cs b/MagMan.Core/DTO/ProjectDTO.cs
new file mode 100644
index 0000000..b8bb59c
--- /dev/null
+++ b/MagMan.Core/DTO/ProjectDTO.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static MagMan.Core.Enums;
+
+namespace MagMan.Core.DTO
+{
+ public class ProjectDTO
+ {
+ ///
+ /// Id macchina (MagMan)
+ ///
+ public int MachineID { get; set; } = 0;
+
+ ///
+ /// Key di riferimento per il progetto
+ ///
+ public int KeyNum { get; set; } = 0;
+
+ ///
+ /// ID del DB EgtBW, univoco con KeyNum
+ ///
+ public int ProjExtDbId { get; set; } = 0;
+
+ ///
+ /// ID esterno (da EgtBW)
+ ///
+ public int ProjExtId { get; set; } = 0;
+
+ ///
+ /// Nome file BTL originale
+ ///
+ public string BTLFileName { get; set; } = "";
+
+ ///
+ /// Tipologia del progetto (Travi, Pareti, ...)
+ ///
+ public BWType PType { get; set; } = BWType.NULL;
+
+ ///
+ /// Macchina (Costruttore/Modello)
+ ///
+ public string Machine { get; set; } = "";
+
+ ///
+ /// Descrizione progetto (copiata da BTLFileName inizialmente)
+ ///
+ public string ProjDescription { get; set; } = "";
+
+ ///
+ /// Data Creazione progetto
+ ///
+ public DateTime DtCreated { get; set; } = DateTime.Now;
+
+ ///
+ /// Data di schedulazione (prevista)
+ ///
+ public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
+
+ ///
+ /// Data Inizio Produzione
+ ///
+ public DateTime DtStartProd { get; set; } = DateTime.MinValue;
+
+ ///
+ /// Data ora ultima operazione registrata
+ ///
+ public DateTime DtLastAction { get; set; } = DateTime.MinValue;
+
+ ///
+ /// ListName del BTL
+ ///
+ public string ListName { get; set; } = "";
+
+ ///
+ /// Tempo lavorazione previsto (stima) in minuti
+ ///
+ public double ProcTimeEst { get; set; } = 0;
+
+ ///
+ /// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
+ ///
+ public double ProcTimeReal { get; set; } = 0;
+
+ ///
+ /// Record attivo (se false == cancellazione logica)
+ ///
+ public bool IsActive { get; set; } = true;
+
+ ///
+ /// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
+ ///
+ public bool IsArchived { get; set; } = false;
+
+ }
+}
diff --git a/MagMan.Core/DTO/ResourceDTO.cs b/MagMan.Core/DTO/ResourceDTO.cs
new file mode 100644
index 0000000..510bf11
--- /dev/null
+++ b/MagMan.Core/DTO/ResourceDTO.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MagMan.Core.DTO
+{
+ public class ResourceDTO
+ {
+ ///
+ /// Ext ref for Material
+ ///
+ public int RawItemId { get; set; } = 0;
+ ///
+ /// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
+ ///
+ public int Qty { get; set; } = 0;
+
+ }
+}
diff --git a/MagMan.Core/Enums.cs b/MagMan.Core/Enums.cs
index 573e11e..4df7c47 100644
--- a/MagMan.Core/Enums.cs
+++ b/MagMan.Core/Enums.cs
@@ -1,7 +1,18 @@
-namespace MagMan.Core
+using StackExchange.Redis;
+
+namespace MagMan.Core
{
public class Enums
{
+ #region Public Enums
+
+ public enum BWType
+ {
+ NULL = 0,
+ BEAM = 1,
+ WALL = 2
+ }
+
public enum ItemState
{
None,
@@ -10,5 +21,39 @@
Request,
}
+
+ public enum ProjResState
+ {
+ ///
+ /// Registrazione consumo effettivo (update giacenza su tab RawItemList)
+ ///
+ Consumed = -1,
+ ///
+ /// Non definito
+ ///
+ ND = 0,
+ ///
+ /// Consumo stimato da nesting (solo simulazione)
+ ///
+ Estimated,
+ ///
+ /// Consumo confermato (da ordinare)
+ ///
+ Confirmed,
+ ///
+ /// Riservato (utile x calcolo quantità da ordinare)
+ ///
+ Reserved
+ }
+
+ public enum ResultTypes
+ {
+ NULL = 0,
+ EXECUTED = 1,
+ RESULT = 2
+ }
+
+
+ #endregion Public Enums
}
-}
+}
\ No newline at end of file
diff --git a/MagMan.Core/MagMan.Core.csproj b/MagMan.Core/MagMan.Core.csproj
index df2e60e..934f236 100644
--- a/MagMan.Core/MagMan.Core.csproj
+++ b/MagMan.Core/MagMan.Core.csproj
@@ -7,9 +7,12 @@
+
+
+
diff --git a/MagMan.Core/RestPayload.cs b/MagMan.Core/RestPayload.cs
index 6eeaf40..7566fc5 100644
--- a/MagMan.Core/RestPayload.cs
+++ b/MagMan.Core/RestPayload.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MagMan.Core.DTO;
+using static MagMan.Core.Enums;
namespace MagMan.Core
{
@@ -16,5 +17,28 @@ namespace MagMan.Core
///
public List? MatList { get; set; }
}
+ public class Items
+ {
+ ///
+ /// Elenco Items x invio POST
+ ///
+ public List? ItemList { get; set; }
+ }
+
+ public class Resources
+ {
+ ///
+ /// ID progetto univoco esterno (da associare a KEY)
+ ///
+ public int ProjDbId { get; set; } = 0;
+ ///
+ /// Tipo di registrazione dato inviata (previsione consumo, consumo effettivo...)
+ ///
+ public ProjResState ReqState { get; set; } = ProjResState.ND;
+ ///
+ /// Elenco Risorse x invio POST
+ ///
+ public List? ResourceList { get; set; }
+ }
}
}
diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs
new file mode 100644
index 0000000..a3dc8dc
--- /dev/null
+++ b/MagMan.Core/Services/MessageService.cs
@@ -0,0 +1,627 @@
+using Blazored.LocalStorage;
+using Blazored.SessionStorage;
+using NLog;
+using StackExchange.Redis;
+using System.Diagnostics;
+
+namespace MagMan.Core.Services
+{
+ public class MessageService
+ {
+ #region Public Constructors
+
+ public MessageService(ILocalStorageService genLocalStorage, ISessionStorageService sessStore, IConnectionMultiplexer RedConn)
+ {
+ // gestione sessioni in browser
+ localStore = genLocalStorage;
+ sessionStore = sessStore;
+ // setup componenti REDIS
+ redisConn = RedConn;
+ redisDb = redisConn.GetDatabase();
+ }
+
+ #endregion Public Constructors
+
+ #region Public Events
+
+ public event Action EA_FilterUpdated = null!;
+
+ public event Action EA_HideSearch = null!;
+
+ public event Action EA_PageUpdated = null!;
+
+ public event Action EA_SearchUpdated = null!;
+
+ public event Action EA_ShowSearch = null!;
+
+ #endregion Public Events
+
+#if false
+ public SelectData DetailFilter
+ {
+ get => _detailFilter;
+ set
+ {
+ if (_detailFilter != value)
+ {
+ _detailFilter = value;
+
+ if (EA_FilterUpdated != null)
+ {
+ EA_FilterUpdated?.Invoke();
+ }
+ }
+ }
+ }
+
+ public SelectOrderData Order_Filter { get; set; } = SelectOrderData.Init(5, 30);
+#endif
+
+ #region Public Properties
+
+ public string PageIcon
+ {
+ get => _pageIcon;
+ set
+ {
+ if (_pageIcon != value)
+ {
+ _pageIcon = value;
+ ReportPageUpd();
+ }
+ }
+ }
+
+ public string PageName
+ {
+ get => _pageName;
+ set
+ {
+ if (_pageName != value)
+ {
+ _pageName = value;
+ ReportPageUpd();
+ }
+ }
+ }
+
+ public string SearchVal
+ {
+ get => _searchVal;
+ set
+ {
+ if (_searchVal != value)
+ {
+ _searchVal = value;
+
+ if (EA_SearchUpdated != null)
+ {
+ EA_SearchUpdated?.Invoke();
+ }
+ }
+ }
+ }
+
+ public string SelOrderCode { get; set; } = "";
+ public string SelPlantId { get; set; } = "0";
+
+ public bool ShowSearch
+ {
+ get => _showSearch;
+ set
+ {
+ if (_showSearch != value)
+ {
+ _showSearch = value;
+ if (_showSearch)
+ {
+ if (EA_ShowSearch != null)
+ {
+ EA_ShowSearch?.Invoke();
+ }
+ }
+ else
+ {
+ if (EA_HideSearch != null)
+ {
+ EA_HideSearch?.Invoke();
+ }
+ }
+ }
+ }
+ }
+
+ ///
+ /// Cliente selezionato (da browser data cache)
+ ///
+ public async Task ClientIdGet()
+ {
+ var answ = await localStore.GetItemAsync("ClientID");
+ return answ;
+ }
+
+ ///
+ /// Imposta Cliente selezionato (browser data cache)
+ ///
+ public async Task ClientIdSet(int machSel)
+ {
+ await localStore.SetItemAsync("ClientID", machSel);
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ ///
+ /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
+ ///
+ ///
+ ///
+ public async Task CustomerIdByToken(string RestToken)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Token2CustID";
+ int answ = await RedisHashGetInt(currKey, RestToken);
+ return answ;
+ }
+
+ ///
+ /// salvataggio in dizionario Redis associativo Token / Customer
+ ///
+ ///
+ ///
+ ///
+ public bool CustomerIdByTokenSet(string RestToken, int CustId)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Token2CustID";
+ bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}");
+ return fatto;
+ }
+
+ ///
+ /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
+ ///
+ ///
+ ///
+ public async Task MainKeyByCustomer(int CustID)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Cust2MKey";
+ int answ = await RedisHashGetInt(currKey, $"{CustID}");
+ return answ;
+ }
+
+ ///
+ /// salvataggio in dizionario Redis associativo Token / Customer
+ ///
+ ///
+ ///
+ ///
+ public bool MainKeyByCustomerSet(int CustId, int MainKey)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Cust2MKey";
+ bool fatto = RedisHashSet(currKey, $"{CustId}", $"{MainKey}");
+ return fatto;
+ }
+
+ ///
+ /// Recupera MainKey dal dizionario dei token noti o cercando sul DB
+ ///
+ ///
+ ///
+ public async Task MainKeyByToken(string RestToken)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Token2MKey";
+ int answ = await RedisHashGetInt(currKey, RestToken);
+ return answ;
+ }
+
+ ///
+ /// salvataggio in dizionario Redis associativo Token / Customer
+ ///
+ ///
+ ///
+ ///
+ public bool MainKeyByTokenSet(string RestToken, int CustId)
+ {
+ string currKey = $"{Const.rKeyConfig}:Dict:Token2MKey";
+ bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}");
+ return fatto;
+ }
+
+ ///
+ /// Get single hash record
+ ///
+ /// Redis Key for Hashlist
+ /// Requested key on list
+ /// Value as Int
+ public async Task RedisHashGetInt(RedisKey currKey, string chiave)
+ {
+ int result = 0;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ var hasVal = await redisDb.HashExistsAsync(currKey, chiave);
+ if (hasVal)
+ {
+ var rawRes = await redisDb.HashGetAsync(currKey, chiave);
+ if (rawRes.HasValue)
+ {
+ int.TryParse($"{rawRes}", out result);
+ }
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Trace($"RedisHashGetInt | {currKey} | in: {ts.TotalMilliseconds} ms");
+ return result;
+ }
+
+ ///
+ /// Get single hash record
+ ///
+ /// Redis Key for Hashlist
+ /// Requested key on list
+ /// Value as string
+ public async Task RedisHashGetString(RedisKey currKey, string chiave)
+ {
+ string result = "";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ var hasVal = await redisDb.HashExistsAsync(currKey, chiave);
+ if (hasVal)
+ {
+ var rawRes = await redisDb.HashGetAsync(currKey, chiave);
+ if (rawRes.HasValue)
+ {
+ result = $"{rawRes}";
+ }
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Trace($"RedisHashGetString | {currKey} | in: {ts.TotalMilliseconds} ms");
+ return result;
+ }
+
+ ///
+ /// Remove for single hash record
+ ///
+ /// Chiave redis della Hashlist
+ /// Chiave nella HashList
+ /// Esito rimozione
+ public async Task RedisHashRemove(RedisKey currKey, string chiave)
+ {
+ bool fatto = false;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ fatto = await redisDb.HashDeleteAsync(currKey, chiave);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Trace($"RedisHashRemove | {currKey} | in: {ts.TotalMilliseconds} ms");
+ return fatto;
+ }
+
+ ///
+ /// Resetta 1:1 i dizionari Hash in Redis
+ ///
+ ///
+ public bool ResetHashDict()
+ {
+ bool fatto = false;
+ string baseKey = $"{Const.rKeyConfig}:Dict";
+ try
+ {
+ // salvo!
+ RedisHashDictSet($"{baseKey}:Token2CustID", new Dictionary());
+ RedisHashDictSet($"{baseKey}:Token2MKey", new Dictionary());
+ RedisHashDictSet($"{baseKey}:Cust2MKey", new Dictionary());
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ResetHashDict{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ ///
+ /// Svuota localstorage (clear)
+ ///
+ ///
+ public async Task StoreLocalClear()
+ {
+ bool answ = false;
+ try
+ {
+ await localStore.ClearAsync();
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Restituisce il valore richiesto da localstorage
+ ///
+ /// Chiave
+ ///
+ public async Task StoreLocalGet(string sKey)
+ {
+ string answ = "";
+ var result = await localStore.GetItemAsync(sKey);
+ if (result != null)
+ {
+ answ = result;
+ }
+ return answ;
+ }
+
+ ///
+ /// Scrive il valore nel localstorage
+ ///
+ /// Chiave
+ /// Valore associato
+ ///
+ public async Task StoreLocalSet(string sKey, string sVal)
+ {
+ bool answ = false;
+ try
+ {
+ await localStore.SetItemAsStringAsync(sKey, sVal);
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in StoreLocalSet{Environment.NewLine}{ex}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Svuota sessionstorage (clear)
+ ///
+ ///
+ public async Task StoreSessClear()
+ {
+ bool answ = false;
+ try
+ {
+ await sessionStore.ClearAsync();
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Restituisce il valore richiesto da sessionstorage
+ ///
+ /// Chiave
+ ///
+ public async Task StoreSessGet(string sKey)
+ {
+ string answ = "";
+ var result = await sessionStore.GetItemAsync(sKey);
+ if (result != null)
+ {
+ answ = result;
+ }
+ return answ;
+ }
+
+ ///
+ /// Scrive il valore nel sessionstorage (tab)
+ ///
+ /// Chiave
+ /// Valore associato
+ ///
+ public async Task StoreSessSet(string sKey, string sVal)
+ {
+ bool answ = false;
+ try
+ {
+ await sessionStore.SetItemAsStringAsync(sKey, sVal);
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in StoreSessSet{Environment.NewLine}{ex}");
+ }
+ return answ;
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ ///
+ /// Oggetto per connessione a REDIS
+ ///
+ protected IConnectionMultiplexer redisConn = null!;
+
+ ///
+ /// Oggetto DB redis da impiegare x chiamate R/W
+ ///
+ protected IDatabase redisDb = null!;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected ILocalStorageService localStore { get; set; } = null!;
+ protected ISessionStorageService sessionStore { get; set; } = null!;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ ///
+ /// Effettua upsert in HasList redis
+ ///
+ /// Chiave redis della Hashlist
+ /// Chiave nella HashList
+ /// Valore da salvare
+ /// Num record nella HashList
+ protected async Task RedisHashUpsert(RedisKey currKey, string chiave, string valore)
+ {
+ long numReq = 0;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ await redisDb.HashSetAsync(currKey, chiave, valore);
+ numReq = await redisDb.HashLengthAsync(currKey);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Trace($"RedisHashUpsert | {currKey} | in: {ts.TotalMilliseconds} ms");
+ return numReq;
+ }
+
+ #endregion Protected Methods
+
+#if false
+ private SelectData _detailFilter = SelectData.Init(5, 15);
+#endif
+
+ #region Private Fields
+
+ private string _pageIcon = "";
+ private string _pageName = "";
+ private string _searchVal = "";
+ private bool _showSearch = false;
+ private Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
+
+ #region Private Methods
+
+ ///
+ /// Recupero HashSet redis come Dictionary
+ ///
+ ///
+ ///
+ private Dictionary RedisHashDictGet(RedisKey currKey)
+ {
+ Dictionary answ = new Dictionary();
+ try
+ {
+ answ = redisDb
+ .HashGetAll(currKey)
+ .ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore RedisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Salvataggio Dictionary come HashSet Redis
+ ///
+ ///
+ ///
+ private bool RedisHashDictSet(RedisKey currKey, Dictionary dict)
+ {
+ bool fatto = false;
+ try
+ {
+ HashEntry[] data2ins = new HashEntry[dict.Count];
+ int i = 0;
+ foreach (KeyValuePair kvp in dict)
+ {
+ data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
+ i++;
+ }
+ // salvo!
+ redisDb.HashSet(currKey, data2ins);
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in RedisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ ///
+ /// Salvataggio Dictionary come HashSet Redis
+ ///
+ ///
+ ///
+ ///
+ private bool RedisHashDictSet(RedisKey currKey, Dictionary dict, TimeSpan ttl)
+ {
+ bool fatto = false;
+ try
+ {
+ HashEntry[] data2ins = new HashEntry[dict.Count];
+ int i = 0;
+ foreach (KeyValuePair kvp in dict)
+ {
+ data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
+ i++;
+ }
+ // salvo!
+ redisDb.HashSet(currKey, data2ins);
+ redisDb.KeyExpire(currKey, ttl);
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in RedisHashDictSet(+TTL) | currKey: {currKey} | ttl: {ttl}{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ ///
+ /// Aggiunta KVP in HashSet Redis
+ ///
+ ///
+ ///
+ private bool RedisHashSet(RedisKey currKey, string hashField, string value)
+ {
+ bool fatto = false;
+ try
+ {
+ // salvo!
+ redisDb.HashSet(currKey, hashField, value);
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in RedisHashSet | currKey: {currKey}{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ private void ReportPageUpd()
+ {
+ if (EA_PageUpdated != null)
+ {
+ EA_PageUpdated?.Invoke();
+ }
+ }
+
+ private void ReportSearch()
+ {
+ if (EA_SearchUpdated != null)
+ {
+ EA_SearchUpdated?.Invoke();
+ }
+ }
+
+ #endregion Private Methods
+
+#if false
+ ///
+ /// Dizionario totale preferenze utente
+ ///
+ public Dictionary UsersPrefDict
+ {
+ get => RedisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}");
+ set => RedisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value);
+ }
+#endif
+ }
+}
\ No newline at end of file
diff --git a/MagMan.Data.Admin/MagMan.Data.Admin.csproj b/MagMan.Data.Admin/MagMan.Data.Admin.csproj
index 2406b07..b222b78 100644
--- a/MagMan.Data.Admin/MagMan.Data.Admin.csproj
+++ b/MagMan.Data.Admin/MagMan.Data.Admin.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/MagMan.Data.Admin/Services/MTAdminService.cs b/MagMan.Data.Admin/Services/MTAdminService.cs
index 808fa58..70eac3e 100644
--- a/MagMan.Data.Admin/Services/MTAdminService.cs
+++ b/MagMan.Data.Admin/Services/MTAdminService.cs
@@ -1,4 +1,5 @@
using MagMan.Core;
+using MagMan.Core.Services;
using MagMan.Data.Admin.Controllers;
using MagMan.Data.Admin.DbModels;
using Microsoft.AspNetCore.Identity.UI.Services;
@@ -14,12 +15,6 @@ namespace MagMan.Data.Admin.Services
{
public class MTAdminService : BaseServ
{
- #region Public Fields
-
- public static MTAdminController dbController = null!;
-
- #endregion Public Fields
-
#region Public Constructors
public MTAdminService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender)
@@ -238,6 +233,34 @@ namespace MagMan.Data.Admin.Services
return dbResult;
}
+ ///
+ /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
+ ///
+ ///
+ ///
+ public async Task CustomerIdByToken(string RestToken)
+ {
+ int answ = -1;
+ if (TokenCustList.ContainsKey(RestToken))
+ {
+ answ = TokenCustList[RestToken];
+ }
+ else
+ {
+ // cerco nel DB
+ var custList = await CustomerGetAll();
+ var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken);
+ // se trovato salvo
+ if (custRow != null)
+ {
+ answ = custRow.CustomerID;
+ TokenCustList.Add(RestToken, answ);
+ Log.Info($"TokenCustList: added {RestToken} --> {answ}");
+ }
+ }
+ return answ;
+ }
+
///
/// Update record customer + refresh cache
///
@@ -395,39 +418,36 @@ namespace MagMan.Data.Admin.Services
return fatto;
}
- #endregion Public Methods
-
- #region Protected Methods
-
///
/// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
///
- ///
+ ///
///
- public async Task CustomerIdByToken(string RestToken)
+ public async Task MainKeyByCustomer(int CustID)
{
int answ = -1;
- if (TokenCustList.ContainsKey(RestToken))
+ if (CustMKeyList.ContainsKey(CustID))
{
- answ = TokenCustList[RestToken];
+ answ = CustMKeyList[CustID];
}
else
{
// cerco nel DB
var custList = await CustomerGetAll();
- var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken);
+ var custRow = custList.FirstOrDefault(x => x.CustomerID == CustID);
// se trovato salvo
if (custRow != null)
{
- answ = custRow.CustomerID;
- TokenCustList.Add(RestToken, answ);
- Log.Info($"TokenCustList: added {RestToken} --> {answ}");
+ answ = custRow.MainKey;
+ CustMKeyList.Add(CustID, answ);
+ Log.Info($"TokenMKeyList: added {CustID} --> {answ}");
}
}
return answ;
}
+
///
- /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
+ /// Recupera MainKey dal dizionario dei token noti o cercando sul DB
///
///
///
@@ -454,11 +474,16 @@ namespace MagMan.Data.Admin.Services
return answ;
}
- #endregion Protected Methods
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ protected static MTAdminController dbController = null!;
+
+ #endregion Protected Fields
#region Private Fields
-
private static JsonSerializerSettings? JSSettings;
private static Logger Log = LogManager.GetCurrentClassLogger();
@@ -495,18 +520,22 @@ namespace MagMan.Data.Admin.Services
#region Private Properties
///
- /// Dizionario dei token 2 customer
+ /// Dizionario customer 2 MainKey (x calcolo DB)
+ ///
+ private Dictionary CustMKeyList { get; set; } = new Dictionary();
+
+ ///
+ /// Dizionario dei token 2 customer
///
private Dictionary TokenCustList { get; set; } = new Dictionary();
+
///
- /// Dizionario dei token 2 MainKey (x calcolo DB)
+ /// Dizionario dei token 2 MainKey (x calcolo DB)
///
private Dictionary TokenMKeyList { get; set; } = new Dictionary();
#endregion Private Properties
-
-
#region Private Methods
///
diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs
index 436a8b4..44fe134 100644
--- a/MagMan.Data.Tenant/Controllers/TenantController.cs
+++ b/MagMan.Data.Tenant/Controllers/TenantController.cs
@@ -1,4 +1,5 @@
using MagMan.Data.Tenant.DbModels;
+using MagMan.Data.Tenant.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using NLog;
@@ -45,7 +46,7 @@ namespace MagMan.Data.Tenant.Controllers
/// Stringa connessione (variabile x cliente)
/// Item da eliminare
///
- public bool ItemDelete(string connString, ItemModel rec2del)
+ public bool ItemDelete(string connString, RawItemModel rec2del)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
@@ -54,7 +55,7 @@ namespace MagMan.Data.Tenant.Controllers
{
var currData = dbCtx
.DbSetItems
- .Where(x => x.ItemID == rec2del.ItemID)
+ .Where(x => x.RawItemId == rec2del.RawItemId)
.FirstOrDefault();
if (currData != null)
{
@@ -78,16 +79,16 @@ namespace MagMan.Data.Tenant.Controllers
///
/// Stringa connessione (variabile x cliente)
///
- public List ItemGetAll(string connString)
+ public List ItemGetAll(string connString)
{
- List dbResult = new List();
+ List dbResult = new List();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetItems
//.Where(x => CustomerId == 0 || x.CustomerID == CustomerId)
.Include(c => c.MaterialNav)
- .OrderBy(x => x.MatID)
+ .OrderBy(x => x.MatId)
.ToList();
}
return dbResult;
@@ -99,52 +100,95 @@ namespace MagMan.Data.Tenant.Controllers
/// Stringa connessione (variabile x cliente)
/// ID del materiale x cui filtrare, 0 = tutti
///
- public List ItemGetByMat(string connString, int matID)
+ public List ItemGetByMat(string connString, int matID)
{
- List dbResult = new List();
+ List dbResult = new List();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetItems
- .Where(x => matID == 0 || x.MatID == matID)
+ .Where(x => matID == 0 || x.MatId == matID)
.Include(c => c.MaterialNav)
- //.OrderBy(x => x.MatID)
+ //.OrderBy(x => x.MatId)
.OrderBy(x => x.WMm)
- .ThenBy(x => x.TMm)
+ .ThenBy(x => x.HMm)
.ThenBy(x => x.LMm)
.ToList();
}
return dbResult;
}
+ /// Aggiunge/Modifica un item in magazzino Stringa connessione (variabile x cliente) Record da aggiornare quantità da
+ /// aggiornare (se <0 è consumo)
+ public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty)
+ {
+ bool done = false;
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ try
+ {
+ /*
+ * Verifica se esistesse: deve essere valido TUTTO
+ * - stesso materiale
+ * - stesse dimensioni
+ * */
+ var currData = dbCtx
+ .DbSetItems
+ .Where(x => (x.RawItemId == rec2upd.RawItemId) ||
+ (x.MatId == rec2upd.MatId && (x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm)))
+ .FirstOrDefault();
+ if (currData != null)
+ {
+ currData.QtyAvail += deltaQty;
+ dbCtx.Entry(currData).State = EntityState.Modified;
+ }
+ dbCtx.SaveChanges();
+ done = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ItemModQty{Environment.NewLine}{exc}");
+ }
+ }
+ return done;
+ }
+
///
/// Aggiunge/Modifica un item in magazzino
///
/// Stringa connessione (variabile x cliente)
/// Record da aggiungere/aggiornare
///
- public bool ItemUpdate(string connString, ItemModel rec2upd)
+ public bool ItemUpdate(string connString, RawItemModel rec2upd)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
+ /*
+ * Verifica se esistesse: deve essere valido TUTTO
+ * - stesso materiale
+ * - stesse dimensioni
+ * */
var currData = dbCtx
.DbSetItems
- .Where(x => x.ItemID == rec2upd.ItemID)
+ .Where(x => (x.RawItemId == rec2upd.RawItemId) ||
+ (x.MatId == rec2upd.MatId && (x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm)))
.FirstOrDefault();
if (currData != null)
{
- currData.MatID = rec2upd.MatID;
+ currData.MatId = rec2upd.MatId;
+ currData.QtyAvail = rec2upd.QtyAvail;
+ currData.IsActive = rec2upd.IsActive;
currData.IsRemn = rec2upd.IsRemn;
currData.Location = rec2upd.Location;
- currData.QtyAvail = rec2upd.QtyAvail;
- currData.Note = rec2upd.Note;
currData.LMm = rec2upd.LMm;
- currData.TMm = rec2upd.TMm;
+ currData.HMm = rec2upd.HMm;
currData.WMm = rec2upd.WMm;
- currData.DtMod = rec2upd.DtMod;
+ currData.Note = rec2upd.Note;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
@@ -179,7 +223,7 @@ namespace MagMan.Data.Tenant.Controllers
{
var currData = dbCtx
.DbSetMaterials
- .Where(x => x.MatID == rec2del.MatID)
+ .Where(x => x.MatId == rec2del.MatId)
.FirstOrDefault();
if (currData != null)
{
@@ -203,18 +247,68 @@ namespace MagMan.Data.Tenant.Controllers
///
/// Stringa connessione (variabile x cliente)
///
- public List MaterialGetAll(string connString)
+ public List MaterialGetAll(string connString, bool withChild)
{
List dbResult = new List();
using (MagManContext dbCtx = new MagManContext(connString))
{
- dbResult = dbCtx
- .DbSetMaterials
- .OrderBy(x => x.MatDesc)
- .ThenBy(x => x.WMm)
- .ThenBy(x => x.TMm)
- .ThenBy(x => x.LMm)
- .ToList();
+ if (withChild)
+ {
+ dbResult = dbCtx
+ .DbSetMaterials
+ .Include(x => x.RawItemList)
+ .OrderBy(x => x.MatDesc)
+ .ThenBy(x => x.WMm)
+ .ThenBy(x => x.HMm)
+ .ThenBy(x => x.LMm)
+ .ToList();
+ }
+ else
+ {
+ dbResult = dbCtx
+ .DbSetMaterials
+ .OrderBy(x => x.MatDesc)
+ .ThenBy(x => x.WMm)
+ .ThenBy(x => x.HMm)
+ .ThenBy(x => x.LMm)
+ .ToList();
+ }
+ }
+ return dbResult;
+ } ///
+
+ /// Elenco Materiali gestiti a magazzino Stringa
+ /// connessione (variabile x cliente) Materiale richiesto, 0
+ /// = tutti Se true allora include record child
+ /// (Items)
+ public List MaterialGetFilt(string connString, int matID, bool withChild)
+ {
+ List dbResult = new List();
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ if (withChild)
+ {
+ dbResult = dbCtx
+ .DbSetMaterials
+ .Where(x => matID == 0 || x.MatId == matID)
+ .Include(x => x.RawItemList)
+ .OrderBy(x => x.MatDesc)
+ .ThenBy(x => x.WMm)
+ .ThenBy(x => x.HMm)
+ .ThenBy(x => x.LMm)
+ .ToList();
+ }
+ else
+ {
+ dbResult = dbCtx
+ .DbSetMaterials
+ .Where(x => matID == 0 || x.MatId == matID)
+ .OrderBy(x => x.MatDesc)
+ .ThenBy(x => x.WMm)
+ .ThenBy(x => x.HMm)
+ .ThenBy(x => x.LMm)
+ .ToList();
+ }
}
return dbResult;
}
@@ -232,18 +326,24 @@ namespace MagMan.Data.Tenant.Controllers
{
try
{
+ /*
+ * Ricerca equal: corrisponde se
+ * - MatId identico
+ * - se Uguali + NonNulli [MatCode oppure MatDescript] + uguali [W/H/L]...
+ */
var currData = dbCtx
.DbSetMaterials
- .Where(x => x.MatID == rec2upd.MatID || x.MatExtCode==rec2upd.MatExtCode)
+ .Where(x => (rec2upd.MatId > 0 && x.MatId == rec2upd.MatId) ||
+ ((x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm) &&
+ ((!string.IsNullOrEmpty(rec2upd.MatCode) && x.MatCode == rec2upd.MatCode) || (!string.IsNullOrEmpty(rec2upd.MatDesc) && x.MatDesc == rec2upd.MatDesc))
+ ))
.FirstOrDefault();
if (currData != null)
{
- currData.MatExtCode = rec2upd.MatExtCode;
+ currData.MatCode = rec2upd.MatCode;
currData.MatDesc = rec2upd.MatDesc;
- currData.ApprovDate = rec2upd.ApprovDate;
- currData.ApprovUser = rec2upd.ApprovUser;
currData.LMm = rec2upd.LMm;
- currData.TMm = rec2upd.TMm;
+ currData.HMm = rec2upd.HMm;
currData.WMm = rec2upd.WMm;
dbCtx.Entry(currData).State = EntityState.Modified;
}
@@ -264,6 +364,165 @@ namespace MagMan.Data.Tenant.Controllers
return done;
}
+ ///
+ /// Elimina record Project
+ ///
+ /// Stringa connessione (variabile x cliente)
+ /// Item da eliminare
+ ///
+ public bool ProjectDelete(string connString, ProjModel rec2del)
+ {
+ bool done = false;
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ try
+ {
+ var currData = dbCtx
+ .DbSetProjects
+ .Where(x => x.ProjDbId == rec2del.ProjDbId)
+ .FirstOrDefault();
+ if (currData != null)
+ {
+ dbCtx
+ .DbSetProjects
+ .Remove(currData);
+ dbCtx.SaveChanges();
+ done = true;
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ProjectDelete{Environment.NewLine}{exc}");
+ }
+ }
+ return done;
+ }
+
+ ///
+ /// Elenco Projects (all)
+ ///
+ /// Stringa connessione (variabile x cliente)
+ ///
+ public List ProjectGetAll(string connString)
+ {
+ List dbResult = new List();
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ dbResult = dbCtx
+ .DbSetProjects
+ .OrderBy(x => x.DtCreated)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Elenco Items gestiti a magazzino dato Materiale
+ ///
+ /// Stringa connessione (variabile x cliente)
+ /// ID del materiale x cui filtrare, 0 = tutti
+ ///
+ public List ProjectGetByNumKey(string connString, int numKey)
+ {
+ List dbResult = new List();
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ dbResult = dbCtx
+ .DbSetProjects
+ .Where(x => numKey == 0 || x.KeyNum == numKey)
+ .OrderBy(x => x.DtCreated)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Elenco Items gestiti a magazzino dato Materiale
+ ///
+ /// Stringa connessione (variabile x cliente)
+ /// ID master key, 0 = tutti
+ /// periodo x filtraggio
+ ///
+ public List ProjectGetFilt(string connString, int numKey, SelectData period)
+ {
+ List dbResult = new List();
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ dbResult = dbCtx
+ .DbSetProjects
+ .Where(x => (numKey == 0 || x.KeyNum == numKey) &&
+ ((x.DtCreated >= period.DateStart && x.DtCreated <= period.DateEnd)
+ || (x.DtSchedule >= period.DateStart && x.DtSchedule <= period.DateEnd)
+ || (x.DtLastAction >= period.DateStart && x.DtLastAction <= period.DateEnd)
+ ))
+ .OrderBy(x => x.DtCreated)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Aggiunge/Modifica un record Project
+ ///
+ /// Stringa connessione (variabile x cliente)
+ /// Record da aggiungere/aggiornare
+ ///
+ public bool ProjectUpdate(string connString, ProjModel rec2upd)
+ {
+ bool done = false;
+ using (MagManContext dbCtx = new MagManContext(connString))
+ {
+ try
+ {
+ /*
+ * Ricerca:
+ * - DbId corrisponde
+ * - Key + Id remoti corrispondono
+ * */
+ var currData = dbCtx
+ .DbSetProjects
+ .Where(x => (x.ProjDbId == rec2upd.ProjDbId) ||
+ (x.ProjExtDbId == rec2upd.ProjExtDbId && x.KeyNum == rec2upd.KeyNum) ||
+ (x.ProjExtId == rec2upd.ProjExtId && x.KeyNum == rec2upd.KeyNum))
+ .FirstOrDefault();
+ if (currData != null)
+ {
+ currData.MachineID = rec2upd.MachineID;
+ currData.KeyNum = rec2upd.KeyNum;
+ currData.ProjExtDbId = rec2upd.ProjExtDbId;
+ currData.ProjExtId = rec2upd.ProjExtId;
+ currData.BTLFileName = rec2upd.BTLFileName;
+ currData.PType = rec2upd.PType;
+ currData.Machine = rec2upd.Machine;
+ currData.ProjDescription = rec2upd.ProjDescription;
+ currData.DtCreated = rec2upd.DtCreated;
+ currData.DtLastAction = rec2upd.DtLastAction;
+ currData.DtSchedule = rec2upd.DtSchedule;
+ currData.DtStartProd = rec2upd.DtStartProd;
+ currData.ListName = rec2upd.ListName;
+ currData.ProcTimeEst = rec2upd.ProcTimeEst;
+ currData.ProcTimeReal = rec2upd.ProcTimeReal;
+ currData.IsActive = rec2upd.IsActive;
+ currData.IsArchived = rec2upd.IsArchived;
+ dbCtx.Entry(currData).State = EntityState.Modified;
+ }
+ else
+ {
+ dbCtx
+ .DbSetProjects
+ .Add(rec2upd);
+ }
+ dbCtx.SaveChanges();
+ done = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ItemUpdate{Environment.NewLine}{exc}");
+ }
+ }
+ return done;
+ }
+
#endregion Public Methods
#region Private Fields
diff --git a/MagMan.Data.Tenant/DbModels/AliasModel.cs b/MagMan.Data.Tenant/DbModels/AliasModel.cs
new file mode 100644
index 0000000..1d0b6fc
--- /dev/null
+++ b/MagMan.Data.Tenant/DbModels/AliasModel.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MagMan.Data.Tenant.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ [Table("AliasList")]
+ public class AliasModel
+ {
+ ///
+ /// Famiglia di sinonimi
+ ///
+ public string Family { get; set; } = "";
+
+ ///
+ /// Codice originale (da trasformare)
+ ///
+ public string ValueOriginal { get; set; } = "";
+
+ ///
+ /// Codice Alias in cui viene convertito
+ ///
+ public string ValueAlias { get; set; } = "";
+ }
+}
diff --git a/MagMan.Data.Tenant/DbModels/LogMachineModel.cs b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs
new file mode 100644
index 0000000..15e65fc
--- /dev/null
+++ b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using static MagMan.Core.Enums;
+
+namespace MagMan.Data.Tenant.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ ///
+ /// Tabella dei LOG Macchina (per macchina)
+ ///
+ [Table("LogMachine")]
+ [Index(nameof(MachineID))]
+ [Index(nameof(KeyNum))]
+ public class LogMachineModel
+ {
+ [Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int LogDbId { get; set; }
+
+ ///
+ /// Id macchina (diMagMan)
+ ///
+ public int MachineID { get; set; } = 0;
+
+ ///
+ /// Key di riferimento per il progetto
+ ///
+ public int KeyNum { get; set; } = 0;
+
+#if false
+ ///
+ /// Codice Allarme
+ ///
+ [Column("AlarmCode")]
+ public string AlarmCode { get; set; } = "";
+
+ ///
+ /// Data Evento
+ ///
+ [Column("AlarmDtEvent")]
+ public DateTime AlarmDatetime { get; set; } = DateTime.Now;
+
+ ///
+ /// Messaggio Allarme
+ ///
+ [Column("AlarmMessage")]
+ public string AlarmMessage { get; set; } = "";
+
+ ///
+ /// Alarm Operation
+ ///
+ [Column("AlarmOperation")]
+ public int AlarmOperation { get; set; } = 0;
+
+ ///
+ /// Alarm Type
+ ///
+ [Column("AlarmType")]
+ public int AlarmType { get; set; } = 0;
+
+ ///
+ /// Esaecuzione comando corretta
+ ///
+ [Column("CommExecuted")]
+ public bool CommandExecutedCorrectly { get; set; } = false;
+
+ ///
+ /// Stato da enum Core
+ ///
+ [Column("CommandState")]
+ public Core.ConstMachComm.CommandStates CommandState { get; set; } = Core.ConstMachComm.CommandStates.NULL;
+
+ ///
+ /// Tipo Comando da enum Core
+ ///
+ [Column("CommandType")]
+ public Core.ConstMachComm.LogCommandTypes CommandType { get; set; } = Core.ConstMachComm.LogCommandTypes.NULL;
+
+ ///
+ /// Descrizione
+ ///
+ [Column("Description")]
+ public string Description { get; set; } = "";
+
+
+
+ ///
+ /// New OP State
+ ///
+ [Column("NewOpState")]
+ public int NewOpState { get; set; } = 0;
+#endif
+
+ ///
+ /// Stato da enum Core
+ ///
+ [Column("ResultType")]
+ public ResultTypes ResultType { get; set; } = ResultTypes.NULL;
+
+ ///
+ /// Indirizzo VAR
+ ///
+ [Column("VarAddress")]
+ public string VarAddress { get; set; } = "";
+
+ ///
+ /// Valore VAR
+ ///
+ [Column("VarValue")]
+ public string VarValue { get; set; } = "";
+
+
+ }
+}
diff --git a/MagMan.Data.Tenant/DbModels/MaterialModel.cs b/MagMan.Data.Tenant/DbModels/MaterialModel.cs
index 8b1cf3d..4217ef9 100644
--- a/MagMan.Data.Tenant/DbModels/MaterialModel.cs
+++ b/MagMan.Data.Tenant/DbModels/MaterialModel.cs
@@ -11,30 +11,33 @@ namespace MagMan.Data.Tenant.DbModels
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("Materials")]
+ [Table("MaterialsList")]
public partial class MaterialModel
{
- [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int MatID { get; set; }
+ ///
+ /// Init classe
+ ///
+ public MaterialModel()
+ {
+ RawItemList = new HashSet();
+ }
///
- /// Codice materiale (esterno)
+ /// Primary Key AUTO
///
- public int MatExtCode { get; set; } = 0;
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int MatId { get; set; }
+
+ ///
+ /// Codice Materiale
+ ///
+ public string MatCode { get; set; } = "";
+
///
/// Descrizione materiale
///
public string MatDesc { get; set; } = "";
- ///
- /// Data approvazione (se non approvato è nel futuro)
- ///
- public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(100);
- ///
- /// Utente approvazione amteriale
- ///
- public string ApprovUser { get; set; } = "";
-
///
/// Lenght/Lunghezza in mm
///
@@ -44,10 +47,11 @@ namespace MagMan.Data.Tenant.DbModels
///
public decimal WMm { get; set; } = 0;
///
- /// Thikness/Spessore in mm
+ /// Height (Thikness/Spessore) in mm
///
- public decimal TMm { get; set; } = 0;
+ public decimal HMm { get; set; } = 0;
+#if false
///
/// Lenght/Lunghezza in inch
///
@@ -68,10 +72,11 @@ namespace MagMan.Data.Tenant.DbModels
/// Thikness/Spessore in inch
///
[NotMapped]
- public decimal TIn
+ public decimal HIn
{
- get => Math.Round(TMm / (decimal)25.4, 3);
- }
+ get => Math.Round(HMm / (decimal)25.4, 3);
+ }
+#endif
///
/// Codice materiale x QR/Datamatrix
@@ -79,10 +84,30 @@ namespace MagMan.Data.Tenant.DbModels
[NotMapped]
public string MatDtmx
{
- get => $"MT{MatExtCode:00000000}";
+ get => $"MT{MatId:00000000}";
}
+ ///
+ /// Verifica che sia Beam, quando L == 0
+ ///
+ [NotMapped]
+ public bool IsBeam
+ {
+ get => (LMm == 0 && (HMm > 0 && WMm > 0));
+ }
- public virtual ICollection? ItemNav { get; set; }
+ ///
+ /// Verifica che sia Wall, quando W/L == 0
+ ///
+ [NotMapped]
+ public bool IsWall
+ {
+ get => (HMm > 0 && (LMm == 0 && WMm == 0));
+ }
+
+ ///
+ /// Navigazione ad oggetti child
+ ///
+ public virtual ICollection? RawItemList { get; set; }
}
}
diff --git a/MagMan.Data.Tenant/DbModels/MovMagModel.cs b/MagMan.Data.Tenant/DbModels/MovMagModel.cs
index 32aac01..6cdd62e 100644
--- a/MagMan.Data.Tenant/DbModels/MovMagModel.cs
+++ b/MagMan.Data.Tenant/DbModels/MovMagModel.cs
@@ -44,8 +44,8 @@ namespace MagMan.Data.Tenant.DbModels
///
/// Navigation property to Items
///
- [ForeignKey("ItemID")]
- public virtual ItemModel? ITemNav { get; set; }
+ [ForeignKey("RawItemId")]
+ public virtual RawItemModel? ITemNav { get; set; }
}
}
diff --git a/MagMan.Data.Tenant/DbModels/ProjModel.cs b/MagMan.Data.Tenant/DbModels/ProjModel.cs
new file mode 100644
index 0000000..0a124b6
--- /dev/null
+++ b/MagMan.Data.Tenant/DbModels/ProjModel.cs
@@ -0,0 +1,123 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static MagMan.Core.Enums;
+
+namespace MagMan.Data.Tenant.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ ///
+ /// Tabella dei PROJ caricati da EgtBeamWall
+ ///
+ [Table("ProjList")]
+ [Index(nameof(MachineID))]
+ [Index(nameof(KeyNum))]
+ [Index(nameof(ProjExtDbId))]
+ [Index(nameof(IsActive))]
+ [Index(nameof(IsArchived))]
+ public class ProjModel
+ {
+ #region Public Properties
+
+ ///
+ /// Chiave univoca su DB
+ ///
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int ProjDbId { get; set; }
+
+ ///
+ /// Id macchina (MagMan)
+ ///
+ public int MachineID { get; set; } = 0;
+
+ ///
+ /// Key di riferimento per il progetto
+ ///
+ public int KeyNum { get; set; } = 0;
+
+ ///
+ /// ID del DB EgtBW, univoco con KeyNum
+ ///
+ public int ProjExtDbId { get; set; } = 0;
+
+ ///
+ /// ID esterno (da EgtBW)
+ ///
+ public int ProjExtId { get; set; } = 0;
+
+ ///
+ /// Nome file BTL originale
+ ///
+ public string BTLFileName { get; set; } = "";
+
+ ///
+ /// Tipologia del progetto (Travi, Pareti, ...)
+ ///
+ public BWType PType { get; set; } = BWType.NULL;
+
+ ///
+ /// Macchina (Costruttore/Modello)
+ ///
+ public string Machine { get; set; } = "";
+
+ ///
+ /// Descrizione progetto (copiata da BTLFileName inizialmente)
+ ///
+ public string ProjDescription { get; set; } = "";
+
+ ///
+ /// Data Creazione progetto
+ ///
+ public DateTime DtCreated { get; set; } = DateTime.Now;
+
+ ///
+ /// Data di schedulazione (prevista)
+ ///
+ public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
+
+ ///
+ /// Data Inizio Produzione
+ ///
+ public DateTime DtStartProd { get; set; } = DateTime.MinValue;
+
+ ///
+ /// Data ora ultima operazione registrata
+ ///
+ public DateTime DtLastAction { get; set; } = DateTime.MinValue;
+
+ ///
+ /// ListName del BTL
+ ///
+ public string ListName { get; set; } = "";
+
+ ///
+ /// Tempo lavorazione previsto (stima) in minuti
+ ///
+ public double ProcTimeEst { get; set; } = 0;
+
+ ///
+ /// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
+ ///
+ public double ProcTimeReal { get; set; } = 0;
+
+ ///
+ /// Record attivo (se false == cancellazione logica)
+ ///
+ public bool IsActive { get; set; } = true;
+
+ ///
+ /// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
+ ///
+ public bool IsArchived { get; set; } = false;
+
+ #endregion Public Properties
+ }
+}
diff --git a/MagMan.Data.Tenant/DbModels/ItemModel.cs b/MagMan.Data.Tenant/DbModels/RawItemModel.cs
similarity index 76%
rename from MagMan.Data.Tenant/DbModels/ItemModel.cs
rename to MagMan.Data.Tenant/DbModels/RawItemModel.cs
index e4a8eac..40644dd 100644
--- a/MagMan.Data.Tenant/DbModels/ItemModel.cs
+++ b/MagMan.Data.Tenant/DbModels/RawItemModel.cs
@@ -12,19 +12,29 @@ namespace MagMan.Data.Tenant.DbModels
// This is here so CodeMaid doesn't reorganize this document
//
//[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))]
- [Table("ItemsList")]
- public partial class ItemModel
+ [Table("RawItemList")]
+ public partial class RawItemModel
{
///
/// Primary Key AUTO
///
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int ItemID { get; set; }
+ public int RawItemId { get; set; }
///
/// Ext ref for Material
///
- public int MatID { get; set; } = 0;
+ public int MatId { get; set; } = 0;
+
+ ///
+ /// Qty available on wharehouse
+ ///
+ public int QtyAvail { get; set; } = 0;
+
+ ///
+ /// Check if is a Remnant
+ ///
+ public bool IsActive { get; set; } = false;
///
/// Check if is a Remnant
@@ -35,16 +45,6 @@ namespace MagMan.Data.Tenant.DbModels
/// Location
///
public string Location { get; set; } = "";
- ///
- /// Qty available on wharehouse
- ///
- public int QtyAvail { get; set; } = 0;
-
- ///
- /// DateTime last modification
- ///
- public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10);
-
///
/// Item's Lenght
///
@@ -56,10 +56,16 @@ namespace MagMan.Data.Tenant.DbModels
public decimal WMm { get; set; } = 0;
///
- /// Item's Thikness
+ /// Item's Height (Thikness/Spessore) in mm
///
- public decimal TMm { get; set; } = 0;
+ public decimal HMm { get; set; } = 0;
+ ///
+ /// Note (optional)
+ ///
+ public string Note { get; set; } = "";
+
+#if false
[NotMapped]
public decimal LIn
{
@@ -71,22 +77,18 @@ namespace MagMan.Data.Tenant.DbModels
get => Math.Round(WMm / (decimal)25.4, 3);
}
[NotMapped]
- public decimal TIn
+ public decimal HIn
{
- get => Math.Round(TMm / (decimal)25.4, 3);
- }
+ get => Math.Round(HMm / (decimal)25.4, 3);
+ }
- ///
- /// Note (optional)
- ///
- public string Note { get; set; } = "";
-
[NotMapped]
public decimal Area
{
get => LMm * WMm;
}
+#endif
[NotMapped]
@@ -94,10 +96,10 @@ namespace MagMan.Data.Tenant.DbModels
{
get
{
- string answ = $"MT99999999-{LMm * 1000:00000000}";
+ string answ = $"MT99999999W{WMm * 10:000000}H{HMm * 10:000000}L{LMm * 10:000000}";
if (MaterialNav != null)
{
- answ = $"MT{MaterialNav.MatExtCode:00000000}-{LMm * 1000:00000000}";
+ answ = $"MT{MaterialNav.MatId:00000000}W{WMm * 10:000000}H{HMm * 10:000000}L{LMm * 10:000000}";
}
return answ;
}
@@ -106,7 +108,7 @@ namespace MagMan.Data.Tenant.DbModels
///
/// Navigation property to Material
///
- [ForeignKey("MatID")]
+ [ForeignKey("MatId")]
public virtual MaterialModel MaterialNav { get; set; } = null!;
}
diff --git a/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs
new file mode 100644
index 0000000..cfa204a
--- /dev/null
+++ b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static MagMan.Core.Enums;
+
+namespace MagMan.Data.Tenant.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ ///
+ /// Tabella dei Piano Richieste associate a Proj
+ ///
+ [Table("RequestPlan")]
+ public class RequestPlanModel
+ {
+ ///
+ /// Init classe
+ ///
+ public RequestPlanModel()
+ {
+ ResourcesList = new HashSet();
+ }
+
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int RequestId { get; set; }
+
+ ///
+ /// Progetto di riferimento
+ ///
+ public int ProjDbId { get; set; }
+
+ ///
+ /// Data richiesta
+ ///
+ public DateTime DtRequest { get; set; }
+
+ ///
+ /// Tipo richiesta
+ ///
+ public ProjResState ReqState { get; set; } = ProjResState.ND;
+
+ ///
+ /// Record attivo (se false == NON è il piano scelto per i casi "previsionali" = ReqState >0 )
+ ///
+ public bool IsActive { get; set; } = true;
+
+ ///
+ /// Navigazione ad oggetti child
+ ///
+ public virtual ICollection? ResourcesList { get; set; }
+ }
+}
diff --git a/MagMan.Data.Tenant/DbModels/ResourceModel.cs b/MagMan.Data.Tenant/DbModels/ResourceModel.cs
new file mode 100644
index 0000000..e8e2a45
--- /dev/null
+++ b/MagMan.Data.Tenant/DbModels/ResourceModel.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static MagMan.Core.Enums;
+
+namespace MagMan.Data.Tenant.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ ///
+ /// Tabella esplosione risorse (richiesta + items)
+ ///
+ [Table("ResourceList")]
+ public class ResourceModel
+ {
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int ResourceId { get; set; }
+
+ ///
+ /// Riferimento richiesta parent
+ ///
+ public int RequestId { get; set; } = 0;
+
+ ///
+ /// Riferimento RawItem specifico
+ ///
+ public int RawItemId { get; set; } = 0;
+
+ ///
+ /// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
+ ///
+ public int Qty { get; set; } = 0;
+
+ ///
+ /// Navigation property to RequestPlan
+ ///
+ [ForeignKey("RequestId")]
+ public virtual RequestPlanModel RequestNav { get; set; } = null!;
+ }
+}
diff --git a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj
index 4be0bad..b27104d 100644
--- a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj
+++ b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj
@@ -13,7 +13,11 @@
-
+
+
+
+
+
@@ -38,6 +42,7 @@
+
diff --git a/MagMan.Data.Tenant/MagManContext.cs b/MagMan.Data.Tenant/MagManContext.cs
index d4ed53c..0be9330 100644
--- a/MagMan.Data.Tenant/MagManContext.cs
+++ b/MagMan.Data.Tenant/MagManContext.cs
@@ -33,56 +33,27 @@ namespace MagMan.Data.Tenant
connString = currConnString;
}
-#if false
- public MagManContext(DbContextOptions options) : base(options)
- {
- try
- {
- // se non ci fosse... crea o migra!
- Database.Migrate();
- }
- catch (Exception exc)
- {
- Log.Error(exc, "Exception during context initialization 02");
- }
- }
-#endif
-
#endregion Public Constructors
#region Public Properties
public virtual DbSet DbSetConfig { get; set; } = null!;
- public virtual DbSet DbSetItems { get; set; } = null!;
+ public virtual DbSet DbSetItems { get; set; } = null!;
public virtual DbSet DbSetMaterials { get; set; } = null!;
- public virtual DbSet DbSetMovMag { get; set; } = null!;
- public virtual DbSet DbSetPrintJob { get; set; } = null!;
+ public virtual DbSet DbSetRawItem { get; set; } = null!;
+ public virtual DbSet DbSetAlias { get; set; } = null!;
+ public virtual DbSet DbSetProjects { get; set; } = null!;
+ public virtual DbSet DbSetReqPlan { get; set; } = null!;
+ public virtual DbSet DbSetResources { get; set; } = null!;
+
#if false
- public virtual DbSet DbSetKeyVal { get; set; }
-
- public virtual DbSet DbSetListVal { get; set; }
-
- public virtual DbSet DbSetOrders { get; set; }
-
- public virtual DbSet DbSetParamSend { get; set; }
-
- public virtual DbSet DbSetParamSet { get; set; }
-
- public virtual DbSet DbSetPlant { get; set; }
-
- public virtual DbSet DbSetPlantLog { get; set; }
-
- public virtual DbSet DbSetPlantStatus { get; set; }
-
- public virtual DbSet DbSetPlantSupplWeekPlan { get; set; }
-
- public virtual DbSet DbSetSupplier { get; set; }
-
- public virtual DbSet DbSetTransporter { get; set; }
+ public virtual DbSet DbSetMovMag { get; set; } = null!;
+ public virtual DbSet DbSetPrintJob { get; set; } = null!;
#endif
+
private string connString = "";
#endregion Public Properties
@@ -99,6 +70,9 @@ namespace MagMan.Data.Tenant
{
if (!optionsBuilder.IsConfigured)
{
+#if DEBUG
+ connString = "Server=localhost;port=3306;database=MagMan_000470;uid=MagMan_DbUser;pwd=viad@nte16!;sslmode=None;";
+#endif
var serverVersion = ServerVersion.AutoDetect(connString);
optionsBuilder.UseMySql(connString, serverVersion);
}
@@ -117,13 +91,8 @@ namespace MagMan.Data.Tenant
.HasComment("Valore di default/riferimento per la variabile");
});
-#if false
- modelBuilder.Entity().HasKey(c => new { c.TabName, c.FieldName, c.Val });
-
- modelBuilder.Entity().HasKey(c => new { c.PlantId, c.FluxType });
-
- modelBuilder.Entity().HasKey(c => new { c.PlantId, c.ParamUid });
-#endif
+ modelBuilder.Entity()
+ .HasKey(c => new { c.Family, c.ValueOriginal});
modelBuilder.Seed();
diff --git a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs b/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs
deleted file mode 100644
index 9171131..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.Designer.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-using MagMan.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- [DbContext(typeof(MagManContext))]
- [Migration("20231222163946_InitDb")]
- partial class InitDb
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "6.0.25")
- .HasAnnotation("Relational:MaxIdentifierLength", 64);
-
- modelBuilder.Entity("MagMan.Data.DbModels.ConfigModel", b =>
- {
- b.Property("KeyName")
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(0);
-
- b.Property("Note")
- .IsRequired()
- .HasMaxLength(250)
- .HasColumnType("varchar(250)")
- .HasColumnOrder(3);
-
- b.Property("Val")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(1);
-
- b.Property("ValStd")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(2)
- .HasComment("Valore di default/riferimento per la variabile");
-
- b.HasKey("KeyName");
-
- b.ToTable("Config");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs b/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs
deleted file mode 100644
index 0a7e484..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222163946_InitDb.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- public partial class InitDb : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterDatabase()
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateTable(
- name: "Config",
- columns: table => new
- {
- KeyName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- Val = table.Column(type: "varchar(50)", maxLength: 50, nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- ValStd = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
- .Annotation("MySql:CharSet", "utf8mb4"),
- Note = table.Column(type: "varchar(250)", maxLength: 250, nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Config", x => x.KeyName);
- })
- .Annotation("MySql:CharSet", "utf8mb4");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Config");
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs b/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs
deleted file mode 100644
index f1aa296..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.Designer.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-using System;
-using MagMan.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- [DbContext(typeof(MagManContext))]
- [Migration("20231222180319_AddMagBaseObj")]
- partial class AddMagBaseObj
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "6.0.25")
- .HasAnnotation("Relational:MaxIdentifierLength", 64);
-
- modelBuilder.Entity("MagMan.Data.DbModels.ConfigModel", b =>
- {
- b.Property("KeyName")
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(0);
-
- b.Property("Note")
- .IsRequired()
- .HasMaxLength(250)
- .HasColumnType("varchar(250)")
- .HasColumnOrder(3);
-
- b.Property("Val")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(1);
-
- b.Property("ValStd")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(2)
- .HasComment("Valore di default/riferimento per la variabile");
-
- b.HasKey("KeyName");
-
- b.ToTable("Config");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b =>
- {
- b.Property("ItemID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("DtMod")
- .HasColumnType("datetime(6)");
-
- b.Property("IsRemn")
- .HasColumnType("tinyint(1)");
-
- b.Property("LMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("Location")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("MatID")
- .HasColumnType("int");
-
- b.Property("Note")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("QtyAvail")
- .HasColumnType("int");
-
- b.Property("TMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("WMm")
- .HasColumnType("decimal(65,30)");
-
- b.HasKey("ItemID");
-
- b.HasIndex("MatID");
-
- b.ToTable("ItemsList");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
- {
- b.Property("MatID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("ApprovDate")
- .HasColumnType("datetime(6)");
-
- b.Property("ApprovUser")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("LMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("MatDesc")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("MatExtCode")
- .HasColumnType("int");
-
- b.Property("TMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("WMm")
- .HasColumnType("decimal(65,30)");
-
- b.HasKey("MatID");
-
- b.ToTable("Materials");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b =>
- {
- b.HasOne("MagMan.Data.DbModels.MaterialModel", "MaterialNav")
- .WithMany("ItemNav")
- .HasForeignKey("MatID")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("MaterialNav");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
- {
- b.Navigation("ItemNav");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs b/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs
deleted file mode 100644
index b141d32..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222180319_AddMagBaseObj.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- public partial class AddMagBaseObj : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Materials",
- columns: table => new
- {
- MatID = table.Column(type: "int", nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- MatExtCode = table.Column(type: "int", nullable: false),
- MatDesc = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- ApprovDate = table.Column(type: "datetime(6)", nullable: false),
- ApprovUser = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- LMm = table.Column(type: "decimal(65,30)", nullable: false),
- WMm = table.Column(type: "decimal(65,30)", nullable: false),
- TMm = table.Column(type: "decimal(65,30)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Materials", x => x.MatID);
- })
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateTable(
- name: "ItemsList",
- columns: table => new
- {
- ItemID = table.Column(type: "int", nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- MatID = table.Column(type: "int", nullable: false),
- IsRemn = table.Column(type: "tinyint(1)", nullable: false),
- Location = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- QtyAvail = table.Column(type: "int", nullable: false),
- DtMod = table.Column(type: "datetime(6)", nullable: false),
- LMm = table.Column(type: "decimal(65,30)", nullable: false),
- WMm = table.Column(type: "decimal(65,30)", nullable: false),
- TMm = table.Column(type: "decimal(65,30)", nullable: false),
- Note = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ItemsList", x => x.ItemID);
- table.ForeignKey(
- name: "FK_ItemsList_Materials_MatID",
- column: x => x.MatID,
- principalTable: "Materials",
- principalColumn: "MatID",
- onDelete: ReferentialAction.Restrict);
- })
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateIndex(
- name: "IX_ItemsList_MatID",
- table: "ItemsList",
- column: "MatID");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ItemsList");
-
- migrationBuilder.DropTable(
- name: "Materials");
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs b/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs
deleted file mode 100644
index bc5a906..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.Designer.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-//
-using System;
-using MagMan.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- [DbContext(typeof(MagManContext))]
- [Migration("20231222180523_AddMagBaseObj01")]
- partial class AddMagBaseObj01
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "6.0.25")
- .HasAnnotation("Relational:MaxIdentifierLength", 64);
-
- modelBuilder.Entity("MagMan.Data.DbModels.ConfigModel", b =>
- {
- b.Property("KeyName")
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(0);
-
- b.Property("Note")
- .IsRequired()
- .HasMaxLength(250)
- .HasColumnType("varchar(250)")
- .HasColumnOrder(3);
-
- b.Property("Val")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(1);
-
- b.Property("ValStd")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("varchar(50)")
- .HasColumnOrder(2)
- .HasComment("Valore di default/riferimento per la variabile");
-
- b.HasKey("KeyName");
-
- b.ToTable("Config");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b =>
- {
- b.Property("ItemID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("DtMod")
- .HasColumnType("datetime(6)");
-
- b.Property("IsRemn")
- .HasColumnType("tinyint(1)");
-
- b.Property("LMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("Location")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("MatID")
- .HasColumnType("int");
-
- b.Property("Note")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("QtyAvail")
- .HasColumnType("int");
-
- b.Property("TMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("WMm")
- .HasColumnType("decimal(65,30)");
-
- b.HasKey("ItemID");
-
- b.HasIndex("MatID");
-
- b.ToTable("ItemsList");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
- {
- b.Property("MatID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("ApprovDate")
- .HasColumnType("datetime(6)");
-
- b.Property("ApprovUser")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("LMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("MatDesc")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("MatExtCode")
- .HasColumnType("int");
-
- b.Property("TMm")
- .HasColumnType("decimal(65,30)");
-
- b.Property("WMm")
- .HasColumnType("decimal(65,30)");
-
- b.HasKey("MatID");
-
- b.ToTable("Materials");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b =>
- {
- b.Property("MovID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("DtRec")
- .HasColumnType("datetime(6)");
-
- b.Property("ItemID")
- .HasColumnType("int");
-
- b.Property("QtyRec")
- .HasColumnType("int");
-
- b.Property("UserId")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("MovID");
-
- b.HasIndex("ItemID");
-
- b.ToTable("MovMag");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.PrintJobQueueModel", b =>
- {
- b.Property("IdxPrintJob")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- b.Property("DtEnd")
- .HasColumnType("datetime(6)");
-
- b.Property("DtLastTry")
- .HasColumnType("datetime(6)");
-
- b.Property("DtStart")
- .HasColumnType("datetime(6)");
-
- b.Property("KeyParam")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("PrtName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("Stato")
- .HasColumnType("int");
-
- b.Property("TipoReport")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("IdxPrintJob");
-
- b.ToTable("PrintJobQueue");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.ItemModel", b =>
- {
- b.HasOne("MagMan.Data.DbModels.MaterialModel", "MaterialNav")
- .WithMany("ItemNav")
- .HasForeignKey("MatID")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("MaterialNav");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b =>
- {
- b.HasOne("MagMan.Data.DbModels.ItemModel", "ITemNav")
- .WithMany()
- .HasForeignKey("ItemID")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("ITemNav");
- });
-
- modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
- {
- b.Navigation("ItemNav");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs b/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs
deleted file mode 100644
index 2ce7017..0000000
--- a/MagMan.Data.Tenant/Migrations/20231222180523_AddMagBaseObj01.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace MagMan.Data.Tenant.Migrations
-{
- public partial class AddMagBaseObj01 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "MovMag",
- columns: table => new
- {
- MovID = table.Column(type: "int", nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- DtRec = table.Column(type: "datetime(6)", nullable: false),
- ItemID = table.Column(type: "int", nullable: false),
- QtyRec = table.Column(type: "int", nullable: false),
- UserId = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_MovMag", x => x.MovID);
- table.ForeignKey(
- name: "FK_MovMag_ItemsList_ItemID",
- column: x => x.ItemID,
- principalTable: "ItemsList",
- principalColumn: "ItemID",
- onDelete: ReferentialAction.Restrict);
- })
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateTable(
- name: "PrintJobQueue",
- columns: table => new
- {
- IdxPrintJob = table.Column(type: "int", nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- TipoReport = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- KeyParam = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- PrtName = table.Column(type: "longtext", nullable: false)
- .Annotation("MySql:CharSet", "utf8mb4"),
- DtStart = table.Column(type: "datetime(6)", nullable: false),
- DtEnd = table.Column(type: "datetime(6)", nullable: true),
- Stato = table.Column(type: "int", nullable: false),
- DtLastTry = table.Column(type: "datetime(6)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_PrintJobQueue", x => x.IdxPrintJob);
- })
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateIndex(
- name: "IX_MovMag_ItemID",
- table: "MovMag",
- column: "ItemID");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "MovMag");
-
- migrationBuilder.DropTable(
- name: "PrintJobQueue");
- }
- }
-}
diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs
new file mode 100644
index 0000000..e10b66d
--- /dev/null
+++ b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs
@@ -0,0 +1,297 @@
+//
+using System;
+using MagMan.Data.Tenant;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace MagMan.Data.Tenant.Migrations
+{
+ [DbContext(typeof(MagManContext))]
+ [Migration("20240122174314_InitDb")]
+ partial class InitDb
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "6.0.25")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.AliasModel", b =>
+ {
+ b.Property("Family")
+ .HasColumnType("varchar(255)");
+
+ b.Property("ValueOriginal")
+ .HasColumnType("varchar(255)");
+
+ b.Property("ValueAlias")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Family", "ValueOriginal");
+
+ b.ToTable("AliasList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
+ {
+ b.Property("KeyName")
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasColumnOrder(0);
+
+ b.Property("Note")
+ .IsRequired()
+ .HasMaxLength(250)
+ .HasColumnType("varchar(250)")
+ .HasColumnOrder(3);
+
+ b.Property("Val")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasColumnOrder(1);
+
+ b.Property("ValStd")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasColumnOrder(2)
+ .HasComment("Valore di default/riferimento per la variabile");
+
+ b.HasKey("KeyName");
+
+ b.ToTable("Config");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
+ {
+ b.Property("MatId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("HMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("LMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("MatCode")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("MatDesc")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("WMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("MatId");
+
+ b.ToTable("MaterialsList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
+ {
+ b.Property("ProjDbId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("BTLFileName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("DtCreated")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DtLastAction")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DtSchedule")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DtStartProd")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsArchived")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("KeyNum")
+ .HasColumnType("int");
+
+ b.Property("ListName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Machine")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("MachineID")
+ .HasColumnType("int");
+
+ b.Property("PType")
+ .HasColumnType("int");
+
+ b.Property("ProcTimeEst")
+ .HasColumnType("double");
+
+ b.Property("ProcTimeReal")
+ .HasColumnType("double");
+
+ b.Property("ProjDescription")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ProjExtDbId")
+ .HasColumnType("int");
+
+ b.Property("ProjExtId")
+ .HasColumnType("int");
+
+ b.HasKey("ProjDbId");
+
+ b.HasIndex("IsActive");
+
+ b.HasIndex("IsArchived");
+
+ b.HasIndex("KeyNum");
+
+ b.HasIndex("MachineID");
+
+ b.HasIndex("ProjExtDbId");
+
+ b.ToTable("ProjList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
+ {
+ b.Property("RawItemId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("HMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("IsRemn")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("LMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("Location")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("MatId")
+ .HasColumnType("int");
+
+ b.Property("Note")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("QtyAvail")
+ .HasColumnType("int");
+
+ b.Property("WMm")
+ .HasColumnType("decimal(65,30)");
+
+ b.HasKey("RawItemId");
+
+ b.HasIndex("MatId");
+
+ b.ToTable("RawItemList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
+ {
+ b.Property("RequestId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("DtRequest")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IsActive")
+ .HasColumnType("tinyint(1)");
+
+ b.Property("ProjDbId")
+ .HasColumnType("int");
+
+ b.Property("ReqState")
+ .HasColumnType("int");
+
+ b.HasKey("RequestId");
+
+ b.ToTable("RequestPlan");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
+ {
+ b.Property("ResourceId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Qty")
+ .HasColumnType("int");
+
+ b.Property("RawItemId")
+ .HasColumnType("int");
+
+ b.Property("RequestId")
+ .HasColumnType("int");
+
+ b.HasKey("ResourceId");
+
+ b.HasIndex("RequestId");
+
+ b.ToTable("ResourceList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
+ {
+ b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
+ .WithMany("RawItemList")
+ .HasForeignKey("MatId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+
+ b.Navigation("MaterialNav");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
+ {
+ b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
+ .WithMany("ResourcesList")
+ .HasForeignKey("RequestId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+
+ b.Navigation("RequestNav");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
+ {
+ b.Navigation("RawItemList");
+ });
+
+ modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
+ {
+ b.Navigation("ResourcesList");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs
new file mode 100644
index 0000000..57b8471
--- /dev/null
+++ b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs
@@ -0,0 +1,235 @@
+using System;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MagMan.Data.Tenant.Migrations
+{
+ public partial class InitDb : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "AliasList",
+ columns: table => new
+ {
+ Family = table.Column(type: "varchar(255)", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ValueOriginal = table.Column(type: "varchar(255)", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ValueAlias = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AliasList", x => new { x.Family, x.ValueOriginal });
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Config",
+ columns: table => new
+ {
+ KeyName = table.Column(type: "varchar(50)", maxLength: 50, nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ Val = table.Column(type: "varchar(50)", maxLength: 50, nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ValStd = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ Note = table.Column(type: "varchar(250)", maxLength: 250, nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Config", x => x.KeyName);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "MaterialsList",
+ columns: table => new
+ {
+ MatId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ MatCode = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ MatDesc = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ LMm = table.Column(type: "decimal(65,30)", nullable: false),
+ WMm = table.Column(type: "decimal(65,30)", nullable: false),
+ HMm = table.Column(type: "decimal(65,30)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_MaterialsList", x => x.MatId);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "ProjList",
+ columns: table => new
+ {
+ ProjDbId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ MachineID = table.Column(type: "int", nullable: false),
+ KeyNum = table.Column(type: "int", nullable: false),
+ ProjExtDbId = table.Column(type: "int", nullable: false),
+ ProjExtId = table.Column(type: "int", nullable: false),
+ BTLFileName = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ PType = table.Column(type: "int", nullable: false),
+ Machine = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ProjDescription = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ DtCreated = table.Column(type: "datetime(6)", nullable: false),
+ DtSchedule = table.Column(type: "datetime(6)", nullable: false),
+ DtStartProd = table.Column(type: "datetime(6)", nullable: false),
+ DtLastAction = table.Column(type: "datetime(6)", nullable: false),
+ ListName = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ProcTimeEst = table.Column(type: "double", nullable: false),
+ ProcTimeReal = table.Column(type: "double", nullable: false),
+ IsActive = table.Column(type: "tinyint(1)", nullable: false),
+ IsArchived = table.Column(type: "tinyint(1)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ProjList", x => x.ProjDbId);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "RequestPlan",
+ columns: table => new
+ {
+ RequestId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ ProjDbId = table.Column(type: "int", nullable: false),
+ DtRequest = table.Column(type: "datetime(6)", nullable: false),
+ ReqState = table.Column