diff --git a/.editorconfig b/.editorconfig index 4ebde410..eb1efe38 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,3 +2,6 @@ # CS8765: Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes). dotnet_diagnostic.CS8765.severity = none + +# CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. +dotnet_diagnostic.CS8632.severity = none diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab1573d9..0f16cd57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,6 +82,7 @@ stages: - installer - release +# ----- Start BUILD ----- LAND:build: stage: build tags: @@ -173,7 +174,21 @@ CONF:build: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj +IOC:build: + stage: build + tags: + - win + variables: + APP_NAME: MP.IOC + SOL_NAME: MP-IOC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + +# ----- Start DEPLOY develop (IIS01) ----- LAND:IIS01:deploy: stage: deploy tags: @@ -293,6 +308,24 @@ CONF:IIS01:deploy: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj +IOC:IIS01:deploy: + stage: deploy + tags: + - win + variables: + APP_NAME: MP.IOC + SOL_NAME: MP-IOC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + needs: ["IOC:build"] + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + +# ----- Start DEPLOY master (IIS02/IIS04) ----- LAND:IIS02:deploy: stage: deploy tags: @@ -309,7 +342,7 @@ LAND:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj PROG:IIS02:deploy: stage: deploy @@ -327,7 +360,7 @@ PROG:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj STAT:IIS02:deploy: stage: deploy @@ -345,7 +378,7 @@ STAT:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj MON:IIS02:deploy: stage: deploy @@ -363,7 +396,7 @@ MON:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj SPEC:IIS02:deploy: stage: deploy @@ -381,7 +414,7 @@ SPEC:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj INVE:IIS02:deploy: stage: deploy @@ -399,7 +432,7 @@ INVE:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj CONF:IIS02:deploy: stage: deploy @@ -417,8 +450,27 @@ CONF:IIS02:deploy: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj - - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj +IOC:IIS02:deploy: + stage: deploy + tags: + - win + variables: + APP_NAME: MP.IOC + SOL_NAME: MP-IOC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + needs: ["IOC:build"] + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PASSWD -p:AllowUntrustedCertificate=true -p:verbosity=quiet $env:APP_NAME/$env:APP_NAME.csproj + +# ----- Start INSTALLER (develop/master) ----- LAND:installer: stage: installer tags: @@ -573,6 +625,29 @@ INVE:installer: # - *hashBuild # - *nexusUpload +IOC:installer: + stage: installer + tags: + - win + variables: + APP_NAME: MP.IOC + SOL_NAME: MP-IOC + NEXUS_PATH: MP-IOC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + - master + needs: ["IOC:build"] + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish -p:verbosity=quiet + # qui il deploy su nexus... + - *hashBuild + - *nexusUpload + +# ----- Start RELEASE (tags only) ----- LAND:release: stage: release tags: @@ -585,8 +660,6 @@ LAND:release: - *nuget-fix - dotnet restore "$env:SOL_NAME.sln" only: - #- feature/Deploy_CI_CD - # - master - tags except: - branches @@ -740,3 +813,26 @@ CONF:release: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj - dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet +IOC:release: + stage: release + tags: + - win + variables: + APP_NAME: MP.IOC + SOL_NAME: MP-IOC + NEXUS_PATH: MP-IOC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - tags + except: + - branches + needs: ["IOC:build"] + artifacts: + paths: + - publish/ + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj -p:verbosity=quiet + diff --git a/Insomnia/MAPO-SPEC.json b/Insomnia/MAPO-SPEC.json new file mode 100644 index 00000000..b14c98f9 --- /dev/null +++ b/Insomnia/MAPO-SPEC.json @@ -0,0 +1 @@ +{"_type":"export","__export_format":4,"__export_date":"2023-04-04T15:23:33.215Z","__export_source":"insomnia.desktop.app:v2023.1.0","resources":[{"_id":"req_cd57cb8728854cd5a7d026b9aba60047","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680616613886,"created":1680616613017,"url":"https://localhost:7212/api/Recipe/GetRecipe?idxPODL=1656","name":"New Request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680616613017,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","parentId":null,"modified":1680615228636,"created":1680615228636,"name":"MAPO-SPEC","description":"","scope":"collection","_type":"workspace"},{"_id":"req_4d233d6fb970485ea929bdffdcfae05a","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621773464,"created":1680615246346,"url":"{{ _.BASE_URL }}/api/Recipe/GetRecipe?idxPODL=1656","name":"GET RECIPE (calc)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680615241541.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_278d5f0a6555457e88ad2e58cfdaae23","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621754168,"created":1680615436433,"url":"{{ BASE_URL }}/api/RecipeArchive/GetFile?idxMacc=SIMUL_02&fileName=10002.xml","name":"GET FILE (from archive)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1679846511868.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615377532,"created":1680615228640,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1680615228640,"_type":"environment"},{"_id":"jar_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228642,"created":1680615228642,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_b61936e963e34a759001c6a22ad8da60","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228637,"created":1680615228637,"fileName":"MAPO-SPEC","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_2757d8ba1b17435987847d0499e9369e","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616993850,"created":1680615301619,"name":"DEV","data":{"BASE_URL":"https://localhost:7212"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#ff0000","isPrivate":false,"metaSortKey":1680615301619,"_type":"environment"},{"_id":"env_f5b6aef3c2b444aab04c9056404d63f9","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616996428,"created":1680615328099,"name":"IIS01","data":{"BASE_URL":"https://iis01.egalware.com/MP/SPEC"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1680615328099,"_type":"environment"}]} \ No newline at end of file diff --git a/IobConf.Core/IniFile.cs b/IobConf.Core/IniFile.cs index 1a0fc606..f02ee733 100644 --- a/IobConf.Core/IniFile.cs +++ b/IobConf.Core/IniFile.cs @@ -41,7 +41,7 @@ namespace IobConf.Core /// public void IniDeleteKey(string Section, string Key) { - WritePrivateProfileString(Section, Key, null, FileName); + WritePrivateProfileString(Section, Key, "", FileName); } /// @@ -50,7 +50,7 @@ namespace IobConf.Core /// public void IniDeleteSection(string Section) { - WritePrivateProfileSection(Section, null, FileName); + WritePrivateProfileSection(Section, "", FileName); } /// diff --git a/IobConf.Core/IobConf.Core.csproj b/IobConf.Core/IobConf.Core.csproj index 7361855e..d36839cf 100644 --- a/IobConf.Core/IobConf.Core.csproj +++ b/IobConf.Core/IobConf.Core.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/IobConf.Core/IobConfTree.cs b/IobConf.Core/IobConfTree.cs index 7c76ca94..d169220a 100644 --- a/IobConf.Core/IobConfTree.cs +++ b/IobConf.Core/IobConfTree.cs @@ -19,7 +19,9 @@ namespace IobConf.Core /// Init classe configurazione /// public IobConfTree() - { } + { + Log = LogManager.GetCurrentClassLogger(); + } /// /// Restituisce un oggetto di conf leggendo INI ed effettuando conversione @@ -33,8 +35,8 @@ namespace IobConf.Core { // leggo file INI IniFile fIni = new IniFile(iniFilePath); - string codIob= Path.GetFileNameWithoutExtension(iniFilePath); - + string codIob = Path.GetFileNameWithoutExtension(iniFilePath); + // effettuo conversione... // Dati generali (vendor, modello...) @@ -46,13 +48,13 @@ namespace IobConf.Core // tipo adapter// verifico tipo adapter try { - newConfObj.IobType = (AdapterType)Enum.Parse(typeof(AdapterType), fIni.ReadString("IOB", "CNCTYPE", "ND")); + newConfObj.IobType = (AdapterType)Enum.Parse(typeof(AdapterType), fIni.ReadString("IOB", "CNCTYPE", "ND")); } catch (Exception exc) { newConfObj.IobType = AdapterType.ND; string rawVal = fIni.ReadString("IOB", "CNCTYPE", "DEMO"); - //newConfObj.lgError($"Eccezione in conversione tipo adapter: richiesto {rawVal} | tipo non codificato...{Environment.NewLine}{exc}"); + newConfObj.lgError($"Eccezione in conversione tipo adapter: richiesto {rawVal} | tipo non codificato...{Environment.NewLine}{exc}"); } newConfObj.GeneralCom = (ComLayer)Enum.Parse(typeof(ComLayer), fIni.ReadString("IOB", "CNCFAMILY", "ND")); @@ -72,16 +74,15 @@ namespace IobConf.Core newConfObj.TempoCiclo.MaxIncrPz = Convert.ToDouble(fIni.ReadString("OPTPAR", "TC_MAX_INCR", "5").Replace(".", ",")); // Server - string MpIp=fIni.ReadString("SERVER", "MPIP", "::1"); + string MpIp = fIni.ReadString("SERVER", "MPIP", "::1"); if (!string.IsNullOrEmpty(MpIp)) { newConfObj.ServerMES.Transport = MpIp.StartsWith("https://") ? "https" : "http"; newConfObj.ServerMES.IpAddr = MpIp.Replace($"{newConfObj.ServerMES.Transport}://", ""); // tolgo http/https... } - //newConfObj.ServerMES.Commands.Alive - + // Altro (versione, ...) - newConfObj.ReleaseVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + newConfObj.ReleaseVers = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"; newConfObj.IobManConf.MinDeltaSec = fIni.ReadInteger("IOB", "MinDeltaSec", 6); // OptPar @@ -101,7 +102,7 @@ namespace IobConf.Core } catch (Exception exc) { - //newConfObj.lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc)); + newConfObj.lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc)); } } // riordino alfabeticamente diff --git a/IobConf.UI/IobConf.UI.csproj b/IobConf.UI/IobConf.UI.csproj index 9e8176b4..e47e885a 100644 --- a/IobConf.UI/IobConf.UI.csproj +++ b/IobConf.UI/IobConf.UI.csproj @@ -9,7 +9,7 @@ <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS01.pubxml" /> <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS02.pubxml" /> - <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS03.pubxml" /> + <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS04.pubxml" /> diff --git a/MP-IOC.sln b/MP-IOC.sln new file mode 100644 index 00000000..a64b294c --- /dev/null +++ b/MP-IOC.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.IOC", "MP.IOC\MP.IOC.csproj", "{B9F508BF-8503-4C25-B9BA-0FAC411C44C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0C7A1E7-6E5F-41BA-8ED0-C4A6C581C1B3}.Release|Any CPU.Build.0 = Release|Any CPU + {B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9F508BF-8503-4C25-B9BA-0FAC411C44C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8030DF52-992F-46A3-A9F1-5FF64A9D5D9D} + EndGlobalSection +EndGlobal diff --git a/MP.Data/Conf/RecipeBlockConfig.cs b/MP.Data/Conf/RecipeBlockConfig.cs new file mode 100644 index 00000000..b960fabc --- /dev/null +++ b/MP.Data/Conf/RecipeBlockConfig.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace MP.Data.Conf +{ + /// + /// Configurazione blocco ricetta (Header / Rows) + /// + public class RecipeBlockConfig + { + #region Public Properties + + /// + /// Dizionario degli enum permessi + /// + public Dictionary> EnumVal { get; set; } = new Dictionary>(); + + /// + /// Dizionario delle chiavi, differenziate dai primi caratteri: + /// C: --> Calcolato + /// E: --> Enum: modificabile ma da dizionario valori seguente + /// F: --> Fixed (NON modificabile) "" --> editabile + /// + public Dictionary ListKeys { get; set; } = new Dictionary(); + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/Conf/RecipeConfig.cs b/MP.Data/Conf/RecipeConfig.cs new file mode 100644 index 00000000..c6744cbd --- /dev/null +++ b/MP.Data/Conf/RecipeConfig.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Data.Conf +{ + public class RecipeConfig + { + /// + /// File di configurazione template ricetta + /// + public string TemplateFile { get; set; } = ""; + + /// + /// Numero di righe da creare x ricetta + /// + public int NumRow { get; set; } = 1; + + /// + /// Configurazione ricetta x header + /// + public RecipeBlockConfig HeadConf { get; set; } = new RecipeBlockConfig(); + + /// + /// Configurazione ricetta x rows + /// + public RecipeBlockConfig RowsConf { get; set; } = new RecipeBlockConfig(); + + } +} diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs new file mode 100644 index 00000000..9b52a93a --- /dev/null +++ b/MP.Data/Controllers/MpIocController.cs @@ -0,0 +1,391 @@ +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; +using NLog; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Data.Controllers +{ + public class MpIocController : IDisposable + { + #region Public Constructors + + public MpIocController(IConfiguration configuration) + { + _configuration = configuration; + Log.Info("Avviata classe MpIocController"); + } + + #endregion Public Constructors + + #region Public Methods + + + /// + /// Elenco da tabella Config + /// + /// + public List ConfigGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetConfig + .AsNoTracking() + .OrderBy(x => x.Chiave) + .ToList(); + } + return dbResult; + } + + /// + /// Update record config + /// + /// + public bool ConfigUpdate(ConfigModel updRec) + { + bool fatto = false; + ConfigModel dbResult = new ConfigModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetConfig + .Where(x => x.Chiave == updRec.Chiave) + .FirstOrDefault(); + if (dbResult != null) + { + dbResult.Valore = updRec.Valore; + dbCtx.SaveChanges(); + fatto = true; + } + } + return fatto; + } + + /// + /// Intera tab dati macchina + /// + /// + public List DatiMacchineGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetDatiMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + + public void Dispose() + { + _configuration = null; + } + + + /// + /// Aggiunta record EventList + /// + /// + /// + public async Task EvListInsert(EventListModel newRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currRec = dbCtx + .DbSetEvList + .Add(newRec); + await dbCtx.SaveChangesAsync(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante EvListInsert{Environment.NewLine}{exc}"); + } + } + await Task.Delay(1); + return fatto; + } + + /// + /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione) + /// + /// Data massima x eventi + /// Data minima x eventi + /// * = tutte, altrimenti solo x una data macchina + /// *=tutti, altrimenti solo selezionato + /// numero massimo record da restituire + /// + public List FluxLogGetLastFilt(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .AsNoTracking() + .Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux)) + .OrderByDescending(x => x.dtEvento) + .Take(MaxRec) + .ToList(); + } + return dbResult; + } + + public bool KeepAliveUpsert(string IdxMacc, DateTime OraServer, DateTime OraMacc) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var currRec = dbCtx + .DbSetKeepAlive + .Where(x => x.IdxMacchina == IdxMacc) + .FirstOrDefault(); + if (currRec != null) + { + currRec.DataOraServer = OraServer; + currRec.DataOraMacchina = OraMacc; + dbCtx.Entry(currRec).State = EntityState.Modified; + } + else + { + KeepAliveModel newRec = new KeepAliveModel() + { + IdxMacchina = IdxMacc, + DataOraMacchina = OraMacc, + DataOraServer = OraServer, + DataOraStart = DateTime.Now + }; + dbCtx + .DbSetKeepAlive + .Add(newRec); + } + dbCtx.SaveChanges(); + fatto = true; + } + return fatto; + } + + + public List ListLinkFilt(string tipoLink) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetLinkMenu + .Where(x => x.TipoLink == tipoLink) + .AsNoTracking() + .OrderBy(x => x.ordine) + .ToList(); + } + return dbResult; + } + + /// + /// Intera tabella relazione master/slave in machine (gestione setup master --> slave) + /// + /// + public List Macchine2Slave() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetM2S + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco da tabella Macchine + /// + /// + /// + public List MacchineGetFilt(string codGruppo) + { + List dbResult = new List(); + try + { + using (var dbCtx = new MoonProContext(_configuration)) + { + if (codGruppo == "*") + { + dbResult = dbCtx + .DbSetMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetGrp2Macc + .Where(g => g.CodGruppo == codGruppo) + .Join(dbCtx.DbSetMacchine, + g => g.IdxMacchina, + m => m.IdxMacchina, + (g, m) => m + ) + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}"); + } + return dbResult; + } + + /// + /// Elenco da tabella MappaStatoExpl + /// + /// + public List MseGetAll(int maxAge = 2000) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge); + + dbResult = dbCtx + .DbSetMSE + .FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Annulla modifiche su una specifica entity (cancel update) + /// + /// + /// + public bool RollBackEntity(object item) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified) + { + dbCtx.Entry(item).Reload(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}"); + } + } + return answ; + } + + /// + /// Intera tabella relazione master/slave in machine (gestione setup master --> slave) + /// + /// + public List StateMachineIngressi(int idxFam) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam); + dbResult = dbCtx + .DbSetSMI + .FromSqlRaw("exec dbo.stp_TRI_getByIdxFamIng @IdxFamigliaIngresso", IdxFamIn) + .AsNoTracking() + .AsEnumerable() + .ToList(); + } + return dbResult; + } + + /// + /// Stato prod macchina + /// + /// + /// + public StatoProdModel StatoProdMacchina(string idxMacchina) + { + StatoProdModel dbResult = new StatoProdModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + dbResult = dbCtx + .DbSetStatoProd + .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina) + .AsNoTracking() + .FirstOrDefault(); + } + return dbResult; + } + + /// + /// Intera vista v_MSFD + /// + /// + public List VMSFDGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetMSFD + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + + /// + /// Vista v_MSFD CALCOALTA x singola macchina (da stored) - singolo record + /// + /// + public List VMSFDGetByMacc(string idxMacc) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc); + + dbResult = dbCtx + .DbSetMSFD + .FromSqlRaw("exec dbo.stp_MSFD_getMacc @IdxMacchina", IdxMacchina) + .AsNoTracking() + .AsEnumerable() + .ToList(); + } + return dbResult; + } + + #endregion Public Methods + + #region Private Fields + + private static IConfiguration _configuration; + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP.Data/Controllers/MpMongoController.cs b/MP.Data/Controllers/MpMongoController.cs new file mode 100644 index 00000000..939a5768 --- /dev/null +++ b/MP.Data/Controllers/MpMongoController.cs @@ -0,0 +1,209 @@ +using Microsoft.Extensions.Configuration; +using NLog; +using NLog.Fluent; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDB.Bson; +using MP.Data.MgModels; +using System.IO; +using MP.Data.Conf; +using Newtonsoft.Json; +using static MP.Data.MgModels.RecipeModel; + +namespace MP.Data.Controllers +{ + public class MpMongoController : IDisposable + { + + public MpMongoController(IConfiguration configuration) + { + _configuration = configuration; + string mongoConf = _configuration.GetConnectionString("mdbConnString"); + client = new MongoClient(mongoConf); + mongoDb = client.GetDatabase("MAPO"); + Log.Info("Avviata classe MpMongoController"); + } + /// + /// Database corrente MongoDB + /// + private IMongoDatabase mongoDb; + + public void Dispose() + { + client = null; + _configuration = null; + } + + /// + /// Ricerca ricetta su MongoDB dato PODL + /// + /// + /// + public async Task RecipeGetByPODL(int idxPODL) + { + await Task.Delay(1); + RecipeModel answ = new RecipeModel(); + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("IdxPODL", idxPODL); + var collectionData = mongoDb.GetCollection("RecipeArchive"); + // recupero + answ = collectionData.Find(filter).Project("{_id: 0}").FirstOrDefault(); + } + catch + { } + return answ; + } + + /// + /// Ricerca ricetta su MongoDB dato ID MongoDB + /// + /// + /// + public async Task RecipeGetByID(string mID) + { + await Task.Delay(1); + RecipeModel answ = new RecipeModel(); + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("_id", mID); + var collectionData = mongoDb.GetCollection("RecipeArchive"); + // recupero + answ = collectionData.Find(filter).Project("{_id: 0}").FirstOrDefault(); + } + catch + { } + return answ; + } + /// + /// Salva ricetta su MongoDB + /// + /// + /// + public async Task RecipeSetByPODL(RecipeModel currRecord) + { + await Task.Delay(1); + bool answ = false; + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("IdxPODL", currRecord.IdxPODL); + var collectionData = mongoDb.GetCollection("RecipeArchive"); + // elimino old + collectionData.DeleteMany(filter); + // aggiungo + collectionData.InsertOne(currRecord); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RecipeSetByPODL{Environment.NewLine}{exc}"); + } + + return answ; + } + + /// + /// Init ricetta dato PODL + conf + /// + /// + /// + /// + /// + public RecipeModel InitRecipe(string confPath, int idxPODL, Dictionary CalcArgs) + { + RecipeModel answ = new RecipeModel(); + // per prima cosa leggo file di conf x inizializzare ricetta... + string fullPath = RecipePath(confPath); + bool fileOk = File.Exists(fullPath); + if (fileOk) + { + string rawData = File.ReadAllText(fullPath); + var currRecipe = JsonConvert.DeserializeObject(rawData); + // inizializzo dalla conf... + answ = new RecipeModel(idxPODL, currRecipe, CalcArgs); + } + + return answ; + } + + + /// + /// Ricetta in formato calcolato (string) + /// + public string CalcRecipe(RecipeModel currRecipe) + { + string answ = ""; + // per prima cosa leggo file di conf x inizializzare ricetta... + string fullPath = RecipePath(currRecipe.TemplateFile); + bool fileOk = File.Exists(fullPath); + if (fileOk) + { + // preparo dati header + var headStrings = currRecipe.HeadVal.Select(x => $"\"{x.Key}\": \"{x.Value}\"").ToList(); + string headVals = string.Join(",", headStrings); + + + // leggo template + string rawData = File.ReadAllText(fullPath); + // recupero configurazione x inizio/fine righe + string[] righe = rawData.Split(Environment.NewLine); + List righeRed = new List(); + string sRow = ""; + string eRow = ""; + foreach (var riga in righe) + { + if (riga.Trim().StartsWith("||SROW:")) + { + sRow = riga.Trim().Replace("||SROW:", "").Replace("||", ""); + } + else if (riga.Trim().StartsWith("||EROW:")) + { + eRow = riga.Trim().Replace("||EROW:", "").Replace("||", ""); + } + else + { + righeRed.Add(riga); + } + } + // rigenero righe senza le parti da ripetere... + rawData = string.Join(Environment.NewLine, righeRed); + // effettuo sostituzione... + answ = rawData.Replace("||PlaceholderHeader||", headVals); + // per le righe prima calcolo blocchi ripetuti + List rowComp = new List(); + foreach (var item in currRecipe.RowsVal) + { + var rowsStrings = item.Value.Select(x => $"\"{x.Key}\": \"{x.Value}\"").ToList(); + rowComp.Add($"{sRow}{string.Join(",", rowsStrings)}{eRow}"); + } + string rowsVals = string.Join($",{Environment.NewLine}", rowComp); + //...poi sostituisco + answ = answ.Replace("||PlaceholderRows||", rowsVals); + } + return answ; + } + + + private MongoClient client = new MongoClient("mongodb://localhost:27017"); + + private static IConfiguration _configuration; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + public static string RecipePath(string ruleName) + { + return string.Format($"Recipe/{ruleName}"); + } + + } +} diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 3f8b3c6d..a05153ba 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -294,6 +294,24 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Intera tab dati macchina + /// + /// + public List DatiMacchineGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetDatiMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + public void Dispose() { _configuration = null; @@ -348,8 +366,8 @@ namespace MP.Data.Controllers .AsNoTracking() .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodArticolo == "*" || x.CodArticolo == CodArticolo) && (x.DtRif >= DtStart && x.DtRif <= DtEnd)) .Include(m => m.MachineNav) - //.Include(o => o.OdlNav) .Include(a => a.ArticoloNav) + ////.Include(o => o.OdlNav) .OrderByDescending(x => x.DtRif) .ToList(); } @@ -571,7 +589,7 @@ namespace MP.Data.Controllers /// Elenco TUTTI GLI ODL /// /// - public List ListOdlAll() + public List OdlListAll() { List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) @@ -619,24 +637,8 @@ namespace MP.Data.Controllers .DbSetODLExp .FromSqlRaw("EXEC stp_ODL_getByFiltSpec @InCorso, @CodArt, @KeyRich, @CodGruppo, @IdxMacchina, @DataFrom, @DataTo", InCorso, CodArt, KeyRich, CodGruppo, IdxMacc, DataFrom, DataTo) .AsNoTracking() - //.AsEnumerable() .ToList(); -#if false - dbResult = dbCtx - .DbSetODL - .Where(x => ((inCorso && x.DataFine == null) || ((!inCorso && x.DataFine != null) - && x.DataInizio >= startDate && x.DataInizio <= endDate)) - && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") - //&& (x.MachineNav.Contains(IdxMacchina) || Reparto == "*") - && (x.IdxMacchina.Contains(IdxMacchina) || IdxMacchina == "*") - && (codArt == "*" || x.CodArticolo.Contains(codArt))) - .AsNoTracking() - .Include(m => m.MachineNav) - .Include(a => a.ArticoloNav) - .OrderByDescending(x => x.IdxOdl) - .ToList(); -#endif } return dbResult; } @@ -656,14 +658,14 @@ namespace MP.Data.Controllers { var Lanc = new SqlParameter("@Lanciato", lanciato); var KeyRich = new SqlParameter("@KeyRich", keyRichPart); - var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); var CodGrp = new SqlParameter("@CodGruppo", codGruppo); - var DateFrom = new SqlParameter("@DateFrom", startDate); - var DateTo = new SqlParameter("@DateTo", endDate); + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var DateFrom = new SqlParameter("@DtInizio", startDate); + var DateTo = new SqlParameter("@DtFine", endDate); dbResult = dbCtx .DbSetPODLExp - .FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DateFrom, @DateTo", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo) + .FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo) .AsNoTracking() .ToList(); } @@ -699,31 +701,38 @@ namespace MP.Data.Controllers public List MacchineGetFilt(string codGruppo) { List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) + try { - if (codGruppo == "*") + using (var dbCtx = new MoonProContext(_configuration)) { - dbResult = dbCtx - .DbSetMacchine - .AsNoTracking() - .OrderBy(x => x.IdxMacchina) - .ToList(); - } - else - { - dbResult = dbCtx - .DbSetGrp2Macc - .Where(g => g.CodGruppo == codGruppo) - .Join(dbCtx.DbSetMacchine, - g => g.IdxMacchina, - m => m.IdxMacchina, - (g, m) => m - ) - .AsNoTracking() - .OrderBy(x => x.IdxMacchina) - .ToList(); + if (codGruppo == "*") + { + dbResult = dbCtx + .DbSetMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetGrp2Macc + .Where(g => g.CodGruppo == codGruppo) + .Join(dbCtx.DbSetMacchine, + g => g.IdxMacchina, + m => m.IdxMacchina, + (g, m) => m + ) + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } } } + catch (Exception exc) + { + Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}"); + } return dbResult; } @@ -821,32 +830,6 @@ namespace MP.Data.Controllers return dbResult; } -#if false - - /// - /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) - /// - /// Cod articolo - /// KeyRich (parziale) da cercare (es cod stato x yacht) - /// - public List ListPODLFiltNOOdl(string codArt, string keyRichPart) - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetPODL - .Where(x => (x.IdxOdl != 0) && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") && (codArt == "*" || x.CodArticolo.Contains(codArt))) - .AsNoTracking() - .Include(m => m.MachineNav) - .Include(a => a.ArticoloNav) - .OrderByDescending(x => x.InsertDate) - .ToList(); - } - return dbResult; - } -#endif - /// /// Chiusura ODL con eventuale conferma pezzi /// @@ -1027,6 +1010,7 @@ namespace MP.Data.Controllers .DbSetPODL .AsNoTracking() .Where(x => x.IdxPromessa == idxPODL) + .Include(a => a.ArticoloNav) .FirstOrDefault(); } catch (Exception exc) @@ -1073,7 +1057,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note) + public async Task PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note, DateTime dtEvent) { bool answ = false; @@ -1115,9 +1099,10 @@ namespace MP.Data.Controllers var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich); var PzPallet = new SqlParameter("@PzPallet", pzPallet); var Note = new SqlParameter("@Note", note); + var DtEvento = new SqlParameter("@dtEvento", dtEvent); var callResult = await dbCtx .Database - .ExecuteSqlRawAsync("EXEC stp_ODL_inizioSetupPromessa @idxPromessa, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note", IdxPromessa, MatrOpr, IdxMacchina, TCRichAttr, PzPallet, Note); + .ExecuteSqlRawAsync("EXEC stp_ODL_inizioSetupPromessa @idxPromessa, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note, @dtEvento", IdxPromessa, MatrOpr, IdxMacchina, TCRichAttr, PzPallet, Note, DtEvento); answ = true; } @@ -1131,6 +1116,41 @@ namespace MP.Data.Controllers return answ; } + /// + /// Chiamata salvataggio ricetta su DB + /// + /// + /// + /// + public async Task PODL_updateRecipe(int idxPODL, string recipeName) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currRec = dbCtx + .DbSetPODL + .Where(x => x.IdxPromessa == idxPODL) + .FirstOrDefault(); + + if (currRec != null) + { + currRec.Recipe = recipeName; + dbCtx.Entry(currRec).State = EntityState.Modified; + await dbCtx.SaveChangesAsync(); + answ = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODL_updateRecipe{Environment.NewLine}{exc}"); + } + } + await Task.Delay(1); + return answ; + } + /// /// Eliminazione Record /// diff --git a/MP.Data/DatabaseModels/DatiMacchineModel.cs b/MP.Data/DatabaseModels/DatiMacchineModel.cs new file mode 100644 index 00000000..329a6a1f --- /dev/null +++ b/MP.Data/DatabaseModels/DatiMacchineModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace MP.Data.DatabaseModels +{ + public partial class DatiMacchineModel + { + public string IdxMacchina { get; set; } + public bool? PalletChange { get; set; } + public string CodArticoloA { get; set; } + public string CodArticoloB { get; set; } + public string SerialPort { get; set; } + public int? RefreshPeriod { get; set; } + public bool? Simulazione { get; set; } + public bool? SimplePallet { get; set; } + /// + /// definisce se l'INSERT sia abilitato per la macchina (disabilitato in fase di ricostruzione batch...) + /// + public bool? InsEnabled { get; set; } + /// + /// definisce se sia abilitata la registrazione di TUTTI gli invii di dati in ingresso da questa specifica macchina + /// + public bool SLogEnabled { get; set; } + /// + /// Abilita o meno il trigger su DiarioDiBordo x ricalcolo eventi + /// + public bool? IsTrigerDbon { get; set; } + /// + /// Indica se la macchina abbia un COUNTER (assoluto) o meno, tipicamente true x IOB-WIN, false per IOB-PI + /// + public bool HasCounter { get; set; } + } +} diff --git a/MP.Data/DatabaseModels/KeepAliveModel.cs b/MP.Data/DatabaseModels/KeepAliveModel.cs new file mode 100644 index 00000000..a30ac535 --- /dev/null +++ b/MP.Data/DatabaseModels/KeepAliveModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace MP.Data.DatabaseModels +{ + public partial class KeepAliveModel + { + public string IdxMacchina { get; set; } + public DateTime? DataOraServer { get; set; } + public DateTime? DataOraMacchina { get; set; } + public DateTime? DataOraStart { get; set; } + } +} diff --git a/MP.Data/DatabaseModels/Macchine.cs b/MP.Data/DatabaseModels/Macchine.cs index a2bbcc56..5cd3c9ac 100644 --- a/MP.Data/DatabaseModels/Macchine.cs +++ b/MP.Data/DatabaseModels/Macchine.cs @@ -17,9 +17,44 @@ namespace MP.Data.DatabaseModels [Key] public string IdxMacchina { get; set; } + /// + /// Cod macchina + /// public string CodMacchina { get; set; } = ""; + /// + /// Nome macchina + /// public string Nome { get; set; } = ""; + /// + /// Descrizione macchina + /// public string Descrizione { get; set; } = ""; + /// + /// Patch del file json di configurazione di una ricetta + /// + public string RecipePath { get; set; } = ""; + /// + /// Path (assoluto!) dell'archivio ricette da impiegare + /// + public string RecipeArchivePath { get; set; } = ""; + + /// + /// Indica se abbia ricetta calcolata + /// + [NotMapped] + public bool hasRecipeCalc + { + get => !string.IsNullOrEmpty(RecipePath); + } + /// + /// Indica se abbia ricetta calcolata + /// + [NotMapped] + public bool hasRecipeArch + { + get => !string.IsNullOrEmpty(RecipeArchivePath); + } + //public string Note { get; set; } = ""; //public string url { get; set; } = ""; //public string locazione { get; set; } = ""; diff --git a/MP.Data/DatabaseModels/Macchine2SlaveModel.cs b/MP.Data/DatabaseModels/Macchine2SlaveModel.cs new file mode 100644 index 00000000..6643c7d0 --- /dev/null +++ b/MP.Data/DatabaseModels/Macchine2SlaveModel.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace MP.Data.DatabaseModels +{ + public partial class Macchine2SlaveModel + { + public string IdxMacchina { get; set; } + public string IdxMacchinaSlave { get; set; } + } +} diff --git a/MP.Data/DatabaseModels/MappaStatoExpl.cs b/MP.Data/DatabaseModels/MappaStatoExpl.cs index 09149dd4..34052fb4 100644 --- a/MP.Data/DatabaseModels/MappaStatoExpl.cs +++ b/MP.Data/DatabaseModels/MappaStatoExpl.cs @@ -15,7 +15,8 @@ namespace MP.Data.DatabaseModels public string CodMacchina { get; set; } public string Nome { get; set; } public string Url { get; set; } - public int? IdxOdl { get; set; } + public int? IdxOdl { get; set; } = 0; + public int? IdxPOdl { get; set; } = 0; public string CodArticolo { get; set; } public string Disegno { get; set; } public int? NumPezzi { get; set; } diff --git a/MP.Data/DatabaseModels/PODLExpModel.cs b/MP.Data/DatabaseModels/PODLExpModel.cs index 849fb33d..ff1c3cfc 100644 --- a/MP.Data/DatabaseModels/PODLExpModel.cs +++ b/MP.Data/DatabaseModels/PODLExpModel.cs @@ -38,6 +38,8 @@ namespace MP.Data.DatabaseModels [MaxLength(50)] public string CodCli { get; set; } = ""; public DateTime InsertDate { get; set; } = DateTime.Now; + [MaxLength(500)] + public string Recipe { get; set; } = ""; [NotMapped] public string CodFase diff --git a/MP.Data/DatabaseModels/PODLModel.cs b/MP.Data/DatabaseModels/PODLModel.cs index 2575e287..668fbb87 100644 --- a/MP.Data/DatabaseModels/PODLModel.cs +++ b/MP.Data/DatabaseModels/PODLModel.cs @@ -39,6 +39,8 @@ namespace MP.Data.DatabaseModels [MaxLength(50)] public string CodCli { get; set; } = ""; public DateTime InsertDate { get; set; } = DateTime.Now; + [MaxLength(500)] + public string Recipe { get; set; } = ""; [NotMapped] public string CodFase diff --git a/MP.Data/DatabaseModels/TransizioneIngressiModel.cs b/MP.Data/DatabaseModels/TransizioneIngressiModel.cs new file mode 100644 index 00000000..72e3ad15 --- /dev/null +++ b/MP.Data/DatabaseModels/TransizioneIngressiModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace MP.Data.DatabaseModels +{ + public partial class TransizioneIngressiModel + { + public int IdxFamigliaIngresso { get; set; } + public int IdxMicroStato { get; set; } + public int ValoreIngresso { get; set; } + public int? IdxTipoEvento { get; set; } + public int NextIdxMicroStato { get; set; } + } +} diff --git a/MP.Data/DatabaseModels/VMSFDModel.cs b/MP.Data/DatabaseModels/VMSFDModel.cs new file mode 100644 index 00000000..f9745bbf --- /dev/null +++ b/MP.Data/DatabaseModels/VMSFDModel.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +namespace MP.Data.DatabaseModels +{ + public partial class VMSFDModel + { + public string IdxMacchina { get; set; } + public string Codmacchina { get; set; } + public bool PalletChange { get; set; } + public string CodArticoloA { get; set; } + public string CodArticoloB { get; set; } + public bool SimplePallet { get; set; } + public bool InsEnabled { get; set; } + public bool SLogEnabled { get; set; } + public int IdxFamigliaIngresso { get; set; } + public int Multi { get; set; } + public int BitFilt { get; set; } + public int MaxVal { get; set; } + public int Bsr { get; set; } + public bool ExplodeBit { get; set; } + public int NumBit { get; set; } + public int IdxMicroStato { get; set; } + public int IdxFamiglia { get; set; } + public int IdxStato { get; set; } + public string LastVal { get; set; } + public string CodArticolo { get; set; } + public double TempoCicloBase { get; set; } + public int PzPalletProd { get; set; } + public int MatrOpr { get; set; } + public string Pallet { get; set; } + public string CodMaccArticolo { get; set; } + } +} diff --git a/MP.Data/MP.Data.csproj b/MP.Data/MP.Data.csproj index 83d8498c..1086aa2d 100644 --- a/MP.Data/MP.Data.csproj +++ b/MP.Data/MP.Data.csproj @@ -26,6 +26,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + \ No newline at end of file diff --git a/MP.Data/MgModels/RecipeModel.cs b/MP.Data/MgModels/RecipeModel.cs new file mode 100644 index 00000000..1e64f17d --- /dev/null +++ b/MP.Data/MgModels/RecipeModel.cs @@ -0,0 +1,283 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MP.Data.Conf; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + +namespace MP.Data.MgModels +{ + [BsonIgnoreExtraElements] + public class RecipeModel + { + #region Public Constructors + + /// + /// Init vuoto + /// + public RecipeModel() + { } + + /// + /// Init da configurazione di base + /// + /// idx PODL + /// + /// Dizionario argomenti x decodifica (es cod articolo, descrizione...) + public RecipeModel(int IdxPODL, RecipeConfig OrigConfig, Dictionary CalcArgs) + { + this.IdxPODL = IdxPODL; + this.TemplateFile = OrigConfig.TemplateFile; + this.HeadConf = OrigConfig.HeadConf; + this.RowsConf = OrigConfig.RowsConf; + // init oggetti tipizzati da valori conf ricevuti + this.HeadVal = ElementConverter(this.HeadConf.ListKeys, CalcArgs); + // aggiungo args x gestione contatori righe... + CalcArgs.Add("RowNum", $"0"); + CalcArgs.Add("RowTot", $"{OrigConfig.NumRow}"); + // aggiungo righe elementi.. + for (int i = 1; i <= OrigConfig.NumRow; i++) + { + // valore calcolato numero riga gestito ad ogni iterazione + CalcArgs["RowNum"] = $"{i}"; + this.RowsVal.Add($"{i}", ElementConverter(this.RowsConf.ListKeys, CalcArgs)); + } + } + /// + /// Aggiunta righe + /// + /// + public List getNewRow(Dictionary CalcArgs) + { + List rowList = new List(); + rowList = ElementConverter(this.RowsConf.ListKeys, CalcArgs); + return rowList; + } + + #endregion Public Constructors + + #region Public Properties + +#if false + /// + /// Ricetta in formato calcolato (string) + /// + public string CalcRecipe { get; set; } = ""; +#endif + + /// + /// Configurazione ricetta x header + /// + public RecipeBlockConfig HeadConf { get; set; } = new RecipeBlockConfig(); + + /// + /// Lista element x testata ricetta + /// + public List HeadVal { get; set; } = new List(); + + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string? Id { get; set; } + + /// + /// idx ODL di riferimento + /// + public int IdxODL { get; set; } = 0; + + /// + /// Idx PODL di riferimento + /// + public int IdxPODL { get; set; } = 0; + + /// + /// Configurazione ricetta x rows + /// + public RecipeBlockConfig RowsConf { get; set; } = new RecipeBlockConfig(); + + /// + /// Dizionario di righe, ognuna come Lista element + /// + public Dictionary> RowsVal { get; set; } = new Dictionary>(); + + /// + /// File di configurazione template ricetta + /// + public string TemplateFile { get; set; } = ""; + + #endregion Public Properties + + #region Public Methods + + /// + /// Converte il dizionario in List Element + /// + public static List ElementConverter(Dictionary ListKeys, Dictionary CalcArgs) + { + List ListObj = ListKeys + .Select(x => new Element(x.Key, x.Value, CalcArgs)) + .ToList(); + return ListObj; + } + + #endregion Public Methods + + #region Public Classes + + /// + /// Elemento unitario con cui costruire la ricetta + /// + public class Element + { + #region Public Constructors + + /// + /// Init classe da valore kvp + /// + /// Chiave item + /// Valore grezzo item + public Element(string rawKey, string rawVal, Dictionary CalcArgs) + { + this.Key = rawKey; + this.OrigVal = rawVal; + this.Value = rawVal; + // cerco se ho uno dei 3 caratteri (C/E/F/S): + if (rawVal.Length >= 2 && rawVal.Substring(1, 1) == ":") + { + string selTipo = rawVal.Substring(0, 2); + switch (selTipo) + { + case "C:": + this.Type = KeyType.Calc; + // recupero item x ricerca in dizionario... + string cKey = rawVal.Substring(2); + if (CalcArgs.ContainsKey(cKey)) + { + this.Value = CalcArgs[cKey]; + } + else + { + this.Value = cKey; + } + break; + + case "E:": + this.Type = KeyType.Enum; + this.Value = ""; + this.EnumType = rawVal.Substring(2); + break; + + case "F:": + this.Type = KeyType.Fixed; + this.Value = rawVal.Substring(2); + break; + + case "S:": + this.Type = KeyType.Calc; + // recupero item x ricerca in dizionario... + string sKey = rawVal.Substring(2); + if (CalcArgs.ContainsKey(sKey)) + { + this.Value = CalcArgs[sKey]; + } + else + { + this.Value = sKey; + } + break; + + default: + this.Type = KeyType.None; + break; + } + } + else + { + this.Type = KeyType.Free; + } + } + + #endregion Public Constructors + + + public override bool Equals(object obj) + { + if (!(obj is Element item)) + return false; + + if (Key != item.Key) + return false; + + if (Value != item.Value) + return false; + + if (OrigVal != item.OrigVal) + return false; + + if (Type != item.Type) + return false; + + if (EnumType != item.EnumType) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #region Public Enums + + /// + /// Tipi di valore ammessi + /// + public enum KeyType + { + None = 0, + /// + /// Campo calcolato (NON modificabile) + /// + Calc, + /// + /// Valore da Enum + /// + Enum, + /// + /// Valore fisso + /// + Fixed, + /// + /// Valore libero + /// + Free, + /// + /// Campo suggerito (=calcolato modificabile) + /// + Suggested + } + + #endregion Public Enums + + #region Public Properties + + [NotMapped] + public string EnumType { get; set; } = ""; + + [NotMapped] + public string Key { get; set; } = ""; + + public string OrigVal { get; set; } = ""; + + [NotMapped] + public KeyType Type { get; set; } = KeyType.None; + + [NotMapped] + public string Value { get; set; } = ""; + + #endregion Public Properties + } + + #endregion Public Classes + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index c971d028..d25b9ddf 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -56,6 +56,11 @@ namespace MP.Data public virtual DbSet DbSetVocabolario { get; set; } public virtual DbSet DbOperatori { get; set; } public virtual DbSet DbSetGrp2Macc { get; set; } + public virtual DbSet DbSetDatiMacchine { get; set; } + public virtual DbSet DbSetMSFD { get; set; } + public virtual DbSet DbSetM2S { get; set; } + public virtual DbSet DbSetSMI { get; set; } + public virtual DbSet DbSetKeepAlive { get; set; } #endregion Public Properties @@ -322,6 +327,146 @@ namespace MP.Data }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdxMacchina); + + entity.ToTable("DatiMacchine"); + + entity.Property(e => e.IdxMacchina) + .HasMaxLength(50) + .HasColumnName("idxMacchina"); + + entity.Property(e => e.CodArticoloA) + .HasMaxLength(50) + .HasColumnName("CodArticolo_A"); + + entity.Property(e => e.CodArticoloB) + .HasMaxLength(50) + .HasColumnName("CodArticolo_B"); + + entity.Property(e => e.HasCounter) + .HasColumnName("hasCounter") + .HasComment("Indica se la macchina abbia un COUNTER (assoluto) o meno, tipicamente true x IOB-WIN, false per IOB-PI"); + + entity.Property(e => e.InsEnabled) + .HasColumnName("insEnabled") + .HasDefaultValueSql("((1))") + .HasComment("definisce se l'INSERT sia abilitato per la macchina (disabilitato in fase di ricostruzione batch...)"); + + entity.Property(e => e.IsTrigerDbon) + .IsRequired() + .HasColumnName("isTrigerDBOn") + .HasDefaultValueSql("((1))") + .HasComment("Abilita o meno il trigger su DiarioDiBordo x ricalcolo eventi"); + + entity.Property(e => e.PalletChange).HasColumnName("palletChange"); + + entity.Property(e => e.RefreshPeriod).HasColumnName("refreshPeriod"); + + entity.Property(e => e.SLogEnabled) + .HasColumnName("sLogEnabled") + .HasComment("definisce se sia abilitata la registrazione di TUTTI gli invii di dati in ingresso da questa specifica macchina"); + + entity.Property(e => e.SerialPort) + .HasMaxLength(50) + .HasColumnName("serialPort"); + + entity.Property(e => e.SimplePallet).HasColumnName("simplePallet"); + + entity.Property(e => e.Simulazione).HasColumnName("simulazione"); + }); + + + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_MSFD"); + + entity.Property(e => e.Bsr).HasColumnName("BSR"); + + entity.Property(e => e.CodArticolo) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.CodArticoloA) + .IsRequired() + .HasMaxLength(50) + .HasColumnName("CodArticolo_A"); + + entity.Property(e => e.CodArticoloB) + .IsRequired() + .HasMaxLength(50) + .HasColumnName("CodArticolo_B"); + + entity.Property(e => e.CodMaccArticolo) + .IsRequired() + .HasMaxLength(103); + + entity.Property(e => e.Codmacchina) + .IsRequired() + .HasMaxLength(50) + .HasColumnName("codmacchina"); + + entity.Property(e => e.IdxMacchina) + .IsRequired() + .HasMaxLength(50) + .HasColumnName("idxmacchina"); + + entity.Property(e => e.InsEnabled).HasColumnName("insEnabled"); + + entity.Property(e => e.LastVal) + .IsRequired() + .HasMaxLength(50) + .HasColumnName("lastVal"); + + entity.Property(e => e.Pallet) + .IsRequired() + .HasMaxLength(20) + .HasColumnName("pallet"); + + entity.Property(e => e.PalletChange).HasColumnName("palletChange"); + + entity.Property(e => e.SLogEnabled).HasColumnName("sLogEnabled"); + + entity.Property(e => e.SimplePallet).HasColumnName("simplePallet"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.IdxMacchinaSlave }) + .HasName("PK_Macc2Slave"); + + entity.ToTable("Macchine2Slave"); + + entity.Property(e => e.IdxMacchina).HasMaxLength(50); + + entity.Property(e => e.IdxMacchinaSlave).HasMaxLength(50); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxFamigliaIngresso, e.IdxMicroStato, e.ValoreIngresso }); + + entity.ToTable("TransizioneIngressi"); + + entity.Property(e => e.NextIdxMicroStato).HasColumnName("next_IdxMicroStato"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdxMacchina); + + entity.ToTable("KeepAlive"); + + entity.Property(e => e.IdxMacchina).HasMaxLength(50); + + entity.Property(e => e.DataOraMacchina).HasColumnType("datetime"); + + entity.Property(e => e.DataOraStart).HasColumnType("datetime"); + }); + OnModelCreatingPartial(modelBuilder); } diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index 7a400db0..77f04a19 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -1,4 +1,5 @@ using MP.Data.DatabaseModels; +using StackExchange.Redis; using System; using System.Collections.Generic; using System.ComponentModel; @@ -43,21 +44,89 @@ namespace MP.Data } /// - /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da - /// funzionalita' DbConfig) + keyName richiesto... + /// Hash dati STATUS x la macchina specificata /// - public static string RedHash(string keyName) + /// + /// + public static RedisKey dtMaccHash(string idxMacchina) { - string answ = keyName; - try + return (RedisKey)$"{redisBaseAddr}DtMac:{idxMacchina}"; + } + + public static string FormDurata(double durataMinuti) + { + string answ = ""; + TimeSpan tsDurata = TimeSpan.FromMinutes(durataMinuti); + if (tsDurata.TotalDays < 1) { - answ = $"MP:Data:{keyName}"; + answ = $"{tsDurata.Hours:00}h {tsDurata.Minutes:00}'"; + } + else + { + answ = $"{tsDurata.Days}gg {tsDurata.Hours:00}h"; } - catch - { } return answ; } + /// + /// RedisKey calcolata x tabella HSI + /// + /// + /// + public static RedisKey hSMI(int idxFamIn) + { + return (RedisKey)$"{redisBaseAddr}hSMI:{idxFamIn}"; + } + + /// + /// Inizializzazione con periodo e arrotondamento + /// + /// + /// + public static DateTime InitDatetime(DateTime dtRif, int minRound) + { + TimeSpan DayElapsed = dtRif.Subtract(dtRif.Date); + int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound; + DateTime endRounded = DateTime.Today.AddMinutes(minDay); + return endRounded; + } + + /// + /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato + /// dafunzionalita' DbConfig) + idxMacchina richiesto... + /// + /// + /// + public static RedisKey OptParHash(string idxMacchina) + { + return (RedisKey)$"{redisBaseAddr}OpPar:{idxMacchina}"; + } + + /// + /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da + /// funzionalita' DbConfig) + idxMacchina richiesto... + /// + public static RedisKey RedHash(string keyName) + { + return (RedisKey)$"MP:Data:{keyName}"; + } + + /// + /// Formato RedisKey delal chaive richeista (completa) + /// + public static RedisKey RedKeyHash(string keyName) + { + return (RedisKey)$"{redisBaseAddr}{keyName}"; + } + + /// + /// Formato RedisValue delal chaive richeista (completa) + /// + public static RedisValue RedValue(string keyName) + { + return (RedisValue)$"{redisBaseAddr}{keyName}"; + } + /// /// Effettua salvataggio in file di un generico oggetto in formato CSV /// @@ -78,36 +147,45 @@ namespace MP.Data await Task.Run(() => File.WriteAllLines(path, lines.ToArray())); } - /// - /// Inizializzazione con periodo e arrotondamento - /// - /// - /// - public static DateTime InitDatetime(DateTime dtRif, int minRound) - { - TimeSpan DayElapsed = dtRif.Subtract(dtRif.Date); - int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound; - DateTime endRounded = DateTime.Today.AddMinutes(minDay); - return endRounded; - } + #endregion Public Methods - public static string FormDurata(double durataMinuti) - { - string answ = ""; - TimeSpan tsDurata = TimeSpan.FromMinutes(durataMinuti); - if (tsDurata.TotalDays < 1) - { - answ = $"{tsDurata.Hours:00}h {tsDurata.Minutes:00}'"; - } - else - { - answ = $"{tsDurata.Days}gg {tsDurata.Hours:00}h"; - } - return answ; - } + #region Public Classes public class POdlExt { + #region Public Methods + + /// + /// Clona un POdleExt, tutti i valori (compreso idxOdl) + /// + /// + /// + public static PODLExpModel clone(PODLExpModel selRec, bool resetOdl) + { + // creo record duplicato... + PODLExpModel newRec = new PODLExpModel() + { + Attivabile = resetOdl ? false : selRec.Attivabile, + CodArticolo = selRec.CodArticolo, + CodCli = selRec.CodCli, + CodGruppo = selRec.CodGruppo, + DueDate = selRec.DueDate, + IdxMacchina = selRec.IdxMacchina, + IdxOdl = resetOdl ? 0 : selRec.IdxOdl, + IdxPromessa = 0, + InsertDate = selRec.InsertDate, + KeyBCode = selRec.KeyBCode, + KeyRichiesta = selRec.KeyRichiesta, + Note = $"DUPLICATED - {selRec.Note}", + NumPezzi = selRec.NumPezzi, + Priorita = selRec.Priorita, + PzPallet = selRec.PzPallet, + Tcassegnato = selRec.Tcassegnato, + Recipe = selRec.Recipe + }; + return newRec; + } + /// /// Clona un POdleExt a POdl /// @@ -133,42 +211,46 @@ namespace MP.Data NumPezzi = selRec.NumPezzi, Priorita = selRec.Priorita, PzPallet = selRec.PzPallet, - Tcassegnato = selRec.Tcassegnato + Tcassegnato = selRec.Tcassegnato, + Recipe = selRec.Recipe }; return newRec; } - /// - /// Clona un POdleExt, tutti i valori (compreso idxOdl) - /// - /// - /// - public static PODLExpModel clone(PODLExpModel selRec, bool resetOdl) - { - // creo record duplicato... - PODLExpModel newRec = new PODLExpModel() - { - Attivabile = selRec.Attivabile, - CodArticolo = selRec.CodArticolo, - CodCli = selRec.CodCli, - CodGruppo = selRec.CodGruppo, - DueDate = selRec.DueDate, - IdxMacchina = selRec.IdxMacchina, - IdxOdl = resetOdl ? 0 : selRec.IdxOdl, - IdxPromessa = 0, - InsertDate = selRec.InsertDate, - KeyBCode = selRec.KeyBCode, - KeyRichiesta = selRec.KeyRichiesta, - Note = $"DUPLICATED - {selRec.Note}", - NumPezzi = selRec.NumPezzi, - Priorita = selRec.Priorita, - PzPallet = selRec.PzPallet, - Tcassegnato = selRec.Tcassegnato - }; - return newRec; - } + #endregion Public Methods } - #endregion Public Methods + #endregion Public Classes + + #region Private Fields + + public const string redisActionReq = redisBaseAddr + "Action:Req"; + public const string redisAnagGruppi = redisBaseAddr + "Cache:AnagGruppi"; + public const string redisArtByDossier = redisBaseAddr + "Cache:ArtByDossier"; + public const string redisArtList = redisBaseAddr + "Cache:ArtList"; + public const string redisBaseAddr = "MP:"; + public const string redisConfKey = redisBaseAddr + "Cache:Config"; + public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac"; + public const string redisFluxByMac = redisBaseAddr + "Cache:FluxByMac"; + public const string redisFluxLogFilt = redisBaseAddr + "Cache:FluxLogFilt"; + public const string redisGiacenzaList = redisBaseAddr + "Cache:GiacenzaList"; + public const string redisMacByFlux = redisBaseAddr + "Cache:MacByFlux"; + public const string redisMacList = redisBaseAddr + "Cache:MacList"; + public const string redisMacRecipeConf = redisBaseAddr + "Cache:RecipeConf"; + public const string redisMacRecipePath = redisBaseAddr + "Cache:RecipePath"; + public const string redisOdlByBatch = redisXdlData + "OdlByBatch"; + public const string redisOdlCurrByMac = redisXdlData + "OdlByMac"; + public const string redisOdlList = redisXdlData + "OdlList"; + public const string redisParamPageExp = redisBaseAddr + "Cache:ParamPage"; + public const string redisPOdlByOdl = redisXdlData + "POdlByOdl"; + public const string redisPOdlByPOdl = redisXdlData + "POdlByPOdl"; + public const string redisPOdlList = redisXdlData + "POdlList"; + public const string redisRecipeConf = redisBaseAddr + "Cache:Recipe:Conf"; + public const string redisStatoCom = redisBaseAddr + "Cache:StatoCom"; + public const string redisTipoArt = redisBaseAddr + "Cache:TipoArt"; + public const string redisVocabolario = redisBaseAddr + "Cache:Vocabolario"; + public const string redisXdlData = redisBaseAddr + "Cache:XDL:"; + + #endregion Private Fields } } \ No newline at end of file diff --git a/MP.FileData/MP.FileData.csproj b/MP.FileData/MP.FileData.csproj index 287fa655..529ef021 100644 --- a/MP.FileData/MP.FileData.csproj +++ b/MP.FileData/MP.FileData.csproj @@ -5,19 +5,21 @@ - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index 3d658b8d..e0ed8811 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2302.2309 + 6.16.2306.915 @@ -18,10 +18,10 @@ - - + + - + diff --git a/MP.INVE/Properties/PublishProfiles/IIS03.pubxml b/MP.INVE/Properties/PublishProfiles/IIS04.pubxml similarity index 89% rename from MP.INVE/Properties/PublishProfiles/IIS03.pubxml rename to MP.INVE/Properties/PublishProfiles/IIS04.pubxml index fd9d1a6e..b86cfa44 100644 --- a/MP.INVE/Properties/PublishProfiles/IIS03.pubxml +++ b/MP.INVE/Properties/PublishProfiles/IIS04.pubxml @@ -8,11 +8,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121. true Release Any CPU - https://iis03.egalware.com/MP/INVE + https://iis04.egalware.com/MP/INVE false fd5b477e-96a4-42f6-b2e8-7fc221c9971c false - https://iis03.egalware.com:8172/MsDeploy.axd + https://iis04.egalware.com:8172/MsDeploy.axd Default Web Site/MP/INVE false diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 000ed40f..18eec117 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

Versione: 6.16.2302.2309

+

Versione: 6.16.2306.915


Note di rilascio: