Compare commits
290 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef54b8762b | |||
| 954543feb4 | |||
| 495811fa26 | |||
| c72756f25b | |||
| f0867272ec | |||
| 7848d7802b | |||
| 95af7cc9b5 | |||
| b6d7b1e7b9 | |||
| d59dea5c51 | |||
| 4eae0fa7ac | |||
| 3bd0806942 | |||
| 0f255e444b | |||
| 62b14754cd | |||
| bd7a82d50f | |||
| 944ae6126c | |||
| c276563d2f | |||
| 3979d378b2 | |||
| 8959cb0751 | |||
| 438ade3a10 | |||
| 13b904f61a | |||
| fcd7788a84 | |||
| 14e4b75b69 | |||
| a39a037aee | |||
| c5f7a7d78e | |||
| b5fcf6cd4d | |||
| bef5fdc203 | |||
| f899ea5380 | |||
| 87b5f37b5a | |||
| 56de33cfc6 | |||
| 4aca1a465a | |||
| d5d28524bd | |||
| c67c37cd2c | |||
| 529179e581 | |||
| 7635da616d | |||
| 7d9999b336 | |||
| 8918110dec | |||
| 287a9929b6 | |||
| dc0cb5fc69 | |||
| 147bd0dc9e | |||
| 75186f4628 | |||
| d9731433d1 | |||
| 1f75a0a39e | |||
| 9b32b9ae95 | |||
| a58458b0e6 | |||
| b466b3e8e5 | |||
| 86664908cb | |||
| f43acfd3ac | |||
| 9bb42101ea | |||
| 13dae1c425 | |||
| 150916acbd | |||
| 08832c26f2 | |||
| f614d3df7f | |||
| 786e850380 | |||
| ceadec4ae6 | |||
| eb02173f67 | |||
| 47bf84c5be | |||
| acccb38a25 | |||
| abf8d30ecd | |||
| ff066ddf1a | |||
| e51870a87b | |||
| e1c3de8199 | |||
| 9a7e273fd5 | |||
| 7d7bbf46c5 | |||
| 71ea0405d8 | |||
| 4ce5157489 | |||
| 162c6ff3a4 | |||
| befbccc9a2 | |||
| 6c84f84e53 | |||
| 9a54256dbd | |||
| c85f99bf10 | |||
| 8d7d8d2f71 | |||
| c01bf85968 | |||
| cec8aa22e4 | |||
| e6751ee3ba | |||
| 4055ce8426 | |||
| e55610870c | |||
| ddd7c1e98b | |||
| f54e5702c2 | |||
| abd4f94279 | |||
| d855a25b0e | |||
| 4172a87982 | |||
| 4c820619ef | |||
| f80ff4d130 | |||
| 35729ec1d5 | |||
| e8e7b804c5 | |||
| 698e168d4c | |||
| 30210b7b8b | |||
| 2175b1a559 | |||
| 0a2b93134c | |||
| a5262711b4 | |||
| 130a8921fd | |||
| 0a18c07788 | |||
| 00e96a1450 | |||
| db30e98ee3 | |||
| 850542fb7d | |||
| 9590087381 | |||
| 4698262742 | |||
| f5d490bd27 | |||
| 51b98c0896 | |||
| acf7be06fa | |||
| 3e3c5ede9c | |||
| 398295f602 | |||
| 9e5f750444 | |||
| 159602440a | |||
| c00de7d839 | |||
| 731e41b89c | |||
| 27beb82723 | |||
| 6072e4bbf9 | |||
| 4b7097e941 | |||
| 569bdac36d | |||
| c13eb15ad0 | |||
| 50b912c3f0 | |||
| e41b7ac97e | |||
| 77ac2c6d1b | |||
| ec1854844a | |||
| eb99ec5437 | |||
| f77e95c9b9 | |||
| b135a4ee3d | |||
| b4ec83e127 | |||
| f12a85aea5 | |||
| 4efb48abe7 | |||
| 848434fd00 | |||
| 50d157005b | |||
| 5a0a543a87 | |||
| 8a339231db | |||
| 15ae17a420 | |||
| 2435e7d0fb | |||
| 102249efe1 | |||
| ee32c8440e | |||
| 09c719f42d | |||
| 1fe95c3fbf | |||
| 4d3a0c74f9 | |||
| dc95214919 | |||
| 883635470f | |||
| 736fb0d5a6 | |||
| 77798f0d60 | |||
| c0b51ef696 | |||
| 07ab77782b | |||
| e120f716d8 | |||
| b45837ec8d | |||
| 32999677ea | |||
| f4f2c9bfec | |||
| 729727610e | |||
| 7e5605aa7b | |||
| cc879c073d | |||
| 660f1f2407 | |||
| 1547cbb0cb | |||
| f4db03a154 | |||
| 458c5e5c64 | |||
| 6fe052addc | |||
| 94cb8101e1 | |||
| 360d9d4332 | |||
| c675e4a5f4 | |||
| 85638afb2c | |||
| fd5df05ee9 | |||
| 7dbc84fe45 | |||
| db087b52e1 | |||
| 437e23b30c | |||
| 6375ec8bd1 | |||
| 8f2545aa29 | |||
| dbdce221e9 | |||
| 455ce65fcc | |||
| 9f53aa0c3f | |||
| 13242fffb1 | |||
| dafd2e6a0b | |||
| 311da2987e | |||
| d34290bf63 | |||
| 7221b56c87 | |||
| 0aad827655 | |||
| bf4f77e1f1 | |||
| 2bf478529d | |||
| 37a911a150 | |||
| 01c239fac1 | |||
| 3a7edacd53 | |||
| 83c77905c9 | |||
| c0d59c09fd | |||
| e9d13f2683 | |||
| 8d65efaa92 | |||
| 466c0e48bb | |||
| 39e1c367c7 | |||
| e5ea713813 | |||
| bcf2695cf8 | |||
| f7f5a97784 | |||
| c41ed6dfe8 | |||
| 342cc73d7f | |||
| bbe2250c7b | |||
| 9767e220ce | |||
| 3bbdb2c25d | |||
| b9c5db56f5 | |||
| d69bc8f18d | |||
| 27522184e3 | |||
| f818ebdda9 | |||
| 8e1124a211 | |||
| 39abb4832c | |||
| 249059e825 | |||
| 9fd274b166 | |||
| 81e36caaa3 | |||
| 5134f3b43f | |||
| b2c4d76d78 | |||
| d4024058b4 | |||
| d412e8e771 | |||
| d70f271e1c | |||
| 7181be9cb6 | |||
| 627b29f06d | |||
| a57b0ce611 | |||
| 41e2b869bd | |||
| 86a0945ad7 | |||
| 7609cf3284 | |||
| 8057b52fc0 | |||
| 74f7827742 | |||
| 7c3c475de2 | |||
| e7c22e5703 | |||
| bbf7385f59 | |||
| e808369929 | |||
| 9849331b40 | |||
| 257f52f9f8 | |||
| 9eaf5716bf | |||
| ab005f72cb | |||
| f53b460ae8 | |||
| 4e50f4332e | |||
| 8762421407 | |||
| 260e3557b3 | |||
| d89abe3aad | |||
| fc8e533983 | |||
| 42e9de7316 | |||
| f57a9d5360 | |||
| c2c179a826 | |||
| 5726d6795c | |||
| e9e724fa7f | |||
| f43aeaf66c | |||
| 4e4280c829 | |||
| 81f8d316f9 | |||
| e90c807a52 | |||
| b0b8dda2c7 | |||
| 0cb19811c5 | |||
| 7a62ecbbd5 | |||
| dc3bd557d2 | |||
| d79120117e | |||
| eed737ebb8 | |||
| 68992269f9 | |||
| 211f52dee3 | |||
| 064f79425d | |||
| 55474308c6 | |||
| 1971e2ed12 | |||
| edd688c7e4 | |||
| ec32cc75ab | |||
| de3e0cf140 | |||
| e49be1b9f0 | |||
| ee95c030f5 | |||
| 34eaa29020 | |||
| bc90034d17 | |||
| fe1606dbbb | |||
| 3295482796 | |||
| ceacddd22c | |||
| 8a5cb4a7b5 | |||
| 8868734b44 | |||
| e33bf8ef4a | |||
| 353dafe9c8 | |||
| 37a9238f73 | |||
| 84200fe515 | |||
| 9207b4350e | |||
| 8917c5570a | |||
| bee30d98e3 | |||
| 41ffd471e2 | |||
| 2e82c08fde | |||
| 7d08078681 | |||
| 8e12957e77 | |||
| 81ebf28c34 | |||
| c7f54277ea | |||
| cf2cef3c3f | |||
| 04dee711fc | |||
| 6fbdee5f2e | |||
| d7ed564d3e | |||
| 7b7c4095a9 | |||
| f31a671f1d | |||
| 983586552b | |||
| 53332b389f | |||
| 1acdde89e8 | |||
| 1669413558 | |||
| eccd839236 | |||
| 96e4e09ba8 | |||
| a0625bc77e | |||
| 009aba0cec | |||
| 88a4b0188e | |||
| 008f288de2 | |||
| af24e2a01d | |||
| ca94cda9c7 | |||
| 393e8b671f | |||
| 82914f2f28 | |||
| eca44a7fc5 |
+210
@@ -0,0 +1,210 @@
|
||||
variables:
|
||||
VERS_MAIN: '1.0'
|
||||
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
|
||||
- |
|
||||
$hasSource = C:\Tools\nuget.exe sources list | find "`"Steamware Nexus`"" /C
|
||||
if ($hasSource -eq 0) {
|
||||
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
|
||||
} else {
|
||||
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
|
||||
}
|
||||
echo $hasSource
|
||||
|
||||
# helper creazione hash files
|
||||
.hashBuild: &hashBuild
|
||||
- |
|
||||
$Target = $env:APP_NAME + "\bin\publish\" + $env:APP_NAME + ".zip"
|
||||
$MD5 = Get-FileHash $Target -Algorithm MD5
|
||||
$SHA1 = Get-FileHash $Target -Algorithm SHA1
|
||||
New-Item $Target".md5"
|
||||
New-Item $Target".sha1"
|
||||
$MD5.Hash | Set-Content -Path $Target".md5"
|
||||
$SHA1.Hash | Set-Content -Path $Target".sha1"
|
||||
|
||||
echo "Created HASH files for $Target"
|
||||
|
||||
# helper x send su NEXUS
|
||||
.nexusUpload: &nexusUpload
|
||||
- |
|
||||
Set-Alias mCurl C:\Windows\system32\curl.exe
|
||||
$currentDate = get-date -format yyMM;
|
||||
$currentTime = get-date -format ddHH;
|
||||
$VersNumb = Get-Content "Resources\VersNum.txt"
|
||||
echo "Curr Version: $VersNumb"
|
||||
if($CI_COMMIT_BRANCH -eq "main")
|
||||
{
|
||||
$version = "stable"
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = "unstable"
|
||||
}
|
||||
$File2Send = Get-ChildItem($env:APP_NAME + "\bin\publish\*")
|
||||
ForEach ($File in $File2Send) {
|
||||
$FileName = Split-Path $File -leaf
|
||||
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName
|
||||
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName
|
||||
|
||||
}
|
||||
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 = "<version>(.|\n)*?</version>";
|
||||
$fileNameRel = "$env:APP_NAME.Release.nuspec";
|
||||
$replRel = "<version>" + $currRelease + "</version>";
|
||||
$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 = "<version>" + $currDebug + "</version>";
|
||||
$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
|
||||
|
||||
# --------------------------------
|
||||
# BUILD
|
||||
# --------------------------------
|
||||
MagMan.UI:build:
|
||||
stage: build
|
||||
tags:
|
||||
- win
|
||||
before_script:
|
||||
- *nuget-fix
|
||||
- dotnet restore "$env:SOL_NAME.sln"
|
||||
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
|
||||
tags:
|
||||
- win
|
||||
only:
|
||||
- develop
|
||||
- main
|
||||
before_script:
|
||||
- *nuget-fix
|
||||
- dotnet restore "$env:SOL_NAME.sln"
|
||||
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/
|
||||
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MagMan.UI/MagMan.UI.csproj -o:publish -r linux-x64 --self-contained false
|
||||
# qui il deploy su nexus...
|
||||
- *hashBuild
|
||||
- *nexusUpload
|
||||
|
||||
# --------------------------------
|
||||
# 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"
|
||||
- '& Remove-Item *.nupkg'
|
||||
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
|
||||
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
|
||||
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
|
||||
@@ -1,108 +0,0 @@
|
||||
variables:
|
||||
VERS_MAIN: '0.9'
|
||||
NEXUS_PATH: 'GWMS'
|
||||
APP_NAME: 'GWMS.UI'
|
||||
|
||||
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
|
||||
.nuget-fix: &nuget-fix
|
||||
- |
|
||||
$hasSource = C:\Tools\nuget.exe sources list | find "`"Steamware Nexus`"" /C
|
||||
if ($hasSource -eq 0) {
|
||||
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
|
||||
} else {
|
||||
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
|
||||
}
|
||||
echo $hasSource
|
||||
|
||||
# helper creazione hash files
|
||||
.hashBuild: &hashBuild
|
||||
- |
|
||||
$Target = $env:APP_NAME + "\bin\publish\" + $env:APP_NAME + ".zip"
|
||||
$MD5 = Get-FileHash $Target -Algorithm MD5
|
||||
$SHA1 = Get-FileHash $Target -Algorithm SHA1
|
||||
New-Item $Target".md5"
|
||||
New-Item $Target".sha1"
|
||||
$MD5.Hash | Set-Content -Path $Target".md5"
|
||||
$SHA1.Hash | Set-Content -Path $Target".sha1"
|
||||
|
||||
echo "Created HASH files for $Target"
|
||||
|
||||
# helper x send su NEXUS
|
||||
.nexusUpload: &nexusUpload
|
||||
- |
|
||||
Set-Alias mCurl C:\Windows\system32\curl.exe
|
||||
$currentDate = get-date -format yyMM;
|
||||
$currentTime = get-date -format ddHH;
|
||||
$VersNumb = Get-Content "Resources\VersNum.txt"
|
||||
echo "Curr Version: $VersNumb"
|
||||
if($CI_COMMIT_BRANCH -eq "master")
|
||||
{
|
||||
$version = "stable"
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = "unstable"
|
||||
}
|
||||
$File2Send = Get-ChildItem($env:APP_NAME + "\bin\publish\*")
|
||||
ForEach ($File in $File2Send) {
|
||||
$FileName = Split-Path $File -leaf
|
||||
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName
|
||||
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName
|
||||
|
||||
}
|
||||
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
|
||||
|
||||
stages:
|
||||
- build
|
||||
- installer
|
||||
- release
|
||||
|
||||
build:
|
||||
stage: build
|
||||
tags:
|
||||
- win
|
||||
before_script:
|
||||
- *nuget-fix
|
||||
- dotnet restore GWMS.sln
|
||||
script:
|
||||
- dotnet build -p:Configuration=Release GWMS.UI/GWMS.UI.csproj
|
||||
|
||||
installer:
|
||||
stage: installer
|
||||
tags:
|
||||
- win
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
needs: ["build"]
|
||||
before_script:
|
||||
# - *nuget-fix
|
||||
# - dotnet restore
|
||||
script:
|
||||
# - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release GWMS.UI/GWMS.UI.csproj -o:publish
|
||||
# pubblico solo installer Linux x64: https://docs.microsoft.com/en-us/dotnet/core/deploying/
|
||||
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release GWMS.UI/GWMS.UI.csproj -o:publish -r linux-x64 --self-contained false
|
||||
# qui il deploy su nexus...
|
||||
- *hashBuild
|
||||
- *nexusUpload
|
||||
|
||||
release:
|
||||
stage: release
|
||||
tags:
|
||||
- win
|
||||
only:
|
||||
#- feature/Deploy_CI_CD
|
||||
# - master
|
||||
- tags
|
||||
except:
|
||||
- branches
|
||||
needs: ["build"]
|
||||
artifacts:
|
||||
paths:
|
||||
- publish/
|
||||
script:
|
||||
- dotnet publish -c Release -o ./publish GWMS.UI/GWMS.UI.csproj
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>EgwProxy.MagMan</id>
|
||||
<version>#version#</version>
|
||||
<title>EgwProxy.MagMan</title>
|
||||
<authors>Samuele E. Locatelli, EgalWare</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<description>Libreria per comunicazione REST con server MagMan online/onsite per EgtBW - beta/unstable</description>
|
||||
<releaseNotes>#releaseNotes#</releaseNotes>
|
||||
<copyright>#copyright#</copyright>
|
||||
<tags>EgwProxy.MagMan MagMan Rest</tags>
|
||||
<dependencies>
|
||||
<dependency id="RestSharp" version="110.2.0.0" />
|
||||
<dependency id="Newtonsoft.Json" version="13.0.0.0" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="EgwProxy.MagMan\bin\Debug\EgwProxy.MagMan*.dll" target="lib" />
|
||||
<file src="EgwProxy.MagMan\bin\Debug\EgwProxy.MagMan*.config" target="lib" />
|
||||
<file src="EgwProxy.MagMan\bin\Debug\EgwProxy.MagMan*.pdb" target="lib" />
|
||||
</files>
|
||||
</package>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>EgwProxy.MagMan</id>
|
||||
<version>#version#</version>
|
||||
<title>EgwProxy.MagMan</title>
|
||||
<authors>Samuele E. Locatelli, EgalWare</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<description>Libreria per comunicazione REST con server MagMan online/onsite per EgtBW</description>
|
||||
<releaseNotes>#releaseNotes#</releaseNotes>
|
||||
<copyright>#copyright#</copyright>
|
||||
<tags>EgwProxy.MagMan MagMan Rest</tags>
|
||||
<dependencies>
|
||||
<dependency id="RestSharp" version="110.2.0.0" />
|
||||
<dependency id="Newtonsoft.Json" version="13.0.0.0" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="EgwProxy.MagMan\bin\Debug\EgwProxy.MagMan*.dll" target="lib" />
|
||||
<file src="EgwProxy.MagMan\bin\Debug\EgwProxy.MagMan*.config" target="lib" />
|
||||
</files>
|
||||
</package>
|
||||
@@ -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
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
public class AliasDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Codice originale (da trasformare)
|
||||
/// </summary>
|
||||
public string ValOrig { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice Alias in cui viene convertito
|
||||
/// </summary>
|
||||
public string ValAlias { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ItemDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Ext Ref Key Materiale (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext Ref Key Materiale (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int MatLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key del RawItem (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
/// </summary>
|
||||
public bool IsRemn { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Location
|
||||
/// </summary>
|
||||
public string Location { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Qty available on wharehouse
|
||||
/// </summary>
|
||||
public int QtyAvail { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Height/Thikness/Spessore
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Lenght
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Width
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Note
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice QR/Matrix Item
|
||||
/// </summary>
|
||||
public string ItemDtmx { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class MaterialDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Codice Univoco (DB) sul CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key Materiale (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int MatLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice materiale (esterno)
|
||||
/// </summary>
|
||||
public string MatCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione materiale
|
||||
/// </summary>
|
||||
public string MatDesc { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Height/Thikness/Spessore in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Lenght/Lunghezza in mm
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Width/Larghezza in mm
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Varianti dimensionali disponibili
|
||||
/// </summary>
|
||||
public int SizeNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Quantità totale in giacenza
|
||||
/// </summary>
|
||||
public int QtyTot { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice QR/Matrix materiale
|
||||
/// </summary>
|
||||
public string MatDtmx { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Beam, quando L == 0
|
||||
/// </summary>
|
||||
public bool IsBeam { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Wall, quando W/L == 0
|
||||
/// </summary>
|
||||
public bool IsWall { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Elenco item e giancenze
|
||||
/// </summary>
|
||||
public List<ItemDTO> ItemList { get; set; } = new List<ItemDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ProjectDTO
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Key progetto (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int ProjCloudId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ID del DB EgtBW, univoco con KeyNum, (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int ProjLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID esterno (da EgtBW)
|
||||
/// </summary>
|
||||
public int ProjExtId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione progetto (copiata da BTLFileName inizialmente)
|
||||
/// </summary>
|
||||
public string ProjDescription { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome file BTL originale
|
||||
/// </summary>
|
||||
public string BTLFileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data Creazione progetto
|
||||
/// </summary>
|
||||
public DateTime DtCreated { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Data ora ultima operazione registrata
|
||||
/// </summary>
|
||||
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Data di schedulazione (prevista)
|
||||
/// </summary>
|
||||
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
|
||||
|
||||
/// <summary>
|
||||
/// Data Inizio Produzione
|
||||
/// </summary>
|
||||
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == cancellazione logica)
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
|
||||
/// </summary>
|
||||
public bool IsArchived { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ListName del BTL
|
||||
/// </summary>
|
||||
public string ListName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Macchina (Costruttore/Modello)
|
||||
/// </summary>
|
||||
public string Machine { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (MagMan) DB / CLOUD
|
||||
/// </summary>
|
||||
public int MachineCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione previsto (stima) in minuti
|
||||
/// </summary>
|
||||
public double ProcTimeEst { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
|
||||
/// </summary>
|
||||
public double ProcTimeReal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia del progetto (Travi, Pareti, ...)
|
||||
/// </summary>
|
||||
public BWType PType { get; set; } = BWType.NULL;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ResourceDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
|
||||
namespace EgwProxy.MagMan.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ResourceExpDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// ID risorsa (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int ResourceCloudId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento richiesta parent
|
||||
/// </summary>
|
||||
public int RequestId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref for Material (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref for Material (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
/// </summary>
|
||||
public bool IsRemn { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Height (Thikness/Spessore) in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Lenght
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Width
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Note (optional)
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data richiesta
|
||||
/// </summary>
|
||||
public DateTime DtRequest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == NON è il piano scelto per i casi "previsionali" = ReqState >0 )
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,799 @@
|
||||
using EgwProxy.MagMan.DTO;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace EgwProxy.MagMan
|
||||
{
|
||||
public class DataSyncro
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza la libreria di comunicazione con il token assegnato
|
||||
/// </summary>
|
||||
/// <param name="serverUrl">URL del server</param>
|
||||
/// <param name="authToken">Token di autorizzazione</param>
|
||||
public DataSyncro(string serverUrl, string authToken)
|
||||
{
|
||||
RestToken = authToken;
|
||||
servAddr = serverUrl;
|
||||
apiUrl = $"https://{servAddr}/api/";
|
||||
rcOptions = new RestClientOptions { BaseUrl = new Uri(apiUrl), MaxTimeout = callTimeout };
|
||||
Log.Info($"DataSyncro initialized | api: {apiUrl} | timeout: {callTimeout}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza la libreria di comunicazione con il token assegnato
|
||||
/// </summary>
|
||||
/// <param name="serverUrl">URL del server</param>
|
||||
/// <param name="authToken">Token di autorizzazione</param>
|
||||
/// <param name="timeout">Timeout chiamate in ms</param>
|
||||
public DataSyncro(string serverUrl, string authToken, int timeout)
|
||||
{
|
||||
RestToken = authToken;
|
||||
servAddr = serverUrl;
|
||||
callTimeout = timeout;
|
||||
apiUrl = $"https://{servAddr}/api/";
|
||||
rcOptions = new RestClientOptions { BaseUrl = new Uri(apiUrl), MaxTimeout = callTimeout };
|
||||
Log.Info($"DataSyncro initialized | api: {apiUrl} | timeout: {callTimeout}");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Test ping x indirizzo indicato
|
||||
/// </summary>
|
||||
/// <param name="tgtAddr">Indirizzo da pingare</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test ping x indirizzo indicato
|
||||
/// </summary>
|
||||
/// <param name="tgtAddr">Indirizzo da pingare</param>
|
||||
/// <param name="timeout">Timeout chiamata in ms</param>
|
||||
/// <returns></returns>
|
||||
public static IPStatus pingAddress(string tgtAddr, int timeout)
|
||||
{
|
||||
IPStatus answ = IPStatus.Unknown;
|
||||
IPAddress address;
|
||||
PingReply reply;
|
||||
using (Ping pingSender = new Ping())
|
||||
{
|
||||
address = IPAddress.Loopback;
|
||||
int pingMsTimeout = timeout;
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Alias dato RestToken
|
||||
/// </summary>
|
||||
public List<AliasDTO> AliasGet()
|
||||
{
|
||||
List<AliasDTO> answ = new List<AliasDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Alias/{MKeyEnc}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<AliasDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione Async Elenco Alias dato RestToken
|
||||
/// </summary>
|
||||
public async Task<List<AliasDTO>> AliasGetAsync()
|
||||
{
|
||||
List<AliasDTO> answ = new List<AliasDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Alias/{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<List<AliasDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invio elenco (anche parziale) di Alias, il server farà il merge
|
||||
/// </summary>
|
||||
public bool AliasSend(List<AliasDTO> List2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Alias newPayload = new RestPayload.Alias()
|
||||
{
|
||||
AliasList = List2Merge
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Alias/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = client.Post(request);
|
||||
Log.Debug($"AliasSend | Response StatusCode: {response.StatusCode}");
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"AliasSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione async Invio elenco (anche parziale) di Alias, il server farà il merge
|
||||
/// </summary>
|
||||
public async Task<bool> AliasSendAsync(List<AliasDTO> List2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Alias newPayload = new RestPayload.Alias()
|
||||
{
|
||||
AliasList = List2Merge
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Alias/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
Log.Debug($"AliasSendAsync | Response StatusCode: {response.StatusCode}");
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"AliasSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata test sul server (ping)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CheckRemote()
|
||||
{
|
||||
IPAddress address = IPAddress.Loopback;
|
||||
string srvIp = servAddr;
|
||||
if (servAddr.Contains(":"))
|
||||
{
|
||||
srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
|
||||
}
|
||||
return pingAddress(srvIp, callTimeout) == IPStatus.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inventario per materiale
|
||||
/// </summary>
|
||||
/// <param name="MatID">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public List<MaterialDTO> InventoryGet(int MatID)
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Inventory/{MKeyEnc}?MatCloudId={MatID}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione Async Inventario per materiale
|
||||
/// </summary>
|
||||
/// <param name="MatID">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MaterialDTO>> InventoryGetAsync(int MatID)
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Inventory/{MKeyEnc}?MatCloudId={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<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invio elenco di RawItems associati ad un singolo materiale, il server farà il merge
|
||||
/// <param name="rec2send">record da inviare</param>
|
||||
/// </summary>
|
||||
public bool InventorySend(List<ItemDTO> rec2send)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Items newPayload = new RestPayload.Items()
|
||||
{
|
||||
ItemList = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = client.Post(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"InventorySend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione Async Invio elenco di RawItems associati ad un singolo materiale, il server
|
||||
/// farà il merge <param name="rec2send">record da inviare</param>
|
||||
/// </summary>
|
||||
public async Task<bool> InventorySendAsync(List<ItemDTO> rec2send)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Items newPayload = new RestPayload.Items()
|
||||
{
|
||||
ItemList = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"InventorySendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Materiali dato RestToken
|
||||
/// </summary>
|
||||
public List<MaterialDTO> MaterialsGet()
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione Async Elenco Materiali dato RestToken
|
||||
/// </summary>
|
||||
public async Task<List<MaterialDTO>> MaterialsGetAsync()
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
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<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invio elenco (anche parziale) di Materiali, il server farà il merge
|
||||
/// </summary>
|
||||
public bool MaterialsSend(List<MaterialDTO> List2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Materials newPayload = new RestPayload.Materials()
|
||||
{
|
||||
MatList = List2Merge
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = client.Post(request);
|
||||
Log.Debug($"MaterialsSend | Response StatusCode: {response.StatusCode}");
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"MaterialsSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione async Invio elenco (anche parziale) di Materiali, il server farà il merge
|
||||
/// </summary>
|
||||
public async Task<bool> MaterialsSendAsync(List<MaterialDTO> List2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Materials newPayload = new RestPayload.Materials()
|
||||
{
|
||||
MatList = List2Merge
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
Log.Debug($"MaterialsSendAsync | Response StatusCode: {response.StatusCode}");
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"MaterialsSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco progetti associati a chiave
|
||||
/// </summary>
|
||||
/// <param name="NumKey">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public List<ProjectDTO> ProjectGet(int NumKey)
|
||||
{
|
||||
List<ProjectDTO> answ = new List<ProjectDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Projects/{MKeyEnc}?KeyNum={NumKey}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<ProjectDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione Async Elenco progetti associati a chiave
|
||||
/// </summary>
|
||||
/// <param name="MatID">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProjectDTO>> ProjectGetAsync(int NumKey)
|
||||
{
|
||||
List<ProjectDTO> answ = new List<ProjectDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Projects/{MKeyEnc}?KeyNum={NumKey}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<ProjectDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record progetto da Key/ID
|
||||
/// </summary>
|
||||
/// <param name="ProjCloudId">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public ProjectDTO ProjectGetSingle(int ProjCloudId)
|
||||
{
|
||||
ProjectDTO answ = new ProjectDTO();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Projects/single/{MKeyEnc}?ProjCloudId={ProjCloudId}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<ProjectDTO>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record progetto da Key/ID
|
||||
/// </summary>
|
||||
/// <param name="ProjCloudId">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ProjectDTO> ProjectGetSingleAsync(int ProjCloudId)
|
||||
{
|
||||
ProjectDTO answ = new ProjectDTO();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Projects/single/{MKeyEnc}?ProjCloudId={ProjCloudId}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<ProjectDTO>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invio record Proj x upsert
|
||||
/// <param name="rec2send">record da inviare</param>
|
||||
/// </summary>
|
||||
/// <returns>ProjCloudId (essitente o nuovo)</returns>
|
||||
public int ProjectSend(ProjectDTO rec2send)
|
||||
{
|
||||
int answ = 0;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Projects newPayload = new RestPayload.Projects()
|
||||
{
|
||||
Project = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Projects/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = client.Post(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
int.TryParse(response.Content, out answ);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"ProjectSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione async Invio elenco di RawItems associati ad un singolo materiale, il server
|
||||
/// farà il merge <param name="rec2send">record da inviare</param>
|
||||
/// </summary>
|
||||
public async Task<int> ProjectSendAsync(ProjectDTO rec2send)
|
||||
{
|
||||
int answ = 0;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Projects newPayload = new RestPayload.Projects()
|
||||
{
|
||||
Project = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Projects/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
int.TryParse(response.Content, out answ);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"ProjectSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco risorse associate a progetto
|
||||
/// </summary>
|
||||
/// <param name="projDbId">ID DB del progetto</param>
|
||||
/// <param name="isEstim">true = solo stimate/ false = consumi reali</param>
|
||||
/// <returns></returns>
|
||||
public List<ResourceExpDTO> ResourceGet(int projDbId, bool isEstim)
|
||||
{
|
||||
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim={isEstim}", Method.Get);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione async Elenco risorse associate a progetto
|
||||
/// </summary>
|
||||
/// <param name="projDbId">ID DB del progetto</param>
|
||||
/// <param name="isEstim">true = solo stimate/ false = consumi reali</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ResourceExpDTO>> ResourceGetAsync(int projDbId, bool isEstim)
|
||||
{
|
||||
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim={isEstim}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invio elenco di risorse associate ad un progetto
|
||||
/// </summary>
|
||||
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
|
||||
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
|
||||
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
|
||||
/// <returns></returns>
|
||||
public bool ResourceSend(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Resources newPayload = new RestPayload.Resources()
|
||||
{
|
||||
ProjCloudId = idxProjDbId,
|
||||
ReqState = recType,
|
||||
ResourceList = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Resources/track/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = client.Post(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"ResourceSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Versione async Invio elenco di risorse associate ad un progetto
|
||||
/// </summary>
|
||||
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
|
||||
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
|
||||
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ResourceSendAsync(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
using (RestClient client = new RestClient(rcOptions))
|
||||
{
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
// impacchetto dati x invio...
|
||||
RestPayload.Resources newPayload = new RestPayload.Resources()
|
||||
{
|
||||
ProjCloudId = idxProjDbId,
|
||||
ReqState = recType,
|
||||
ResourceList = rec2send
|
||||
};
|
||||
var jsonBody = JsonConvert.SerializeObject(newPayload);
|
||||
var request = new RestRequest($"Resources/track/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"ResourceSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// URL dell'API x chiamate gestione licenze
|
||||
/// </summary>
|
||||
private string apiUrl = $"";
|
||||
|
||||
private int callTimeout = 500;
|
||||
|
||||
/// <summary>
|
||||
/// Istanza logger
|
||||
/// </summary>
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Opzioni standard di chiamata
|
||||
/// </summary>
|
||||
private RestClientOptions rcOptions = new RestClientOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Token di chiamata per l'applicazione
|
||||
/// </summary>
|
||||
private string RestToken = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo server (URL con eventuale porta)
|
||||
/// </summary>
|
||||
private string servAddr = $"";
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1696D7A5-765A-4D25-8D29-CA7345023479}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>EgwProxy.MagMan</RootNamespace>
|
||||
<AssemblyName>EgwProxy.MagMan</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataSyncro.cs" />
|
||||
<Compile Include="DTO\AliasDTO.cs" />
|
||||
<Compile Include="DTO\ItemDTO.cs" />
|
||||
<Compile Include="DTO\MaterialDTO.cs" />
|
||||
<Compile Include="DTO\ProjectDTO.cs" />
|
||||
<Compile Include="DTO\ResourceDTO.cs" />
|
||||
<Compile Include="DTO\ResourceExpDTO.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RestPayload.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EgwProxy.MagMan
|
||||
{
|
||||
public enum BWType
|
||||
{
|
||||
NULL = 0,
|
||||
BEAM = 1,
|
||||
WALL = 2
|
||||
}
|
||||
public enum ProjResState
|
||||
{
|
||||
/// <summary>
|
||||
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
|
||||
/// </summary>
|
||||
Consumed = -1,
|
||||
/// <summary>
|
||||
/// Non definito
|
||||
/// </summary>
|
||||
ND = 0,
|
||||
/// <summary>
|
||||
/// Consumo stimato da nesting (solo simulazione)
|
||||
/// </summary>
|
||||
Estimated,
|
||||
/// <summary>
|
||||
/// Consumo confermato (da ordinare)
|
||||
/// </summary>
|
||||
Confirmed,
|
||||
/// <summary>
|
||||
/// Riservato (utile x calcolo quantità da ordinare)
|
||||
/// </summary>
|
||||
Reserved
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
@@ -0,0 +1,83 @@
|
||||
using EgwProxy.MagMan.DTO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EgwProxy.MagMan
|
||||
{
|
||||
public class RestPayload
|
||||
{
|
||||
#region Public Classes
|
||||
|
||||
public class Alias
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco decodifica Alias Materiali x invio POST
|
||||
/// </summary>
|
||||
public List<AliasDTO> AliasList { get; set; } = new List<AliasDTO>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Items
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Items x invio POST
|
||||
/// </summary>
|
||||
public List<ItemDTO> ItemList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Materials
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco materiali x invio POST
|
||||
/// </summary>
|
||||
public List<MaterialDTO> MatList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Projects
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public ProjectDTO Project { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Resources
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// ID progetto univoco su Cloud
|
||||
/// </summary>
|
||||
public int ProjCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di registrazione dato inviata (previsione consumo, consumo effettivo...)
|
||||
/// </summary>
|
||||
public ProjResState ReqState { get; set; } = ProjResState.ND;
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Risorse x invio POST
|
||||
/// </summary>
|
||||
public List<ResourceDTO> ResourceList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-110.1.0.0" newVersion="110.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.3" newVersion="7.0.0.3" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="NLog" version="5.0.1" targetFramework="net472" />
|
||||
<package id="RestSharp" version="110.2.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="7.0.3" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core
|
||||
{
|
||||
//// <Auto-Generated>
|
||||
//// This is here so CodeMaid doesn't reorganize this document
|
||||
//// </Auto-Generated>
|
||||
public class Const
|
||||
{
|
||||
// dati conf REDIS Cache
|
||||
public static readonly string BASE_PATH = Directory.GetCurrentDirectory();
|
||||
|
||||
public const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9";
|
||||
|
||||
// classi utilità x cache REDIS dati DB
|
||||
public const string redisBaseAddr = "MagManUi";
|
||||
public const string rKeyConfig = $"{redisBaseAddr}:Cache";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
public class AliasDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Codice originale (da trasformare)
|
||||
/// </summary>
|
||||
public string ValOrig { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice Alias in cui viene convertito
|
||||
/// </summary>
|
||||
public string ValAlias { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ItemDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Ext Ref Key Materiale (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext Ref Key Materiale (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int MatLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key del RawItem di riferimento (se zero da verificare con quote) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
/// </summary>
|
||||
public bool IsRemn { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Location
|
||||
/// </summary>
|
||||
public string Location { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Qty available on wharehouse
|
||||
/// </summary>
|
||||
public int QtyAvail { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Thikness
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Lenght
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Width
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Note (optional)
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice QR/Matrix Item
|
||||
/// </summary>
|
||||
public string ItemDtmx { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class MaterialDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key Materiale (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key Materiale (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int MatLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice Materiale
|
||||
/// </summary>
|
||||
public string MatCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione materiale
|
||||
/// </summary>
|
||||
public string MatDesc { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Thikness/Spessore in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Lenght/Lunghezza in mm
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Width/Larghezza in mm
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Varianti dimensionali disponibili
|
||||
/// </summary>
|
||||
public int SizeNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Quantità totale in giacenza
|
||||
/// </summary>
|
||||
public int QtyTot { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice materiale x QR/Datamatrix
|
||||
/// </summary>
|
||||
public string MatDtmx { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Beam, quando L == 0
|
||||
/// </summary>
|
||||
public bool IsBeam { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Wall, quando W/L == 0
|
||||
/// </summary>
|
||||
public bool IsWall { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Elenco item e giancenze
|
||||
/// </summary>
|
||||
public List<ItemDTO>? ItemList { get; set; } = new List<ItemDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using static MagMan.Core.Enums;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ProjectDTO
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Key progetto (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int ProjCloudId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ID del DB EgtBW, univoco con KeyNum, (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int ProjLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID esterno (da EgtBW)
|
||||
/// </summary>
|
||||
public int ProjExtId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione progetto (copiata da BTLFileName inizialmente)
|
||||
/// </summary>
|
||||
public string ProjDescription { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome file BTL originale
|
||||
/// </summary>
|
||||
public string BTLFileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data Creazione progetto
|
||||
/// </summary>
|
||||
public DateTime DtCreated { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Data ora ultima operazione registrata
|
||||
/// </summary>
|
||||
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Data di schedulazione (prevista)
|
||||
/// </summary>
|
||||
public DateTime DtSchedule { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Data Inizio Produzione
|
||||
/// </summary>
|
||||
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == cancellazione logica)
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
|
||||
/// </summary>
|
||||
public bool IsArchived { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ListName del BTL
|
||||
/// </summary>
|
||||
public string ListName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Macchina (Costruttore/Modello)
|
||||
/// </summary>
|
||||
public string Machine { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (MagMan) DB / CLOUD
|
||||
/// </summary>
|
||||
public int MachineCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione previsto (stima) in minuti
|
||||
/// </summary>
|
||||
public double ProcTimeEst { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
|
||||
/// </summary>
|
||||
public double ProcTimeReal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia del progetto (Travi, Pareti, ...)
|
||||
/// </summary>
|
||||
public BWType PType { get; set; } = BWType.NULL;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ResourceDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public class ResourceExpDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// ID risorsa (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int ResourceCloudId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento richiesta parent
|
||||
/// </summary>
|
||||
public int RequestId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref for Material (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int MatCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref for Material (DB) / CLOUD
|
||||
/// </summary>
|
||||
public int RawItemCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key RawItem (DB) / istanza locale
|
||||
/// </summary>
|
||||
public int RawItemLocalId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
/// </summary>
|
||||
public bool IsRemn { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Height (Thikness/Spessore) in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Lenght
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Width
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Note (optional)
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data richiesta
|
||||
/// </summary>
|
||||
public DateTime DtRequest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Richiesta attiva (se false == NON è il piano scelto per i casi "previsionali" = ReqState >0 )
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
+47
-2
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
|
||||
/// </summary>
|
||||
Consumed = -1,
|
||||
/// <summary>
|
||||
/// Non definito
|
||||
/// </summary>
|
||||
ND = 0,
|
||||
/// <summary>
|
||||
/// Consumo stimato da nesting (solo simulazione)
|
||||
/// </summary>
|
||||
Estimated,
|
||||
/// <summary>
|
||||
/// Consumo confermato (da ordinare)
|
||||
/// </summary>
|
||||
Confirmed,
|
||||
/// <summary>
|
||||
/// Riservato (utile x calcolo quantità da ordinare)
|
||||
/// </summary>
|
||||
Reserved
|
||||
}
|
||||
|
||||
public enum ResultTypes
|
||||
{
|
||||
NULL = 0,
|
||||
EXECUTED = 1,
|
||||
RESULT = 2
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Enums
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@@ -6,4 +6,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core
|
||||
{
|
||||
public class MailKitMailData
|
||||
{
|
||||
// Receiver
|
||||
public List<string> To { get; set; } = new List<string>();
|
||||
public List<string> Bcc { get; set; } = new List<string>();
|
||||
|
||||
public List<string> Cc { get; set; } = new List<string>();
|
||||
|
||||
// Sender
|
||||
public string? From { get; set; }
|
||||
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
public string? ReplyTo { get; set; }
|
||||
|
||||
public string? ReplyToName { get; set; }
|
||||
|
||||
// Content
|
||||
public string Subject { get; set; } = "";
|
||||
|
||||
public string? Body { get; set; }
|
||||
|
||||
//// Attach (opzionale)
|
||||
//public IFormFileCollection? Attachments { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core
|
||||
{
|
||||
public class MailKitMailSettings
|
||||
{
|
||||
public string? DisplayName { get; set; }
|
||||
public string? From { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public string? Host { get; set; }
|
||||
public int Port { get; set; }
|
||||
public bool UseSSL { get; set; }
|
||||
public bool UseStartTls { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MagMan.Core.DTO;
|
||||
using static MagMan.Core.Enums;
|
||||
|
||||
namespace MagMan.Core
|
||||
{
|
||||
public class RestPayload
|
||||
{
|
||||
#region Public Classes
|
||||
|
||||
public class Alias
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco decodifica Alias Materiali x invio POST
|
||||
/// </summary>
|
||||
public List<AliasDTO> AliasList { get; set; } = new List<AliasDTO>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Items
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Items x invio POST
|
||||
/// </summary>
|
||||
public List<ItemDTO>? ItemList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Materials
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Elenco materiali x invio POST
|
||||
/// </summary>
|
||||
public List<MaterialDTO>? MatList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Projects
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public ProjectDTO? Project { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Resources
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// ID progetto univoco su cloud
|
||||
/// </summary>
|
||||
public int ProjCloudId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di registrazione dato inviata (previsione consumo, consumo effettivo...)
|
||||
/// </summary>
|
||||
public ProjResState ReqState { get; set; } = ProjResState.ND;
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Risorse x invio POST
|
||||
/// </summary>
|
||||
public List<ResourceDTO>? ResourceList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core.Services
|
||||
{
|
||||
public interface IMailService
|
||||
{
|
||||
Task<bool> SendAsync(MailKitMailData mailData, CancellationToken ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using NLog;
|
||||
using MagMan.Core;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione MailKit come descritto qui https://blog.christian-schou.dk/send-emails-with-asp-net-core-with-mailkit/
|
||||
/// </summary>
|
||||
public partial class MailService : IMailService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailService(IOptions<MailKitMailSettings> settings)
|
||||
{
|
||||
_settings = settings.Value;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<bool> SendAsync(MailKitMailData mailData, CancellationToken ct = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Initialize a new instance of the MimeKit.MimeMessage class
|
||||
var mail = new MimeMessage();
|
||||
|
||||
#region Sender / Receiver
|
||||
|
||||
// Sender
|
||||
mail.From.Add(new MailboxAddress(_settings.DisplayName, mailData.From ?? _settings.From));
|
||||
mail.Sender = new MailboxAddress(mailData.DisplayName ?? _settings.DisplayName, mailData.From ?? _settings.From);
|
||||
|
||||
// Receiver
|
||||
foreach (string mailAddress in mailData.To)
|
||||
mail.To.Add(MailboxAddress.Parse(mailAddress));
|
||||
|
||||
// Set Reply to if specified in mail data
|
||||
if (!string.IsNullOrEmpty(mailData.ReplyTo))
|
||||
mail.ReplyTo.Add(new MailboxAddress(mailData.ReplyToName, mailData.ReplyTo));
|
||||
|
||||
// BCC Check if a BCC was supplied in the request
|
||||
if (mailData.Bcc != null)
|
||||
{
|
||||
// Get only addresses where value is not null or with whitespace. x = value of address
|
||||
foreach (string mailAddress in mailData.Bcc.Where(x => !string.IsNullOrWhiteSpace(x)))
|
||||
mail.Bcc.Add(MailboxAddress.Parse(mailAddress.Trim()));
|
||||
}
|
||||
|
||||
// CC Check if a CC address was supplied in the request
|
||||
if (mailData.Cc != null)
|
||||
{
|
||||
foreach (string mailAddress in mailData.Cc.Where(x => !string.IsNullOrWhiteSpace(x)))
|
||||
mail.Cc.Add(MailboxAddress.Parse(mailAddress.Trim()));
|
||||
}
|
||||
|
||||
#endregion Sender / Receiver
|
||||
|
||||
#region Content
|
||||
|
||||
// Add Content to Mime Message
|
||||
var body = new BodyBuilder();
|
||||
mail.Subject = mailData.Subject;
|
||||
body.HtmlBody = mailData.Body;
|
||||
mail.Body = body.ToMessageBody();
|
||||
|
||||
//// Check if we got any attachments and add the to the builder for our message
|
||||
//if (mailData.Attachments != null)
|
||||
//{
|
||||
// byte[] attachmentFileByteArray;
|
||||
|
||||
// foreach (IFormFile attachment in mailData.Attachments)
|
||||
// {
|
||||
// // Check if length of the file in bytes is larger than 0
|
||||
// if (attachment.Length > 0)
|
||||
// {
|
||||
// // Create a new memory stream and attach attachment to mail body
|
||||
// using (MemoryStream memoryStream = new MemoryStream())
|
||||
// {
|
||||
// // Copy the attachment to the stream
|
||||
// attachment.CopyTo(memoryStream);
|
||||
// attachmentFileByteArray = memoryStream.ToArray();
|
||||
// }
|
||||
// // Add the attachment from the byte array
|
||||
// body.Attachments.Add(attachment.FileName, attachmentFileByteArray, ContentType.Parse(attachment.ContentType));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion Content
|
||||
|
||||
#region Send Mail
|
||||
|
||||
using var smtp = new SmtpClient();
|
||||
|
||||
if (_settings.UseSSL)
|
||||
{
|
||||
await smtp.ConnectAsync(_settings.Host, _settings.Port, SecureSocketOptions.SslOnConnect, ct);
|
||||
}
|
||||
else if (_settings.UseStartTls)
|
||||
{
|
||||
await smtp.ConnectAsync(_settings.Host, _settings.Port, SecureSocketOptions.StartTls, ct);
|
||||
}
|
||||
await smtp.AuthenticateAsync(_settings.UserName, _settings.Password, ct);
|
||||
await smtp.SendAsync(mail, ct);
|
||||
await smtp.DisconnectAsync(true, ct);
|
||||
|
||||
#endregion Send Mail
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in SendAsync{Environment.NewLine}{exc}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly MailKitMailSettings _settings;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,673 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
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!;
|
||||
public event Action EA_CustomerSel = null!;
|
||||
public event Action EA_KeySel = null!;
|
||||
public event Action<bool> EA_ShowCustomers = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string UserName { get; set; } = "NA";
|
||||
|
||||
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 int CustomerID
|
||||
{
|
||||
get => _customerID;
|
||||
set
|
||||
{
|
||||
if (_customerID != value)
|
||||
{
|
||||
_customerID = value;
|
||||
if (EA_CustomerSel != null)
|
||||
{
|
||||
EA_CustomerSel?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int KeyNum
|
||||
{
|
||||
get => _keyNum;
|
||||
set
|
||||
{
|
||||
if (_keyNum != value)
|
||||
{
|
||||
_keyNum = value;
|
||||
if (EA_KeySel != null)
|
||||
{
|
||||
EA_KeySel?.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowCustomers
|
||||
{
|
||||
get => _showCustomers;
|
||||
set
|
||||
{
|
||||
_showCustomers = value;
|
||||
if (EA_ShowCustomers != null)
|
||||
{
|
||||
EA_ShowCustomers?.Invoke(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cliente selezionato (da browser data cache)
|
||||
/// </summary>
|
||||
public async Task<int> ClientIdGet()
|
||||
{
|
||||
var answ = await localStore.GetItemAsync<int>("ClientID");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta Cliente selezionato (browser data cache)
|
||||
/// </summary>
|
||||
public async Task ClientIdSet(int newVal)
|
||||
{
|
||||
await localStore.SetItemAsync("ClientID", newVal);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// KeyNum da cliente selezionato (da browser data cache)
|
||||
/// </summary>
|
||||
public async Task<int> KeyNumGet()
|
||||
{
|
||||
var answ = await localStore.GetItemAsync<int>("KeyNum");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta KeyNum da cliente selezionato (browser data cache)
|
||||
/// </summary>
|
||||
public async Task KeyNumSet(int newVal)
|
||||
{
|
||||
await localStore.SetItemAsync("KeyNum", newVal);
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> CustomerIdByToken(string RestToken)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Token2CustID";
|
||||
int answ = await RedisHashGetInt(currKey, RestToken);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// salvataggio in dizionario Redis associativo Token / Customer
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <param name="CustId"></param>
|
||||
/// <returns></returns>
|
||||
public bool CustomerIdByTokenSet(string RestToken, int CustId)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Token2CustID";
|
||||
bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="CustID"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> MainKeyByCustomer(int CustID)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Cust2MKey";
|
||||
int answ = await RedisHashGetInt(currKey, $"{CustID}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// salvataggio in dizionario Redis associativo Token / Customer
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <param name="CustId"></param>
|
||||
/// <returns></returns>
|
||||
public bool MainKeyByCustomerSet(int CustId, int MainKey)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Cust2MKey";
|
||||
bool fatto = RedisHashSet(currKey, $"{CustId}", $"{MainKey}");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera MainKey dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> MainKeyByToken(string RestToken)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Token2MKey";
|
||||
int answ = await RedisHashGetInt(currKey, RestToken);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// salvataggio in dizionario Redis associativo Token / Customer
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <param name="CustId"></param>
|
||||
/// <returns></returns>
|
||||
public bool MainKeyByTokenSet(string RestToken, int CustId)
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Mserv:Dict:Token2MKey";
|
||||
bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Redis Key for Hashlist</param>
|
||||
/// <param name="chiave">Requested key on list</param>
|
||||
/// <returns>Value as Int</returns>
|
||||
public async Task<int> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Redis Key for Hashlist</param>
|
||||
/// <param name="chiave">Requested key on list</param>
|
||||
/// <returns>Value as string</returns>
|
||||
public async Task<string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove for single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Chiave redis della Hashlist</param>
|
||||
/// <param name="chiave">Chiave nella HashList</param>
|
||||
/// <returns>Esito rimozione</returns>
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resetta 1:1 i dizionari Hash in Redis
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ResetHashDict()
|
||||
{
|
||||
bool fatto = false;
|
||||
string baseKey = $"{Const.rKeyConfig}:Mserv:Dict";
|
||||
try
|
||||
{
|
||||
// salvo!
|
||||
RedisHashDictSet($"{baseKey}:Token2CustID", new Dictionary<string, string>());
|
||||
RedisHashDictSet($"{baseKey}:Token2MKey", new Dictionary<string, string>());
|
||||
RedisHashDictSet($"{baseKey}:Cust2MKey", new Dictionary<string, string>());
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ResetHashDict{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Svuota localstorage (clear)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreLocalClear()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await localStore.ClearAsync();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore richiesto da localstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> StoreLocalGet(string sKey)
|
||||
{
|
||||
string answ = "";
|
||||
var result = await localStore.GetItemAsync<string>(sKey);
|
||||
if (result != null)
|
||||
{
|
||||
answ = result;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive il valore nel localstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <param name="sVal">Valore associato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Svuota sessionstorage (clear)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreSessClear()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await sessionStore.ClearAsync();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore richiesto da sessionstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> StoreSessGet(string sKey)
|
||||
{
|
||||
string answ = "";
|
||||
var result = await sessionStore.GetItemAsync<string>(sKey);
|
||||
if (result != null)
|
||||
{
|
||||
answ = result;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive il valore nel sessionstorage (tab)
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <param name="sVal">Valore associato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected IConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Effettua upsert in HasList redis
|
||||
/// </summary>
|
||||
/// <param name="currKey">Chiave redis della Hashlist</param>
|
||||
/// <param name="chiave">Chiave nella HashList</param>
|
||||
/// <param name="valore">Valore da salvare</param>
|
||||
/// <returns>Num record nella HashList</returns>
|
||||
protected async Task<long> 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 int _customerID = -1;
|
||||
private int _keyNum = -1;
|
||||
private bool _showSearch = false;
|
||||
private bool _showCustomers = true;
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero HashSet redis come Dictionary
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
private Dictionary<string, string> RedisHashDictGet(RedisKey currKey)
|
||||
{
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
private bool RedisHashDictSet(RedisKey currKey, Dictionary<string, string> dict)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
/// <param name="ttl"></param>
|
||||
private bool RedisHashDictSet(RedisKey currKey, Dictionary<string, string> dict, TimeSpan ttl)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta KVP in HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
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
|
||||
/// <summary>
|
||||
/// Dizionario totale preferenze utente
|
||||
/// </summary>
|
||||
public Dictionary<string, string> UsersPrefDict
|
||||
{
|
||||
get => RedisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}");
|
||||
set => RedisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace MagMan.Data.Admin.Controllers
|
||||
{
|
||||
public class MTAdminController : IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MTAdminController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elimina item AuthKey
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool AuthKeyDelete(AuthKeyModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetAuthKey
|
||||
.Where(x => x.AuthKeyID == updItem.AuthKeyID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetAuthKey
|
||||
.Remove(currData);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AuthKeyDelete{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco AuthKey dato Customer
|
||||
/// </summary>
|
||||
/// <param name="CustomerId">0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<AuthKeyModel> AuthKeyByCustId(int CustomerId)
|
||||
{
|
||||
List<AuthKeyModel> dbResult = new List<AuthKeyModel>();
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAuthKey
|
||||
.Where(x => CustomerId == 0 || x.CustomerID == CustomerId)
|
||||
.Include(c => c.CustomerNav)
|
||||
.OrderBy(x => x.KeyNum)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un item AuthKey
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool AuthKeyUpdate(AuthKeyModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetAuthKey
|
||||
.Where(x => x.AuthKeyID == updItem.AuthKeyID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.KeyNum = updItem.KeyNum;
|
||||
currData.KeyValue = updItem.KeyValue;
|
||||
currData.Note = updItem.Note;
|
||||
currData.CustomerID = updItem.CustomerID;
|
||||
currData.IsActive = updItem.IsActive;
|
||||
currData.DtActivation = updItem.DtActivation;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetAuthKey
|
||||
.Add(updItem);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AuthKeyUpdate{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elimina item Customer
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool CustomerDelete(CustomerModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetCustomers
|
||||
.Where(x => x.CustomerID == updItem.CustomerID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetCustomers
|
||||
.Remove(currData);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in CustomerDelete{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco clienti
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<CustomerModel> CustomerGetAll()
|
||||
{
|
||||
List<CustomerModel> dbResult = new List<CustomerModel>();
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetCustomers
|
||||
.Select(s => new CustomerModel
|
||||
{
|
||||
CustomerID = s.CustomerID,
|
||||
DtActivation = s.DtActivation,
|
||||
IsActive = s.IsActive,
|
||||
RestToken = s.RestToken,
|
||||
Name = s.Name,
|
||||
Note = s.Note,
|
||||
MainKey = s.MainKey,
|
||||
HasDb = s.HasDb,
|
||||
HasChildren = s.MachineNav.Any()
|
||||
})
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un item Customer
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool CustomerUpdate(CustomerModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetCustomers
|
||||
.Where(x => x.CustomerID == updItem.CustomerID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Name = updItem.Name;
|
||||
currData.Note = updItem.Note;
|
||||
currData.IsActive = updItem.IsActive;
|
||||
currData.DtActivation = updItem.DtActivation;
|
||||
currData.RestToken = updItem.RestToken;
|
||||
currData.MainKey = updItem.MainKey;
|
||||
currData.HasDb = updItem.HasDb;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetCustomers
|
||||
.Add(updItem);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in CustomerUpdate{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
Log.Info("Dispose di MultiTenantController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina item Machine
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachineDelete(MachineModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetMachines
|
||||
.Where(x => x.MachineID == updItem.MachineID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetMachines
|
||||
.Remove(currData);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in MachineDelete{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Machine dato Customer
|
||||
/// </summary>
|
||||
/// <param name="CustomerId">0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<MachineModel> MachineGetByCustId(int CustomerId)
|
||||
{
|
||||
List<MachineModel> dbResult = new List<MachineModel>();
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMachines
|
||||
.Where(x => CustomerId == 0 || x.CustomerID == CustomerId)
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un item Machine
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachineUpdate(MachineModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetMachines
|
||||
.Where(x => x.MachineID == updItem.MachineID)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Name = updItem.Name;
|
||||
currData.Note = updItem.Note;
|
||||
currData.CustomerID = updItem.CustomerID;
|
||||
currData.IsActive = updItem.IsActive;
|
||||
currData.DtActivation = updItem.DtActivation;
|
||||
currData.MainKey = updItem.MainKey;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetMachines
|
||||
.Add(updItem);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in MachineUpdate{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe amministrazione Db principale:
|
||||
/// - creazione utenti sul Server MySql
|
||||
/// - gestione DB/Tabele x identity & gestione multi-tenant
|
||||
/// </summary>
|
||||
public class DbAdmin : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
@@ -24,10 +32,10 @@ namespace MagMan.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static bool checkCreateUser(string username, string pwd)
|
||||
public static bool CheckCreateUser(string username, string pwd, string dbName)
|
||||
{
|
||||
bool answ = false;
|
||||
using (AdminContext adbCtx = new AdminContext())
|
||||
using (ServerAdminContext adbCtx = new ServerAdminContext())
|
||||
{
|
||||
// ricerca utente...
|
||||
var numUser = adbCtx
|
||||
@@ -55,21 +63,49 @@ namespace MagMan.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static async Task<bool> migrateDbIdentity()
|
||||
public static bool CheckCreateCustDb(int nKeyMain)
|
||||
{
|
||||
bool answ = false;
|
||||
using (UserIdentityDbContext dbCtx = new UserIdentityDbContext())
|
||||
string dbName = $"MagMan_{nKeyMain:000000}";
|
||||
using (ServerAdminContext adbCtx = new ServerAdminContext())
|
||||
{
|
||||
// ricerca DB...
|
||||
string sqlCommand = $"SHOW DATABASES;";
|
||||
var searchDb = adbCtx
|
||||
.DbList
|
||||
.FromSqlRaw(sqlCommand)
|
||||
.ToList();
|
||||
// se trovato qualcosa procedo
|
||||
if (searchDb != null)
|
||||
{
|
||||
var rigaDb = searchDb.Where(x => x.Database.Contains(dbName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
|
||||
answ = rigaDb != null;
|
||||
}
|
||||
// altrimenti crea
|
||||
if (!answ)
|
||||
{
|
||||
// creo DB
|
||||
sqlCommand = $"CREATE DATABASE IF NOT EXISTS {dbName};";
|
||||
adbCtx.Database.ExecuteSqlRaw(sqlCommand);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static async Task<bool> MigrateDbIdentity()
|
||||
{
|
||||
bool answ = false;
|
||||
using (IdentityContext dbCtx = new IdentityContext())
|
||||
{
|
||||
await dbCtx.Database.MigrateAsync();
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static async Task<bool> migrateDbMain()
|
||||
public static async Task<bool> MigrateDbMultiTenant()
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext())
|
||||
using (MultiTenantContext dbCtx = new MultiTenantContext())
|
||||
{
|
||||
await dbCtx.Database.MigrateAsync();
|
||||
answ = true;
|
||||
@@ -77,18 +113,6 @@ namespace MagMan.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static bool resetPlantLogTable()
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext())
|
||||
{
|
||||
string sqlCommand = "TRUNCATE TABLE PlantLog;";
|
||||
dbCtx.Database.ExecuteSqlRaw(sqlCommand);
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
@@ -5,21 +5,17 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public static class DbConfig
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public static string DATABASE_NAME = "MagMan";
|
||||
|
||||
public static string DATABASE_NAME = "MagMan_Admin";
|
||||
public static int DATABASE_PROCESS_TIMEOUT = 5;
|
||||
public static string DATABASE_PWD = "viadante16";
|
||||
|
||||
// Database config
|
||||
public static string DATABASE_PWD = "viad@nte16!";
|
||||
public static string DATABASE_SERV = "127.0.0.1";
|
||||
|
||||
public static string DATABASE_USER = "MagMan_User";
|
||||
public static string DATABASE_USER = "MagMan_DbUser";
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
@@ -39,37 +35,41 @@ namespace MagMan.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static bool CheckCustDb(int masterKey)
|
||||
{
|
||||
// esecuzione script di install locale
|
||||
return DbAdmin.CheckCreateCustDb(masterKey);
|
||||
}
|
||||
|
||||
public static bool CheckUser(string nKey, string sKey)
|
||||
{
|
||||
// esecuzione script di install locale
|
||||
return DbAdmin.checkCreateUser(DATABASE_USER, DATABASE_PWD);
|
||||
return DbAdmin.CheckCreateUser(DATABASE_USER, DATABASE_PWD, DATABASE_NAME);
|
||||
}
|
||||
|
||||
public static bool ExecMigrationIdentity()
|
||||
{
|
||||
// esecuzione migrazione
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbIdentity());
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.MigrateDbIdentity());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
public static bool ExecMigrationMain()
|
||||
public static bool ExecMigrationMultiTenant()
|
||||
{
|
||||
// esecuzione migrazione
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain());
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.MigrateDbMultiTenant());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
public static void InitDb(string server, string nKey, string sKey)
|
||||
public static void InitDb(string server)
|
||||
{
|
||||
DATABASE_SERV = server;
|
||||
DATABASE_NAME = $"MagMan_{nKey}";
|
||||
DATABASE_USER = $"user_{nKey}";
|
||||
DATABASE_PWD = $"pwd_{sKey}";
|
||||
CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
|
||||
// stringa admin con utente root egalware...
|
||||
ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=MagMan_pwd;sslmode=None";
|
||||
// tutto fisso x gestione utenti
|
||||
CONNECTION_STRING = $"Server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None;";
|
||||
// stringa admin con utente admin dell'applicazione (già creato)...
|
||||
ADMIN_CONNECTION_STRING = $"Server={DATABASE_SERV};port=3306;database=mysql;uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None;";
|
||||
}
|
||||
|
||||
public static ServerVersion MysqlServerVersion(string connString)
|
||||
@@ -0,0 +1,59 @@
|
||||
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.Admin.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("AuthKeyList")]
|
||||
public partial class AuthKeyModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key AUTO
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int AuthKeyID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref Customers
|
||||
/// </summary>
|
||||
public int CustomerID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Numero chiave
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Nome
|
||||
/// </summary>
|
||||
public string KeyValue { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Note/Descrizione
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Check attivo
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// DateTime Attivazione
|
||||
/// </summary>
|
||||
public DateTime DtActivation { get; set; } = DateTime.Today;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property to Customer
|
||||
/// </summary>
|
||||
[ForeignKey("CustomerID")]
|
||||
public virtual CustomerModel CustomerNav { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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.Admin.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("CustomerList")]
|
||||
public partial class CustomerModel
|
||||
{
|
||||
public CustomerModel()
|
||||
{
|
||||
MachineNav = new HashSet<MachineModel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key AUTO
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int CustomerID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Nome
|
||||
/// </summary>
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Note/Descrizione
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Check attivo
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// DateTime Attivazione
|
||||
/// </summary>
|
||||
public DateTime DtActivation { get; set; } = DateTime.Today;
|
||||
|
||||
/// <summary>
|
||||
/// Token autorizzazione x comunicazione REST
|
||||
/// </summary>
|
||||
public string RestToken { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Chiave principale (primo impianto) per creazione DB
|
||||
/// </summary>
|
||||
public int MainKey { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean di creazione DB
|
||||
/// </summary>
|
||||
public bool HasDb { get; set; } = false;
|
||||
|
||||
[NotMapped]
|
||||
public bool HasChildren { get; set; } = false;
|
||||
|
||||
[NotMapped]
|
||||
public virtual ICollection<MachineModel> MachineNav { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dei Database di MySql
|
||||
/// </summary>
|
||||
[Table("Database"), Keyless]
|
||||
public class DbModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Column("Database", Order = 1)]
|
||||
public string Database { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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.Admin.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("MachineList")]
|
||||
public partial class MachineModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key AUTO
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int MachineID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref Customers
|
||||
/// </summary>
|
||||
public int CustomerID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Nome
|
||||
/// </summary>
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Note/Descrizione
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Check attivo
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// DateTime Attivazione
|
||||
/// </summary>
|
||||
public DateTime DtActivation { get; set; } = DateTime.Today;
|
||||
|
||||
/// <summary>
|
||||
/// Chiave principale (impianto) associata
|
||||
/// </summary>
|
||||
public int MainKey { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property to Customer
|
||||
/// </summary>
|
||||
[ForeignKey("CustomerID")]
|
||||
public virtual CustomerModel CustomerNav { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe fake x il conteggio tabelle e check preliminari
|
||||
/// </summary>
|
||||
[Keyless]
|
||||
public class TableCount
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public int Count { get; set; } = 0;
|
||||
public string TableName { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Admin.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dei USER di MySql
|
||||
@@ -0,0 +1,57 @@
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class IdentityContext : IdentityDbContext
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public IdentityContext()
|
||||
{
|
||||
}
|
||||
|
||||
public IdentityContext(DbContextOptions<IdentityContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<TableCount> DbSetCounts { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connString = DbConfig.CONNECTION_STRING;
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
// Gestione in blocco user/permessi di base (salvata con migrazione AddUserAndRoles) come in GWMS + https://stackoverflow.com/questions/34343599/how-to-seed-users-and-roles-with-code-first-migration-using-identity-asp-net-cor
|
||||
|
||||
builder.Seed();
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@@ -7,13 +7,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="DTO\" />
|
||||
<Folder Include="Services\" />
|
||||
<Compile Remove="Migrations\UserIdentityDb\20240110191326_AddAdminUsers.Designer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MailKit" Version="4.3.0" />
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
@@ -28,11 +32,8 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,125 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
[Migration("20240111160917_MultiTenantInitDb")]
|
||||
partial class MultiTenantInitDb
|
||||
{
|
||||
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.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("KeyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
public partial class MultiTenantInitDb : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CustomerList",
|
||||
columns: table => new
|
||||
{
|
||||
CustomerID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
DtActivation = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CustomerList", x => x.CustomerID);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AuthKeyList",
|
||||
columns: table => new
|
||||
{
|
||||
MachineID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
CustomerID = table.Column<int>(type: "int", nullable: false),
|
||||
KeyName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
KeyValue = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AuthKeyList", x => x.MachineID);
|
||||
table.ForeignKey(
|
||||
name: "FK_AuthKeyList_CustomerList_CustomerID",
|
||||
column: x => x.CustomerID,
|
||||
principalTable: "CustomerList",
|
||||
principalColumn: "CustomerID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MachineList",
|
||||
columns: table => new
|
||||
{
|
||||
MachineID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
CustomerID = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MachineList", x => x.MachineID);
|
||||
table.ForeignKey(
|
||||
name: "FK_MachineList_CustomerList_CustomerID",
|
||||
column: x => x.CustomerID,
|
||||
principalTable: "CustomerList",
|
||||
principalColumn: "CustomerID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AuthKeyList_CustomerID",
|
||||
table: "AuthKeyList",
|
||||
column: "CustomerID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MachineList_CustomerID",
|
||||
table: "MachineList",
|
||||
column: "CustomerID");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AuthKeyList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MachineList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CustomerList");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
[Migration("20240112104822_UpdateMachineModel")]
|
||||
partial class UpdateMachineModel
|
||||
{
|
||||
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.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("KeyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
public partial class UpdateMachineModel : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DtActivation",
|
||||
table: "MachineList",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsActive",
|
||||
table: "MachineList",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DtActivation",
|
||||
table: "MachineList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsActive",
|
||||
table: "MachineList");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
[Migration("20240112134116_UpdateKeyModel")]
|
||||
partial class UpdateKeyModel
|
||||
{
|
||||
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.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("AuthKeyID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("KeyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("AuthKeyID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
public partial class UpdateKeyModel : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "MachineID",
|
||||
table: "AuthKeyList",
|
||||
newName: "AuthKeyID");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DtActivation",
|
||||
table: "AuthKeyList",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsActive",
|
||||
table: "AuthKeyList",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DtActivation",
|
||||
table: "AuthKeyList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsActive",
|
||||
table: "AuthKeyList");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "AuthKeyID",
|
||||
table: "AuthKeyList",
|
||||
newName: "MachineID");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
[Migration("20240115132229_MachineKeyAndDb")]
|
||||
partial class MachineKeyAndDb
|
||||
{
|
||||
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.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("AuthKeyID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("AuthKeyID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("HasDb")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MainKey")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany("MachineNav")
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Navigation("MachineNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
public partial class MachineKeyAndDb : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "KeyName",
|
||||
table: "AuthKeyList");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasDb",
|
||||
table: "MachineList",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MainKey",
|
||||
table: "MachineList",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "KeyNum",
|
||||
table: "AuthKeyList",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasDb",
|
||||
table: "MachineList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MainKey",
|
||||
table: "MachineList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "KeyNum",
|
||||
table: "AuthKeyList");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "KeyName",
|
||||
table: "AuthKeyList",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
[Migration("20240116072852_AddCustomerRestToken01")]
|
||||
partial class AddCustomerRestToken01
|
||||
{
|
||||
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.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("AuthKeyID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("AuthKeyID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("HasDb")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MainKey")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("RestToken")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MainKey")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany("MachineNav")
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Navigation("MachineNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
public partial class AddCustomerRestToken01 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasDb",
|
||||
table: "MachineList");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasDb",
|
||||
table: "CustomerList",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MainKey",
|
||||
table: "CustomerList",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "RestToken",
|
||||
table: "CustomerList",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasDb",
|
||||
table: "CustomerList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MainKey",
|
||||
table: "CustomerList");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RestToken",
|
||||
table: "CustomerList");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasDb",
|
||||
table: "MachineList",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(MultiTenantContext))]
|
||||
partial class MultiTenantContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.Property<int>("AuthKeyID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("KeyValue")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("AuthKeyID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("AuthKeyList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Property<int>("CustomerID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("HasDb")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MainKey")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("RestToken")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("CustomerID");
|
||||
|
||||
b.ToTable("CustomerList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.Property<int>("MachineID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CustomerID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtActivation")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("MainKey")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MachineID");
|
||||
|
||||
b.HasIndex("CustomerID");
|
||||
|
||||
b.ToTable("MachineList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.AuthKeyModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.MachineModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Admin.DbModels.CustomerModel", "CustomerNav")
|
||||
.WithMany("MachineNav")
|
||||
.HasForeignKey("CustomerID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CustomerNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.CustomerModel", b =>
|
||||
{
|
||||
b.Navigation("MachineNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
@@ -8,9 +8,9 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
[Migration("20231222165912_CreateIdentitySchema")]
|
||||
partial class CreateIdentitySchema
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
+11
-11
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
public partial class CreateIdentitySchema : Migration
|
||||
{
|
||||
@@ -207,16 +207,16 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetRoles",
|
||||
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ "86a8f484-ca14-4e4d-a786-3eba35da6e06", "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb", "Admin", "ADMIN" },
|
||||
{ "ca44b425-5c7e-4812-a28a-047ec6aa2e68", "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6", "User", "USER" },
|
||||
{ "eebed9c1-7433-4716-a62f-df9829dc0f09", "4a1affe9-543f-4165-816a-2ed6d3f06c77", "Undef", "UNDEF" },
|
||||
{ "f5bd74e5-df26-4c52-963e-2d87e858c4d6", "1d620875-05b0-490d-91d5-6f21a83844f1", "SuperAdmin", "SUPERADMIN" }
|
||||
});
|
||||
//migrationBuilder.InsertData(
|
||||
// table: "AspNetRoles",
|
||||
// columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
||||
// values: new object[,]
|
||||
// {
|
||||
// { "86a8f484-ca14-4e4d-a786-3eba35da6e06", "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb", "Admin", "ADMIN" },
|
||||
// { "ca44b425-5c7e-4812-a28a-047ec6aa2e68", "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6", "User", "USER" },
|
||||
// { "eebed9c1-7433-4716-a62f-df9829dc0f09", "4a1affe9-543f-4165-816a-2ed6d3f06c77", "Undef", "UNDEF" },
|
||||
// { "f5bd74e5-df26-4c52-963e-2d87e858c4d6", "1d620875-05b0-490d-91d5-6f21a83844f1", "SuperAdmin", "SUPERADMIN" }
|
||||
// });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetRoleClaims_RoleId",
|
||||
+438
@@ -0,0 +1,438 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
[Migration("20240111134425_AddUserAndRoles")]
|
||||
partial class AddUserAndRoles
|
||||
{
|
||||
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.Admin.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("TableName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.ToTable("DbSetCounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "82b54f2b-4da8-4e46-83bf-57ffc17cf8ed",
|
||||
ConcurrencyStamp = "763dedf1-0868-424e-bc0a-1572a548c1d7",
|
||||
Name = "Undef",
|
||||
NormalizedName = "UNDEF"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "34ae910e-acaf-46d1-aaa8-279a74c5bc61",
|
||||
ConcurrencyStamp = "8b90b548-3d22-40c6-95ba-c3fb0ea032a7",
|
||||
Name = "User",
|
||||
NormalizedName = "USER"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1",
|
||||
ConcurrencyStamp = "63d84be1-17ac-4e8c-9bd7-35e0ed056533",
|
||||
Name = "Admin",
|
||||
NormalizedName = "ADMIN"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "285df363-706d-498e-b1ad-4680e141ad01",
|
||||
ConcurrencyStamp = "365f0dc5-81c1-4deb-945b-58dd8fc9d18a",
|
||||
Name = "SuperAdmin",
|
||||
NormalizedName = "SUPERADMIN"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "b23608ab-d50a-464d-8db2-8274f088b0ad",
|
||||
Email = "samuele.locatelli@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "SAMUELE.LOCATELLI@EGALWARE.COM",
|
||||
NormalizedUserName = "SAMUELE.LOCATELLI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEAQsxwpx5DzxcFhzIhUciCtBEHZo/GLlB4HtG49I3gTh/WtXSg9VVl0e5KBmopG9VQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "8f4ecdd7-9078-4345-82bc-7c1570e71387",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "samuele.locatelli@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "f62ab486-c4e0-450a-8fb4-6905d2e3da64",
|
||||
Email = "emmanuele.sassi@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "EMMANUELE.SASSI@EGALWARE.COM",
|
||||
NormalizedUserName = "EMMANUELE.SASSI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAECZ2BzJe3VOrXIgdmjBrD+JP/HqsV/eFwMO4DaGzAmFPvHG+xxkRFbwRkI2sYoWt8Q==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "1be739d4-3aed-4a9a-a5c0-80c45a1474a6",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "emmanuele.sassi@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "9c306ce8-ec94-49b9-ad24-87b3d9937188",
|
||||
Email = "luca.mazzoleni@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "LUCA.MAZZOLENI@EGALWARE.COM",
|
||||
NormalizedUserName = "LUCA.MAZZOLENI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEHdDRZVkzBW4qlCF+vvpURb/4bj/b2/kl4+HSEjhbHRAekqX5WMnfJfWMPuyjKrgUg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "121bb662-adf9-4cba-bbc8-12bf1d2bc693",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "luca.mazzoleni@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "20720e13-89b3-4660-8c6e-1f11e1e730b4",
|
||||
Email = "info@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "INFO@EGALWARE.COM",
|
||||
NormalizedUserName = "INFO@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEDEuPnbPPl/9vc6xg/mvOmyEfvirN5ZNDWu21im+PjvtNQcqvqfc9k3KQxtJKBs5EQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "3bd9e353-ab86-47b2-85da-d857e618f44e",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "info@egalware.com"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
public partial class AddUserAndRoles : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetUserTokens",
|
||||
type: "varchar(128)",
|
||||
maxLength: 128,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(255)")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserTokens",
|
||||
type: "varchar(128)",
|
||||
maxLength: 128,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(255)")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderKey",
|
||||
table: "AspNetUserLogins",
|
||||
type: "varchar(128)",
|
||||
maxLength: 128,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(255)")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserLogins",
|
||||
type: "varchar(128)",
|
||||
maxLength: 128,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(255)")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetRoles",
|
||||
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ "285df363-706d-498e-b1ad-4680e141ad01", "365f0dc5-81c1-4deb-945b-58dd8fc9d18a", "SuperAdmin", "SUPERADMIN" },
|
||||
{ "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "8b90b548-3d22-40c6-95ba-c3fb0ea032a7", "User", "USER" },
|
||||
{ "82b54f2b-4da8-4e46-83bf-57ffc17cf8ed", "763dedf1-0868-424e-bc0a-1572a548c1d7", "Undef", "UNDEF" },
|
||||
{ "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "63d84be1-17ac-4e8c-9bd7-35e0ed056533", "Admin", "ADMIN" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUsers",
|
||||
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ "238a34e8-7a80-4307-bfcc-41bdc4a39c1f", 0, "f62ab486-c4e0-450a-8fb4-6905d2e3da64", "emmanuele.sassi@egalware.com", true, false, null, "EMMANUELE.SASSI@EGALWARE.COM", "EMMANUELE.SASSI@EGALWARE.COM", "AQAAAAEAACcQAAAAECZ2BzJe3VOrXIgdmjBrD+JP/HqsV/eFwMO4DaGzAmFPvHG+xxkRFbwRkI2sYoWt8Q==", null, false, "1be739d4-3aed-4a9a-a5c0-80c45a1474a6", false, "emmanuele.sassi@egalware.com" },
|
||||
{ "3282b9f4-5240-4946-a8d0-5570df880642", 0, "20720e13-89b3-4660-8c6e-1f11e1e730b4", "info@egalware.com", true, false, null, "INFO@EGALWARE.COM", "INFO@EGALWARE.COM", "AQAAAAEAACcQAAAAEDEuPnbPPl/9vc6xg/mvOmyEfvirN5ZNDWu21im+PjvtNQcqvqfc9k3KQxtJKBs5EQ==", null, false, "3bd9e353-ab86-47b2-85da-d857e618f44e", false, "info@egalware.com" },
|
||||
{ "3fac0523-697f-4b42-ac39-82026839ba2c", 0, "b23608ab-d50a-464d-8db2-8274f088b0ad", "samuele.locatelli@egalware.com", true, false, null, "SAMUELE.LOCATELLI@EGALWARE.COM", "SAMUELE.LOCATELLI@EGALWARE.COM", "AQAAAAEAACcQAAAAEAQsxwpx5DzxcFhzIhUciCtBEHZo/GLlB4HtG49I3gTh/WtXSg9VVl0e5KBmopG9VQ==", null, false, "8f4ecdd7-9078-4345-82bc-7c1570e71387", false, "samuele.locatelli@egalware.com" },
|
||||
{ "be261afb-580a-4cb6-a040-c4a335f9ff3a", 0, "9c306ce8-ec94-49b9-ad24-87b3d9937188", "luca.mazzoleni@egalware.com", true, false, null, "LUCA.MAZZOLENI@EGALWARE.COM", "LUCA.MAZZOLENI@EGALWARE.COM", "AQAAAAEAACcQAAAAEHdDRZVkzBW4qlCF+vvpURb/4bj/b2/kl4+HSEjhbHRAekqX5WMnfJfWMPuyjKrgUg==", null, false, "121bb662-adf9-4cba-bbc8-12bf1d2bc693", false, "luca.mazzoleni@egalware.com" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUserRoles",
|
||||
columns: new[] { "RoleId", "UserId" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ "285df363-706d-498e-b1ad-4680e141ad01", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" },
|
||||
{ "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" },
|
||||
{ "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" },
|
||||
{ "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "3282b9f4-5240-4946-a8d0-5570df880642" },
|
||||
{ "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "3282b9f4-5240-4946-a8d0-5570df880642" },
|
||||
{ "285df363-706d-498e-b1ad-4680e141ad01", "3fac0523-697f-4b42-ac39-82026839ba2c" },
|
||||
{ "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "3fac0523-697f-4b42-ac39-82026839ba2c" },
|
||||
{ "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "3fac0523-697f-4b42-ac39-82026839ba2c" },
|
||||
{ "285df363-706d-498e-b1ad-4680e141ad01", "be261afb-580a-4cb6-a040-c4a335f9ff3a" },
|
||||
{ "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "be261afb-580a-4cb6-a040-c4a335f9ff3a" },
|
||||
{ "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "be261afb-580a-4cb6-a040-c4a335f9ff3a" }
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetRoles",
|
||||
keyColumn: "Id",
|
||||
keyValue: "82b54f2b-4da8-4e46-83bf-57ffc17cf8ed");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "285df363-706d-498e-b1ad-4680e141ad01", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "238a34e8-7a80-4307-bfcc-41bdc4a39c1f" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "3282b9f4-5240-4946-a8d0-5570df880642" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "3282b9f4-5240-4946-a8d0-5570df880642" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "285df363-706d-498e-b1ad-4680e141ad01", "3fac0523-697f-4b42-ac39-82026839ba2c" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "3fac0523-697f-4b42-ac39-82026839ba2c" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "3fac0523-697f-4b42-ac39-82026839ba2c" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "285df363-706d-498e-b1ad-4680e141ad01", "be261afb-580a-4cb6-a040-c4a335f9ff3a" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "34ae910e-acaf-46d1-aaa8-279a74c5bc61", "be261afb-580a-4cb6-a040-c4a335f9ff3a" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUserRoles",
|
||||
keyColumns: new[] { "RoleId", "UserId" },
|
||||
keyValues: new object[] { "8352aca0-c5e8-4a2d-be76-f6cde5f963a1", "be261afb-580a-4cb6-a040-c4a335f9ff3a" });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetRoles",
|
||||
keyColumn: "Id",
|
||||
keyValue: "285df363-706d-498e-b1ad-4680e141ad01");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetRoles",
|
||||
keyColumn: "Id",
|
||||
keyValue: "34ae910e-acaf-46d1-aaa8-279a74c5bc61");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetRoles",
|
||||
keyColumn: "Id",
|
||||
keyValue: "8352aca0-c5e8-4a2d-be76-f6cde5f963a1");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUsers",
|
||||
keyColumn: "Id",
|
||||
keyValue: "238a34e8-7a80-4307-bfcc-41bdc4a39c1f");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUsers",
|
||||
keyColumn: "Id",
|
||||
keyValue: "3282b9f4-5240-4946-a8d0-5570df880642");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUsers",
|
||||
keyColumn: "Id",
|
||||
keyValue: "3fac0523-697f-4b42-ac39-82026839ba2c");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "AspNetUsers",
|
||||
keyColumn: "Id",
|
||||
keyValue: "be261afb-580a-4cb6-a040-c4a335f9ff3a");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "AspNetUserTokens",
|
||||
type: "varchar(255)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(128)",
|
||||
oldMaxLength: 128)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserTokens",
|
||||
type: "varchar(255)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(128)",
|
||||
oldMaxLength: 128)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "ProviderKey",
|
||||
table: "AspNetUserLogins",
|
||||
type: "varchar(255)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(128)",
|
||||
oldMaxLength: 128)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LoginProvider",
|
||||
table: "AspNetUserLogins",
|
||||
type: "varchar(255)",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "varchar(128)",
|
||||
oldMaxLength: 128)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
||||
}
|
||||
+143
-16
@@ -1,15 +1,15 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
partial class UserIdentityDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
@@ -19,7 +19,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
@@ -59,29 +59,29 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "eebed9c1-7433-4716-a62f-df9829dc0f09",
|
||||
ConcurrencyStamp = "4a1affe9-543f-4165-816a-2ed6d3f06c77",
|
||||
Id = "82b54f2b-4da8-4e46-83bf-57ffc17cf8ed",
|
||||
ConcurrencyStamp = "763dedf1-0868-424e-bc0a-1572a548c1d7",
|
||||
Name = "Undef",
|
||||
NormalizedName = "UNDEF"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "ca44b425-5c7e-4812-a28a-047ec6aa2e68",
|
||||
ConcurrencyStamp = "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6",
|
||||
Id = "34ae910e-acaf-46d1-aaa8-279a74c5bc61",
|
||||
ConcurrencyStamp = "8b90b548-3d22-40c6-95ba-c3fb0ea032a7",
|
||||
Name = "User",
|
||||
NormalizedName = "USER"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "86a8f484-ca14-4e4d-a786-3eba35da6e06",
|
||||
ConcurrencyStamp = "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb",
|
||||
Id = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1",
|
||||
ConcurrencyStamp = "63d84be1-17ac-4e8c-9bd7-35e0ed056533",
|
||||
Name = "Admin",
|
||||
NormalizedName = "ADMIN"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "f5bd74e5-df26-4c52-963e-2d87e858c4d6",
|
||||
ConcurrencyStamp = "1d620875-05b0-490d-91d5-6f21a83844f1",
|
||||
Id = "285df363-706d-498e-b1ad-4680e141ad01",
|
||||
ConcurrencyStamp = "365f0dc5-81c1-4deb-945b-58dd8fc9d18a",
|
||||
Name = "SuperAdmin",
|
||||
NormalizedName = "SUPERADMIN"
|
||||
});
|
||||
@@ -172,6 +172,72 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "b23608ab-d50a-464d-8db2-8274f088b0ad",
|
||||
Email = "samuele.locatelli@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "SAMUELE.LOCATELLI@EGALWARE.COM",
|
||||
NormalizedUserName = "SAMUELE.LOCATELLI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEAQsxwpx5DzxcFhzIhUciCtBEHZo/GLlB4HtG49I3gTh/WtXSg9VVl0e5KBmopG9VQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "8f4ecdd7-9078-4345-82bc-7c1570e71387",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "samuele.locatelli@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "f62ab486-c4e0-450a-8fb4-6905d2e3da64",
|
||||
Email = "emmanuele.sassi@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "EMMANUELE.SASSI@EGALWARE.COM",
|
||||
NormalizedUserName = "EMMANUELE.SASSI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAECZ2BzJe3VOrXIgdmjBrD+JP/HqsV/eFwMO4DaGzAmFPvHG+xxkRFbwRkI2sYoWt8Q==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "1be739d4-3aed-4a9a-a5c0-80c45a1474a6",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "emmanuele.sassi@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "9c306ce8-ec94-49b9-ad24-87b3d9937188",
|
||||
Email = "luca.mazzoleni@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "LUCA.MAZZOLENI@EGALWARE.COM",
|
||||
NormalizedUserName = "LUCA.MAZZOLENI@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEHdDRZVkzBW4qlCF+vvpURb/4bj/b2/kl4+HSEjhbHRAekqX5WMnfJfWMPuyjKrgUg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "121bb662-adf9-4cba-bbc8-12bf1d2bc693",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "luca.mazzoleni@egalware.com"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "20720e13-89b3-4660-8c6e-1f11e1e730b4",
|
||||
Email = "info@egalware.com",
|
||||
EmailConfirmed = true,
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "INFO@EGALWARE.COM",
|
||||
NormalizedUserName = "INFO@EGALWARE.COM",
|
||||
PasswordHash = "AQAAAAEAACcQAAAAEDEuPnbPPl/9vc6xg/mvOmyEfvirN5ZNDWu21im+PjvtNQcqvqfc9k3KQxtJKBs5EQ==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "3bd9e353-ab86-47b2-85da-d857e618f44e",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "info@egalware.com"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
@@ -200,10 +266,12 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("varchar(255)");
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("longtext");
|
||||
@@ -232,6 +300,63 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3fac0523-697f-4b42-ac39-82026839ba2c",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "238a34e8-7a80-4307-bfcc-41bdc4a39c1f",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "be261afb-580a-4cb6-a040-c4a335f9ff3a",
|
||||
RoleId = "285df363-706d-498e-b1ad-4680e141ad01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
RoleId = "34ae910e-acaf-46d1-aaa8-279a74c5bc61"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = "3282b9f4-5240-4946-a8d0-5570df880642",
|
||||
RoleId = "8352aca0-c5e8-4a2d-be76-f6cde5f963a1"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
@@ -240,10 +365,12 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("varchar(255)");
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("longtext");
|
||||
@@ -0,0 +1,90 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static StackExchange.Redis.Role;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public static class ModelBuilderExtensions
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Estensione per seed iniziale dei dati nel DB (auth)
|
||||
/// </summary>
|
||||
/// <param name="modelBuilder"></param>
|
||||
public static void Seed(this ModelBuilder modelBuilder)
|
||||
{
|
||||
// seed ruoli
|
||||
List<IdentityRole> roles = new List<IdentityRole>()
|
||||
{
|
||||
new IdentityRole { Name = "Undef", NormalizedName = "UNDEF" },
|
||||
new IdentityRole { Name = "User", NormalizedName = "USER" },
|
||||
new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" },
|
||||
new IdentityRole { Name = "SuperAdmin", NormalizedName = "SUPERADMIN" }
|
||||
};
|
||||
modelBuilder.Entity<IdentityRole>().HasData(roles);
|
||||
|
||||
// seed utenti
|
||||
List<IdentityUser> users = new List<IdentityUser>()
|
||||
{
|
||||
// SuperAdmins
|
||||
getNewUser("samuele.locatelli@egalware.com", "th1sIsTh3R1vrOfThNgt202401"),
|
||||
getNewUser("emmanuele.sassi@egalware.com", "th1sIsTh3R1vrOfThNgt202402"),
|
||||
getNewUser("luca.mazzoleni@egalware.com", "th1sIsTh3R1vrOfThNgt202403"),
|
||||
// Admin egalware base
|
||||
getNewUser("info@egalware.com", "th1sIsTh3R1vrOfThNgt202404")
|
||||
};
|
||||
modelBuilder.Entity<IdentityUser>().HasData(users);
|
||||
|
||||
List<IdentityUserRole<string>> userRoles = new List<IdentityUserRole<string>>();
|
||||
|
||||
for (int i = 0; i < users.Count; i++)
|
||||
{
|
||||
|
||||
// nei primi 3 rendo SuperAdmin
|
||||
if (i < 2)
|
||||
{
|
||||
userRoles.Add(new IdentityUserRole<string>
|
||||
{
|
||||
UserId = users[i].Id,
|
||||
RoleId = roles.First(q => q.Name == "SuperAdmin").Id
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// aggiungo ruoli User x altri
|
||||
userRoles.Add(new IdentityUserRole<string>
|
||||
{
|
||||
UserId = users[i].Id,
|
||||
RoleId = roles.First(q => q.Name == "User").Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
modelBuilder.Entity<IdentityUserRole<string>>().HasData(userRoles);
|
||||
}
|
||||
|
||||
private static IdentityUser getNewUser(string email, string passwd)
|
||||
{
|
||||
var newRec = new IdentityUser
|
||||
{
|
||||
UserName = email,
|
||||
NormalizedUserName = email.ToUpper(),
|
||||
Email = email,
|
||||
NormalizedEmail = email.ToUpper(),
|
||||
EmailConfirmed = true,
|
||||
PasswordHash = hasher.HashPassword(null!, passwd),
|
||||
};
|
||||
return newRec;
|
||||
}
|
||||
|
||||
private static PasswordHasher<IdentityUser> hasher = new PasswordHasher<IdentityUser>();
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public partial class MultiTenantContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MultiTenantContext()
|
||||
{
|
||||
}
|
||||
|
||||
public MultiTenantContext(DbContextOptions<MultiTenantContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public virtual DbSet<CustomerModel> DbSetCustomers { get; set; } = null!;
|
||||
public virtual DbSet<MachineModel> DbSetMachines { get; set; } = null!;
|
||||
public virtual DbSet<AuthKeyModel> DbSetAuthKey { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
// default
|
||||
string connString = DbConfig.CONNECTION_STRING;
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
#if DEBUG
|
||||
connString = "Server=localhost;port=3306;database=MagMan_Admin;uid=MagMan_DbUser;pwd=viad@nte16!;sslmode=None;";
|
||||
#endif
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
|
||||
{
|
||||
relationship.DeleteBehavior = DeleteBehavior.Restrict;
|
||||
}
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void DbForceMigrate()
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
Log.Info("MultiTenantContext DbForceMigrate: done!");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "MultiTenantContext DbForceMigrate: Exception during context initialization 01");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,32 @@
|
||||
using MagMan.Data.DbModels;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public partial class AdminContext : DbContext
|
||||
/// <summary>
|
||||
/// Classe gestione Server MySql:
|
||||
/// - creazione utenti su DB principale
|
||||
/// - aggiunta permessi lettura/scrittura
|
||||
/// </summary>
|
||||
public partial class ServerAdminContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public AdminContext()
|
||||
public ServerAdminContext()
|
||||
{
|
||||
}
|
||||
|
||||
public AdminContext(IConfiguration configuration)
|
||||
public ServerAdminContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public AdminContext(DbContextOptions<AdminContext> options) : base(options)
|
||||
public ServerAdminContext(DbContextOptions<ServerAdminContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,7 +37,11 @@ namespace MagMan.Data
|
||||
/// <summary>
|
||||
/// User management
|
||||
/// </summary>
|
||||
public DbSet<UserPriv> UserList { get; set; }
|
||||
public virtual DbSet<UserPriv> UserList { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// User management
|
||||
/// </summary>
|
||||
public virtual DbSet<DbModel> DbList { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -41,11 +49,11 @@ namespace MagMan.Data
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connString = DbConfig.ADMIN_CONNECTION_STRING;
|
||||
string connString = "";
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
//connString = _configuration.GetConnectionString("MagMan.Data");
|
||||
connString = "Server=localhost;port=3306;database=MagMan_Dev;user=root;pwd=MagMan_pwd;sslmode=None;";
|
||||
// chiave cablata x gestione Server
|
||||
connString = "Server=localhost;port=3306;database=mysql;user=root;pwd=Egalware_24068!;sslmode=None;";
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
@@ -54,22 +62,19 @@ namespace MagMan.Data
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<UserPriv>().HasKey(c => new { c.Host, c.User });
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di partenza x costruzione servizi di accesso dati + cache
|
||||
/// </summary>
|
||||
public class BaseServ
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve (1 min circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraFastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
|
||||
protected static IConfiguration _configuration = null!;
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,772 @@
|
||||
using MagMan.Core;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.Controllers;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.VisualBasic;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MagMan.Data.Admin.Services
|
||||
{
|
||||
public class MTAdminService : BaseServ
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MTAdminService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender, UserManager<IdentityUser> userManager)
|
||||
{
|
||||
Log.Info("MTAdminService starting...");
|
||||
_configuration = configuration;
|
||||
_emailSender = emailSender;
|
||||
_userManager = userManager;
|
||||
// Conf cache
|
||||
redisConn = redisConnMult;
|
||||
redisDb = this.redisConn.GetDatabase();
|
||||
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
|
||||
// cod app
|
||||
CodApp = _configuration["CodApp"];
|
||||
dbController = new MTAdminController(configuration);
|
||||
|
||||
// chiudo log
|
||||
Log.Info("MTAdminService started!");
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string CodApp { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Lista AuthKey
|
||||
/// </summary>
|
||||
/// <param name="CustomerId">0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AuthKeyModel>> AuthKeyByCustId(int CustomerId)
|
||||
{
|
||||
string source = "DB";
|
||||
List<AuthKeyModel>? dbResult = new List<AuthKeyModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:AuthKeyList:{CustomerId}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<AuthKeyModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<AuthKeyModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.AuthKeyByCustId(CustomerId);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<AuthKeyModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"AuthKeyByCustId | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during AuthKeyByCustId:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete record AuthKey + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AuthKeyDelete(AuthKeyModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.AuthKeyDelete(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during AuthKeyDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista AuthKey da Rest Token
|
||||
/// </summary>
|
||||
/// <param name="RestToken">token di auth del cliente</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AuthKeyModel>> AuthKeyGetByToken(string RestToken)
|
||||
{
|
||||
List<AuthKeyModel>? dbResult = new List<AuthKeyModel>();
|
||||
// cerco in primis customer ID...
|
||||
int CustomerId = await CustomerIdByToken(RestToken);
|
||||
if (CustomerId >= 0)
|
||||
{
|
||||
dbResult = await AuthKeyByCustId(CustomerId);
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record AuthKey + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AuthKeyUpdate(AuthKeyModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.AuthKeyUpdate(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during AuthKeyUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete record customer + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CustomerDelete(CustomerModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.CustomerDelete(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during CustomerDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Customers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CustomerModel>> CustomerGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
List<CustomerModel>? dbResult = new List<CustomerModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:CustomersList";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<CustomerModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<CustomerModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.CustomerGetAll();
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<CustomerModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"CustomerGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during CustomerGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> CustomerIdByToken(string RestToken)
|
||||
{
|
||||
int answ = -1;
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:Dict:Token2CustID";
|
||||
answ = RedisHashGetInt(currKey, RestToken);
|
||||
if (answ <= 0)
|
||||
{
|
||||
// cerco nel DB
|
||||
var custList = await CustomerGetAll();
|
||||
var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken);
|
||||
// se trovato salvo
|
||||
if (custRow != null)
|
||||
{
|
||||
answ = custRow.CustomerID;
|
||||
RedisHashSet(currKey, RestToken, $"{answ}");
|
||||
Log.Info($"Token2CustID: added {RestToken} --> {answ}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record customer + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CustomerUpdate(CustomerModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.CustomerUpdate(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during CustomerUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh globale cache redis
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushRedisCache()
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{Const.rKeyConfig}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
stopWatch.Stop();
|
||||
Log.Debug($"FlushRedisCache in {stopWatch.Elapsed.TotalMilliseconds} ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete record Machine + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> MachineDelete(MachineModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.MachineDelete(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during MachineDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Macchine
|
||||
/// </summary>
|
||||
/// <param name="CustomerId">0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MachineModel>> MachineGetByCustId(int CustomerId)
|
||||
{
|
||||
string source = "DB";
|
||||
List<MachineModel>? dbResult = new List<MachineModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:MachineList:{CustomerId}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MachineModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<MachineModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.MachineGetByCustId(CustomerId);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
// per evitare loopback uso deserialize...
|
||||
var tempResult = JsonConvert.DeserializeObject<List<MachineModel>>(rawData);
|
||||
if (tempResult != null)
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<MachineModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"MachineGetByCustId | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during MachineGetByCustId:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Macchine da Rest Token
|
||||
/// </summary>
|
||||
/// <param name="RestToken">token di auth del cliente</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MachineModel>> MachineGetByToken(string RestToken)
|
||||
{
|
||||
List<MachineModel>? dbResult = new List<MachineModel>();
|
||||
// cerco in primis customer ID...
|
||||
int CustomerId = await CustomerIdByToken(RestToken);
|
||||
if (CustomerId >= 0)
|
||||
{
|
||||
dbResult = await MachineGetByCustId(CustomerId);
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record Machine + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> MachineUpdate(MachineModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
fatto = dbController.MachineUpdate(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during MachineUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera CustomerID dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="CustID"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> MainKeyByCustomer(int CustID)
|
||||
{
|
||||
int answ = -1;
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:Dict:Cust2MKey";
|
||||
answ = RedisHashGetInt(currKey, $"{CustID}");
|
||||
if (answ <= 0)
|
||||
{
|
||||
// cerco nel DB
|
||||
var custList = await CustomerGetAll();
|
||||
var custRow = custList.FirstOrDefault(x => x.CustomerID == CustID);
|
||||
// se trovato salvo
|
||||
if (custRow != null)
|
||||
{
|
||||
answ = custRow.MainKey;
|
||||
RedisHashSet(currKey, $"{CustID}", $"{answ}");
|
||||
Log.Info($"Cust2MKey: added {CustID} --> {answ}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera MainKey dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> MainKeyByToken(string RestToken)
|
||||
{
|
||||
int answ = -1;
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:Dict:Token2MKey";
|
||||
answ = RedisHashGetInt(currKey, RestToken);
|
||||
if (answ <= 0)
|
||||
{
|
||||
// cerco nel DB
|
||||
var custList = await CustomerGetAll();
|
||||
var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken);
|
||||
// se trovato salvo
|
||||
if (custRow != null)
|
||||
{
|
||||
answ = custRow.MainKey;
|
||||
RedisHashSet(currKey, RestToken, $"{answ}");
|
||||
Log.Info($"TokenMKey: added {RestToken} --> {answ}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset dati cache redis
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task ResetUserDataCache()
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:UserData:*";
|
||||
await ExecFlushRedisPattern((RedisValue)currKey);
|
||||
}
|
||||
|
||||
private readonly UserManager<IdentityUser> _userManager;
|
||||
public async Task<List<UserData>> UserDataGetFilt(string searchVal)
|
||||
{
|
||||
// Collezione utenti
|
||||
List<IdentityUser> RawList = new List<IdentityUser>();
|
||||
List<UserData> dbResult = new List<UserData>();
|
||||
|
||||
string source = "DB";
|
||||
try
|
||||
{
|
||||
string typeSearch = string.IsNullOrEmpty(searchVal) ? "ALL" : searchVal;
|
||||
string currKey = $"{Const.rKeyConfig}:Admin:UserData:{typeSearch}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2)
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<UserData>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<UserData>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// recupero utenti da obj _userManager
|
||||
var allData = _userManager.Users.ToList();
|
||||
if (!string.IsNullOrEmpty(searchVal))
|
||||
{
|
||||
RawList = allData.Where(x => x.NormalizedEmail.Contains(searchVal.ToUpper()) || x.NormalizedUserName.Contains(searchVal.ToUpper())).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
RawList = allData;
|
||||
}
|
||||
var user = RawList.Select(x => new IdentityUser
|
||||
{
|
||||
Id = x.Id,
|
||||
UserName = x.UserName,
|
||||
Email = x.Email,
|
||||
PhoneNumber = x.PhoneNumber,
|
||||
PasswordHash = "*****",
|
||||
EmailConfirmed = x.EmailConfirmed
|
||||
}).ToList();
|
||||
|
||||
foreach (var item in user)
|
||||
{
|
||||
var UserRoles = await _userManager.GetRolesAsync(item);
|
||||
var UserClaims = await _userManager.GetClaimsAsync(item);
|
||||
|
||||
var newItem = new UserData()
|
||||
{
|
||||
Identity = item,
|
||||
Roles = UserRoles.ToList(),
|
||||
Claims = UserClaims.ToList()
|
||||
};
|
||||
dbResult.Add(newItem);
|
||||
}
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<UserData>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"UserDataGetFilt | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during UserDataGetFilt:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#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();
|
||||
|
||||
private readonly IEmailSender _emailSender;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private IDatabase redisDb = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Generatore random
|
||||
/// </summary>
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera UN SINGOLO VALORE dalla hash per un dato field
|
||||
/// </summary>
|
||||
/// <param name="hashKey"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <returns></returns>
|
||||
private string RedisHashGet(RedisKey hashKey, string hashField)
|
||||
{
|
||||
string answ = "";
|
||||
var hasVal = redisDb.HashExists(hashKey, hashField);
|
||||
if (hasVal)
|
||||
{
|
||||
answ = redisDb.HashGet(hashKey, hashField).ToString();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero HashSet redis come Dictionary
|
||||
/// </summary>
|
||||
/// <param name="hashKey"></param>
|
||||
private Dictionary<string, string> RedisHashGetDict(RedisKey hashKey)
|
||||
{
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
answ = redisDb
|
||||
.HashGetAll(hashKey)
|
||||
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"Errore RedisHashGetDict | hashKey: {hashKey}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera UN SINGOLO VALORE dalla hash per un dato field come INT
|
||||
/// </summary>
|
||||
/// <param name="hashKey">Redis Key for Hashlist</param>
|
||||
/// <param name="hashField">Requested key on list</param>
|
||||
/// <returns>Value as Int</returns>
|
||||
private int RedisHashGetInt(RedisKey hashKey, string hashField)
|
||||
{
|
||||
int result = 0;
|
||||
var rawRes = RedisHashGet(hashKey, hashField);
|
||||
if (!string.IsNullOrEmpty(rawRes))
|
||||
{
|
||||
int.TryParse($"{rawRes}", out result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunta KVP in HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="hashKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
private bool RedisHashSetDict(RedisKey hashKey, Dictionary<string, string> dict)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in dict)
|
||||
{
|
||||
data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
// salvo!
|
||||
redisDb.HashSet(hashKey, data2ins);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RedisHashSet | hashKey: {hashKey}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="hashKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
/// <param name="ttl"></param>
|
||||
private bool RedisHashSetDict(RedisKey hashKey, Dictionary<string, string> dict, TimeSpan ttl)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in dict)
|
||||
{
|
||||
data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
// salvo!
|
||||
redisDb.HashSet(hashKey, data2ins);
|
||||
redisDb.KeyExpire(hashKey, ttl);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RedisHashSet | hashKey: {hashKey}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe generalizzaizone identity (user + roles + claims) x gestione semplificata in editing
|
||||
///
|
||||
/// per deserializzare i claims vedere questi link:
|
||||
/// - https://stackoverflow.com/questions/63634652/c-sharp-newtonsoft-deserialize-custom-object-with-claims
|
||||
/// - https://stackoverflow.com/questions/28155169/how-to-programmatically-choose-a-constructor-during-deserialization/28155770#28155770
|
||||
/// </summary>
|
||||
public class UserData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[JsonProperty(ItemConverterType = typeof(ClaimConverter))]
|
||||
public List<Claim> Claims { get; set; } = new List<Claim>();
|
||||
|
||||
public IdentityUser Identity { get; set; } = new IdentityUser();
|
||||
|
||||
public List<string> Roles { get; set; } = new List<string>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
class ClaimConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return (objectType == typeof(System.Security.Claims.Claim));
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = JObject.Load(reader);
|
||||
string type = (string)jo["Type"];
|
||||
string value = (string)jo["Value"];
|
||||
string valueType = (string)jo["ValueType"];
|
||||
string issuer = (string)jo["Issuer"];
|
||||
string originalIssuer = (string)jo["OriginalIssuer"];
|
||||
return new Claim(type, value, valueType, issuer, originalIssuer);
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe x gestione dei claim come record editabile
|
||||
/// </summary>
|
||||
public class ClaimRec
|
||||
{
|
||||
public int Id { get; set; } = 0;
|
||||
public string Type { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
public ClaimRec(Claim currItem, int nId)
|
||||
{
|
||||
this.Id = nId;
|
||||
this.Type = currItem.Type;
|
||||
this.Value = currItem.Value;
|
||||
}
|
||||
public ClaimRec(string newType, string newValue, int nId)
|
||||
{
|
||||
this.Id = nId;
|
||||
this.Type = newType;
|
||||
this.Value = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public class DbAdmin : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public DbAdmin()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static async Task<bool> migrateDbMain(string connString)
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
await dbCtx.Database.MigrateAsync();
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static bool resetPlantLogTable()
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext())
|
||||
{
|
||||
string sqlCommand = "TRUNCATE TABLE PlantLog;";
|
||||
dbCtx.Database.ExecuteSqlRaw(sqlCommand);
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public static class DbConfig
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public static string DATABASE_NAME = "MagMan_000000";
|
||||
public static int DATABASE_PROCESS_TIMEOUT = 5;
|
||||
public static string DATABASE_PWD = "viad@nte16!";
|
||||
public static string DATABASE_SERV = "127.0.0.1";
|
||||
public static string DATABASE_USER = "MagMan_DbUser";
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// DB Connection string
|
||||
/// </summary>
|
||||
public static string CONNECTION_STRING { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static string CustomerConnString(string server, int nKey)
|
||||
{
|
||||
string dbName = $"MagMan_{nKey:000000}";
|
||||
return $"server={server};port=3306;database={dbName};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
|
||||
}
|
||||
|
||||
public static bool ExecMigrationMain(string connString)
|
||||
{
|
||||
// esecuzione migrazione
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain(connString));
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
public static void InitDb(string server, int nKey)
|
||||
{
|
||||
DATABASE_SERV = server;
|
||||
DATABASE_NAME = $"MagMan_{nKey:000000}";
|
||||
CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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 MagMan.Data.Tenant.Services;
|
||||
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("AliasList")]
|
||||
public class AliasModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Famiglia di sinonimi
|
||||
/// </summary>
|
||||
public string Family { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice originale (da trasformare)
|
||||
/// </summary>
|
||||
public string ValueOriginal { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Codice Alias in cui viene convertito
|
||||
/// </summary>
|
||||
public string ValueAlias { get; set; } = "";
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj is AliasModel item))
|
||||
return false;
|
||||
|
||||
if (Family != item.Family)
|
||||
return false;
|
||||
|
||||
if (ValueOriginal != item.ValueOriginal)
|
||||
return false;
|
||||
|
||||
if (ValueAlias != item.ValueAlias)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella Config
|
||||
@@ -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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
/// <summary>
|
||||
/// Tabella dei LOG Macchina (per macchina)
|
||||
/// </summary>
|
||||
[Table("LogMachine")]
|
||||
[Index(nameof(MachineID))]
|
||||
[Index(nameof(KeyNum))]
|
||||
public class LogMachineModel
|
||||
{
|
||||
[Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int LogDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (diMagMan)
|
||||
/// </summary>
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Codice Allarme
|
||||
/// </summary>
|
||||
[Column("AlarmCode")]
|
||||
public string AlarmCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data Evento
|
||||
/// </summary>
|
||||
[Column("AlarmDtEvent")]
|
||||
public DateTime AlarmDatetime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Messaggio Allarme
|
||||
/// </summary>
|
||||
[Column("AlarmMessage")]
|
||||
public string AlarmMessage { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Alarm Operation
|
||||
/// </summary>
|
||||
[Column("AlarmOperation")]
|
||||
public int AlarmOperation { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Alarm Type
|
||||
/// </summary>
|
||||
[Column("AlarmType")]
|
||||
public int AlarmType { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Esaecuzione comando corretta
|
||||
/// </summary>
|
||||
[Column("CommExecuted")]
|
||||
public bool CommandExecutedCorrectly { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Stato da enum Core
|
||||
/// </summary>
|
||||
[Column("CommandState")]
|
||||
public Core.ConstMachComm.CommandStates CommandState { get; set; } = Core.ConstMachComm.CommandStates.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Comando da enum Core
|
||||
/// </summary>
|
||||
[Column("CommandType")]
|
||||
public Core.ConstMachComm.LogCommandTypes CommandType { get; set; } = Core.ConstMachComm.LogCommandTypes.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione
|
||||
/// </summary>
|
||||
[Column("Description")]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// New OP State
|
||||
/// </summary>
|
||||
[Column("NewOpState")]
|
||||
public int NewOpState { get; set; } = 0;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Stato da enum Core
|
||||
/// </summary>
|
||||
[Column("ResultType")]
|
||||
public ResultTypes ResultType { get; set; } = ResultTypes.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo VAR
|
||||
/// </summary>
|
||||
[Column("VarAddress")]
|
||||
public string VarAddress { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore VAR
|
||||
/// </summary>
|
||||
[Column("VarValue")]
|
||||
public string VarValue { get; set; } = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("MaterialsList")]
|
||||
public partial class MaterialModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
public MaterialModel()
|
||||
{
|
||||
RawItemList = new HashSet<RawItemModel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Primary Key AUTO
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int MatId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Codice Materiale
|
||||
/// </summary>
|
||||
public string MatCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione materiale
|
||||
/// </summary>
|
||||
public string MatDesc { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Height (Thikness/Spessore) in mm
|
||||
/// </summary>
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Lenght/Lunghezza in mm
|
||||
/// </summary>
|
||||
public decimal LMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Width/Larghezza in mm
|
||||
/// </summary>
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Codice materiale x QR/Datamatrix
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public string MatDtmx
|
||||
{
|
||||
get => $"MT{MatId:00000000}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Beam, quando L == 0
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool IsBeam
|
||||
{
|
||||
get => (LMm == 0 && (HMm > 0 && WMm > 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Wall, quando W/L == 0
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool IsWall
|
||||
{
|
||||
get => (HMm > 0 && (LMm == 0 && WMm == 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione ad oggetti child
|
||||
/// </summary>
|
||||
public virtual ICollection<RawItemModel>? RawItemList { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -29,7 +29,7 @@ namespace MagMan.Data.DbModels
|
||||
/// <summary>
|
||||
/// Ext ref for Items
|
||||
/// </summary>
|
||||
public int ItemID { get; set; }
|
||||
public int RawItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Qty recorded (delta +/-)
|
||||
@@ -41,11 +41,16 @@ namespace MagMan.Data.DbModels
|
||||
/// </summary>
|
||||
public string UserId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Note opzionali
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property to Items
|
||||
/// </summary>
|
||||
[ForeignKey("ItemID")]
|
||||
public virtual ItemModel? ITemNav { get; set; }
|
||||
[ForeignKey("RawItemId")]
|
||||
public virtual RawItemModel? ItemNav { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
/// <summary>
|
||||
/// Tabella dei PROJ caricati da EgtBeamWall
|
||||
/// </summary>
|
||||
[Table("ProjList")]
|
||||
[Index(nameof(MachineID))]
|
||||
[Index(nameof(KeyNum))]
|
||||
[Index(nameof(ProjExtDbId))]
|
||||
[Index(nameof(IsActive))]
|
||||
[Index(nameof(IsArchived))]
|
||||
public class ProjModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Chiave univoca su DB
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ProjDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (MagMan)
|
||||
/// </summary>
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID del DB EgtBW, univoco con KeyNum
|
||||
/// </summary>
|
||||
public int ProjExtDbId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID esterno (da EgtBW)
|
||||
/// </summary>
|
||||
public int ProjExtId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Nome file BTL originale
|
||||
/// </summary>
|
||||
public string BTLFileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia del progetto (Travi, Pareti, ...)
|
||||
/// </summary>
|
||||
public BWType PType { get; set; } = BWType.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Macchina (Costruttore/Modello)
|
||||
/// </summary>
|
||||
public string Machine { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione progetto (copiata da BTLFileName inizialmente)
|
||||
/// </summary>
|
||||
public string ProjDescription { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data Creazione progetto
|
||||
/// </summary>
|
||||
public DateTime DtCreated { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Data di schedulazione (prevista)
|
||||
/// </summary>
|
||||
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
|
||||
|
||||
/// <summary>
|
||||
/// Data Inizio Produzione
|
||||
/// </summary>
|
||||
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Data ora ultima operazione registrata
|
||||
/// </summary>
|
||||
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// ListName del BTL
|
||||
/// </summary>
|
||||
public string ListName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione previsto (stima) in minuti
|
||||
/// </summary>
|
||||
public double ProcTimeEst { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
|
||||
/// </summary>
|
||||
public double ProcTimeReal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == cancellazione logica)
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
|
||||
/// </summary>
|
||||
public bool IsArchived { get; set; } = false;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,35 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
//[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))]
|
||||
[Table("ItemsList")]
|
||||
public partial class ItemModel
|
||||
[Table("RawItemList")]
|
||||
public partial class RawItemModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key AUTO
|
||||
/// </summary>
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ItemID { get; set; }
|
||||
public int RawItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ext ref for Material
|
||||
/// </summary>
|
||||
public int MatID { get; set; } = 0;
|
||||
public int MatId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty available on wharehouse
|
||||
/// </summary>
|
||||
public int QtyAvail { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Active, for logical delete...
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
@@ -35,16 +45,6 @@ namespace MagMan.Data.DbModels
|
||||
/// Location
|
||||
/// </summary>
|
||||
public string Location { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Qty available on wharehouse
|
||||
/// </summary>
|
||||
public int QtyAvail { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// DateTime last modification
|
||||
/// </summary>
|
||||
public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10);
|
||||
|
||||
/// <summary>
|
||||
/// Item's Lenght
|
||||
/// </summary>
|
||||
@@ -56,48 +56,24 @@ namespace MagMan.Data.DbModels
|
||||
public decimal WMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Item's Thikness
|
||||
/// Item's Height (Thikness/Spessore) in mm
|
||||
/// </summary>
|
||||
public decimal TMm { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public decimal LIn
|
||||
{
|
||||
get => Math.Round(LMm / (decimal)25.4, 3);
|
||||
}
|
||||
[NotMapped]
|
||||
public decimal WIn
|
||||
{
|
||||
get => Math.Round(WMm / (decimal)25.4, 3);
|
||||
}
|
||||
[NotMapped]
|
||||
public decimal TIn
|
||||
{
|
||||
get => Math.Round(TMm / (decimal)25.4, 3);
|
||||
}
|
||||
|
||||
public decimal HMm { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Note (optional)
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
[NotMapped]
|
||||
public decimal Area
|
||||
{
|
||||
get => LMm * WMm;
|
||||
}
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public string ItemDtmx
|
||||
{
|
||||
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 +82,7 @@ namespace MagMan.Data.DbModels
|
||||
/// <summary>
|
||||
/// Navigation property to Material
|
||||
/// </summary>
|
||||
[ForeignKey("MatID")]
|
||||
[ForeignKey("MatId")]
|
||||
public virtual MaterialModel MaterialNav { get; set; } = null!;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
/// <summary>
|
||||
/// Tabella dei Piano Richieste associate a Proj
|
||||
/// </summary>
|
||||
[Table("RequestPlan")]
|
||||
public class RequestPlanModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
public RequestPlanModel()
|
||||
{
|
||||
ResourcesList = new HashSet<ResourceModel>();
|
||||
}
|
||||
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int RequestId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Progetto di riferimento
|
||||
/// </summary>
|
||||
public int ProjDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data richiesta
|
||||
/// </summary>
|
||||
public DateTime DtRequest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tipo richiesta
|
||||
/// </summary>
|
||||
public ProjResState ReqState { get; set; } = ProjResState.ND;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == NON è il piano scelto per i casi "previsionali" = ReqState >0 )
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione ad oggetti child
|
||||
/// </summary>
|
||||
public virtual ICollection<ResourceModel>? ResourcesList { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
/// <summary>
|
||||
/// Tabella esplosione risorse (richiesta + items)
|
||||
/// </summary>
|
||||
[Table("ResourceList")]
|
||||
public class ResourceModel
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ResourceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento richiesta parent
|
||||
/// </summary>
|
||||
public int RequestId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento RawItem specifico
|
||||
/// </summary>
|
||||
public int RawItemId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property to RequestPlan
|
||||
/// </summary>
|
||||
[ForeignKey("RequestId")]
|
||||
public virtual RequestPlanModel RequestNav { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Navigation property to RawItem
|
||||
/// </summary>
|
||||
[ForeignKey("RawItemId")]
|
||||
public virtual RawItemModel ItemNav { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe fake x il conteggio tabelle e check preliminari
|
||||
@@ -16,7 +16,7 @@ namespace MagMan.Data.DbModels
|
||||
#region Public Properties
|
||||
|
||||
public int Count { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public string TableName { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dei USER di MySql
|
||||
/// </summary>
|
||||
[Table("user")]
|
||||
public class UserPriv
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Column("Host", Order = 1)]
|
||||
public string Host { get; set; } = "";
|
||||
|
||||
[Column("User", Order = 2)]
|
||||
public string User { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Migrations\UserIdentityDb\**" />
|
||||
<EmbeddedResource Remove="Migrations\UserIdentityDb\**" />
|
||||
<None Remove="Migrations\UserIdentityDb\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Services\MessageService.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="DTO\" />
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,6 +1,7 @@
|
||||
using MagMan.Data.DbModels;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Pqc.Crypto.Lms;
|
||||
using System;
|
||||
@@ -9,7 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public partial class MagManContext : DbContext
|
||||
{
|
||||
@@ -17,7 +18,6 @@ namespace MagMan.Data
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -25,60 +25,33 @@ namespace MagMan.Data
|
||||
|
||||
public MagManContext()
|
||||
{
|
||||
// default
|
||||
connString = DbConfig.CONNECTION_STRING;
|
||||
}
|
||||
|
||||
public MagManContext(IConfiguration configuration)
|
||||
public MagManContext(string currConnString)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public MagManContext(DbContextOptions<MagManContext> options) : base(options)
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "Exception during context initialization 02");
|
||||
}
|
||||
connString = currConnString;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
|
||||
public virtual DbSet<ItemModel> DbSetItems { get; set; }
|
||||
public virtual DbSet<MaterialModel> DbSetMaterials { get; set; }
|
||||
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; }
|
||||
public virtual DbSet<PrintJobQueueModel> DbSetPrintJob { get; set; }
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; } = null!;
|
||||
|
||||
public virtual DbSet<RawItemModel> DbSetItems { get; set; } = null!;
|
||||
public virtual DbSet<MaterialModel> DbSetMaterials { get; set; } = null!;
|
||||
public virtual DbSet<RawItemModel> DbSetRawItem { get; set; } = null!;
|
||||
public virtual DbSet<AliasModel> DbSetAlias { get; set; } = null!;
|
||||
public virtual DbSet<ProjModel> DbSetProjects { get; set; } = null!;
|
||||
public virtual DbSet<RequestPlanModel> DbSetReqPlan { get; set; } = null!;
|
||||
public virtual DbSet<ResourceModel> DbSetResources { get; set; } = null!;
|
||||
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
|
||||
|
||||
|
||||
#if false
|
||||
public virtual DbSet<AnKeyValModel> DbSetKeyVal { get; set; }
|
||||
|
||||
public virtual DbSet<ListValModel> DbSetListVal { get; set; }
|
||||
|
||||
public virtual DbSet<OrderModel> DbSetOrders { get; set; }
|
||||
|
||||
public virtual DbSet<ParamSendModel> DbSetParamSend { get; set; }
|
||||
|
||||
public virtual DbSet<ParamSetModel> DbSetParamSet { get; set; }
|
||||
|
||||
public virtual DbSet<PlantDetailModel> DbSetPlant { get; set; }
|
||||
|
||||
public virtual DbSet<PlantLogModel> DbSetPlantLog { get; set; }
|
||||
|
||||
public virtual DbSet<PlantStatusModel> DbSetPlantStatus { get; set; }
|
||||
|
||||
public virtual DbSet<WeekPlanModel> DbSetPlantSupplWeekPlan { get; set; }
|
||||
|
||||
public virtual DbSet<SupplierModel> DbSetSupplier { get; set; }
|
||||
|
||||
public virtual DbSet<TransporterModel> DbSetTransporter { get; set; }
|
||||
#endif
|
||||
private string connString = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -92,13 +65,8 @@ namespace MagMan.Data
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
// default
|
||||
string connString = DbConfig.CONNECTION_STRING;
|
||||
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
//connString = _configuration.GetConnectionString("MagMan.Data");
|
||||
connString = "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;";
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
@@ -117,13 +85,8 @@ namespace MagMan.Data
|
||||
.HasComment("Valore di default/riferimento per la variabile");
|
||||
});
|
||||
|
||||
#if false
|
||||
modelBuilder.Entity<ListValModel>().HasKey(c => new { c.TabName, c.FieldName, c.Val });
|
||||
|
||||
modelBuilder.Entity<PlantStatusModel>().HasKey(c => new { c.PlantId, c.FluxType });
|
||||
|
||||
modelBuilder.Entity<ParamSendModel>().HasKey(c => new { c.PlantId, c.ParamUid });
|
||||
#endif
|
||||
modelBuilder.Entity<AliasModel>()
|
||||
.HasKey(c => new { c.Family, c.ValueOriginal });
|
||||
|
||||
modelBuilder.Seed();
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
// <auto-generated />
|
||||
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("20240125174457_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<string>("Family")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ValueOriginal")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ValueAlias")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Family", "ValueOriginal");
|
||||
|
||||
b.ToTable("AliasList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
|
||||
{
|
||||
b.Property<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Val")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("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<int>("MatId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("HMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("MatCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("MatDesc")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("MatId");
|
||||
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.Property<int>("MovID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRec")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyRec")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MovID");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.ToTable("MovMag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BTLFileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("DtCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtLastAction")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtSchedule")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtStartProd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsArchived")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ListName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Machine")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MachineID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("ProcTimeEst")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("ProcTimeReal")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ProjDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("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<int>("RawItemId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("HMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsRemn")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyAvail")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("RawItemId");
|
||||
|
||||
b.HasIndex("MatId");
|
||||
|
||||
b.ToTable("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRequest")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId");
|
||||
|
||||
b.ToTable("RequestPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.Property<int>("ResourceId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Qty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
});
|
||||
|
||||
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.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
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<string>(type: "varchar(255)", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ValueOriginal = table.Column<string>(type: "varchar(255)", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ValueAlias = table.Column<string>(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<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ValStd = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MatCode = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
MatDesc = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
HMm = table.Column<decimal>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MachineID = table.Column<int>(type: "int", nullable: false),
|
||||
KeyNum = table.Column<int>(type: "int", nullable: false),
|
||||
ProjExtDbId = table.Column<int>(type: "int", nullable: false),
|
||||
ProjExtId = table.Column<int>(type: "int", nullable: false),
|
||||
BTLFileName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PType = table.Column<int>(type: "int", nullable: false),
|
||||
Machine = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProjDescription = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DtCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtSchedule = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtStartProd = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtLastAction = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ListName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProcTimeEst = table.Column<double>(type: "double", nullable: false),
|
||||
ProcTimeReal = table.Column<double>(type: "double", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsArchived = table.Column<bool>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
ProjDbId = table.Column<int>(type: "int", nullable: false),
|
||||
DtRequest = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ReqState = table.Column<int>(type: "int", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RequestPlan", x => x.RequestId);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RawItemList",
|
||||
columns: table => new
|
||||
{
|
||||
RawItemId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MatId = table.Column<int>(type: "int", nullable: false),
|
||||
QtyAvail = table.Column<int>(type: "int", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsRemn = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
Location = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
HMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RawItemList", x => x.RawItemId);
|
||||
table.ForeignKey(
|
||||
name: "FK_RawItemList_MaterialsList_MatId",
|
||||
column: x => x.MatId,
|
||||
principalTable: "MaterialsList",
|
||||
principalColumn: "MatId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MovMag",
|
||||
columns: table => new
|
||||
{
|
||||
MovID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
DtRec = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
RawItemId = table.Column<int>(type: "int", nullable: false),
|
||||
QtyRec = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MovMag", x => x.MovID);
|
||||
table.ForeignKey(
|
||||
name: "FK_MovMag_RawItemList_RawItemId",
|
||||
column: x => x.RawItemId,
|
||||
principalTable: "RawItemList",
|
||||
principalColumn: "RawItemId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ResourceList",
|
||||
columns: table => new
|
||||
{
|
||||
ResourceId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
RequestId = table.Column<int>(type: "int", nullable: false),
|
||||
RawItemId = table.Column<int>(type: "int", nullable: false),
|
||||
Qty = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ResourceList", x => x.ResourceId);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResourceList_RawItemList_RawItemId",
|
||||
column: x => x.RawItemId,
|
||||
principalTable: "RawItemList",
|
||||
principalColumn: "RawItemId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResourceList_RequestPlan_RequestId",
|
||||
column: x => x.RequestId,
|
||||
principalTable: "RequestPlan",
|
||||
principalColumn: "RequestId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MovMag_RawItemId",
|
||||
table: "MovMag",
|
||||
column: "RawItemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_IsActive",
|
||||
table: "ProjList",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_IsArchived",
|
||||
table: "ProjList",
|
||||
column: "IsArchived");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_KeyNum",
|
||||
table: "ProjList",
|
||||
column: "KeyNum");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_MachineID",
|
||||
table: "ProjList",
|
||||
column: "MachineID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_ProjExtDbId",
|
||||
table: "ProjList",
|
||||
column: "ProjExtDbId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RawItemList_MatId",
|
||||
table: "RawItemList",
|
||||
column: "MatId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResourceList_RawItemId",
|
||||
table: "ResourceList",
|
||||
column: "RawItemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResourceList_RequestId",
|
||||
table: "ResourceList",
|
||||
column: "RequestId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AliasList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Config");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MovMag");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ResourceList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RawItemList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestPlan");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MaterialsList");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data.Tenant;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
partial class MagManContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(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<string>("Family")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ValueOriginal")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ValueAlias")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Family", "ValueOriginal");
|
||||
|
||||
b.ToTable("AliasList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
|
||||
{
|
||||
b.Property<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Val")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("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<int>("MatId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("HMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("MatCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("MatDesc")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("MatId");
|
||||
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.Property<int>("MovID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRec")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyRec")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MovID");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.ToTable("MovMag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BTLFileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("DtCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtLastAction")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtSchedule")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtStartProd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsArchived")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ListName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Machine")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MachineID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("ProcTimeEst")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("ProcTimeReal")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ProjDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("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<int>("RawItemId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("HMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsRemn")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyAvail")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("RawItemId");
|
||||
|
||||
b.HasIndex("MatId");
|
||||
|
||||
b.ToTable("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRequest")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId");
|
||||
|
||||
b.ToTable("RequestPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.Property<int>("ResourceId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Qty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RawItemId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
});
|
||||
|
||||
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.RawItemModel", "ItemNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RawItemId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ItemNav");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public static class ModelBuilderExtensions
|
||||
{
|
||||
@@ -17,23 +17,23 @@ namespace MagMan.Data
|
||||
/// <param name="modelBuilder"></param>
|
||||
public static void Seed(this ModelBuilder modelBuilder)
|
||||
{
|
||||
#if false
|
||||
// inizializzazione dei valori di default x USER
|
||||
#if false
|
||||
modelBuilder.Entity<UserModel>().HasData(
|
||||
new UserModel { UserId = 1, AuthKey = "th1sIsTh3R1vrOfThNgt98", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "samuele.locatelli", Email = "samuele@steamware.net", Firstname = "Samuele", Lastname = "Locatelli" },
|
||||
new UserModel { UserId = 2, AuthKey = "th1sIsTh3R1vrOfThNgt91", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "giancarlo.rottoli", Email = "giancarlo@steamware.net", Firstname = "Giancarlo", Lastname = "Rottoli" },
|
||||
new UserModel { UserId = 3, AuthKey = "th1sIsTh3R1vrOfThNgt93", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "steamw.admin", Email = "info@steamware.net", Firstname = "Steamware", Lastname = "Admin" },
|
||||
new UserModel { UserId = 4, AuthKey = "th1sIsTh3R1vrOfThNgt97", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "angelo.pizzaferri", Email = "a.pizzaferri@pizzaferripetroli.it", Firstname = "Angelo", Lastname = "Pizzaferri" },
|
||||
new UserModel { UserId = 5, AuthKey = "th1sIsTh3R1vrOfThNgt99", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "andrei.valeanu", Email = "andrei.valeanu@winnlab.it", Firstname = "Andrei", Lastname = "Valeanu" },
|
||||
new UserModel { UserId = 6, AuthKey = "th1sIsTh3R1vrOfThNgt92", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 1, MaskTranspId = 0, UserName = "liquigas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LIQUIGAS" },
|
||||
new UserModel { UserId = 7, AuthKey = "th1sIsTh3R1vrOfThNgt94", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 2, MaskTranspId = 0, UserName = "vulkangas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "VULKANGAS" },
|
||||
new UserModel { UserId = 8, AuthKey = "th1sIsTh3R1vrOfThNgt95", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 1, UserName = "levorato.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LEVORATO" },
|
||||
new UserModel { UserId = 9, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 2, UserName = "traffik.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "TRAFFIK" },
|
||||
new UserModel { UserId = 10, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 1, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz03.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Collecchio" },
|
||||
new UserModel { UserId = 11, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 2, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz04.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Noceto" },
|
||||
new UserModel { UserId = 12, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 3, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz05.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Baganzola" },
|
||||
new UserModel { UserId = 13, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 4, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz08.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Pilastrello" }
|
||||
);
|
||||
new UserModel { UserId = 1, AuthKey = "th1sIsTh3R1vrOfThNgt98", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "samuele.locatelli", Email = "samuele@steamware.net", Firstname = "Samuele", Lastname = "Locatelli" },
|
||||
new UserModel { UserId = 2, AuthKey = "th1sIsTh3R1vrOfThNgt91", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "giancarlo.rottoli", Email = "giancarlo@steamware.net", Firstname = "Giancarlo", Lastname = "Rottoli" },
|
||||
new UserModel { UserId = 3, AuthKey = "th1sIsTh3R1vrOfThNgt93", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "steamw.admin", Email = "info@steamware.net", Firstname = "Steamware", Lastname = "Admin" },
|
||||
new UserModel { UserId = 4, AuthKey = "th1sIsTh3R1vrOfThNgt97", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "angelo.pizzaferri", Email = "a.pizzaferri@pizzaferripetroli.it", Firstname = "Angelo", Lastname = "Pizzaferri" },
|
||||
new UserModel { UserId = 5, AuthKey = "th1sIsTh3R1vrOfThNgt99", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "andrei.valeanu", Email = "andrei.valeanu@winnlab.it", Firstname = "Andrei", Lastname = "Valeanu" },
|
||||
new UserModel { UserId = 6, AuthKey = "th1sIsTh3R1vrOfThNgt92", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 1, MaskTranspId = 0, UserName = "liquigas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LIQUIGAS" },
|
||||
new UserModel { UserId = 7, AuthKey = "th1sIsTh3R1vrOfThNgt94", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 2, MaskTranspId = 0, UserName = "vulkangas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "VULKANGAS" },
|
||||
new UserModel { UserId = 8, AuthKey = "th1sIsTh3R1vrOfThNgt95", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 1, UserName = "levorato.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LEVORATO" },
|
||||
new UserModel { UserId = 9, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 2, UserName = "traffik.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "TRAFFIK" },
|
||||
new UserModel { UserId = 10, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 1, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz03.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Collecchio" },
|
||||
new UserModel { UserId = 11, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 2, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz04.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Noceto" },
|
||||
new UserModel { UserId = 12, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 3, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz05.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Baganzola" },
|
||||
new UserModel { UserId = 13, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 4, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz08.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Pilastrello" }
|
||||
);
|
||||
#endif
|
||||
|
||||
#if false
|
||||
@@ -0,0 +1,132 @@
|
||||
using MagMan.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di partenza x costruzione servizi di accesso dati + cache
|
||||
/// </summary>
|
||||
public class BaseServ
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
protected IConfiguration _configuration = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
protected int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
protected int cacheTtlShort = 60 * 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected IConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
protected Random rnd = new Random();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve (1 min circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraFastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh globale cache redis
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> FlushRedisCache()
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{Const.rKeyConfig}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
stopWatch.Stop();
|
||||
Log.Debug($"FlushRedisCache in {stopWatch.Elapsed.TotalMilliseconds} ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class SelectData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione con periodo e arrotondamento
|
||||
/// </summary>
|
||||
/// <param name="minRound"></param>
|
||||
/// <param name="numDayPrev"></param>
|
||||
/// <returns></returns>
|
||||
public static SelectData Init(int minRound, int numDayPrev)
|
||||
{
|
||||
DateTime endRounded = DateTime.Today.AddDays(1);
|
||||
SelectData answ = new SelectData()
|
||||
{
|
||||
DateEnd = endRounded,
|
||||
DateStart = endRounded.AddDays(-numDayPrev)
|
||||
};
|
||||
return answ;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj is SelectData item))
|
||||
return false;
|
||||
|
||||
if (DateEnd != item.DateEnd)
|
||||
return false;
|
||||
if (DateStart != item.DateStart)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class SelectOrderData : SelectData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public int PlantId { get; set; } = 0;
|
||||
public bool ShowClosed { get; set; } = false;
|
||||
public int SupplierId { get; set; } = 0;
|
||||
|
||||
public int TransporterId { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione con periodo e arrotondamento
|
||||
/// </summary>
|
||||
/// <param name="minRound"></param>
|
||||
/// <param name="numDayPrev"></param>
|
||||
/// <returns></returns>
|
||||
public static new SelectOrderData Init(int minRound, int numDayPrev)
|
||||
{
|
||||
var selD = SelectData.Init(minRound, numDayPrev);
|
||||
return new SelectOrderData() { DateStart = selD.DateStart, DateEnd = selD.DateEnd, ShowClosed = false };
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj is SelectOrderData item))
|
||||
return false;
|
||||
|
||||
if (ShowClosed != item.ShowClosed)
|
||||
return false;
|
||||
if (PlantId != item.PlantId)
|
||||
return false;
|
||||
if (SupplierId != item.SupplierId)
|
||||
return false;
|
||||
if (TransporterId != item.TransporterId)
|
||||
return false;
|
||||
|
||||
return ((SelectData)this).Equals((SelectData)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
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.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
[Table("Materials")]
|
||||
public partial class MaterialModel
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int MatID { get; set; }
|
||||
|
||||
public int MatExtCode { get; set; } = 0;
|
||||
public string MatDesc { get; set; } = "";
|
||||
public DateTime ApprovDate { get; set; } = DateTime.Now.AddYears(10);
|
||||
public string ApprovUser { get; set; } = "";
|
||||
public decimal LMm { get; set; } = 0;
|
||||
public decimal WMm { get; set; } = 0;
|
||||
public decimal TMm { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public string MatDtmx
|
||||
{
|
||||
get => $"MT{MatExtCode:00000000}";
|
||||
}
|
||||
|
||||
|
||||
public virtual ICollection<ItemModel>? ItemNav { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit.Text;
|
||||
using MimeKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione interfaccia email con pacchetto MailKIT
|
||||
///
|
||||
/// https://www.ryadel.com/en/asp-net-core-send-email-messages-smtp-mailkit/
|
||||
/// </summary>
|
||||
public class MailKitEmailSender : IEmailSender
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSender(IOptions<MailKitEmailSenderOptions> options)
|
||||
{
|
||||
this.Options = options.Value;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public MailKitEmailSenderOptions Options { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task Execute(string to, string subject, string message)
|
||||
{
|
||||
// create message
|
||||
var email = new MimeMessage();
|
||||
email.Sender = MailboxAddress.Parse(Options.Sender_EMail);
|
||||
if (!string.IsNullOrEmpty(Options.Sender_Name))
|
||||
email.Sender.Name = Options.Sender_Name;
|
||||
email.From.Add(email.Sender);
|
||||
email.To.Add(MailboxAddress.Parse(to));
|
||||
email.Subject = subject;
|
||||
email.Body = new TextPart(TextFormat.Html) { Text = message };
|
||||
|
||||
// send email
|
||||
using (var smtp = new SmtpClient())
|
||||
{
|
||||
smtp.Connect(Options.Host_Address, Options.Host_Port, Options.Host_SecureSocketOptions);
|
||||
smtp.Authenticate(Options.Host_Username, Options.Host_Password);
|
||||
smtp.Send(email);
|
||||
smtp.Disconnect(true);
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task SendEmailAsync(string email, string subject, string message)
|
||||
{
|
||||
return Execute(email, subject, message);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using MailKit.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
public class MailKitEmailSenderOptions
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSenderOptions()
|
||||
{
|
||||
Host_SecureSocketOptions = SecureSocketOptions.Auto;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string Host_Address { get; set; } = "";
|
||||
|
||||
public string Host_Password { get; set; } = "";
|
||||
public int Host_Port { get; set; } = 0;
|
||||
|
||||
public SecureSocketOptions Host_SecureSocketOptions { get; set; } = SecureSocketOptions.None;
|
||||
public string Host_Username { get; set; } = "";
|
||||
public string Sender_EMail { get; set; } = "";
|
||||
|
||||
public string Sender_Name { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// <auto-generated />
|
||||
using MagMan.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.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<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Val")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.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<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ValStd = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "Valore di default/riferimento per la variabile")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
// <auto-generated />
|
||||
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.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<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Val")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("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<int>("ItemID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtMod")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsRemn")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyAvail")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("ItemID");
|
||||
|
||||
b.HasIndex("MatID");
|
||||
|
||||
b.ToTable("ItemsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
|
||||
{
|
||||
b.Property<int>("MatID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("ApprovDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ApprovUser")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("MatDesc")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatExtCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
{
|
||||
public partial class AddMagBaseObj : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Materials",
|
||||
columns: table => new
|
||||
{
|
||||
MatID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MatExtCode = table.Column<int>(type: "int", nullable: false),
|
||||
MatDesc = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ApprovDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ApprovUser = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
TMm = table.Column<decimal>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MatID = table.Column<int>(type: "int", nullable: false),
|
||||
IsRemn = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
Location = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
QtyAvail = table.Column<int>(type: "int", nullable: false),
|
||||
DtMod = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
LMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
WMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
TMm = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
||||
Note = table.Column<string>(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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
// <auto-generated />
|
||||
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.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<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Val")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("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<int>("ItemID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtMod")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsRemn")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("QtyAvail")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("ItemID");
|
||||
|
||||
b.HasIndex("MatID");
|
||||
|
||||
b.ToTable("ItemsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.MaterialModel", b =>
|
||||
{
|
||||
b.Property<int>("MatID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("ApprovDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ApprovUser")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<decimal>("LMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<string>("MatDesc")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MatExtCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.Property<decimal>("WMm")
|
||||
.HasColumnType("decimal(65,30)");
|
||||
|
||||
b.HasKey("MatID");
|
||||
|
||||
b.ToTable("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.MovMagModel", b =>
|
||||
{
|
||||
b.Property<int>("MovID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRec")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("ItemID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("QtyRec")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("MovID");
|
||||
|
||||
b.HasIndex("ItemID");
|
||||
|
||||
b.ToTable("MovMag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.PrintJobQueueModel", b =>
|
||||
{
|
||||
b.Property<int>("IdxPrintJob")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("DtEnd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("DtLastTry")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtStart")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("KeyParam")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PrtName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("Stato")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
{
|
||||
public partial class AddMagBaseObj01 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MovMag",
|
||||
columns: table => new
|
||||
{
|
||||
MovID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
DtRec = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ItemID = table.Column<int>(type: "int", nullable: false),
|
||||
QtyRec = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<string>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
TipoReport = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
KeyParam = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PrtName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DtStart = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtEnd = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
Stato = table.Column<int>(type: "int", nullable: false),
|
||||
DtLastTry = table.Column<DateTime>(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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user