diff --git a/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2 b/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2 index 1c74a2d..80a744f 100644 Binary files a/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2 and b/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/ApiPolo/v17/.futdcache.v2 b/.vs/ApiPolo/v17/.futdcache.v2 index 75a280e..49e851b 100644 Binary files a/.vs/ApiPolo/v17/.futdcache.v2 and b/.vs/ApiPolo/v17/.futdcache.v2 differ diff --git a/.vs/ApiPolo/v17/.suo b/.vs/ApiPolo/v17/.suo index 44265fd..12f3225 100644 Binary files a/.vs/ApiPolo/v17/.suo and b/.vs/ApiPolo/v17/.suo differ diff --git a/.vs/ProjectEvaluation/apipolo.metadata.v7.bin b/.vs/ProjectEvaluation/apipolo.metadata.v7.bin index 454e225..a385d18 100644 Binary files a/.vs/ProjectEvaluation/apipolo.metadata.v7.bin and b/.vs/ProjectEvaluation/apipolo.metadata.v7.bin differ diff --git a/.vs/ProjectEvaluation/apipolo.projects.v7.bin b/.vs/ProjectEvaluation/apipolo.projects.v7.bin index d09b166..c8a560e 100644 Binary files a/.vs/ProjectEvaluation/apipolo.projects.v7.bin and b/.vs/ProjectEvaluation/apipolo.projects.v7.bin differ diff --git a/ApiPolo/Controllers/PoloController.cs b/ApiPolo/Controllers/PoloController.cs index b2b161d..58f1e54 100644 --- a/ApiPolo/Controllers/PoloController.cs +++ b/ApiPolo/Controllers/PoloController.cs @@ -51,6 +51,7 @@ using System.Data; using System.Linq; using Microsoft.Extensions.Primitives; using System.Text.RegularExpressions; +using System.Runtime.CompilerServices; namespace ApiPolo.Controllers { @@ -490,6 +491,7 @@ namespace ApiPolo.Controllers private DbSet? _impianto; private DbSet? _sostituzione; private DbSet? _chiatable; + private DbSet? _chiatableTaskManager; private DbSet? _chiamateser; private DbSet? _chiamateprogr; private DbSet? _cpwarns; @@ -2268,12 +2270,26 @@ namespace ApiPolo.Controllers case Clienti.VT: _chia = _VT_chiatable.Chi; break; - case Clienti.LW: - _chia = _LW_chiatable.Chi; - break; + case Clienti.Tedesco: _chia = _Tedes_chiatable.Chi; break; + + default: + _chia = null; + break; + } + return _chia; + } + private DbSet getChiamateTableTaskManagerByTenant(string tenant) + { + DbSet? _chia; + + switch (tenant) + { + case Clienti.LW: + _chia = _LW_chiatable.Chi; + break; case Clienti.Syscom: _chia = _Sys_chiatable.Chi; break; @@ -11682,10 +11698,10 @@ namespace ApiPolo.Controllers r.ore_viaggio = i.ore_viaggio; r.data_timbratura = i.data_timbratura; - if (ten.Equals(Clienti.Marrocco) && !string.IsNullOrEmpty(i.commessa)) - { - i.commessa = i.commessa.Substring(0, 15); - } + //if (ten.Equals(Clienti.Marrocco) && !string.IsNullOrEmpty(i.commessa)) + //{ + // i.commessa = i.commessa.Substring(0, 15); + //} r.commessa = i.commessa; r.tecnico = tecnico; @@ -12612,7 +12628,7 @@ namespace ApiPolo.Controllers var l = await _impianto.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten)).ToListAsync(); if (!string.IsNullOrEmpty(cli)) { - l = l.Where(t => t.descCliente != null && t.descCliente.Contains(cli)).ToList(); + l = l.Where(t => t.descCliente != null && t.descCliente.ToUpper().Contains(cli.ToUpper())).ToList(); } l = l.Take(300).ToList(); foreach (Impianto i in l) @@ -13164,6 +13180,114 @@ namespace ApiPolo.Controllers return o; } + private async Task fillChiamateTableTaskManagerInput(ChiamateTableTaskManager i, string codimp, string tecnico, string tenant, string serialeLetto, string progLetto, string seriale_commessa) + { + + DateTime adesso = DateTime.Now; + ChiamateTableTaskManager o = new ChiamateTableTaskManager(); + string codiceEsercizio = string.Empty; + codiceEsercizio = Convert.ToString(adesso.Year); + string nuovoSeriale = string.Empty; + nuovoSeriale = getNuovoSerialeChiamata(serialeLetto); + + o.chcodazi = i.chcodazi; + o.chserial = nuovoSeriale; + //o.chtipo = i.chtipo; scrivo tipo A per distinguere le chiamate normali da quelle inserite da app + o.chtipo = "X"; + o.chcodese = codiceEsercizio; + o.chnumero = Convert.ToDecimal(progLetto) + 1; + o.chdata = adesso.Date; + o.chora = adesso.Hour; + o.chmin = adesso.Minute; + o.chopins = i.chopins; + o.chopass = i.chopass; + o.chopchi = i.chopchi; + o.chcodimp = codimp; + o.chaziimp = i.chaziimp; + + o.chtchiam = tecnico; + o.chtmanut = i.chtmanut; + o.chstato = "C"; + o.chdtapp = adesso.Date; + o.choraapi = adesso.Hour; + o.chminapi = adesso.Minute; + o.choraapf = adesso.Hour + 1; + o.chminapf = adesso.Minute; + + //TODO il seriale della commessa lo devo avere e lo memorizzo qui + //per ora prendo quello che scrivo sul template; poi quello che mi viene passato dalla ricerca + o.chrifer = seriale_commessa; + o.chtelef = i.chtelef; + + o.chcodseg = i.chcodseg; + o.chstopi = i.chstopi; + o.chnote = i.chnote; + o.chdtass = adesso.Date; + o.chorass = adesso.Hour; + o.chminass = adesso.Minute; + o.chdtchi = i.chdtchi; + o.chorachi = i.chorachi; + o.chminchi = i.chminchi; + o.chdtlin = i.chdtlin; + o.chorali = i.chorali; + o.chminli = i.chminli; + + o.chdtlfi = i.chdtlfi; + o.choralf = i.choralf; + o.chminlf = i.chminlf; + o.chvalfat = i.chvalfat; + o.cpccchk = getCpccchk(10); + o.chnrap1 = i.chnrap1; + o.chsrap1 = i.chsrap1; + o.chnrap2 = i.chnrap2; + o.chsrap2 = i.chsrap2; + o.chmodrac = i.chmodrac; + o.chprgann = i.chprgann; + o.chserchi = i.chserchi; + o.chdesfat = i.chdesfat; + o.chdessup = i.chdessup; + o.chimpofa = i.chimpofa; + o.chserdoc = i.chserdoc; + o.chimpmat = i.chimpmat; + o.chimpman = i.chimpman; + o.chperman = i.chperman; + o.chfleste = i.chfleste; + o.chflstim = i.chflstim; + o.chserext = i.chserext; + o.chrifiutata = i.chrifiutata; + + //o.chincarico = i.chincarico; + //o.chserweb = i.chserweb; + //o.chinlinea = i.chinlinea; + //o.chtelesan = i.chtelesan; + string _cli = string.Empty; + _cli = await getCodCliByImp(tenant, codimp); + o.cliente = _cli; + return o; + } + private async Task getCodCliByImp(string tenant, string codiceImpianto) + { + string codiceCliente = string.Empty; + switch (tenant) + { + case Clienti.LW: + _impianto = _LW_impianti.Impia; + break; + case Clienti.Syscom: + _impianto = _Sys_impianti.Impia; + break; + default: + // code block + break; + } + var i = await _impianto.Where(t => t.imcodimp!=null && t.imcodimp.Equals(codiceImpianto)).ToListAsync(); + if(i!=null) + { + codiceCliente = i.First().imultcli; + } + + return codiceCliente; + } private string getNuovoSerialeChiamata(string lastSerial) { //lunghezza 10 fissa @@ -13184,7 +13308,9 @@ namespace ApiPolo.Controllers string serialeTemplate = string.Empty; ChiamateTable t = new ChiamateTable(); + ChiamateTableTaskManager tm = new ChiamateTableTaskManager(); var tt = new List(); + var ttTaskManager = new List(); if (string.IsNullOrEmpty(ten)) { ten = tenConf; @@ -13194,7 +13320,7 @@ namespace ApiPolo.Controllers ten = ten2; } _chiatable = getChiamateTableByTenant(ten); - + _chiatableTaskManager = getChiamateTableTaskManagerByTenant(ten); switch (ten) { @@ -13203,6 +13329,13 @@ namespace ApiPolo.Controllers serialeTemplate = _confLette.seriale_template_chi; tt = await _chiatable.Where(t => t.chcodazi != null && t.chcodazi.Equals(ten2) && t.chserial != null && t.chserial.Equals(serialeTemplate)).ToListAsync(); break; + case Clienti.LW: + case Clienti.Syscom: + + _confLette = await readConf(tenConf); + serialeTemplate = _confLette.seriale_template_chi; + ttTaskManager = await _chiatableTaskManager.Where(t => t.chcodazi != null && t.chcodazi.Equals(ten2) && t.chserial != null && t.chserial.Equals(serialeTemplate)).ToListAsync(); + break; default: _confLette = await readConf(tenConf); serialeTemplate = _confLette.seriale_template_chi; @@ -13278,21 +13411,22 @@ namespace ApiPolo.Controllers } break; case Clienti.LW: - t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + tm = await fillChiamateTableTaskManagerInput(ttTaskManager.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); using (var tranLW = _LW_chiatable.Database.BeginTransaction()) { - await _LW_chiatable.Chi.AddAsync(t); + await _LW_chiatable.Chi.AddAsync(tm); await _LW_chiatable.SaveChangesAsync(); tranLW.Commit(); } break; case Clienti.Syscom: - t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + tm = await fillChiamateTableTaskManagerInput(ttTaskManager.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); using (var transys = _Sys_chiatable.Database.BeginTransaction()) { - await _Sys_chiatable.Chi.AddAsync(t); + await _Sys_chiatable.Chi.AddAsync(tm); await _Sys_chiatable.SaveChangesAsync(); transys.Commit(); } @@ -13304,8 +13438,20 @@ namespace ApiPolo.Controllers } _chiamate = getChiamateByTenant(ten); - var chiamata_new = _chiamate.Where(x => x.chserial.Equals(t.chserial)).FirstOrDefault(); - c = fillChiamateOut(chiamata_new, ten); + switch (ten) + { + case Clienti.LW: + case Clienti.Syscom: + var chiamata_newTM = _chiamate.Where(x => x.chserial.Equals(tm.chserial)).FirstOrDefault(); + c = fillChiamateOut(chiamata_newTM, ten); + break; + + default: + var chiamata_new = _chiamate.Where(x => x.chserial.Equals(t.chserial)).FirstOrDefault(); + c = fillChiamateOut(chiamata_new, ten); + break; + } + return c; } diff --git a/ApiPolo/Models/ChiamateTableTaskManager.cs b/ApiPolo/Models/ChiamateTableTaskManager.cs new file mode 100644 index 0000000..1a25372 --- /dev/null +++ b/ApiPolo/Models/ChiamateTableTaskManager.cs @@ -0,0 +1,212 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Tabella CHIAMATE (insert da app) per le installazioni di TaskManager + public class ChiamateTableTaskManager + { + /// + [Key] + public string? chcodazi { get; set; } + + /// + [Key] + public string? chserial { get; set; } + + /// + public string? chcodese { get; set; } + + /// + public string? chtipo { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(10, 0)")] + public decimal? chnumero { get; set; } + + /// + public DateTime? chdata { get; set; } + + /// + public int? chora { get; set; } + + /// + public int? chmin { get; set; } + + /// + public int? chopins { get; set; } + + /// + public int? chopass { get; set; } + + /// + public int? chopchi { get; set; } + + /// + public string? chcodimp { get; set; } + + /// + public string? chaziimp { get; set; } + + + + /// + public string? chtchiam { get; set; } + + /// + public string? chtmanut { get; set; } + + /// + public string? chstato { get; set; } + + /// + public DateTime? chdtapp { get; set; } + + /// + public int? choraapi { get; set; } + + /// + public int? chminapi { get; set; } + + /// + public int? choraapf { get; set; } + + /// + public int? chminapf { get; set; } + + /// + public string? chrifer { get; set; } + + /// + public string? chtelef { get; set; } + + + + /// + public string? chcodseg { get; set; } + + /// + public string? chstopi { get; set; } + + /// + public string? chnote { get; set; } + + /// + public DateTime? chdtass { get; set; } + + /// + public int? chorass { get; set; } + + /// + public int? chminass { get; set; } + + /// + public DateTime? chdtchi { get; set; } + + /// + public int? chorachi { get; set; } + + /// + public int? chminchi { get; set; } + + /// + public DateTime? chdtlin { get; set; } + + /// + public int? chorali { get; set; } + + /// + public int? chminli { get; set; } + + + + /// + public DateTime? chdtlfi { get; set; } + + /// + public int? choralf { get; set; } + + /// + public int? chminlf { get; set; } + + /// + public string? chvalfat { get; set; } + + /// + public string? cpccchk { get; set; } + + /// + public int? chnrap1 { get; set; } + + /// + public string? chsrap1 { get; set; } + + /// + public int? chnrap2 { get; set; } + + /// + public string? chsrap2 { get; set; } + + /// + public string? chmodrac { get; set; } + + /// + public int? chprgann { get; set; } + + /// + public string? chserchi { get; set; } + + /// + public string? chdesfat { get; set; } + + /// + public string? chdessup { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? chimpofa { get; set; } + + /// + public string? chserdoc { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? chimpmat { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? chimpman { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")] + public decimal? chperman { get; set; } + + /// + public string? chflstim { get; set; } + + /// + public string? chfleste { get; set; } + + /// + public string? chserext { get; set; } + + /// + public string? chrifiutata { get; set; } + + ///// + //public string? chincarico { get; set; } + + ///// + //public string? chserweb { get; set; } + + ///// + //public string? chinlinea { get; set; } + + ///// + //public string? chpreinc { get; set; } + + /// campo cliente su tabella chiamate di TaskManager + public string? cliente { get; set; } + + + } +} diff --git a/ApiPolo/Models/Lift_web_dbcontext/LIFT_WEB_CHIAMATE_TABLE_DbContext.cs b/ApiPolo/Models/Lift_web_dbcontext/LIFT_WEB_CHIAMATE_TABLE_DbContext.cs index a67ac88..23b2712 100644 --- a/ApiPolo/Models/Lift_web_dbcontext/LIFT_WEB_CHIAMATE_TABLE_DbContext.cs +++ b/ApiPolo/Models/Lift_web_dbcontext/LIFT_WEB_CHIAMATE_TABLE_DbContext.cs @@ -7,7 +7,7 @@ namespace ApiPolo.Models.Lift_web_dbcontext public class LIFT_WEB_CHIAMATE_TABLE_DbContext : DbContext { /// - public DbSet? Chi { get; set; } + public DbSet? Chi { get; set; } /// public LIFT_WEB_CHIAMATE_TABLE_DbContext(DbContextOptions options) : base(options) @@ -17,11 +17,12 @@ namespace ApiPolo.Models.Lift_web_dbcontext /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity().ToTable("CHIAMATE"); - modelBuilder.Entity().HasKey(table => new { + modelBuilder.Entity().ToTable("CHIAMATE"); + modelBuilder.Entity().HasKey(table => new { table.chcodazi, table.chserial }); } } + } diff --git a/ApiPolo/Models/Security_dbcontext/SECURITY_CHIAMATE_TABLE_DbContext.cs b/ApiPolo/Models/Security_dbcontext/SECURITY_CHIAMATE_TABLE_DbContext.cs index e044aff..2205635 100644 --- a/ApiPolo/Models/Security_dbcontext/SECURITY_CHIAMATE_TABLE_DbContext.cs +++ b/ApiPolo/Models/Security_dbcontext/SECURITY_CHIAMATE_TABLE_DbContext.cs @@ -3,11 +3,11 @@ using Microsoft.EntityFrameworkCore; namespace ApiPolo.Models.Security_dbcontext { - /// + /// SYSCOM public class SECURITY_CHIAMATE_TABLE_DbContext:DbContext { /// - public DbSet? Chi { get; set; } + public DbSet? Chi { get; set; } /// public SECURITY_CHIAMATE_TABLE_DbContext(DbContextOptions options) : base(options) @@ -17,8 +17,8 @@ namespace ApiPolo.Models.Security_dbcontext /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity().ToTable("CHIAMATE"); - modelBuilder.Entity().HasKey(table => new { + modelBuilder.Entity().ToTable("CHIAMATE"); + modelBuilder.Entity().HasKey(table => new { table.chcodazi, table.chserial }); diff --git a/ApiPolo/appsettings.json b/ApiPolo/appsettings.json index 0e20d0d..3281992 100644 --- a/ApiPolo/appsettings.json +++ b/ApiPolo/appsettings.json @@ -10,7 +10,7 @@ //connessione non sicura: Encrypt=False - /*"ApiStr": "Data Source=172.25.30.1;Initial Catalog=API_POLO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + //"ApiStr": "Data Source=172.25.30.1;Initial Catalog=API_POLO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", "ApiStr": "Data Source=MARCO_PC\\SQL_2022;Initial Catalog=API_POLO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", /*"FERRA": "Data Source=10.0.0.10;Initial Catalog=AHR60_FERRARI;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/