diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b53693c..52c09fc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -121,6 +121,19 @@ MON:build: script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj +SPEC:build: + stage: build + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + script: + - dotnet build $env:APP_NAME/$env:APP_NAME.csproj + # WAMON:build: # stage: build # tags: @@ -216,6 +229,22 @@ MON:test: # script: # - dotnet test $env:PROJ_PATH/$env:APP_NAME.csproj +SPEC:test: + stage: test + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + needs: ["SPEC:build"] + script: + - dotnet test $env:APP_NAME/$env:APP_NAME.csproj + LAND:IIS01:deploy: stage: deploy tags: @@ -297,6 +326,22 @@ MON:IIS01:deploy: # script: # - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj +SPEC:IIS01:deploy: + stage: deploy + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + needs: ["SPEC:test"] + script: + - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj + LAND:IIS02:deploy: stage: deploy tags: @@ -383,6 +428,23 @@ MON:IIS02:deploy: # - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj # - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:PROJ_PATH/$env:APP_NAME.csproj +SPEC:IIS02:deploy: + stage: deploy + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - master + needs: ["SPEC:build"] + script: + - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj + - dotnet publish -p:PublishProfile=IIS03.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj + LAND:installer: stage: installer tags: @@ -489,6 +551,27 @@ MON:installer: # - *hashBuild # - *nexusUpload +SPEC:installer: + stage: installer + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + NEXUS_PATH: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - develop + - master + needs: ["SPEC:build"] + script: + - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj -o:publish + # qui il deploy su nexus... + - *hashBuild + - *nexusUpload + LAND:release: stage: release tags: @@ -606,3 +689,25 @@ MON:release: # script: # - dotnet publish -c Release -o ./publish $env:PROJ_PATH/$env:APP_NAME.csproj +SPEC:release: + stage: release + tags: + - win + variables: + APP_NAME: MP.SPEC + SOL_NAME: MP-SPEC + NEXUS_PATH: MP-SPEC + before_script: + - *nuget-fix + - dotnet restore "$env:SOL_NAME.sln" + only: + - tags + except: + - branches + needs: ["SPEC:build"] + artifacts: + paths: + - publish/ + script: + - dotnet publish -c Release -o ./publish $env:APP_NAME/$env:APP_NAME.csproj + diff --git a/MP-SPEC.sln b/MP-SPEC.sln new file mode 100644 index 00000000..cf0cb950 --- /dev/null +++ b/MP-SPEC.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32126.317 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{10BA8450-301D-49C7-8E1E-21B7469C225C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.SPEC", "MP.SPEC\MP.SPEC.csproj", "{C777A098-6F91-45AF-A85E-0AD08CBCAC52}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.Build.0 = Release|Any CPU + {C777A098-6F91-45AF-A85E-0AD08CBCAC52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C777A098-6F91-45AF-A85E-0AD08CBCAC52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C777A098-6F91-45AF-A85E-0AD08CBCAC52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C777A098-6F91-45AF-A85E-0AD08CBCAC52}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {632D11D1-088B-4795-97E5-048534002558} + EndGlobalSection +EndGlobal diff --git a/MP.Data/Controllers/MpMonController.cs b/MP.Data/Controllers/MpMonController.cs index fd0ec868..4d13053b 100644 --- a/MP.Data/Controllers/MpMonController.cs +++ b/MP.Data/Controllers/MpMonController.cs @@ -10,14 +10,6 @@ namespace MP.Data.Controllers { public class MpMonController : IDisposable { - #region Private Fields - - private static IConfiguration _configuration; - - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields - #region Public Constructors public MpMonController(IConfiguration configuration) @@ -36,13 +28,13 @@ namespace MP.Data.Controllers /// /// /// - public List ArticoliGetSearch(int numRecord, string searchVal = "") + public List ArticoliGetSearch(int numRecord, string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx - .DbSetArticoli + .DbSetStatArticoli .AsNoTracking() .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) .OrderBy(x => x.CodArticolo) @@ -52,6 +44,24 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco da tabella Macchine + /// + /// + public List ConfigGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetConfig + .AsNoTracking() + .OrderBy(x => x.Chiave) + .ToList(); + } + return dbResult; + } + public void Dispose() { } @@ -74,24 +84,6 @@ namespace MP.Data.Controllers return dbResult; } - /// - /// Elenco da tabella Macchine - /// - /// - public List ConfigGetAll() - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetConfig - .AsNoTracking() - .OrderBy(x => x.Chiave) - .ToList(); - } - return dbResult; - } - /// /// Elenco da tabella MappaStatoExpl /// @@ -138,5 +130,13 @@ namespace MP.Data.Controllers } #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/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs new file mode 100644 index 00000000..a3ad818b --- /dev/null +++ b/MP.Data/Controllers/MpSpecController.cs @@ -0,0 +1,578 @@ +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Data.Controllers +{ + public class MpSpecController : IDisposable + { + #region Public Constructors + + public MpSpecController(IConfiguration configuration) + { + _configuration = configuration; + Log.Info("Avviata classe MpSpecController"); + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Elenco Gruppi tipo Azienda + /// + /// + public List AnagGruppiAziende() + { + return AnagGruppiGetTipo("AZIENDA"); + } + + /// + /// Elenco Gruppi tipo Fasi + /// + /// + public List AnagGruppiFase() + { + return AnagGruppiGetTipo("FASE"); + } + + /// + /// Elenco Gruppi + /// + /// + public List AnagGruppiGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetAnagGruppi + .AsNoTracking() + .OrderBy(x => x.CodGruppo) + .ToList(); + } + return dbResult; + } + + /// + /// Gruppi x tipo + /// + /// + /// + public List AnagGruppiGetTipo(string tipoGruppo) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetAnagGruppi + .Where(x => x.TipoGruppo == tipoGruppo) + .AsNoTracking() + .OrderBy(x => x.CodGruppo) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco valori ammessi x Stati commessa (es Yacht Baglietto) + /// + /// + public List AnagStatiComm() + { + return ListValuesFilt("PODL", "StatoComm"); + } + + /// + /// Elenco valori ammessi x Tipo articoli + /// + /// + public List AnagTipoArtLV() + { + return ListValuesFilt("AnagArticoli", "Tipo"); + } + + /// + /// Eliminazione Record + /// + /// + /// + public async Task ArticoliDeleteRecord(DatabaseModels.AnagArticoli currRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currVal = dbCtx + .DbSetArticoli + .Where(x => x.CodArticolo == currRec.CodArticolo) + .FirstOrDefault(); + dbCtx + .DbSetArticoli + .Remove(currVal); + await dbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ArticoliDeleteRecord{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .AsNoTracking() + .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "") + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .AsNoTracking() + .Where(x => (x.Azienda == azienda || azienda == "*") && (x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal))) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco tabella Articoli IMPIEGATI (da stored stp_ART_getUsed) + /// + /// + public List ArticoliGetUsed() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .FromSqlRaw("EXEC stp_ART_getUsed") + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Update Record + /// + /// + /// + public async Task ArticoliUpdateRecord(DatabaseModels.AnagArticoli editRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currRec = dbCtx + .DbSetArticoli + .Where(x => x.CodArticolo == editRec.CodArticolo) + .FirstOrDefault(); + if (currRec != null) + { + currRec.Disegno = editRec.Disegno; + currRec.DescArticolo = editRec.DescArticolo; + currRec.Tipo = editRec.Tipo; + currRec.Azienda = editRec.Azienda; + dbCtx.Entry(currRec).State = EntityState.Modified; + } + else + { + dbCtx + .DbSetArticoli + .Add(editRec); + } + await dbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ArticoliUpdateRecord{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// 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(DatabaseModels.ConfigModel updRec) + { + bool fatto = false; + DatabaseModels.ConfigModel dbResult = new DatabaseModels.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; + } + + public void Dispose() + { + } + + /// + /// Elenco valori link (x home e navMenu laterale) + /// + /// + public List ElencoLink() + { + return ListLinkFilt("SpecLink"); + } + + /// + /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione) + /// + /// * = tutte, altrimenti solo x una data macchina + /// *=tutti, altrimenti solo selezionato + /// numero massimo record da restituire + /// + public List FluxLogGetLastFilt(string IdxMacchina, string CodFlux, int MaxRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .AsNoTracking() + .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux)) + .OrderByDescending(x => x.dtEvento) + .Take(MaxRec) + .ToList(); + } + return dbResult; + } + + 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; + } + + /// + /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato) + /// + /// Stato ODL: true=in corso/completato + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public List ListODLFilt(bool inCorso, string codArt, string keyRichPart) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetODL + .Where(x => ((inCorso && x.DataFine == null) || (!inCorso && x.DataFine != null)) && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") && (codArt == "*" || x.CodArticolo.Contains(codArt))) + .AsNoTracking() + .OrderBy(x => x.IdxOdl) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) + /// + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public List ListPODLFilt(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() + .OrderBy(x => x.InsertDate) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco valori ammessi x tabella/colonna + /// + /// + /// + /// + public List ListValuesFilt(string tabName, string fieldName) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetListValues + .Where(x => x.TableName == tabName && x.FieldName == fieldName) + .AsNoTracking() + .OrderBy(x => x.ordinal) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco da tabella Macchine + /// + /// + public List MacchineGetAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco id Macchine che abbiano dati FLuxLog + /// + /// + public List MacchineWithFlux() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .AsNoTracking() + .Select(i => i.IdxMacchina) + .Distinct() + .ToList(); + } + 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; + } + + /// + /// Elenco parametri validi x una data macchina + /// + /// + /// + public List ParametriGetFilt(string IdxMacchina) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .AsNoTracking() + .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina)) + .Select(i => i.CodFlux) + .Distinct() + .ToList(); + } + return dbResult; + } + + /// + /// Eliminazione Record + /// + /// + /// + public async Task PODLDeleteRecord(DatabaseModels.PODLModel currRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currVal = dbCtx + .DbSetPODL + .Where(x => x.IdxPromessa == currRec.IdxPromessa) + .FirstOrDefault(); + dbCtx + .DbSetPODL + .Remove(currVal); + await dbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODLDeleteRecord{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Update Record + /// + /// + /// + public async Task PODLUpdateRecord(DatabaseModels.PODLModel editRec) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currRec = dbCtx + .DbSetPODL + .Where(x => x.IdxPromessa == editRec.IdxPromessa) + .FirstOrDefault(); + if (currRec != null) + { + currRec.CodGruppo = editRec.CodGruppo; + currRec.CodArticolo = editRec.CodArticolo; + currRec.IdxMacchina = editRec.IdxMacchina; + currRec.KeyBCode = editRec.KeyBCode; + currRec.KeyRichiesta = editRec.KeyRichiesta; + currRec.NumPezzi = editRec.NumPezzi; + currRec.Tcassegnato = editRec.Tcassegnato; + dbCtx.Entry(currRec).State = EntityState.Modified; + } + else + { + dbCtx + .DbSetPODL + .Add(editRec); + } + await dbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODLUpdateRecord{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// 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; + } + + #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/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 20c982fc..e070696e 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -52,9 +52,9 @@ namespace MP.Data.Controllers /// /// /// - public List ArticoliGetSearch(int numRecord, string searchVal = "") + public List ArticoliGetSearch(int numRecord, string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonPro_STATSContext(_configuration)) { dbResult = dbCtx @@ -73,9 +73,9 @@ namespace MP.Data.Controllers /// /// /// - public List CommesseGetSearch(int numRecord, string searchVal = "") + public List CommesseGetSearch(int numRecord, string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonPro_STATSContext(_configuration)) { dbResult = dbCtx @@ -223,9 +223,9 @@ namespace MP.Data.Controllers /// /// /// - public List StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + public List StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonPro_STATSContext(_configuration)) { var dataFrom = new SqlParameter("@dataFrom", DataStart); diff --git a/MP.Data/DatabaseModels/AnagArticoli.cs b/MP.Data/DatabaseModels/AnagArticoli.cs index 0480a0bb..a3e6bddd 100644 --- a/MP.Data/DatabaseModels/AnagArticoli.cs +++ b/MP.Data/DatabaseModels/AnagArticoli.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable namespace MP.Data.DatabaseModels { + [Table("AnagArticoli")] public partial class AnagArticoli { #region Public Properties @@ -13,6 +15,7 @@ namespace MP.Data.DatabaseModels public string DescArticolo { get; set; } public string Disegno { get; set; } public string Tipo { get; set; } + public string Azienda { get; set; } #endregion Public Properties } diff --git a/MP.Data/DatabaseModels/AnagGruppi.cs b/MP.Data/DatabaseModels/AnagGruppi.cs new file mode 100644 index 00000000..bab7168a --- /dev/null +++ b/MP.Data/DatabaseModels/AnagGruppi.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("AnagraficaGruppi")] + public partial class AnagGruppi + { + #region Public Properties + + //[Key, DatabaseGenerated(DatabaseGeneratedOption.None), MaxLength(50)] + public string CodGruppo { get; set; } + + //[MaxLength(50)] + public string TipoGruppo { get; set; } + + //[MaxLength(250)] + public string DescrGruppo { get; set; } + + public bool SelEnabled { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/FluxLog.cs b/MP.Data/DatabaseModels/FluxLog.cs new file mode 100644 index 00000000..52ee8133 --- /dev/null +++ b/MP.Data/DatabaseModels/FluxLog.cs @@ -0,0 +1,29 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("FluxLog")] + public partial class FluxLog + { + #region Public Properties + + [MaxLength(50)] + public string IdxMacchina { get; set; } + + public DateTime dtEvento { get; set; } + + [MaxLength(50)] + public string CodFlux { get; set; } + + [MaxLength(250)] + public string Valore { get; set; } + + public int Cnt { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/LinkMenuJQM.cs b/MP.Data/DatabaseModels/LinkMenuJQM.cs new file mode 100644 index 00000000..6f885057 --- /dev/null +++ b/MP.Data/DatabaseModels/LinkMenuJQM.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("LinkMenuJQM")] + public partial class LinkMenu + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int idxLink { get; set; } + + [MaxLength(50)] + public string TipoLink { get; set; } = ""; + + public int ordine { get; set; } = 0; + + [MaxLength(50)] + public string Testo { get; set; } = ""; + + [MaxLength(50)] + public string NavigateUrl { get; set; } = ""; + + [MaxLength(50)] + public string icona { get; set; } = ""; + + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ListValues.cs b/MP.Data/DatabaseModels/ListValues.cs new file mode 100644 index 00000000..75a6f12c --- /dev/null +++ b/MP.Data/DatabaseModels/ListValues.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("ListValues")] + public partial class ListValues + { + #region Public Properties + + [MaxLength(50)] + public string TableName { get; set; } + + [MaxLength(50)] + public string FieldName { get; set; } + + [MaxLength(50)] + public string value { get; set; } + + [MaxLength(50)] + public string label { get; set; } + + public int ordinal { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ODLModel.cs b/MP.Data/DatabaseModels/ODLModel.cs new file mode 100644 index 00000000..6e411485 --- /dev/null +++ b/MP.Data/DatabaseModels/ODLModel.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("ODL")] + public partial class ODLModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxOdl { get; set; } + [MaxLength(50)] + public string CodArticolo { get; set; } = ""; + [MaxLength(50)] + public string IdxMacchina { get; set; } + public int NumPezzi { get; set; } + public decimal Tcassegnato { get; set; } + public DateTime? DataInizio { get; set; } + public DateTime? DataFine { get; set; } + [MaxLength(2500)] + public string Note { get; set; } = ""; + [MaxLength(50)] + public string KeyRichiesta { get; set; } + public int PzPallet { get; set; } = 1; + [MaxLength(50)] + public string CodCli { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/PODLModel.cs b/MP.Data/DatabaseModels/PODLModel.cs new file mode 100644 index 00000000..3f0dd58b --- /dev/null +++ b/MP.Data/DatabaseModels/PODLModel.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("PromesseODL")] + public partial class PODLModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxPromessa { get; set; } + [MaxLength(50)] + public string KeyRichiesta { get; set; } + [MaxLength(50)] + public string KeyBCode { get; set; } + public bool Attivabile { get; set; } = false; + public int IdxOdl { get; set; } = 0; + [MaxLength(50)] + public string CodArticolo { get; set; } = ""; + [MaxLength(50)] + public string CodGruppo { get; set; } = ""; + [MaxLength(50)] + public string IdxMacchina { get; set; } + public int NumPezzi { get; set; } = 1; + public decimal Tcassegnato { get; set; } = 1; + public DateTime? DueDate { get; set; } + public int Priorita { get; set; } = 1; + public int PzPallet { get; set; } = 1; + [MaxLength(2500)] + public string Note { get; set; } = ""; + [MaxLength(50)] + public string CodCli { get; set; } = ""; + public DateTime InsertDate { get; set; } = DateTime.Now; + + [NotMapped] + public string CodFase + { + get + { + string answ = "*"; + var allData = KeyRichiesta.Split('_'); + if (allData.Length > 0) + { + answ = allData[0]; + } + return answ; + } + } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/StatsAnagArticoli.cs b/MP.Data/DatabaseModels/StatsAnagArticoli.cs new file mode 100644 index 00000000..02b6ad12 --- /dev/null +++ b/MP.Data/DatabaseModels/StatsAnagArticoli.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + public partial class StatsAnagArticoli + { + #region Public Properties + + public string CodArticolo { get; set; } + public string DescArticolo { get; set; } + public string Disegno { get; set; } + public string Tipo { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ODL.cs b/MP.Data/DatabaseModels/StatsODL.cs similarity index 96% rename from MP.Data/DatabaseModels/ODL.cs rename to MP.Data/DatabaseModels/StatsODL.cs index 52bc9f61..b84a6a98 100644 --- a/MP.Data/DatabaseModels/ODL.cs +++ b/MP.Data/DatabaseModels/StatsODL.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace MP.Data.DatabaseModels { - public partial class ODL + public partial class StatsODL { #region Public Properties diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 957d91ae..d1b3f033 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -34,10 +34,17 @@ namespace MP.Data #region Public Properties + public virtual DbSet DbSetStatArticoli { get; set; } public virtual DbSet DbSetArticoli { get; set; } public virtual DbSet DbSetMacchine { get; set; } public virtual DbSet DbSetMSE { get; set; } public virtual DbSet DbSetConfig { get; set; } + public virtual DbSet DbSetAnagGruppi { get; set; } + public virtual DbSet DbSetListValues { get; set; } + public virtual DbSet DbSetLinkMenu { get; set; } + public virtual DbSet DbSetODL { get; set; } + public virtual DbSet DbSetPODL { get; set; } + public virtual DbSet DbSetFluxLog { get; set; } #endregion Public Properties @@ -53,7 +60,15 @@ namespace MP.Data { if (!optionsBuilder.IsConfigured) { - string connString = _configuration.GetConnectionString("Mp.Mon"); + string connString = _configuration.GetConnectionString("Mp.Data"); + if (string.IsNullOrEmpty(connString)) + { + connString = _configuration.GetConnectionString("Mp.Mon"); + } + if (string.IsNullOrEmpty(connString)) + { + connString = _configuration.GetConnectionString("Mp.STATS"); + } optionsBuilder.UseSqlServer(connString); //optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;"); @@ -64,9 +79,9 @@ namespace MP.Data { modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasNoKey(); + entity.HasKey(e => e.CodArticolo); entity.ToView("v_UI_AnagArticoli"); @@ -86,10 +101,36 @@ namespace MP.Data .IsRequired() .HasMaxLength(50); }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.CodArticolo); + + entity.ToView("AnagArticoli"); + + entity.Property(e => e.CodArticolo) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.DescArticolo) + .IsRequired() + .HasMaxLength(250); + + entity.Property(e => e.Disegno) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.Tipo) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.Azienda) + .IsRequired() + .HasMaxLength(50); + }); modelBuilder.Entity(entity => { - entity.HasNoKey(); + entity.HasKey(e => e.IdxMacchina); entity.ToView("Macchine"); @@ -223,6 +264,36 @@ namespace MP.Data .HasColumnName("valoreStd") .HasComment("Valore di default/riferimento per la variabile"); }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.CodGruppo); + + entity.Property(e => e.CodGruppo) + .HasMaxLength(50) + .HasColumnName("CodGruppo"); + + entity.Property(e => e.TipoGruppo) + .HasMaxLength(50) + .HasColumnName("TipoGruppo"); + + entity.Property(e => e.DescrGruppo) + .HasMaxLength(250) + .HasColumnName("DescrGruppo"); + + entity.Property(e => e.SelEnabled) + .HasColumnName("SelEnabled"); + + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.TableName, e.FieldName, e.value }); + + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux}); + + }); OnModelCreatingPartial(modelBuilder); } diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index 02f17741..3a83c4f8 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -34,12 +34,12 @@ namespace MP.Data #region Public Properties - public virtual DbSet DbSetArticoli { get; set; } + public virtual DbSet DbSetArticoli { get; set; } public virtual DbSet DbSetAzioniUL { get; set; } public virtual DbSet DbSetControlli { get; set; } public virtual DbSet DbSetDdbTurni { get; set; } public virtual DbSet DbSetMacchine { get; set; } - public virtual DbSet DbSetODL { get; set; } + public virtual DbSet DbSetODL { get; set; } public virtual DbSet DbSetScarti { get; set; } public virtual DbSet DbSetTurniOee { get; set; } public virtual DbSet DbSetUserLog { get; set; } @@ -98,7 +98,7 @@ namespace MP.Data .HasMaxLength(5); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasNoKey(); @@ -325,7 +325,7 @@ namespace MP.Data .HasMaxLength(250); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasKey(e => e.IdxOdl) .HasName("PK_ODL_1"); diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index 48f7c3b4..5d70ae78 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -39,6 +39,30 @@ namespace MP.Data await Task.Run(() => File.WriteAllLines(path, lines.ToArray())); } + public static string redKeyArtUsed + { + get => RedHash($"CACHE:CheckArtUsed"); + } + public static string redKeyTabCheckArt + { + get => RedHash($"CACHE:TabCheckArt"); + } + + /// + /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da funzionalita' DbConfig) + keyName richiesto... + /// + public static string RedHash(string keyName) + { + string answ = keyName; + try + { + answ =$"MP:Data:{keyName}"; + } + catch + { } + return answ; + } + #endregion Public Methods } } \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 7f9fc705..e0b5a080 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.15.2207.1417 + 6.15.2209.1212 diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 968637e5..2cec6778 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.15.2207.1417

+

Versione: 6.15.2209.1212


Note di rilascio: