using ApiPolo.Interfaces; using ApiPolo.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.IdentityModel.Tokens.Jwt; using System.Text; using static ApiPolo.Controllers.PoloController; namespace ApiPolo.Controllers { /// public class TestController : Controller { //interfaccia con tutti i possibili dbset private readonly ITenantDbContextFactory _dbContextFactory; //DI con ITenantDbContextFactory /// private DbSet? _chiamate; public TestController(ITenantDbContextFactory dbContextFactory) { _dbContextFactory = dbContextFactory; } //ATTENZIONE - CONFLITTO TRA Compo_Impia_Table e #region GET_BY_TENANT private DbSet getTecniciByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Tecnici; // Use Set() to handle different DbContexts } private DbSet getRappNewByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Rapps; // Use Set() to handle different DbContexts } private DbSet getChiamateByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Chiamate; // Use Set() to handle different DbContexts } private DbSet? getChiusureByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Chiusure; } private DbSet getManutenzioniByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Manutenzioni; // Use Set() to handle different DbContexts } private DbSet getPreseByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Prese; // Use Set() to handle different DbContexts } private DbSet getSto_RappByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.StoRapp; // Use Set() to handle different DbContexts } private DbSet getClientiByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Clienti; // Use Set() to handle different DbContexts } private DbSet getCausaliRappByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Causali; // Use Set() to handle different DbContexts } private DbSet getPagamentiByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Pagamenti; // Use Set() to handle different DbContexts } private DbSet getSaldiartByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Saldi; // Use Set() to handle different DbContexts } /// /// CONFLITTO CON Compo_Impia_Table /// /* private DbSet getComponentiByTenant(string tenant) { // IN CONFLITTO CON Compo_Impia_Table var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Componen; // Use Set() to handle different DbContexts }*/ private DbSet getComponentiTableByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Componen; // Use Set() to handle different DbContexts } private DbSet getMagazziniByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Magaz; // Use Set() to handle different DbContexts } private DbSet getMag_NewByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Mag; // Use Set() to handle different DbContexts } private DbSet getImpiantiByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Impia; // Use Set() to handle different DbContexts } private DbSet getCommesseByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Commesse; // Use Set() to handle different DbContexts } private DbSet getTimbratureByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Timbr; // Use Set() to handle different DbContexts } private DbSet getStoricoImpiantoByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.StoImp; // Use Set() to handle different DbContexts } private DbSet getAziendeRifByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Azi; // Use Set() to handle different DbContexts } private DbSet getSostituzioneByTenant(string tenant) { var dbContext = _dbContextFactory.GetDbContext(tenant); return dbContext.Sost; // Use Set() to handle different DbContexts } #endregion #region utility private string getClaimValueByToken(string token, string claimName) { string t = string.Empty; var handler = new JwtSecurityTokenHandler(); var jwtSecurityToken = handler.ReadJwtToken(token); if (jwtSecurityToken != null) { var id = jwtSecurityToken.Claims.First(claim => claim.Type == claimName).Value; t = id; } return t; } private Chiamate_out fillChiamateOut(Chiamate i, string tenant) { Chiamate_out o = new Chiamate_out(); o.chcodazi = i.chcodazi; o.chserial = i.chserial; o.chstato = i.chstato; o.chtchiam = i.chtchiam; o.chdtapp = i.chdtapp; o.choraaPI = i.choraaPI; o.chminapi = i.chminapi; o.chnote = i.chnote; o.chcodimp = i.chcodimp; o.csdescr = i.csdescr; o.antelefo = i.antelefo; o.andescri = i.andescri; o.imindiri1 = i.imindiri1; o.imindiri2 = i.imindiri2; o.imindiri3 = i.imindiri3; o.imindiri4 = i.imindiri4; o.imindiri5 = i.imindiri5; o.imlocali = i.imlocali; o.imrefref = i.imrefref; //costruisco il campo indirizzo StringBuilder sb = new StringBuilder(); string chiamataIndStampa = string.Empty; switch (tenant) { case Clienti.Marrocco: #region marrocco chiamataIndStampa = formattaIndirizzoStampaMarrocco(i); #endregion break; case Clienti.Gitoga: #region gitoga chiamataIndStampa = formattaIndirizzoStampaMarrocco(i); #endregion break; case Clienti.Lifta: #region lifta chiamataIndStampa = formattaIndirizzoStampaMarrocco(i); #endregion break; case Clienti.Discovery: #region Discovery chiamataIndStampa = formattaIndirizzoStampaDiscovery(i); #endregion break; case Clienti.Siet: //ragione sociale cliente sb.Append("SPETT.LE :"); sb.Append(!string.IsNullOrEmpty(i.andescri) ? i.andescri + " " : string.Empty); sb.Append("
"); //indirizzo sb.Append(!string.IsNullOrEmpty(i.imindiri1) ? i.imindiri1.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri2) ? i.imindiri2.Trim() + " " : string.Empty); sb.Append(i.imindiri3 != null ? i.imindiri3.ToString() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri4) ? i.imindiri4.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri5) ? i.imindiri5.Trim() : string.Empty); chiamataIndStampa = sb.ToString(); break; default: sb.Append("SPETT.LE :"); if (!string.IsNullOrEmpty(i.andescri)) { sb.Append(!string.IsNullOrEmpty(i.andescri) ? i.andescri + " " : string.Empty); sb.Append("
"); } sb.Append(!string.IsNullOrEmpty(i.imindiri1) ? i.imindiri1.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri2) ? i.imindiri2.Trim() + " " : string.Empty); sb.Append(i.imindiri3 != null ? i.imindiri3.ToString() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri4) ? i.imindiri4.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri5) ? i.imindiri5.Trim() : string.Empty); chiamataIndStampa = sb.ToString(); break; } o.indirizzo_stampa = chiamataIndStampa; sb.Clear(); string chiamataItemList = string.Empty; switch (tenant) { case Clienti.Marrocco: #region marrocco chiamataItemList = formattaItemChiamateMarrocco(i); #endregion break; case Clienti.Gitoga: #region gitoga chiamataItemList = formattaItemChiamateMarrocco(i); #endregion break; case Clienti.Lifta: #region lifta chiamataItemList = formattaItemChiamateMarrocco(i); #endregion break; case Clienti.Tedesco: #region Tedesco chiamataItemList = formattaItemChiamateTedesco(i); #endregion break; case Clienti.VT: chiamataItemList = formattaItemChiamateVT(i); break; default: #region default sb.Append(!string.IsNullOrEmpty(i.imindiri1) ? i.imindiri1.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri2) ? i.imindiri2.Trim() + " " : string.Empty); sb.Append(i.imindiri3 != null ? i.imindiri3.ToString() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri4) ? i.imindiri4.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imindiri5) ? i.imindiri5.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imcodcap) ? " " + i.imcodcap.Trim() + " " : string.Empty); sb.Append(!string.IsNullOrEmpty(i.imlocali) ? " " + i.imlocali.Trim() + " " : string.Empty); if (!string.IsNullOrEmpty(i.chcodimp)) { sb.Append("
"); sb.Append("Impianto : " + i.chcodimp.Trim()); } chiamataItemList = sb.ToString(); break; #endregion } o.impianto_list = chiamataItemList; sb.Clear(); string rif_impianto = string.Empty; switch (tenant) { case Clienti.Marrocco: #region marrocco rif_impianto = formattaRiferimentoImpiantoMarrocco(i); #endregion break; case Clienti.Gitoga: #region gitoga rif_impianto = formattaRiferimentoImpiantoMarrocco(i); #endregion break; case Clienti.Lifta: #region lifta rif_impianto = formattaRiferimentoImpiantoMarrocco(i); #endregion break; case Clienti.Discovery: #region discovery rif_impianto = formattaRiferimentoImpiantoDiscovery(i); #endregion break; case Clienti.Ferrari: #region ferrari rif_impianto = formattaRiferimentoImpiantoFerrari(i); #endregion break; case Clienti.Siet: #region SIET sb.AppendLine("N. Impianto: " + i.chcodimp); if (!string.IsNullOrEmpty(i.imubicaz)) { sb.AppendLine("Ubicazione: " + i.imubicaz); } if (!string.IsNullOrEmpty(i.chrifer)) { string comm = getCommessaSietBySerial(i.chrifer); if (!string.IsNullOrEmpty(comm)) { sb.AppendLine("Commessa: " + comm); } } rif_impianto = sb.ToString(); #endregion break; default: sb.AppendLine("N. Impianto: " + i.chcodimp); if (!string.IsNullOrEmpty(i.imubicaz)) sb.AppendLine("Ubicazione: " + i.imubicaz); rif_impianto = sb.ToString(); break; } o.riferimento_impianto = rif_impianto; sb.Clear(); o.imcodcap = i.imcodcap; o.imcomune = i.imcomune; o.improvin = i.improvin; o.imcodnaz = i.imcodnaz; o.immatric = i.immatric; o.imnumimp = i.imnumimp; o.imubicaz = i.imubicaz; o.tcdescri = i.tcdescri; o.tccodice = i.tccodice; o.ser_rapp_ic = i.ser_rapp_ic; o.tipo_rapp_ic = i.tipo_rapp_ic; o.ic = i.ic; o.ser_rapp_rif = i.ser_rapp_rif; o.tipo_rapp_rif = i.tipo_rapp_rif; o.rif = i.rif; o.ser_rapp_chiu = i.ser_rapp_chiu; o.tipo_rapp_chiu = i.tipo_rapp_chiu; o.ser_buono_chiu = i.ser_buono_chiu; o.err_title = i.err_title; o.err_detail = i.err_detail; o.err_status_code = i.err_status_code; o.ancodice = i.ancodice; o.chiamata = i.chiamata; o.spe_viaggio = i.spe_viaggio; o.chnumero = i.chnumero; Dictionary dic = new Dictionary(); switch (tenant) { case Clienti.Marrocco: #region marrocco dic.Add("Esercizio ", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("REF ", !string.IsNullOrEmpty(i.imrefref) ? i.imrefref : String.Empty); dic.Add("Riferimento:", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Telefono rif.:", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); #endregion break; case Clienti.Gitoga: #region gitoga dic.Add("Esercizio ", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("REF ", !string.IsNullOrEmpty(i.imrefref) ? i.imrefref : String.Empty); dic.Add("Riferimento:", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Telefono rif.:", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); #endregion break; case Clienti.Lifta: #region lifta dic.Add("Esercizio ", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("REF ", !string.IsNullOrEmpty(i.imrefref) ? i.imrefref : String.Empty); dic.Add("Riferimento:", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Telefono rif.:", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); #endregion break; case Clienti.Ferrari: #region ferrari dic.Add("Esercizio", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("Tipo", !string.IsNullOrEmpty(i.chtipo) ? i.chtipo : String.Empty); dic.Add("Numero chiamata", !string.IsNullOrEmpty(i.chnumero.ToString()) ? i.chnumero.ToString() : String.Empty); dic.Add("Data chiamata", !string.IsNullOrEmpty(i.chdata.ToString()) ? i.chdata.ToString() : String.Empty); dic.Add("Ora inserimento chiamata", !string.IsNullOrEmpty(i.chora.ToString()) ? i.chora.ToString() : String.Empty); dic.Add("Min inserimento chiamata", !string.IsNullOrEmpty(i.chmin.ToString()) ? i.chmin.ToString() : String.Empty); dic.Add("Operatore assegnazione", !string.IsNullOrEmpty(i.chopass.ToString()) ? i.chopass.ToString() : String.Empty); dic.Add("Operatore chiusura", !string.IsNullOrEmpty(i.chopchi.ToString()) ? i.chopchi.ToString() : String.Empty); dic.Add("Azienda impianto", !string.IsNullOrEmpty(i.chaziimp) ? i.chaziimp : String.Empty); dic.Add("Ora appuntamento fine", !string.IsNullOrEmpty(i.choraapf.ToString()) ? i.choraapf.ToString() : String.Empty); dic.Add("Min appuntamento fine", !string.IsNullOrEmpty(i.chminapf.ToString()) ? i.chminapf.ToString() : String.Empty); dic.Add("Riferimento chiamata", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Riferimento telefono", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); dic.Add("Codice segnalazione", !string.IsNullOrEmpty(i.chcodseg) ? i.chcodseg : String.Empty); dic.Add("Fermo impianto", !string.IsNullOrEmpty(i.chstopi) ? i.chstopi : String.Empty); dic.Add("Data assegnazione chiamata", !string.IsNullOrEmpty(i.chdtass.ToString()) ? i.chdtass.ToString() : String.Empty); dic.Add("Ora assegnazione chiamata", !string.IsNullOrEmpty(i.chorass.ToString()) ? i.chorass.ToString() : String.Empty); dic.Add("Min assegnazione chiamata", !string.IsNullOrEmpty(i.chminass.ToString()) ? i.chminass.ToString() : String.Empty); dic.Add("Data chiusura chiamata", !string.IsNullOrEmpty(i.chdtchi.ToString()) ? i.chdtchi.ToString() : String.Empty); dic.Add("Ora chiusura chiamata", !string.IsNullOrEmpty(i.chorachi.ToString()) ? i.chorachi.ToString() : String.Empty); dic.Add("Min chiusura chiamata", !string.IsNullOrEmpty(i.chminchi.ToString()) ? i.chminchi.ToString() : String.Empty); dic.Add("Data inizio intervento", !string.IsNullOrEmpty(i.chdtlin.ToString()) ? i.chdtlin.ToString() : String.Empty); dic.Add("Ora inizio intervento", !string.IsNullOrEmpty(i.chorali.ToString()) ? i.chorali.ToString() : String.Empty); dic.Add("Min inizio intervento", !string.IsNullOrEmpty(i.chminli.ToString()) ? i.chminli.ToString() : String.Empty); dic.Add("Data fine intervento", !string.IsNullOrEmpty(i.chdtlfi.ToString()) ? i.chdtlfi.ToString() : String.Empty); dic.Add("Ora fine intervento", !string.IsNullOrEmpty(i.choralf.ToString()) ? i.choralf.ToString() : String.Empty); dic.Add("Min fine intervento", !string.IsNullOrEmpty(i.chminlf.ToString()) ? i.chminlf.ToString() : String.Empty); dic.Add("Numero 1 rapportino futuro", !string.IsNullOrEmpty(i.chnrap1.ToString()) ? i.chnrap1.ToString() : String.Empty); dic.Add("Serie 1 rapportino futuro", !string.IsNullOrEmpty(i.chsrap1) ? i.chsrap1 : String.Empty); dic.Add("Numero 2 rapportino futuro", !string.IsNullOrEmpty(i.chnrap2.ToString()) ? i.chnrap2.ToString() : String.Empty); dic.Add("Modalità raccolta chiamata", !string.IsNullOrEmpty(i.chmodrac) ? i.chmodrac : String.Empty); dic.Add("Numero chiamata per impianto per anno", !string.IsNullOrEmpty(i.chprgann.ToString()) ? i.chprgann.ToString() : String.Empty); dic.Add("Importo manodopera", !string.IsNullOrEmpty(i.chimpman.ToString()) ? i.chimpman.ToString() : String.Empty); dic.Add("Percentuale manodopera", !string.IsNullOrEmpty(i.chperman.ToString()) ? i.chperman.ToString() : String.Empty); dic.Add("Stampa manodopera", !string.IsNullOrEmpty(i.chflstim) ? i.chflstim : String.Empty); dic.Add("Chiusura da remoto", !string.IsNullOrEmpty(i.chfleste) ? i.chfleste : String.Empty); dic.Add("Riferimento seriale importazione", !string.IsNullOrEmpty(i.chserext) ? i.chserext : String.Empty); dic.Add("Descrizione impianto", !string.IsNullOrEmpty(i.imdescri) ? i.imdescri : String.Empty); dic.Add("Tipo impianto", !string.IsNullOrEmpty(i.imtipoim) ? i.imtipoim : String.Empty); dic.Add("Matricola impianto ", !string.IsNullOrEmpty(i.immatric) ? i.immatric : String.Empty); dic.Add("Numero impianto ", !string.IsNullOrEmpty(i.imnumimp) ? i.imnumimp : String.Empty); dic.Add("Ultimo amministratore ", !string.IsNullOrEmpty(i.imultamm) ? i.imultamm : String.Empty); dic.Add("Desc Ultimo amministratore ", !string.IsNullOrEmpty(i.imultdam) ? i.imultdam : String.Empty); dic.Add("Telefono Ult. Amministratore", !string.IsNullOrEmpty(i.imulttam) ? i.imulttam : String.Empty); dic.Add("Ubicazione impianto", !string.IsNullOrEmpty(i.imubicaz) ? i.imubicaz : String.Empty); dic.Add("Zona manutenzione", !string.IsNullOrEmpty(i.imzonman) ? i.imzonman : String.Empty); dic.Add("Pubblico/privato", !string.IsNullOrEmpty(i.imflpupr) ? i.imflpupr : String.Empty); dic.Add("Zona chiamate", !string.IsNullOrEmpty(i.imzonchi) ? i.imzonchi : String.Empty); dic.Add("Zona supervisione", !string.IsNullOrEmpty(i.imzonsup) ? i.imzonsup : String.Empty); dic.Add("Data inizio manutenzione", i.imdainma != null ? i.imdainma.ToString() : String.Empty); dic.Add("Data fine manutenzione", !string.IsNullOrEmpty(i.imdafima.ToString()) ? i.imdafima.ToString() : String.Empty); dic.Add("Data costruzione", !string.IsNullOrEmpty(i.imdatcos.ToString()) ? i.imdatcos.ToString() : String.Empty); dic.Add("Numero telesoccorso ", !string.IsNullOrEmpty(i.imteleso) ? i.imteleso : String.Empty); dic.Add("Email cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Ultimo cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Codice cliente", !string.IsNullOrEmpty(i.ancodice) ? i.ancodice : String.Empty); dic.Add("Tipo anagrafica", !string.IsNullOrEmpty(i.antipcon) ? i.antipcon : String.Empty); #endregion break; case Clienti.Sicilia: #region sicilia dic.Add("Esercizio", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("Tipo", !string.IsNullOrEmpty(i.chtipo) ? i.chtipo : String.Empty); dic.Add("Numero chiamata", !string.IsNullOrEmpty(i.chnumero.ToString()) ? i.chnumero.ToString() : String.Empty); dic.Add("Data chiamata", !string.IsNullOrEmpty(i.chdata.ToString()) ? i.chdata.ToString() : String.Empty); dic.Add("Ora inserimento chiamata", !string.IsNullOrEmpty(i.chora.ToString()) ? i.chora.ToString() : String.Empty); dic.Add("Min inserimento chiamata", !string.IsNullOrEmpty(i.chmin.ToString()) ? i.chmin.ToString() : String.Empty); dic.Add("Operatore assegnazione", !string.IsNullOrEmpty(i.chopass.ToString()) ? i.chopass.ToString() : String.Empty); dic.Add("Operatore chiusura", !string.IsNullOrEmpty(i.chopchi.ToString()) ? i.chopchi.ToString() : String.Empty); dic.Add("Azienda impianto", !string.IsNullOrEmpty(i.chaziimp) ? i.chaziimp : String.Empty); dic.Add("Ora appuntamento fine", !string.IsNullOrEmpty(i.choraapf.ToString()) ? i.choraapf.ToString() : String.Empty); dic.Add("Min appuntamento fine", !string.IsNullOrEmpty(i.chminapf.ToString()) ? i.chminapf.ToString() : String.Empty); dic.Add("Riferimento chiamata", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Riferimento telefono", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); dic.Add("Codice segnalazione", !string.IsNullOrEmpty(i.chcodseg) ? i.chcodseg : String.Empty); dic.Add("Fermo impianto", !string.IsNullOrEmpty(i.chstopi) ? i.chstopi : String.Empty); dic.Add("Data assegnazione chiamata", !string.IsNullOrEmpty(i.chdtass.ToString()) ? i.chdtass.ToString() : String.Empty); dic.Add("Ora assegnazione chiamata", !string.IsNullOrEmpty(i.chorass.ToString()) ? i.chorass.ToString() : String.Empty); dic.Add("Min assegnazione chiamata", !string.IsNullOrEmpty(i.chminass.ToString()) ? i.chminass.ToString() : String.Empty); dic.Add("Data chiusura chiamata", !string.IsNullOrEmpty(i.chdtchi.ToString()) ? i.chdtchi.ToString() : String.Empty); dic.Add("Ora chiusura chiamata", !string.IsNullOrEmpty(i.chorachi.ToString()) ? i.chorachi.ToString() : String.Empty); dic.Add("Min chiusura chiamata", !string.IsNullOrEmpty(i.chminchi.ToString()) ? i.chminchi.ToString() : String.Empty); dic.Add("Data inizio intervento", !string.IsNullOrEmpty(i.chdtlin.ToString()) ? i.chdtlin.ToString() : String.Empty); dic.Add("Ora inizio intervento", !string.IsNullOrEmpty(i.chorali.ToString()) ? i.chorali.ToString() : String.Empty); dic.Add("Min inizio intervento", !string.IsNullOrEmpty(i.chminli.ToString()) ? i.chminli.ToString() : String.Empty); dic.Add("Data fine intervento", !string.IsNullOrEmpty(i.chdtlfi.ToString()) ? i.chdtlfi.ToString() : String.Empty); dic.Add("Ora fine intervento", !string.IsNullOrEmpty(i.choralf.ToString()) ? i.choralf.ToString() : String.Empty); dic.Add("Min fine intervento", !string.IsNullOrEmpty(i.chminlf.ToString()) ? i.chminlf.ToString() : String.Empty); dic.Add("Numero 1 rapportino futuro", !string.IsNullOrEmpty(i.chnrap1.ToString()) ? i.chnrap1.ToString() : String.Empty); dic.Add("Serie 1 rapportino futuro", !string.IsNullOrEmpty(i.chsrap1) ? i.chsrap1 : String.Empty); dic.Add("Numero 2 rapportino futuro", !string.IsNullOrEmpty(i.chnrap2.ToString()) ? i.chnrap2.ToString() : String.Empty); dic.Add("Modalità raccolta chiamata", !string.IsNullOrEmpty(i.chmodrac) ? i.chmodrac : String.Empty); dic.Add("Numero chiamata per impianto per anno", !string.IsNullOrEmpty(i.chprgann.ToString()) ? i.chprgann.ToString() : String.Empty); dic.Add("Importo manodopera", !string.IsNullOrEmpty(i.chimpman.ToString()) ? i.chimpman.ToString() : String.Empty); dic.Add("Percentuale manodopera", !string.IsNullOrEmpty(i.chperman.ToString()) ? i.chperman.ToString() : String.Empty); dic.Add("Stampa manodopera", !string.IsNullOrEmpty(i.chflstim) ? i.chflstim : String.Empty); dic.Add("Chiusura da remoto", !string.IsNullOrEmpty(i.chfleste) ? i.chfleste : String.Empty); dic.Add("Riferimento seriale importazione", !string.IsNullOrEmpty(i.chserext) ? i.chserext : String.Empty); dic.Add("Descrizione impianto", !string.IsNullOrEmpty(i.imdescri) ? i.imdescri : String.Empty); dic.Add("Tipo impianto", !string.IsNullOrEmpty(i.imtipoim) ? i.imtipoim : String.Empty); dic.Add("Matricola impianto ", !string.IsNullOrEmpty(i.immatric) ? i.immatric : String.Empty); dic.Add("Numero impianto ", !string.IsNullOrEmpty(i.imnumimp) ? i.imnumimp : String.Empty); dic.Add("Ultimo amministratore ", !string.IsNullOrEmpty(i.imultamm) ? i.imultamm : String.Empty); dic.Add("Desc Ultimo amministratore ", !string.IsNullOrEmpty(i.imultdam) ? i.imultdam : String.Empty); dic.Add("Telefono Ult. Amministratore", !string.IsNullOrEmpty(i.imulttam) ? i.imulttam : String.Empty); dic.Add("Ubicazione impianto", !string.IsNullOrEmpty(i.imubicaz) ? i.imubicaz : String.Empty); dic.Add("Zona manutenzione", !string.IsNullOrEmpty(i.imzonman) ? i.imzonman : String.Empty); dic.Add("Pubblico/privato", !string.IsNullOrEmpty(i.imflpupr) ? i.imflpupr : String.Empty); dic.Add("Zona chiamate", !string.IsNullOrEmpty(i.imzonchi) ? i.imzonchi : String.Empty); dic.Add("Zona supervisione", !string.IsNullOrEmpty(i.imzonsup) ? i.imzonsup : String.Empty); dic.Add("Data inizio manutenzione", i.imdainma != null ? i.imdainma.ToString() : String.Empty); dic.Add("Data fine manutenzione", !string.IsNullOrEmpty(i.imdafima.ToString()) ? i.imdafima.ToString() : String.Empty); dic.Add("Data costruzione", !string.IsNullOrEmpty(i.imdatcos.ToString()) ? i.imdatcos.ToString() : String.Empty); dic.Add("Numero telesoccorso ", !string.IsNullOrEmpty(i.imteleso) ? i.imteleso : String.Empty); dic.Add("Email cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Ultimo cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Codice cliente", !string.IsNullOrEmpty(i.ancodice) ? i.ancodice : String.Empty); dic.Add("Tipo anagrafica", !string.IsNullOrEmpty(i.antipcon) ? i.antipcon : String.Empty); #endregion break; case Clienti.Discovery: #region discovery dic.Add("Esercizio", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("Tipo", !string.IsNullOrEmpty(i.chtipo) ? i.chtipo : String.Empty); dic.Add("Numero chiamata", !string.IsNullOrEmpty(i.chnumero.ToString()) ? i.chnumero.ToString() : String.Empty); dic.Add("Data chiamata", !string.IsNullOrEmpty(i.chdata.ToString()) ? i.chdata.ToString() : String.Empty); dic.Add("Ora inserimento chiamata", !string.IsNullOrEmpty(i.chora.ToString()) ? i.chora.ToString() : String.Empty); dic.Add("Min inserimento chiamata", !string.IsNullOrEmpty(i.chmin.ToString()) ? i.chmin.ToString() : String.Empty); dic.Add("Operatore assegnazione", !string.IsNullOrEmpty(i.chopass.ToString()) ? i.chopass.ToString() : String.Empty); dic.Add("Operatore chiusura", !string.IsNullOrEmpty(i.chopchi.ToString()) ? i.chopchi.ToString() : String.Empty); dic.Add("Azienda impianto", !string.IsNullOrEmpty(i.chaziimp) ? i.chaziimp : String.Empty); dic.Add("Ora appuntamento fine", !string.IsNullOrEmpty(i.choraapf.ToString()) ? i.choraapf.ToString() : String.Empty); dic.Add("Min appuntamento fine", !string.IsNullOrEmpty(i.chminapf.ToString()) ? i.chminapf.ToString() : String.Empty); dic.Add("Riferimento chiamata", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Riferimento telefono", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); dic.Add("Codice segnalazione", !string.IsNullOrEmpty(i.chcodseg) ? i.chcodseg : String.Empty); dic.Add("Fermo impianto", !string.IsNullOrEmpty(i.chstopi) ? i.chstopi : String.Empty); dic.Add("Data assegnazione chiamata", !string.IsNullOrEmpty(i.chdtass.ToString()) ? i.chdtass.ToString() : String.Empty); dic.Add("Ora assegnazione chiamata", !string.IsNullOrEmpty(i.chorass.ToString()) ? i.chorass.ToString() : String.Empty); dic.Add("Min assegnazione chiamata", !string.IsNullOrEmpty(i.chminass.ToString()) ? i.chminass.ToString() : String.Empty); dic.Add("Data chiusura chiamata", !string.IsNullOrEmpty(i.chdtchi.ToString()) ? i.chdtchi.ToString() : String.Empty); dic.Add("Ora chiusura chiamata", !string.IsNullOrEmpty(i.chorachi.ToString()) ? i.chorachi.ToString() : String.Empty); dic.Add("Min chiusura chiamata", !string.IsNullOrEmpty(i.chminchi.ToString()) ? i.chminchi.ToString() : String.Empty); dic.Add("Data inizio intervento", !string.IsNullOrEmpty(i.chdtlin.ToString()) ? i.chdtlin.ToString() : String.Empty); dic.Add("Ora inizio intervento", !string.IsNullOrEmpty(i.chorali.ToString()) ? i.chorali.ToString() : String.Empty); dic.Add("Min inizio intervento", !string.IsNullOrEmpty(i.chminli.ToString()) ? i.chminli.ToString() : String.Empty); dic.Add("Data fine intervento", !string.IsNullOrEmpty(i.chdtlfi.ToString()) ? i.chdtlfi.ToString() : String.Empty); dic.Add("Ora fine intervento", !string.IsNullOrEmpty(i.choralf.ToString()) ? i.choralf.ToString() : String.Empty); dic.Add("Min fine intervento", !string.IsNullOrEmpty(i.chminlf.ToString()) ? i.chminlf.ToString() : String.Empty); dic.Add("Numero 1 rapportino futuro", !string.IsNullOrEmpty(i.chnrap1.ToString()) ? i.chnrap1.ToString() : String.Empty); dic.Add("Serie 1 rapportino futuro", !string.IsNullOrEmpty(i.chsrap1) ? i.chsrap1 : String.Empty); dic.Add("Numero 2 rapportino futuro", !string.IsNullOrEmpty(i.chnrap2.ToString()) ? i.chnrap2.ToString() : String.Empty); dic.Add("Modalità raccolta chiamata", !string.IsNullOrEmpty(i.chmodrac) ? i.chmodrac : String.Empty); dic.Add("Numero chiamata per impianto per anno", !string.IsNullOrEmpty(i.chprgann.ToString()) ? i.chprgann.ToString() : String.Empty); dic.Add("Importo manodopera", !string.IsNullOrEmpty(i.chimpman.ToString()) ? i.chimpman.ToString() : String.Empty); dic.Add("Percentuale manodopera", !string.IsNullOrEmpty(i.chperman.ToString()) ? i.chperman.ToString() : String.Empty); dic.Add("Stampa manodopera", !string.IsNullOrEmpty(i.chflstim) ? i.chflstim : String.Empty); dic.Add("Chiusura da remoto", !string.IsNullOrEmpty(i.chfleste) ? i.chfleste : String.Empty); dic.Add("Riferimento seriale importazione", !string.IsNullOrEmpty(i.chserext) ? i.chserext : String.Empty); dic.Add("Descrizione impianto", !string.IsNullOrEmpty(i.imdescri) ? i.imdescri : String.Empty); dic.Add("Tipo impianto", !string.IsNullOrEmpty(i.imtipoim) ? i.imtipoim : String.Empty); dic.Add("Matricola impianto ", !string.IsNullOrEmpty(i.immatric) ? i.immatric : String.Empty); dic.Add("Numero impianto ", !string.IsNullOrEmpty(i.imnumimp) ? i.imnumimp : String.Empty); dic.Add("Ultimo amministratore ", !string.IsNullOrEmpty(i.imultamm) ? i.imultamm : String.Empty); dic.Add("Desc Ultimo amministratore ", !string.IsNullOrEmpty(i.imultdam) ? i.imultdam : String.Empty); dic.Add("Telefono Ult. Amministratore", !string.IsNullOrEmpty(i.imulttam) ? i.imulttam : String.Empty); dic.Add("Ubicazione impianto", !string.IsNullOrEmpty(i.imubicaz) ? i.imubicaz : String.Empty); dic.Add("Zona manutenzione", !string.IsNullOrEmpty(i.imzonman) ? i.imzonman : String.Empty); dic.Add("Pubblico/privato", !string.IsNullOrEmpty(i.imflpupr) ? i.imflpupr : String.Empty); dic.Add("Zona chiamate", !string.IsNullOrEmpty(i.imzonchi) ? i.imzonchi : String.Empty); dic.Add("Zona supervisione", !string.IsNullOrEmpty(i.imzonsup) ? i.imzonsup : String.Empty); dic.Add("Data inizio manutenzione", i.imdainma != null ? i.imdainma.ToString() : String.Empty); dic.Add("Data fine manutenzione", !string.IsNullOrEmpty(i.imdafima.ToString()) ? i.imdafima.ToString() : String.Empty); dic.Add("Data costruzione", !string.IsNullOrEmpty(i.imdatcos.ToString()) ? i.imdatcos.ToString() : String.Empty); dic.Add("Numero telesoccorso ", !string.IsNullOrEmpty(i.imteleso) ? i.imteleso : String.Empty); dic.Add("Email cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Ultimo cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Codice cliente", !string.IsNullOrEmpty(i.ancodice) ? i.ancodice : String.Empty); dic.Add("Tipo anagrafica", !string.IsNullOrEmpty(i.antipcon) ? i.antipcon : String.Empty); #endregion break; case Clienti.Sarom: #region Sarom dic.Add("Esercizio", !string.IsNullOrEmpty(i.chcodese) ? i.chcodese : String.Empty); dic.Add("Tipo", !string.IsNullOrEmpty(i.chtipo) ? i.chtipo : String.Empty); dic.Add("Numero chiamata", !string.IsNullOrEmpty(i.chnumero.ToString()) ? i.chnumero.ToString() : String.Empty); dic.Add("Data chiamata", !string.IsNullOrEmpty(i.chdata.ToString()) ? i.chdata.ToString() : String.Empty); dic.Add("Ora inserimento chiamata", !string.IsNullOrEmpty(i.chora.ToString()) ? i.chora.ToString() : String.Empty); dic.Add("Min inserimento chiamata", !string.IsNullOrEmpty(i.chmin.ToString()) ? i.chmin.ToString() : String.Empty); dic.Add("Operatore assegnazione", !string.IsNullOrEmpty(i.chopass.ToString()) ? i.chopass.ToString() : String.Empty); dic.Add("Operatore chiusura", !string.IsNullOrEmpty(i.chopchi.ToString()) ? i.chopchi.ToString() : String.Empty); dic.Add("Azienda impianto", !string.IsNullOrEmpty(i.chaziimp) ? i.chaziimp : String.Empty); dic.Add("Ora appuntamento fine", !string.IsNullOrEmpty(i.choraapf.ToString()) ? i.choraapf.ToString() : String.Empty); dic.Add("Min appuntamento fine", !string.IsNullOrEmpty(i.chminapf.ToString()) ? i.chminapf.ToString() : String.Empty); dic.Add("Riferimento chiamata", !string.IsNullOrEmpty(i.chrifer) ? i.chrifer : String.Empty); dic.Add("Riferimento telefono", !string.IsNullOrEmpty(i.chtelef) ? i.chtelef : String.Empty); dic.Add("Codice segnalazione", !string.IsNullOrEmpty(i.chcodseg) ? i.chcodseg : String.Empty); dic.Add("Fermo impianto", !string.IsNullOrEmpty(i.chstopi) ? i.chstopi : String.Empty); dic.Add("Data assegnazione chiamata", !string.IsNullOrEmpty(i.chdtass.ToString()) ? i.chdtass.ToString() : String.Empty); dic.Add("Ora assegnazione chiamata", !string.IsNullOrEmpty(i.chorass.ToString()) ? i.chorass.ToString() : String.Empty); dic.Add("Min assegnazione chiamata", !string.IsNullOrEmpty(i.chminass.ToString()) ? i.chminass.ToString() : String.Empty); dic.Add("Data chiusura chiamata", !string.IsNullOrEmpty(i.chdtchi.ToString()) ? i.chdtchi.ToString() : String.Empty); dic.Add("Ora chiusura chiamata", !string.IsNullOrEmpty(i.chorachi.ToString()) ? i.chorachi.ToString() : String.Empty); dic.Add("Min chiusura chiamata", !string.IsNullOrEmpty(i.chminchi.ToString()) ? i.chminchi.ToString() : String.Empty); dic.Add("Data inizio intervento", !string.IsNullOrEmpty(i.chdtlin.ToString()) ? i.chdtlin.ToString() : String.Empty); dic.Add("Ora inizio intervento", !string.IsNullOrEmpty(i.chorali.ToString()) ? i.chorali.ToString() : String.Empty); dic.Add("Min inizio intervento", !string.IsNullOrEmpty(i.chminli.ToString()) ? i.chminli.ToString() : String.Empty); dic.Add("Data fine intervento", !string.IsNullOrEmpty(i.chdtlfi.ToString()) ? i.chdtlfi.ToString() : String.Empty); dic.Add("Ora fine intervento", !string.IsNullOrEmpty(i.choralf.ToString()) ? i.choralf.ToString() : String.Empty); dic.Add("Min fine intervento", !string.IsNullOrEmpty(i.chminlf.ToString()) ? i.chminlf.ToString() : String.Empty); dic.Add("Numero 1 rapportino futuro", !string.IsNullOrEmpty(i.chnrap1.ToString()) ? i.chnrap1.ToString() : String.Empty); dic.Add("Serie 1 rapportino futuro", !string.IsNullOrEmpty(i.chsrap1) ? i.chsrap1 : String.Empty); dic.Add("Numero 2 rapportino futuro", !string.IsNullOrEmpty(i.chnrap2.ToString()) ? i.chnrap2.ToString() : String.Empty); dic.Add("Modalità raccolta chiamata", !string.IsNullOrEmpty(i.chmodrac) ? i.chmodrac : String.Empty); dic.Add("Numero chiamata per impianto per anno", !string.IsNullOrEmpty(i.chprgann.ToString()) ? i.chprgann.ToString() : String.Empty); dic.Add("Importo manodopera", !string.IsNullOrEmpty(i.chimpman.ToString()) ? i.chimpman.ToString() : String.Empty); dic.Add("Percentuale manodopera", !string.IsNullOrEmpty(i.chperman.ToString()) ? i.chperman.ToString() : String.Empty); dic.Add("Stampa manodopera", !string.IsNullOrEmpty(i.chflstim) ? i.chflstim : String.Empty); dic.Add("Chiusura da remoto", !string.IsNullOrEmpty(i.chfleste) ? i.chfleste : String.Empty); dic.Add("Riferimento seriale importazione", !string.IsNullOrEmpty(i.chserext) ? i.chserext : String.Empty); dic.Add("Descrizione impianto", !string.IsNullOrEmpty(i.imdescri) ? i.imdescri : String.Empty); dic.Add("Tipo impianto", !string.IsNullOrEmpty(i.imtipoim) ? i.imtipoim : String.Empty); dic.Add("Matricola impianto ", !string.IsNullOrEmpty(i.immatric) ? i.immatric : String.Empty); dic.Add("Numero impianto ", !string.IsNullOrEmpty(i.imnumimp) ? i.imnumimp : String.Empty); dic.Add("Ultimo amministratore ", !string.IsNullOrEmpty(i.imultamm) ? i.imultamm : String.Empty); dic.Add("Desc Ultimo amministratore ", !string.IsNullOrEmpty(i.imultdam) ? i.imultdam : String.Empty); dic.Add("Telefono Ult. Amministratore", !string.IsNullOrEmpty(i.imulttam) ? i.imulttam : String.Empty); dic.Add("Ubicazione impianto", !string.IsNullOrEmpty(i.imubicaz) ? i.imubicaz : String.Empty); dic.Add("Zona manutenzione", !string.IsNullOrEmpty(i.imzonman) ? i.imzonman : String.Empty); dic.Add("Pubblico/privato", !string.IsNullOrEmpty(i.imflpupr) ? i.imflpupr : String.Empty); dic.Add("Zona chiamate", !string.IsNullOrEmpty(i.imzonchi) ? i.imzonchi : String.Empty); dic.Add("Zona supervisione", !string.IsNullOrEmpty(i.imzonsup) ? i.imzonsup : String.Empty); dic.Add("Data inizio manutenzione", i.imdainma != null ? i.imdainma.ToString() : String.Empty); dic.Add("Data fine manutenzione", !string.IsNullOrEmpty(i.imdafima.ToString()) ? i.imdafima.ToString() : String.Empty); dic.Add("Data costruzione", !string.IsNullOrEmpty(i.imdatcos.ToString()) ? i.imdatcos.ToString() : String.Empty); dic.Add("Numero telesoccorso ", !string.IsNullOrEmpty(i.imteleso) ? i.imteleso : String.Empty); dic.Add("Email cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Ultimo cliente", !string.IsNullOrEmpty(i.an_email) ? i.an_email : String.Empty); dic.Add("Codice cliente", !string.IsNullOrEmpty(i.ancodice) ? i.ancodice : String.Empty); dic.Add("Tipo anagrafica", !string.IsNullOrEmpty(i.antipcon) ? i.antipcon : String.Empty); #endregion break; default: break; } o.altri = dic; o.imazirif = i.imazirif; o.imrefref = i.imrefref; return o; } private string getCommessaSietBySerial(string seriale) { string commessa = string.Empty; try { //_commDescSiet = _Siet_commDesc.Commdesc; //var c = _commDescSiet.Where(c => c.laserial.Equals(seriale)).First(); //if (c != null && !string.IsNullOrEmpty(c.lacodcom)) //{ // commessa = c.lacodcom.Trim(); // if (!string.IsNullOrEmpty(c.lacodcen)) // { // commessa = commessa + " - " + c.lacodcen.Trim(); // } //} } catch { Console.WriteLine(string.Format("*********** {1} Errore Chiamata al metodo getCommessaSietBySerial: seriale:{0} ", seriale, DateTime.Now.ToString())); } return commessa; } #endregion /// chiamatetest [HttpGet("chiamatetest")] public async Task>> chiamate(string token) { try { List ilist = new List(); string ten = getClaimValueByToken(token, "tenant"); string ten2 = getClaimValueByToken(token, "tenant2"); string tenOut = getClaimValueByToken(token, "tenant"); string tecnico = getClaimValueByToken(token, "tccodice"); string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); if (string.IsNullOrEmpty(ten)) { ten = tenConf; } _chiamate = getChiamateByTenant(ten); var calltec = await _chiamate.Where( t => t.tccodice == tecnico && t.chcodazi == ten ).OrderByDescending(t => t.chdtapp).ToListAsync(); foreach (Chiamate ch in calltec) { Chiamate_out o = new Chiamate_out(); o = fillChiamateOut(ch, ten); ilist.Add(o); } // cerco le chiamate che devo fare per sostituzioni SE funzione abilitata //bool cerca_sostituzioni = false; //cerca_sostituzioni = checkSostituzioneAbilitata(ten); //if (cerca_sostituzioni) //{ // //step 1 : trovo tutte le MIE sostituzioni // _sostituzione = getSostituzioneByTenant(ten); // var s = _sostituzione.Where(t => t.tscodazi.Equals(ten) && t.tscodsos.Trim().Equals(tecnico)); // foreach (Sostituzione ss in s) // { // string tecnico_sostituito = string.Empty; // tecnico_sostituito = ss.tscodtec != null ? ss.tscodtec : string.Empty; // //2023-03-13: cancellato il filtro sulla zona perchè il tecnico che sostituisce spesso è di un'altra zona // //string zona = string.Empty; // //zona = ss.tscodzon != null ? ss.tscodzon : "zonavuota"; // //step 2 : trovo tutte le chiamate del tecnico che sto sostitutendo e le aggiungo alla mie // var calltecSost = await _chiamate.Where( // t => t.tccodice == tecnico_sostituito // && t.chcodazi == ten // //&& t.imzonchi.Equals(zona) // ).OrderByDescending(t => t.chdtapp).ToListAsync(); // foreach (Chiamate ch in calltecSost) // { // Chiamate_out o = new Chiamate_out(); // if (tenOut.Equals(Clienti.VT)) // { // o = fillChiamateOutVT(ch, ten); // } // else // { // o = fillChiamateOut(ch, ten); // } // ilist.Add(o); // } // } //} IEnumerable enumerable = ilist as IEnumerable; //return StatusCode(StatusCodes.Status200OK, enumerable.Take(100)); return StatusCode(StatusCodes.Status200OK, enumerable); } catch (Exception ex) { string err = "Errore: " + ex.Message; return StatusCode(StatusCodes.Status500InternalServerError, err); } } } }