commit ed9a803aebee1ee811f369b86ab01a1e9b4dabfd Author: michele Date: Thu May 8 17:41:48 2025 +0200 Api VT diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b45c758 --- /dev/null +++ b/.gitignore @@ -0,0 +1,366 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd +/.vs/ApiPolo/v17/.suo +/.vs/ApiPolo/v17/.futdcache.v2 +/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2 diff --git a/ApiPolo/.config/dotnet-tools.json b/ApiPolo/.config/dotnet-tools.json new file mode 100644 index 0000000..fccc806 --- /dev/null +++ b/ApiPolo/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "7.0.0", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/ApiPolo/Api_VT.csproj b/ApiPolo/Api_VT.csproj new file mode 100644 index 0000000..aed9739 --- /dev/null +++ b/ApiPolo/Api_VT.csproj @@ -0,0 +1,35 @@ + + + + net6.0 + enable + enable + True + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + diff --git a/ApiPolo/Controllers/AdminController.cs b/ApiPolo/Controllers/AdminController.cs new file mode 100644 index 0000000..62f0dc5 --- /dev/null +++ b/ApiPolo/Controllers/AdminController.cs @@ -0,0 +1,75 @@ +using ApiPolo.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Data.SqlClient; +using System.Data; +using System.IdentityModel.Tokens.Jwt; + +namespace ApiPolo.Controllers +{ + /// Controller per Admin + [Route("api/[controller]")] + [ApiController] + public class AdminController : Controller + { + private readonly IConfiguration _configuration; + + /// + public AdminController(IConfiguration configuration) + { + _configuration = configuration; + } + + /// + [HttpGet("esegui")] + public IActionResult EseguiStoredProcedure([FromQuery] string token, [FromQuery] int idReg,[FromQuery] string stored) + { + string connStr = _configuration.GetConnectionString("ApiStr"); + string sa = getClaimValueByToken(token, "superAdmin"); + if(!string.IsNullOrEmpty(sa) && sa.Equals("S")) + { + using (SqlConnection conn = new SqlConnection(connStr)) + { + using (SqlCommand cmd = new SqlCommand(stored, conn)) + { + cmd.CommandType = CommandType.StoredProcedure; + // Aggiungi i parametri richiesti dalla stored procedure + cmd.Parameters.Add(new SqlParameter("@idReg", idReg)); + + try + { + conn.Open(); + int righeEffettuate = cmd.ExecuteNonQuery(); + + return Ok(new { Successo = true, RigheInserite = righeEffettuate }); + } + catch (Exception ex) + { + return StatusCode(500, $"Errore durante l'inserimento: {ex.Message}"); + } + } + } + } + else + { + return StatusCode(403, "Accesso negato: non hai i permessi necessari."); + } + + + } + + + 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; + } + } +} diff --git a/ApiPolo/Controllers/PoloController.cs b/ApiPolo/Controllers/PoloController.cs new file mode 100644 index 0000000..5c474ae --- /dev/null +++ b/ApiPolo/Controllers/PoloController.cs @@ -0,0 +1,14840 @@ +using ApiPolo.Models; + + +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.IdentityModel.Tokens; +using Renci.SshNet; +using System.IdentityModel.Tokens.Jwt; +using System.Net; +using System.Security.Claims; +using System.Text; + +using System.Collections.Generic; +using System.Drawing; +using FirebaseAdmin; +using FirebaseAdmin.Messaging; +using Google.Apis.Auth.OAuth2; +using Newtonsoft.Json; +using static ApiPolo.Controllers.PoloController; +using System.Net.Http.Headers; +using Newtonsoft.Json.Linq; +using System.Linq.Expressions; +using FirebaseAdmin.Auth.Multitenancy; +using System.Globalization; +using ApiPolo.Models.VT_dbcontext; +using System.Diagnostics.Contracts; +using Microsoft.EntityFrameworkCore.Storage; +using System.Diagnostics.Metrics; +using System.Transactions; +using System.Web.Razor.Parser; +using System; +using System.Collections; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; +using static System.Net.Mime.MediaTypeNames; +using System.IO; +using Microsoft.AspNetCore.Http; +using System.Data; +using System.Linq; +using Microsoft.Extensions.Primitives; +using System.Text.RegularExpressions; +using System.Runtime.CompilerServices; +using System.Diagnostics; +using Api_VT.Models.VT_dbcontext; +using Api_VT.Models; + +namespace ApiPolo.Controllers +{ + /// + /// Controller unico + /// + [Route("api/[controller]")] + [ApiController] + public class PoloController : Controller + { + private string _token = string.Empty; + private readonly ConfigurazioniDbContext? _config; + private readonly IConfiguration? _configuration; + + private readonly TokenDbContext? _tokens; + + #region TECNICI + + private readonly VT_TECNICI_DbContext _VT_tecnici; + + #endregion + + #region VT - Chiusure + private readonly VT_CHIUSURE_TABLE_DbContext _VT_chiutable; + private readonly VT_CHIUSURE_DbContext _VT_chiu; + #endregion + + #region VT - Tecnici + private readonly VT_TECNICI_TABLE_DbContext _VT_tectable; + private readonly VT_TECNICI_DbContext _VT_tec; + #endregion + + #region VT - anagrafiche + private readonly VT_CONTI_TABLE_DbContext _VT_anagtable; + private readonly VT_CONTI_DbContext _VT_anag; + #endregion + + #region VT - Impianti + private readonly VT_IMPIANTI_TABLE_DbContext _VT_impiatable; + private readonly VT_IMPIANTI_DbContext _VT_impia; + private readonly VT_IMPIANTI_MANAGER_DbContext _VT_impiaMngr; + #endregion + + #region VT-RAPP NEW + private readonly VT_RAPP_NEW_TABLE_DbContext _VT_rapptable; + private readonly VT_RAPP_NEW_DbContext _VT_rapp; + #endregion + + #region VT-CHIAMATE + private readonly VT_CHIAMATE_TABLE_DbContext _VT_chiatable; + private readonly VT_CHIAMATE_DbContext _VT_chia; + private readonly VT_CHIAMATE_MANAGER_DbContext _VT_chiaMngr; + #endregion + + #region VT-Progressivi + private readonly VT_PROGRESSIVI_DbContext _VT_progtable; + #endregion + + #region VT-aziende + private readonly VT_AZIENDA_RIF_DbContext _VT_azi; + #endregion + + #region VT-registrazioni + private readonly VT_REGISTRAZIONE_DbContext _VT_reg; + #endregion + + #region VT-aziendePresenti + private readonly VT_AZIENDE_PRESENTI_DbContext _VT_AziPres; + #endregion + + #region VT-commesse + private readonly VT_COMMESSE_DbContext _VT_Comm; + private readonly VT_COMMESSE_TABLE_DbContext _VT_CommTable; + private readonly VT_COMMESSE_APP_DbContext _VT_CommApp; + #endregion + + #region VT-rapportini excel + private readonly VT_RAPPORTINI_DbContext _VT_Rapportini; + + #endregion + + #region VT-Buoni + private readonly VT_Buoni_DbContext _VT_Buoni; + #endregion + + #region VT - Dati azienda + private readonly VT_DATI_AZIENDA_DbContext _VT_DatiAzienda; + #endregion + + #region VT-Storico Rapp + private readonly VT_STO_RAPP_DbContext _VT_StoRapp; + #endregion + + #region VT-TIMBRATURE + private readonly VT_TIMBRATURE_DbContext _VT_timbr; + #endregion + + #region VT-ARTICOLI + private readonly VT_ARTICOLI_TABLE_DbContext _VT_articoliTable; + #endregion + + #region VT-MAG_NEW + private readonly VT_MAG_NEW_DbContext _VT_MagNew; + #endregion + + #region VT-MAGAZZINI + private readonly VT_MAGAZZINI_DbContext _VT_Magazzini; + #endregion + + #region VT-CODICI SEGNALAZIONI + private readonly VT_CODICE_SEGNALAZIONE_DbContext _VT_CodSegn; + #endregion + + + private DbSet? _tecnici; + private DbSet? _rapp_new; + private DbSet? _chiamate; + private DbSet? _chiusure; + private DbSet? _manutprog; + private DbSet? _prese; + private DbSet? _compo; + private DbSet? _compoTable; + private DbSet? _saldi; + private DbSet? _mag; + private DbSet? _magazzini; + private DbSet? _sto_rapp; + private DbSet? _clienti; + private DbSet? _cau_rapp; + private DbSet? _pagam; + private DbSet? _comm; + private DbSet? _timbr; + private DbSet? _sto_imp; + private DbSet? _azi_coll; + private DbSet? _impianto; + private DbSet? _sostituzione; + private DbSet? _chiatable; + private DbSet? _chiatableTaskManager; + private DbSet? _chiamateser; + private DbSet? _chiamateprogr; + private DbSet? _cpwarns; + + private DbSet? _chiuTable; + private DbSet? _tecTable; + private DbSet? _anagTable; + private DbSet? _impiaTable; + private DbSet? _clientiVT; + private DbSet? _VT_prog; + private DbSet? _VT_regi; + private DbSet? _VT_AziPresenti; + private DbSet? _VT_Commesse; + private DbSet? _VT_CommesseTable; + private DbSet? _VT_DatiAzi; + private DbSet? _VT_rapport; + private DbSet? _VT_buo; + private DbSet? _rapp_new_view; + private DbSet? _articoliTable; + private DbSet? _magNewVT; + private DbSet? _magazziniVT; + private DbSet? _codSegnVT; + + private DbSet? _commDesc; + + private DbSet? _ccci; + private DbSet? _ccciView; + + private Configurazioni? _confLette; + + /// polocontroller + public PoloController(IConfiguration configuration,ConfigurazioniDbContext config + ,TokenDbContext tokens,VT_TECNICI_DbContext VT_tecnici, + #region Virtual task + VT_TECNICI_TABLE_DbContext VT_tectable, + VT_TECNICI_DbContext VT_tec, + VT_CHIUSURE_TABLE_DbContext VT_chiutable, + VT_CHIUSURE_DbContext VT_chiu, + VT_CONTI_TABLE_DbContext VT_anagtable, + VT_CONTI_DbContext VT_anag, + VT_RAPP_NEW_TABLE_DbContext VT_rapptable, + VT_RAPP_NEW_DbContext VT_rapp, + VT_IMPIANTI_TABLE_DbContext VT_impiatable, + VT_IMPIANTI_DbContext VT_impia, + VT_IMPIANTI_MANAGER_DbContext VT_impiaMngr, + VT_CHIAMATE_TABLE_DbContext VT_chiatable, + VT_CHIAMATE_DbContext VT_chia, + VT_PROGRESSIVI_DbContext VT_progtable, + VT_CHIAMATE_MANAGER_DbContext VT_chiaMngr, + VT_AZIENDA_RIF_DbContext VT_azi, + VT_REGISTRAZIONE_DbContext VT_reg, + VT_AZIENDE_PRESENTI_DbContext VT_AziPres, + VT_COMMESSE_DbContext VT_Comm, + VT_COMMESSE_TABLE_DbContext VT_CommTable, + VT_COMMESSE_APP_DbContext VT_CommApp, + VT_DATI_AZIENDA_DbContext VT_DatiAzienda, + VT_RAPPORTINI_DbContext VT_Rapportini, + VT_Buoni_DbContext VT_Buoni, + VT_STO_RAPP_DbContext VT_StoRapp, + VT_TIMBRATURE_DbContext VT_timbr, + VT_ARTICOLI_TABLE_DbContext VT_artTable, + VT_MAG_NEW_DbContext VT_MagNew, + VT_MAGAZZINI_DbContext VT_Magazzini, + VT_CODICE_SEGNALAZIONE_DbContext VT_CodSegn + #endregion + ) + { + _configuration = configuration; + _config = config; + _tokens = tokens; + + #region TECNICI + _VT_tecnici = VT_tecnici; + #endregion + + #region VIRTUAL TASK + _VT_tectable = VT_tectable; + _VT_tec = VT_tec; + _VT_chiutable = VT_chiutable; + _VT_chiu = VT_chiu; + _VT_anagtable = VT_anagtable; + _VT_anag = VT_anag; + _VT_rapptable = VT_rapptable; + _VT_rapp = VT_rapp; + _VT_impiatable = VT_impiatable; + _VT_impia = VT_impia; + _VT_impiaMngr = VT_impiaMngr; + _VT_chiatable = VT_chiatable; + _VT_chia = VT_chia; + _VT_progtable = VT_progtable; + _VT_chiaMngr = VT_chiaMngr; + _VT_azi = VT_azi; + _VT_reg = VT_reg; + _VT_AziPres = VT_AziPres; + _VT_Comm = VT_Comm; + _VT_CommTable = VT_CommTable; + _VT_CommApp = VT_CommApp; + _VT_DatiAzienda = VT_DatiAzienda; + _VT_Rapportini = VT_Rapportini; + _VT_Buoni = VT_Buoni; + _VT_StoRapp = VT_StoRapp; + _VT_articoliTable = VT_artTable; + _VT_MagNew = VT_MagNew; + _VT_Magazzini = VT_Magazzini; + _VT_CodSegn = VT_CodSegn; + #endregion + + } + + #region Utility + private async Task readConf(string ten) + { + Configurazioni c=new Configurazioni(); + List co =new List(); + if(_config is not null && _config.conf is not null) + //co = await _config.conf.Where(t => t.azienda_adhoc == ten).ToListAsync(); + co = await _config.conf.Where(t => t.azienda == ten).ToListAsync(); + + foreach (var a in co) + { + c.azienda = a.azienda != null ? a.azienda.Trim() : string.Empty; ; + c.prefisso_buoni_chia = a.prefisso_buoni_chia!=null ?a.prefisso_buoni_chia.Trim():string.Empty; + c.prefisso_buoni_man = a.prefisso_buoni_man !=null ? a.prefisso_buoni_man.Trim():string.Empty; + c.path_buoni = a.path_buoni != null ? a.path_buoni.Trim() : string.Empty; + c.ftp_url = a.ftp_url != null ? a.ftp_url.Trim() : string.Empty; + c.ftp_usr = a.ftp_usr != null ? a.ftp_usr.Trim() : string.Empty; + c.ftp_pwd = a.ftp_pwd != null ? a.ftp_pwd.Trim() : string.Empty; + c.listino=a.listino!=null? a.listino.Trim() : string.Empty; + + + c.abilita_naviga = a.abilita_naviga != null ? a.abilita_naviga : true; + c.abilita_telefona = a.abilita_telefona != null ? a.abilita_telefona : true; + c.abilita_chiamate = a.abilita_chiamate != null ? a.abilita_chiamate : true; + c.abilita_manutenzioni = a.abilita_manutenzioni != null ? a.abilita_manutenzioni : true; + c.abilita_barcode = a.abilita_barcode != null ? a.abilita_barcode : true; + c.chiamate_accetta = a.chiamate_accetta != null ? a.chiamate_accetta : true; + c.chiamate_accetta_barcode = a.chiamate_accetta_barcode != null ? a.chiamate_accetta_barcode : true; + c.chiamate_accetta_offline = a.chiamate_accetta_offline != null ? a.chiamate_accetta_offline : true; + c.chiamate_rifiuta = a.chiamate_rifiuta != null ? a.chiamate_rifiuta : true; + c.chiamate_rifiuta_barcode = a.chiamate_rifiuta_barcode != null ? a.chiamate_rifiuta_barcode : true; + c.chiamate_rifiuta_offline = a.chiamate_rifiuta_offline != null ? a.chiamate_rifiuta_offline : true; + c.chiamate_chiudi_barcode = a.chiamate_chiudi_barcode != null ? a.chiamate_chiudi_barcode : true; + c.chiamate_firma_barcode = a.chiamate_firma_barcode != null ? a.chiamate_firma_barcode : true; + c.chiamate_chiudi_salva_barcode = a.chiamate_chiudi_salva_barcode != null ? a.chiamate_chiudi_salva_barcode : true; + c.chiamate_chiudi_salva_offline = a.chiamate_chiudi_salva_offline != null ? a.chiamate_chiudi_salva_offline : true; + + c.manutenzioni_accetta = a.manutenzioni_accetta != null ? a.manutenzioni_accetta : true; + c.manutenzioni_rifiuta = a.manutenzioni_rifiuta != null ? a.manutenzioni_rifiuta : true; + c.manutenzioni_accetta_barcode = a.manutenzioni_accetta_barcode != null ? a.manutenzioni_accetta_barcode : true; + c.manutenzioni_accetta_offline = a.manutenzioni_accetta_offline != null ? a.manutenzioni_accetta_offline : true; + c.manutenzioni_chiudi_barcode = a.manutenzioni_chiudi_barcode != null ? a.manutenzioni_chiudi_barcode : true; + c.manutenzioni_firma_barcode = a.manutenzioni_firma_barcode != null ? a.manutenzioni_firma_barcode : true; + c.manutenzioni_chiudi_salva_barcode = a.manutenzioni_chiudi_salva_barcode != null ? a.manutenzioni_chiudi_salva_barcode : true; + c.manutenzioni_chiudi_salva_offline = a.manutenzioni_chiudi_salva_offline != null ? a.manutenzioni_chiudi_salva_offline : true; + c.manutenzioni_rifiuta_barcode = a.manutenzioni_rifiuta_barcode != null ? a.manutenzioni_rifiuta_barcode : true; + + c.dpi_checkbox = a.dpi_checkbox != null ? a.dpi_checkbox : true; + + c.anagrafica = a.anagrafica != null ? a.anagrafica : true; + c.stato_finale = a.stato_finale != null ? a.stato_finale : true; + c.descrizione_intervento = a.descrizione_intervento != null ? a.descrizione_intervento : true; + c.composizione_impianto = a.composizione_impianto != null ? a.composizione_impianto : true; + c.note_intervento = a.note_intervento != null ? a.note_intervento : true; + c.esito_intervento = a.esito_intervento != null ? a.esito_intervento : true; + c.ora_inizio_fine = a.ora_inizio_fine != null ? a.ora_inizio_fine : true; + c.materiali = a.materiali != null ? a.materiali : true; + c.diritto_chiamata = a.diritto_chiamata != null ? a.diritto_chiamata : true; + c.manodopera = a.manodopera != null ? a.manodopera : true; + c.spese_viaggio = a.spese_viaggio != null ? a.spese_viaggio : true; + c.tipo_pagamento = a.tipo_pagamento != null ? a.tipo_pagamento : true; + c.note_pagamento = a.note_pagamento != null ? a.note_pagamento : true; + c.causale = a.causale != null ? a.causale : true; + + c.time_sheet=a.time_sheet!= null ? a.time_sheet : true; + c.time_sheet_offline = a.time_sheet_offline != null ? a.time_sheet_offline : true; + c.costo_orario = a.costo_orario != null ? a.costo_orario : 0; + c.ftp_port = a.ftp_port != null ? a.ftp_port : 0; + + c.storico=a.storico != null ? a.storico : true; + c.storico_tecnico = a.storico_tecnico != null ? a.storico_tecnico : true; + + c.storico_interventi = a.storico_interventi != null ? a.storico_interventi : true; + c.storico_impianto = a.storico_impianto != null ? a.storico_impianto : true; + c.ricerca_impianti = a.ricerca_impianti != null ? a.ricerca_impianti : true; + c.ora_inizio_fine_automatica = a.ora_inizio_fine_automatica != null ? a.ora_inizio_fine_automatica : true; + c.stampa_orario = a.stampa_orario != null ? a.stampa_orario : true; + c.intestazione_stampa = a.intestazione_stampa != null ? a.intestazione_stampa.Trim() : string.Empty; + c.abilita_inserimento_chiamate = a.abilita_inserimento_chiamate != null ? a.abilita_inserimento_chiamate : 0; + c.seriale_template_chi = a.seriale_template_chi != null ? a.seriale_template_chi : string.Empty; + c.abilita_data_rapp_edit = a.abilita_data_rapp_edit != null ? a.abilita_data_rapp_edit : false; + c.numeri_decimali = a.numeri_decimali != null ? a.numeri_decimali : 0; + c.max_record = a.max_record != null ? a.max_record : 100; + c.prezzi_visibili = a.prezzi_visibili != null ? a.prezzi_visibili : true; + c.desc_supp_prodotti_visibile=a.desc_supp_prodotti_visibile!=null?a.desc_supp_prodotti_visibile:false; + c.azienda_adhoc = a.azienda_adhoc != null ? a.azienda_adhoc : string.Empty; + + c.azienda_adhoc = a.azienda_adhoc != null ? a.azienda_adhoc : string.Empty; + c.desc_interv_stampa = a.desc_interv_stampa != null ? a.desc_interv_stampa : false; + c.note_interv_stampa = a.note_interv_stampa != null ? a.note_interv_stampa :false; + + } + return c; + } + 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 DbSet getTecniciByTenant(string tenant) + { + DbSet? _tecs; + string appo = string.Empty; + _tecs = _VT_tec.Tecnici; + + return _tecs; + } + + + private DbSet getChiamateByTenant(string tenant) + { + DbSet? _calls; + + _calls = _VT_chia.Chiamate; + + return _calls; + } + private DbSet getChiusureByTenant(string tenant) + { + DbSet? _chiu; + _chiu = _VT_chiu.Chiu; + return _chiu; + } + + //private DbSet getManutenzioniByTenant(string tenant) + //{ + // DbSet? _mans; + + // switch (tenant) + // { + // case Clienti.Ferrari: + // _mans = _Ferra_mp.Manutenzioni; + // break; + // case Clienti.Marrocco: + // _mans = _Marro_mp.Manutenzioni; + // break; + // case Clienti.Sicilia: + // _mans = _Sicilia_mp.Manutenzioni; + // break; + // case Clienti.Discovery: + // _mans = _Disco_mp.Manutenzioni; + // break; + // case Clienti.Sarom: + // _mans = _Sarom_mp.Manutenzioni; + // break; + // case Clienti.Gitoga: + // _mans = _Gitoga_mp.Manutenzioni; + // break; + // case Clienti.Lifta: + // _mans = _Lifta_mp.Manutenzioni; + // break; + // case Clienti.Siet: + // _mans = _Siet_mp.Manutenzioni; + // break; + // case Clienti.PMS: + // _mans = _PMS_mp.Manutenzioni; + // break; + // case Clienti.LW: + // _mans = _LW_mp.Manutenzioni; + // break; + // case Clienti.Tedesco: + // _mans = _Tedes_mp.Manutenzioni; + // break; + // case Clienti.Syscom: + // _mans = _Sys_mp.Manutenzioni; + // break; + // default: + // _mans = null; + // break; + // } + // return _mans; + //} + + //private DbSet getPreseByTenant(string tenant) + //{ + // DbSet? _pre; + + // switch (tenant) + // { + // case Clienti.Ferrari: + // _pre = _Ferra_prese.Prese; + // break; + // case Clienti.Marrocco: + // _pre = _Marro_prese.Prese; + // break; + // case Clienti.Sicilia: + // _pre = _Sicilia_prese.Prese; + // break; + // case Clienti.Discovery: + // _pre = _Disco_prese.Prese; + // break; + // case Clienti.Sarom: + // _pre = _Sarom_prese.Prese; + // break; + // case Clienti.Gitoga: + // _pre = _Gitoga_prese.Prese; + // break; + // case Clienti.Lifta: + // _pre = _Lifta_prese.Prese; + // break; + // case Clienti.Siet: + // _pre = _Siet_prese.Prese; + // break; + // case Clienti.PMS: + // _pre = _PMS_prese.Prese; + // break; + // case Clienti.LW: + // _pre = _LW_prese.Prese; + // break; + // case Clienti.Tedesco: + // _pre = _Tedes_prese.Prese; + // break; + // case Clienti.Syscom: + // _pre = _Sys_prese.Prese; + // break; + // default: + // _pre = null; + // break; + // } + // return _pre; + //} + + //private DbSet getSto_RappByTenant(string tenant) + //{ + // DbSet? _sto; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _sto = _Sicilia_sto_rapp.StoRapp; + // break; + // case Clienti.Discovery: + // _sto = _Disco_sto_rapp.StoRapp; + // break; + // case Clienti.Marrocco: + // _sto = _Marro_sto_rapp.StoRapp; + // break; + // case Clienti.Ferrari: + // _sto = _Ferra_sto_rapp.StoRapp; + // break; + // case Clienti.Sarom: + // _sto = _Sarom_sto_rapp.StoRapp; + // break; + // case Clienti.Gitoga: + // _sto = _Gitoga_sto_rapp.StoRapp; + // break; + // case Clienti.Lifta: + // _sto = _Lifta_sto_rapp.StoRapp; + // break; + // case Clienti.Siet: + // _sto = _Siet_sto_rapp.StoRapp; + // break; + // case Clienti.PMS: + // _sto = _PMS_sto_rapp.StoRapp; + // break; + // case Clienti.LW: + // _sto = _LW_sto_rapp.StoRapp; + // break; + // case Clienti.Tedesco: + // _sto = _Tedes_sto_rapp.StoRapp; + // break; + // case Clienti.Syscom: + // _sto = _Sys_sto_rapp.StoRapp; + // break; + // default: + // _sto = null; + // break; + // } + // return _sto; + //} + + //private DbSet getClientiByTenant(string tenant) + //{ + // DbSet? _cli; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _cli = _Sicilia_clienti.Clienti; + // break; + // case Clienti.Discovery: + // _cli = _Disco_clienti.Clienti; + // break; + // case Clienti.Ferrari: + // _cli = _Ferra_clienti.Clienti; + // break; + // case Clienti.Marrocco: + // _cli = _Marro_clienti.Clienti; + // break; + // case Clienti.Sarom: + // _cli = _Sarom_clienti.Clienti; + // break; + // case Clienti.Gitoga: + // _cli = _Gitoga_clienti.Clienti; + // break; + // case Clienti.Lifta: + // _cli = _Lifta_clienti.Clienti; + // break; + // case Clienti.Siet: + // _cli = _Siet_clienti.Clienti; + // break; + // case Clienti.PMS: + // _cli = _PMS_clienti.Clienti; + // break; + // case Clienti.LW: + // _cli = _LW_clienti.Clienti; + // break; + // case Clienti.Tedesco: + // _cli = _Tedes_clienti.Clienti; + // break; + // case Clienti.Syscom: + // _cli = _Sys_clienti.Clienti; + // break; + // default: + // _cli = null; + // break; + // } + // return _cli; + //} + + //private DbSet getCausaliRappByTenant(string tenant) + //{ + // DbSet? _cau; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _cau = _Sicilia_caus_rapp.Causali; + // break; + // case Clienti.Discovery: + // _cau = _Disco_caus_rapp.Causali; + // break; + // case Clienti.Ferrari: + // _cau = _Ferra_caus_rapp.Causali; + // break; + // case Clienti.Marrocco: + // _cau = _Marro_caus_rapp.Causali; + // break; + // case Clienti.Sarom: + // _cau = _Sarom_caus_rapp.Causali; + // break; + // case Clienti.Gitoga: + // _cau = _Gitoga_caus_rapp.Causali; + // break; + // case Clienti.Lifta: + // _cau = _Lifta_caus_rapp.Causali; + // break; + // case Clienti.Siet: + // _cau = _Siet_caus_rapp.Causali; + // break; + // case Clienti.PMS: + // _cau = _PMS_caus_rapp.Causali; + // break; + // case Clienti.LW: + // _cau = _LW_caus_rapp.Causali; + // break; + // case Clienti.Tedesco: + // _cau = _Tedes_caus_rapp.Causali; + // break; + // case Clienti.Syscom: + // _cau = _Sys_caus_rapp.Causali; + // break; + // default: + // _cau = null; + // break; + // } + // return _cau; + //} + + private DbSet getVTCodiciSegnalaz(string tenant) + { + DbSet? _codSeg; + + if (tenant.Equals(Clienti.VT)) + { + _codSeg = _VT_CodSegn.CodSegn; + + return _codSeg; + } + return _codSeg = null; + } + + //private DbSet getPagamentiByTenant(string tenant) + //{ + // DbSet? _pag; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _pag = _Sicilia_pagam.Pagamenti; + // break; + // case Clienti.Discovery: + // _pag = _Disco_pagam.Pagamenti; + // break; + // case Clienti.Ferrari: + // _pag = _Ferra_pagam.Pagamenti; + // break; + // case Clienti.Marrocco: + // _pag = _Marro_pagam.Pagamenti; + // break; + // case Clienti.Sarom: + // _pag = _Sarom_pagam.Pagamenti; + // break; + // case Clienti.Gitoga: + // _pag = _Gitoga_pagam.Pagamenti; + // break; + // case Clienti.Lifta: + // _pag = _Lifta_pagam.Pagamenti; + // break; + // case Clienti.Siet: + // _pag = _Siet_pagam.Pagamenti; + // break; + // case Clienti.PMS: + // _pag = _PMS_pagam.Pagamenti; + // break; + // case Clienti.LW: + // _pag = _LW_pagam.Pagamenti; + // break; + // case Clienti.Tedesco: + // _pag = _Tedes_pagam.Pagamenti; + // break; + // case Clienti.Syscom: + // _pag = _Sys_pagam.Pagamenti; + // break; + // default: + // _pag = null; + // break; + // } + // return _pag; + //} + + //private DbSet getSaldiartByTenant(string tenant) + //{ + // DbSet? _sa; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _sa = _Sicilia_saldi.Saldi; + // break; + // case Clienti.Discovery: + // _sa = _Disco_saldi.Saldi; + // break; + // case Clienti.Siet : + // _sa = _Siet_saldi.Saldi; + // break; + // case Clienti.PMS: + // _sa = _PMS_saldi.Saldi; + // break; + // case Clienti.LW: + // _sa = _LW_saldi.Saldi; + // break; + // case Clienti.Tedesco: + // _sa = _Tedes_saldi.Saldi; + // break; + // case Clienti.Syscom: + // _sa = _Sys_saldi.Saldi; + // break; + // default: + // _sa = null; + // break; + // } + // return _sa; + //} + + //private DbSet getComponentiByTenant(string tenant) + //{ + // DbSet? _compon; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _compon = _Sicilia_comp.Componen; + // break; + // case Clienti.Discovery: + // _compon = _Disco_comp.Componen; + // break; + // case Clienti.Siet: + // _compon = _Siet_comp.Componen; + // break; + // case Clienti.PMS: + // _compon = _PMS_comp.Componen; + // break; + // case Clienti.LW: + // _compon = _LW_comp.Componen; + // break; + // case Clienti.Tedesco: + // _compon = _Tedes_comp.Componen; + // break; + // case Clienti.Syscom: + // _compon = _Sys_comp.Componen; + // break; + // default: + // _compon = null; + // break; + // } + // return _compon; + //} + + //private DbSet getComponentiTableByTenant(string tenant) + //{ + // DbSet? _compon; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _compon = _Sicilia_compTable.Componen; + // break; + // case Clienti.Discovery: + // _compon = _Disco_compTable.Componen; + // break; + // case Clienti.Siet: + // _compon = _Siet_compTable.Componen; + // break; + // case Clienti.PMS: + // _compon = _PMS_compTable.Componen; + // break; + // case Clienti.LW: + // _compon = _LW_compTable.Componen; + // break; + // case Clienti.Tedesco: + // _compon = _Tedes_compTable.Componen; + // break; + // case Clienti.Syscom: + // _compon = _Sys_compTable.Componen; + // break; + // default: + // _compon = null; + // break; + // } + // return _compon; + //} + + //private DbSet getMagazziniByTenant(string tenant) + //{ + // DbSet? _maga; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _maga = _Sicilia_magazzini.Magaz; + // break; + // case Clienti.Discovery: + // _maga = _Disco_magazzini.Magaz; + // break; + // case Clienti.Siet: + // _maga = _Siet_magazzini.Magaz; + // break; + // case Clienti.PMS: + // _maga = _PMS_magazzini.Magaz; + // break; + // case Clienti.LW: + // _maga = _LW_magazzini.Magaz; + // break; + // case Clienti.Tedesco: + // _maga = _Tedes_magazzini.Magaz; + // break; + // case Clienti.Syscom: + // _maga = _Sys_magazzini.Magaz; + // break; + // default: + // _maga = null; + // break; + // } + // return _maga; + //} + + //private DbSet getMag_NewByTenant(string tenant) + //{ + // DbSet? _ma; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _ma = _Sicilia_mag.Mag; + // break; + // case Clienti.Discovery: + // _ma = _Disco_mag.Mag; + // break; + // case Clienti.Siet: + // _ma = _Siet_mag.Mag; + // break; + // case Clienti.PMS: + // _ma = _PMS_mag.Mag; + // break; + // case Clienti.LW: + // _ma = _LW_mag.Mag; + // break; + // case Clienti.Tedesco: + // _ma = _Tedes_mag.Mag; + // break; + // case Clienti.Syscom: + // _ma = _Sys_mag.Mag; + // break; + // default: + // _ma = null; + // break; + // } + // return _ma; + //} + //private DbSet getImpiantiByTenant(string tenant) + //{ + // DbSet? _imp; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _imp = _Sicilia_impianti.Impia; + // break; + // case Clienti.Discovery: + // _imp = _Disco_impianti.Impia; + // break; + // case Clienti.Marrocco: + // _imp = _Marro_impianti.Impia; + // break; + // case Clienti.Ferrari: + // _imp = null; + // break; + // case Clienti.Sarom: + // _imp = null; + // break; + // case Clienti.Gitoga: + // _imp = _Gitoga_impianti.Impia; + // break; + // case Clienti.Lifta: + // _imp = _Lifta_impianti.Impia; + // break; + // case Clienti.Siet: + // _imp = _Siet_impianti.Impia; + // break; + // case Clienti.PMS: + // _imp = _PMS_impianti.Impia; + // break; + // case Clienti.LW: + // _imp = _LW_impianti.Impia; + // break; + // case Clienti.Tedesco: + // _imp = _Tedes_impianti.Impia; + // break; + // case Clienti.Syscom: + // _imp = _Sys_impianti.Impia; + // break; + // default: + // _imp = null; + // break; + // } + // return _imp; + //} + + //private DbSet getCommesseByTenant(string tenant) + //{ + // DbSet? _commesse; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _commesse = _Sicilia_comm.Commesse; + // break; + // case Clienti.Discovery: + // _commesse = null; + // break; + // case Clienti.Ferrari: + // _commesse = _Ferra_comm.Commesse; + // break; + // case Clienti.Sinergo: + // _commesse = _Sinergo_comm.Commesse; + // break; + // case Clienti.Marrocco: + // _commesse = _Marro_comm.Commesse; + // break; + // case Clienti.Gitoga: + // _commesse = _Gitoga_comm.Commesse; + // break; + // case Clienti.Lifta: + // _commesse = _Lifta_comm.Commesse; + // break; + // case Clienti.Siet: + // _commesse = _Siet_comm.Commesse; + // break; + // case Clienti.PMS: + // _commesse = _PMS_comm.Commesse; + // break; + // case Clienti.LW: + // _commesse = _LW_comm.Commesse; + // break; + // case Clienti.Tedesco: + // _commesse = _Tedes_comm.Commesse; + // break; + // case Clienti.Syscom: + // _commesse = _Sys_comm.Commesse; + // break; + // default: + // _commesse = null; + // break; + // } + // return _commesse; + //} + private DbSet getTimbratureByTenant(string tenant) + { + DbSet? _timbrature; + _timbrature = _VT_timbr.Timbr; + + return _timbrature; + } + + //private DbSet getStoricoImpiantoByTenant(string tenant) + //{ + // DbSet? _sto; + + // switch (tenant) + // { + // case Clienti.Sicilia: + // _sto = _Sicilia_sto_imp.StoImp; + // break; + // case Clienti.Siet: + // _sto = _Siet_sto_imp.StoImp; + // break; + // case Clienti.PMS : + // _sto = _PMS_sto_imp.StoImp; + // break; + // case Clienti.LW: + // _sto = _LW_sto_imp.StoImp; + // break; + // case Clienti.Tedesco: + // _sto = _Tedes_sto_imp.StoImp; + // break; + // case Clienti.Syscom: + // _sto = _Sys_sto_imp.StoImp; + // break; + // default: + // _sto = null; + // break; + // } + // return _sto; + //} + + //private DbSet getAziendeRifByTenant(string tenant) + //{ + // DbSet? _azi; + + // switch (tenant) + // { + // case Clienti.Discovery: + // _azi = _Disco_azi_coll.Azi; + // break; + // case Clienti.Siet: + // _azi = _Siet_azi_coll.Azi; + // break; + // case Clienti.PMS: + // _azi = _PMS_azi_coll.Azi; + // break; + // case Clienti.LW: + // _azi = _LW_azi_coll.Azi; + // break; + // case Clienti.Tedesco: + // _azi = _Tedes_azi_coll.Azi; + // break; + // default: + // _azi = null; + // break; + // } + // return _azi; + //} + + //private DbSet getSostituzioneByTenant(string tenant) + //{ + // DbSet? _sost; + + // switch (tenant) + // { + // case Clienti.Marrocco: + // _sost = _Marro_sostituzioni.Sost; + // break; + // case Clienti.Gitoga: + // _sost = _Gitoga_sostituzioni.Sost; + // break; + // case Clienti.Lifta: + // _sost = _Lifta_sostituzioni.Sost; + // break; + // case Clienti.Discovery: + // _sost = _Disco_sostituzioni.Sost; + // break; + // case Clienti.Siet: + // _sost = _Siet_sostituzioni.Sost; + // break; + // case Clienti.Sicilia: + // _sost = _Sicilia_sostituzioni.Sost; + // break; + // case Clienti.PMS: + // _sost = _PMS_sostituzioni.Sost; + // break; + // case Clienti.LW: + // _sost = _LW_sostituzioni.Sost; + // break; + // case Clienti.Tedesco: + // _sost = _Tedes_sostituzioni.Sost; + // break; + // case Clienti.Syscom: + // _sost = _Sys_sostituzioni.Sost; + // break; + // default: + // _sost = null; + // break; + // } + // return _sost; + //} + private DbSet getChiamateTableByTenant(string tenant) + { + DbSet? _chia; + _chia = _VT_chiatable.Chi; + 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; + // default: + // _chia = null; + // break; + // } + // return _chia; + //} + + //private DbSet getChiamateSerialeByTenant(string tenant) + //{ + // DbSet? _chiaser; + + // switch (tenant) + // { + // case Clienti.Marrocco: + // _chiaser = _Marro_chiaser.Seriali; + // break; + // case Clienti.Gitoga: + // _chiaser = _Gitoga_chiaser.Seriali; + // break; + // case Clienti.Lifta: + // _chiaser = _Lifta_chiaser.Seriali; + // break; + // case Clienti.Siet: + // _chiaser = _Siet_chiaser.Seriali; + // break; + // case Clienti.Sicilia: + // _chiaser = _Sicilia_chiaser.Seriali; + // break; + // case Clienti.PMS: + // _chiaser = _PMS_chiaser.Seriali; + // break; + + // default: + // _chiaser = null; + // break; + // } + // return _chiaser; + //} + + //private DbSet getChiamateProgressiviByTenant(string tenant) + //{ + // //gestione per cvpwarn con campo float + // DbSet? _chiaprog; + + // switch (tenant) + // { + // case Clienti.Marrocco: + // case Clienti.Gitoga: + // case Clienti.Lifta: + // _chiaprog = _Marro_chiaprog.Progressivi; + // break; + // case Clienti.Sicilia: + // _chiaprog = _Sicilia_chiaprog.Progressivi; + // break; + // case Clienti.Siet: + // _chiaprog = _Siet_chiaprog.Progressivi; + // break; + // default: + // _chiaprog = null; + // break; + // } + // return _chiaprog; + //} + + //private DbSet getCpwarnByTenant(string tenant) + //{ + // //gestione per cvpwarn con campo float + // DbSet? _cpwarn; + + // switch (tenant) + // { + + // case Clienti.Sicilia: + // _cpwarn = _Sicilia_cpwarn.Progressivi; + // break; + // case Clienti.Siet: + // _cpwarn = _Siet_cpwarn.Progressivi; + // break; + // case Clienti.PMS: + // _cpwarn = _PMS_cpwarn.Progressivi; + // break; + // case Clienti.LW: + // _cpwarn = _LW_cpwarn.Progressivi; + // break; + // case Clienti.Tedesco: + // _cpwarn = _Tedes_cpwarn.Progressivi; + // break; + // case Clienti.Syscom: + // _cpwarn = _Sys_cpwarn.Progressivi; + // break; + // default: + // _cpwarn = null; + // break; + // } + // return _cpwarn; + //} + + //private bool checkSostituzioneAbilitata(string tenant) + //{ + // bool abilitata; + // switch (tenant) + // { + // case Clienti.Marrocco: + // abilitata =true; + // break; + // case Clienti.Gitoga: + // abilitata = true; + // break; + // case Clienti.Lifta: + // abilitata = true; + // break; + // case Clienti.Discovery: + // abilitata = true; + // break; + // case Clienti.Siet: + // abilitata = true; + // break; + // case Clienti.Sicilia: + // abilitata = true; + // break; + // case Clienti.LW: + // abilitata = true; + // break; + // case Clienti.Tedesco: + // abilitata = true; + // break; + // case Clienti.Syscom: + // abilitata = true; + // break; + // default: + // abilitata = false; + // break; + // } + // return abilitata; + //} + + private async Task getSeriale(string token) + { + string seriale = string.Empty; + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + _rapp_new = _VT_rapptable.Rapps; + + //switch (ten) + //{ + // case Clienti.VT: + // //ten = ten2; + // break; + // default: + // _rapp_new = getRappNewByTenant(ten); + // break; + //} + + string suff_rapp = string.Empty; + string primo_seriale = string.Empty; + //D000000004 + + var rapp = await Task.WhenAll(_rapp_new.Where(t => t.seriale_rapportino != null + && t.seriale_rapportino.Contains(suff_rapp)).OrderByDescending(t => t.seriale_rapportino).Take(1).ToListAsync()); + + string? ser=string.Empty; + if (rapp.Any()) + { + foreach(var i in rapp) + { + if(i.Count()>0) + { + ser = i.First().seriale_rapportino; + seriale = getNewSerialeRapportino(ser, ten); + } + else + { + seriale = primo_seriale; + } + } + } + return seriale; + } + + private async Task getNewId(string token) + { + int newId =1; + string ten = getClaimValueByToken(token, "tenant"); + _timbr = getTimbratureByTenant(ten); + var t = await Task.WhenAll(_timbr.OrderByDescending(t => t.id).Take(1).ToListAsync()); + + if (t.Any() && t.First().Count()>0) + { + foreach (var i in t) + { + newId = i.First().id; + } + newId++; + } + return newId; + } + private string getNewSerialeRapportino(string? lastSerial, string tenant) + { + string new_serial = string.Empty; + + //lastSerial = lastSerial.Substring(1, lastSerial.Length-1); + lastSerial = lastSerial!=null? lastSerial.Substring(1, lastSerial.Length - 1):String.Empty; + + int ser = int.Parse(lastSerial); + ser++; + new_serial = ser.ToString(); + new_serial = new_serial.PadLeft(9, '0'); + new_serial = suffClienti.VT + new_serial; + + return new_serial; + } + + private string getNewSerialeBuono(string lastSerial, string suff) + { + //CAM00118 CA=chiamata M=Marrocco 00118=seriale + //MAM00254 MA=manutenzione M=Marrocco 00254=seriale + //lunghezza 8 fissa + string new_serial = string.Empty; + + string parteNum = lastSerial.Substring(3, 5); + int ser = int.Parse(parteNum); + ser++; + new_serial = ser.ToString(); + new_serial = new_serial.PadLeft(5, '0'); + new_serial = suff + new_serial; + + return new_serial; + } + + private string getNewSerialeBuonoMan(string lastSerial, string suff) + { + //CAM00118 CA=chiamata M=Marrocco 00118=seriale + //MAM00254 MA=manutenzione M=Marrocco 00254=seriale + //lunghezza 8 fissa + string new_serial = string.Empty; + + string parteNum = lastSerial.Substring(3, 5); + int ser = int.Parse(parteNum); + ser++; + new_serial = ser.ToString(); + new_serial = new_serial.PadLeft(5, '0'); + new_serial = suff + new_serial; + + return new_serial; + } + + private async Task getChiamataBySerial(string ser_chiamata, string token) + { + string new_serial = string.Empty; + string ten = string.Empty; + ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + if (ten.Equals(Clienti.VT)) + { + ten = getClaimValueByToken(token, "tenant2"); + _chiamate= _VT_chia.Chiamate; + } + else + { + _chiamate = getChiamateByTenant(ten); + } + + var calltec = await _chiamate.Where( + t => t.chserial == ser_chiamata + && t.chcodazi == ten + ).OrderBy(t => t.chdtapp).ToListAsync(); + + return calltec.First(); + } + + private async Task getManutenzioneByChiave(Input i, string token ) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico= getClaimValueByToken(token, "tccodice"); + + //_manutprog =getManutenzioniByTenant(ten); + var manutenz = await _manutprog.Where( + t => t.ctcodazi.Equals(ten) + && t.ctcodimp.Trim().Equals(i.pimpianto.Trim()) + && t.ctcodint.Trim().Equals(i.picodint.Trim()) + && t.ctdatpro==i.pidatman + //&& t.tccodice.Trim().Equals(tecnico.Trim() + //la devo ripescare solo per la chiave della tabella delle manutenzioni + ).ToListAsync(); + + Manprog risultato = manutenz.First(); + return risultato; + } + private async Task getManutenzioneByChiave2(Prese i, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + //_manutprog = getManutenzioniByTenant(ten); + var manutenz = await _manutprog.Where( + t => t.ctcodazi.Equals(ten) + && t.ctcodimp.Trim().Equals(i.pimpianto.Trim()) + && t.ctcodint.Trim().Equals(i.picodint.Trim()) + && t.ctdatpro == i.pidatman + //&& t.tccodice.Trim().Equals(tecnico.Trim() + //la devo ripescare solo per la chiave della tabella delle manutenzioni + ).ToListAsync(); + + Manprog risultato = manutenz.First(); + return risultato; + } + + private async Task getManutenzioneByChiaveOut(Input i, string token, Rapp_New ingresso) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + //_manutprog = getManutenzioniByTenant(ten); + var manutenz = await _manutprog.Where( + t => t.ctcodazi.Equals(ten) + && t.ctcodimp.Trim().Equals(i.pimpianto.Trim()) + && t.ctcodint.Trim().Equals(i.picodint.Trim()) + && t.ctdatpro == i.pidatman + //&& t.tccodice.Trim().Equals(tecnico.Trim() + //la devo ripescare solo per la chiave della tabella delle manutenzioni + ).ToListAsync(); + + Manprog risultato = manutenz.First(); + risultato.ser_buono = ingresso.ser_buono; + risultato.seriale_rapportino = ingresso.seriale_rapportino; + + return risultato; + } + + /// vuoto=chiamata presa in carico 3=chiamata chiusa 2=manutenzione chiusa + public static class TipoRapportino + { + /// + public const string PresaInCarico = ""; + + /// + public const string ManutenzioneChiusa = "2"; + + /// + public const string ChiamataChiusa = "3"; + + /// + public const string ChiamataDaCommessa = "4"; + + /// + public const string ChiamataCapoTecnico = "5"; + } + private async Task checkChiamataPresa(string ten, string serChiamata,string tipo, string ten2) + { + //tipo rapportino ="" + int trovati = 0; + + _rapp_new = _VT_rapptable.Rapps; + ten = ten2; + + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten + && t.seriale_chiamata !=null && t.seriale_chiamata.Equals(serChiamata) + && t.tipo_rapportino !=null && t.tipo_rapportino.Equals(tipo) + && t.incarico!=null && t.incarico.Equals("S")).ToListAsync(); + if(rapp.Any()) + { + trovati = rapp.Count(); + } + + return trovati; + } + private async Task checkChiamataDaRilasciare(string ten, string serRapportino, string tipo,string ten2) + { + //tipo rapportino ="" + Rapp_New trovati = null; + + _rapp_new = _VT_rapptable.Rapps; + ten = ten2; + + //switch (ten) + //{ + // case Clienti.VT: + // break; + // default: + // _rapp_new = getRappNewByTenant(ten); + // break; + //} + + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten + && t.seriale_rapportino != null && t.seriale_rapportino.Equals(serRapportino) + && t.tipo_rapportino != null && t.tipo_rapportino.Equals(tipo) + && t.incarico != null && t.incarico.Equals("S")).ToListAsync(); + if (rapp.Any()) + { + trovati = rapp.First(); + } + + return trovati; + } + private async Task checkChiamataRifiutata(string ten, string serChiamata, string tipo,string ten2) + { + //tipo rapportino ="" + int trovati = 0; + + _rapp_new = _VT_rapptable.Rapps; + ten = ten2; + + //switch (ten) + //{ + // case Clienti.VT: + + // break; + // default: + // _rapp_new = getRappNewByTenant(ten); + // break; + //} + + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten + && t.seriale_chiamata != null && t.seriale_chiamata.Equals(serChiamata) + && t.tipo_rapportino != null && t.tipo_rapportino.Equals(tipo) + && t.incarico != null && t.rifiutata.Equals("S")).ToListAsync(); + if (rapp.Any()) + { + trovati = rapp.Count(); + } + + return trovati; + } + private async Task checkChiamataChiusa(string ten, string serChiamata, string tipo) + { + //tipo rapportino =3 o tipo rapportino=4 + int trovati = 0; + + _rapp_new = _VT_rapptable.Rapps; + + //if (ten.Equals(Clienti.VT)) + //{ + //} + //else + //{ + // _rapp_new = getRappNewByTenant(ten); + //} + + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten + && t.seriale_chiamata != null && t.seriale_chiamata.Equals(serChiamata) + && t.tipo_rapportino != null && (t.tipo_rapportino.Equals(TipoRapportino.ChiamataChiusa) || t.tipo_rapportino.Equals(TipoRapportino.ChiamataDaCommessa))).ToListAsync(); + + if (rapp.Any()) + { + trovati = rapp.Count(); + } + + return trovati; + } + private async Task checkTimbraturaPresente(string ten, Timbratura model) + { + int trovati = 0; + _timbr = getTimbratureByTenant(ten); + var ti = await _timbr.Where(t => t.azienda == ten && t.ora_ini== model.ora_ini && t.min_ini== model.min_ini && t.ora_fin==model.ora_fin && t.min_fin==model.min_fin + && t.commessa.Equals(model.commessa) && t.data_timbratura==model.data_timbratura && t.ore_viaggio==model.ore_viaggio + ).ToListAsync(); + if (ti.Any()) + { + trovati = ti.Count(); + } + + return trovati; + } + /// 200=Ok 500=ErroreInterno 400=OperazioneNonAmmessa + public static class StatiRisposta + { + /// + public const string Ok = "200"; + + /// + public const string ErroreInterno = "500"; + + /// + public const string OperazioneNonAmmessa = "400"; + } + private async Task checkManutenzionePresaInCarico(string ten, string impianto,string codint,DateTime? dataMan) + { + int trovati = 0; + //_prese=getPreseByTenant(ten); + var pre =await _prese.Where(t => t.picodazi.Equals(ten) && t.pimpianto.Equals(impianto) && t.picodint.Equals(codint) && t.pidatman== dataMan).ToListAsync(); + if (pre.Any()) + { + trovati = pre.Count(); + } + return trovati; + } + private async Task checkManutenzioneDaRilasciare(string ten, string impianto, string codint, DateTime? dataMan) + { + Prese p = null; + //_prese = getPreseByTenant(ten); + var pre = await _prese.Where(t => t.picodazi.Equals(ten) && t.pimpianto.Equals(impianto) && t.picodint.Equals(codint) && t.pidatman == dataMan).ToListAsync(); + if (pre.Any()) + { + p = pre.First(); + } + return p; + } + private async Task checkManutenzioneChiusa(string ten,string tipo,string codImp, DateTime? dataMan, string codInt) + { + int trovati = 0; + //_rapp_new = getRappNewByTenant(ten); + var rapp = await _rapp_new.Where( + t => t.azienda_impianto == ten + && t.tipo_rapportino != null && t.tipo_rapportino.Equals(tipo) + && t.seriale_chiamata !=null && string.IsNullOrEmpty(t.seriale_chiamata.Trim()) + && t.codice_impianto !=null && t.codice_impianto.Equals(codImp) + && t.data_validita== dataMan + && t.codice_intervento !=null && t.codice_intervento.Equals(codInt) + ).ToListAsync(); + + if (rapp.Any()) + { + trovati = rapp.Count(); + } + return trovati; + } + + /// + public static class Clienti + { + /// VT app + public const string VT = "VIRTU"; + } + /// + public static class suffClienti + { + /// Virtual task + public const string VT = "V"; + } + + /// trasforma un Saldiart in un Mag_New + private Mag_New saldiartToMag_New(Saldiart co, int riga,string newSerial, string tecnico) + { + Mag_New mn = new Mag_New(); + mn.seriale_rapportino = newSerial; + mn.riga = riga; + mn.magazzino = co.slcodmag; + mn.articolo = co.slcodice; + mn.tipo_movimento = "A"; + mn.quantita = co.slqtaper; + mn.prezzo = co.liprezzo; + mn.codice_tecnico = tecnico; + mn.codlotto = co.locodice; + mn.matricola = co.amcodice; + mn.desc_art = co.ardesart; + mn.cpccchk = getCpccchk(10); + mn.desc_sup = co.desc_sup; + return mn; + } + + /// trasforma un Saldiart in un Vt_Mag_New + private Vt_Mag_New SaldiArtToVtMag_New(Saldiart co, int riga, string newSerial, string tecnico, string azienda) + { + Vt_Mag_New vtmn = new Vt_Mag_New(); + vtmn.Azienda = azienda; + vtmn.Seriale_Rapportino = newSerial; + vtmn.Riga = riga; + vtmn.Magazzino = co.slcodmag; + vtmn.Articolo = co.slcodice; + vtmn.Tipo_Movimento = "A"; + vtmn.Quantita = co.slqtaper; + vtmn.Prezzo = co.liprezzo; + vtmn.Codice_Tecnico = tecnico; + vtmn.CodLotto = co.locodice; + vtmn.Matricola = co.amcodice; + vtmn.Desc_Art = co.ardesart; + vtmn.Cpccchk = getCpccchk(10); + vtmn.Desc_Sup = co.desc_sup; + return vtmn; + + } + + /// trasforma un Compi_Impia in un Mag_New + private Mag_New compo_ImpiaToMag_New(Compo_Impia co, int riga, string newSerial, string tecnico) + { + + Mag_New mn = new Mag_New(); + mn.seriale_rapportino = newSerial; + mn.riga = riga; + mn.magazzino = "001"; + mn.articolo = co.cocodart; + mn.tipo_movimento = "E"; + mn.quantita = co.coqtaart; + mn.prezzo = 0; + mn.codice_tecnico = tecnico; + mn.codlotto = co.lotto; + mn.matricola = co.matricola; + mn.cprownum = co.cprownum; + mn.codimp = co.cocodimp; + mn.desc_art = co.ardesart; + mn.cpccchk = getCpccchk(10); + mn.desc_sup = co.desc_sup; + + + string appoNote = string.Empty; + appoNote = (co.co__note != null && co.co__note.Length>254) ? co.co__note.Substring(0, 254) : co.co__note; + mn.note = appoNote; + return mn; + } + + /// trasforma un Compi_Impia in un Vt_Mag_New + private Vt_Mag_New compo_ImpiaToVt_Mag_New(Compo_Impia co, int riga, string newSerial, string tecnico, string azienda) + { + + Vt_Mag_New vtmn = new Vt_Mag_New(); + vtmn.Azienda = azienda; + vtmn.Seriale_Rapportino = newSerial; + vtmn.Riga = riga; + vtmn.Matricola = "001"; + vtmn.Articolo = co.cocodart; + vtmn.Tipo_Movimento = "E"; + vtmn.Quantita = co.coqtaart; + vtmn.Prezzo = 0; + vtmn.Codice_Tecnico = tecnico; + vtmn.CodLotto = co.lotto; + vtmn.Matricola = co.matricola; + vtmn.Cprownum = co.cprownum; + vtmn.CodImp = co.cocodimp; + vtmn.Desc_Art = co.ardesart; + vtmn.Cpccchk = getCpccchk(10); + vtmn.Desc_Sup = co.desc_sup; + + + string appoNote = string.Empty; + appoNote = (co.co__note != null && co.co__note.Length>254) ? co.co__note.Substring(0, 254) : co.co__note; + vtmn.Note = appoNote; + return vtmn; + } + + private static Random random = new Random(); + /// crea un cpccchk + public static string getCpccchk(int length) + { + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray()); + } + + /// formatta l'indirizzo della lista chiamate + public static string formattaItemChiamateMarrocco(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + 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()); + } + + if (!string.IsNullOrEmpty(i.imrefref)) + { + sb.Append("
"); + sb.Append("Ref. : " + i.imrefref.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + /// formatta l'indirizzo stampa chiamate + public static string formattaIndirizzoStampaMarrocco(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("SPETT. AMM. COND. : "); + 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); + if (!string.IsNullOrEmpty(i.imrefref)) + { + sb.Append("
"); + sb.Append("Numero Ref. : " + i.imrefref.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + /// formatta l'indirizzo stampa chiamateper Discovery + public static string formattaIndirizzoStampaDiscovery(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("SPETT. AMM. COND. : "); + 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.imlocali) ? i.imlocali.Trim() + " " : string.Empty); + + formatst = sb.ToString(); + + return formatst; + } + + /// formatta l'indirizzo della lista chiamate TEDESCO + public static string formattaItemChiamateTedesco(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + if (!string.IsNullOrEmpty(i.imdescri)) + { + sb.Append("N.pratica : " + i.imdescri.Trim()); + 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); + 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()); + } + + formatst = sb.ToString(); + + return formatst; + } + + /// formatta l'indirizzo della lista chiamate Virtual task + public static string formattaItemChiamateVT(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + if (!string.IsNullOrEmpty(i.andescri)) + { + sb.Append("Cliente : " + i.andescri.Trim()); + sb.Append("
"); + } + if (!string.IsNullOrEmpty(i.chcodimp)) + { + sb.Append("Impianto : " + i.chcodimp.Trim()); + sb.Append("
"); + } + if(!string.IsNullOrEmpty(i.imindiri2)) + { + 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); + sb.Append(!string.IsNullOrEmpty(i.improvin) ? " " + i.improvin.Trim() + " " : string.Empty); + sb.Append("
"); + } + if (!string.IsNullOrEmpty(i.chrifer)) + { + sb.Append("Rif. : " + i.chrifer.Trim()); + sb.Append("
"); + } + if (!string.IsNullOrEmpty(i.chtelef)) + { + sb.Append("Tel. : " + i.chtelef.Trim()); + sb.Append("
"); + } + if (!string.IsNullOrEmpty(i.chcodseg)) + { + sb.Append("Cod.Segn. : " + i.chcodseg.Trim()); + sb.Append("
"); + } + + + + formatst = sb.ToString(); + + return formatst; + } + + + /// formatta il riferimento impainto (html) + public static string formattaRiferimentoImpiantoMarrocco(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("N. Impianto : " + i.chcodimp.Trim()); + + if (!string.IsNullOrEmpty(i.imubicaz)) + { + sb.Append("
"); + sb.Append("Ubicazione : " + i.imubicaz.Trim()); + } + if (!string.IsNullOrEmpty(i.chcodimp)) + { + sb.Append("
"); + sb.Append("Matricola impianto : "); + sb.Append(!string.IsNullOrEmpty(i.immatric) ? i.immatric.Trim() + " " : string.Empty); + } + + formatst = sb.ToString(); + + return formatst; + } + + /// formatta il riferimento impianto Disco (html) + public static string formattaRiferimentoImpiantoDiscovery(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("N. Impianto : " + i.chcodimp.Trim()); + + if (!string.IsNullOrEmpty(i.imubicaz)) + { + sb.Append("
"); + sb.Append("Ubicazione : " + i.imubicaz.Trim()); + } + if (!string.IsNullOrEmpty(i.chcodimp)) + { + sb.Append("
"); + sb.Append("Matricola impianto : "); + sb.Append(!string.IsNullOrEmpty(i.immatric) ? i.immatric.Trim() + " " : string.Empty); + } + + formatst = sb.ToString(); + + return formatst; + } + + + /// formatta il riferimento impianto Ferrari (html) + public static string formattaRiferimentoImpiantoFerrari(Chiamate i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("N. Impianto : " + i.chcodimp.Trim()); + + if (!string.IsNullOrEmpty(i.imubicaz)) + { + sb.Append("
"); + sb.Append("Ubicazione : " + i.imubicaz.Trim()); + } + if (!string.IsNullOrEmpty(i.chcodimp)) + { + sb.Append("
"); + sb.Append("Matricola impianto : "); + sb.Append(!string.IsNullOrEmpty(i.immatric) ? i.immatric.Trim() + " " : string.Empty); + } + + formatst = sb.ToString(); + + return formatst; + } + + + /// formatta l'indirizzo stampa manutenzioni + public static string formattaIndirizzoStampaManutMarrocco(Manprog i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("SPETT. AMM. COND. :"); + 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.imlocali) ? i.imlocali.Trim() + " " : string.Empty); + + if (!string.IsNullOrEmpty(i.imrefref)) + { + sb.Append("
"); + sb.Append("Numero Ref. : " + i.imrefref.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + /// formatta il riferimento impainto (html) + public static string formattaIndirizzoStampaManutDiscovery(Manprog i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + sb.Append("SPETT. AMM. COND. :"); + 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.imlocali) ? i.imlocali.Trim() + " " : string.Empty); + + if (!string.IsNullOrEmpty(i.imrefref)) + { + sb.Append("
"); + sb.Append("Numero Ref. : " + i.imrefref.Trim()); + } + + + formatst = sb.ToString(); + + return formatst; + } + + /// formatta l'indirizzo della lista manutenzioni + public static string formattaItemManutenzioniMarrocco(Manprog i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + 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.ctcodimp)) + { + sb.Append("
"); + sb.Append("Impianto : " + i.ctcodimp.Trim()); + } + + if (!string.IsNullOrEmpty(i.imrefref)) + { + sb.Append("
"); + sb.Append("Ref. : " + i.imrefref.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + /// formatta riferimwnto impianto su buono (html) + public static string formattaRifImpMarrocco(Manprog i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + + if (!string.IsNullOrEmpty(i.ctcodimp)) + { + sb.Append("Matricola impianto : " + i.ctcodimp.Trim()); + if(!string.IsNullOrEmpty(i.immatric)) + { + sb.Append( " - " + i.immatric.Trim()); + } + } + if (!string.IsNullOrEmpty(i.imubicaz)) + { + sb.Append("
"); + sb.Append("Ubicazione : " + i.imubicaz.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + /// formatta riferimwnto impianto su buono (html) Disco + public static string formattaRifImpDiscovery(Manprog i) + { + string formatst = string.Empty; + StringBuilder sb = new StringBuilder(); + + if (!string.IsNullOrEmpty(i.ctcodimp)) + { + sb.Append("N. Impianto : " + i.ctcodimp.Trim()); + } + if (!string.IsNullOrEmpty(i.imubicaz)) + { + sb.Append("
"); + sb.Append("Ubicazione : " + i.imubicaz.Trim()); + } + if (!string.IsNullOrEmpty(i.immatric)) + { + sb.Append("
"); + sb.AppendLine("Matricola : " + i.immatric.Trim()); + } + formatst = sb.ToString(); + + return formatst; + } + + #endregion + + #region Configurazioni + private Configurazione_out fillConfigurazione(Configurazioni co) + { + Configurazione_out output = new Configurazione_out(); + + output.azienda = co.azienda; + output.path_buoni = co.path_buoni; + output.prefisso_buoni_chia = co.prefisso_buoni_chia; + output.prefisso_buoni_man = co.prefisso_buoni_man; + output.ftp_url = co.ftp_url; + output.ftp_usr = co.ftp_usr; + output.ftp_pwd = co.ftp_pwd; + output.ftp_port = co.ftp_port; + output.listino = co.listino; + + output.abilita_barcode = co.abilita_barcode; + output.abilita_naviga = co.abilita_naviga; + output.abilita_telefona = co.abilita_telefona; + output.abilita_chiamate = co.abilita_chiamate; + + output.abilita_manutenzioni = co.abilita_manutenzioni; + output.chiamate_accetta = co.chiamate_accetta; + output.chiamate_accetta_barcode = co.chiamate_accetta_barcode; + output.chiamate_accetta_offline = co.chiamate_accetta_offline; + output.chiamate_rifiuta = co.chiamate_rifiuta; + output.chiamate_rifiuta_barcode = co.chiamate_rifiuta_barcode; + output.chiamate_rifiuta_offline = co.chiamate_rifiuta_offline; + output.chiamate_chiudi_barcode = co.chiamate_chiudi_barcode; + output.chiamate_firma_barcode = co.chiamate_firma_barcode; + output.chiamate_chiudi_salva_barcode = co.chiamate_chiudi_salva_barcode; + output.chiamate_chiudi_salva_offline = co.chiamate_chiudi_salva_offline; + + output.manutenzioni_accetta = co.manutenzioni_accetta; + output.manutenzioni_rifiuta = co.manutenzioni_rifiuta; + output.manutenzioni_accetta_barcode = co.manutenzioni_accetta_barcode; + output.manutenzioni_accetta_offline = co.manutenzioni_accetta_offline; + output.manutenzioni_chiudi_barcode = co.manutenzioni_chiudi_barcode; + output.manutenzioni_firma_barcode = co.manutenzioni_firma_barcode; + output.manutenzioni_chiudi_salva_barcode = co.manutenzioni_chiudi_salva_barcode; + output.manutenzioni_chiudi_salva_offline = co.manutenzioni_chiudi_salva_offline; + + output.dpi_checkbox = co.dpi_checkbox; + + output.anagrafica = co.anagrafica; + output.stato_finale = co.stato_finale; + output.descrizione_intervento = co.descrizione_intervento; + output.composizione_impianto = co.composizione_impianto; + output.note_intervento = co.note_intervento; + output.esito_intervento = co.esito_intervento; + output.ora_inizio_fine = co.ora_inizio_fine; + output.materiali = co.materiali; + output.diritto_chiamata = co.diritto_chiamata; + output.manodopera = co.manodopera; + output.spese_viaggio = co.spese_viaggio; + output.tipo_pagamento = co.tipo_pagamento; + output.note_pagamento = co.note_pagamento; + output.causale = co.causale; + + output.time_sheet = co.time_sheet; + output.time_sheet_offline = co.time_sheet_offline; + output.costo_orario = co.costo_orario; + + output.manutenzioni_rifiuta_barcode = co.manutenzioni_rifiuta_barcode; + + //OBSOLETI + //output.storico = co.storico; + //output.storico_tecnico = co.storico_tecnico; + //FINE OBSOLETI + + output.storico_interventi = co.storico_interventi; + output.storico_impianto = co.storico_impianto; + output.ricerca_impianti = co.ricerca_impianti; + output.abilita_data_rapp_edit = co.abilita_data_rapp_edit; + + return output; + } + + /// Configurazioni per azienda return:ActionResult + [HttpGet("configurazioni")] + public async Task> configurazioni(string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + Configurazione_out output = new Configurazione_out(); + try + { + var c = await _config.conf.Where(t => t.azienda == ten).ToListAsync(); + var cc = c.First(); + + if (cc == null) + { + return NotFound(); + } + + output = fillConfigurazione(cc); + + //cerco le aziende collegate + bool bCercaAzcoll = false; + List l = new List(); + //switch (ten) + //{ + // case Clienti.Discovery: + // bCercaAzcoll = true; + // break; + //} + if(bCercaAzcoll) + { + //_azi_coll = getAziendeRifByTenant(ten); + var a = await _azi_coll.Where(t => t.piazihoc != null && t.piazihoc.Equals(ten)).ToListAsync(); + if (a.Any()) + { + foreach (AziendaRif appo in a) + { + l.Add(appo); + } + } + } + output.aziende_coll = l; + + + return StatusCode(StatusCodes.Status200OK, output); + } + catch(Exception ex) + { + string err = "Errore: " + ex.Message; + output.err_detail = err; + output.err_title = err; + output.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + + } + + [HttpPost] + [Route("configurazioni/add")] + public async Task> addConfigurazione([FromBody] Configurazioni model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + + try + { + using (var transaction = _config.Database.BeginTransaction()) + { + await _config.conf.AddAsync(model); + await _config.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + #endregion + + #region Token + + /// token riewmpimento + private Token fillTokenByInput(string tokenDevice, string tokenLogin) + { + Token r = new Token(); + + string ten = getClaimValueByToken(tokenLogin, "tenant"); + string tecnico = getClaimValueByToken(tokenLogin, "tccodice"); + + r.tenant = ten; + r.usr = tecnico; + r.token = tokenDevice; + r.ts = DateTime.Now; + return r; + } + + /// elimina Token + private async void deleteToken(Token t) + { + using (var transaction = _tokens.Database.BeginTransaction()) + { + _tokens.tok.Remove(t); + await _tokens.SaveChangesAsync(); + transaction.Commit(); + } + } + + /// inserisce Token + private async void insertToken(Token t) + { + using (var transaction = _tokens.Database.BeginTransaction()) + { + await _tokens.tok.AddAsync(t); + await _tokens.SaveChangesAsync(); + transaction.Commit(); + } + } + + /// token salvataggio + [HttpPost] + [Route("token/add")] + public async Task> addToken(string tokenDevice, string token) + { + Token_out t = new Token_out(); + bool da_inserire = false; + + try + { + List co = new List(); + if (_tokens is not null && _tokens.tok is not null) + { + co = await _tokens.tok.Where(c => c.token.Equals(tokenDevice)).ToListAsync(); + } + Token inp = fillTokenByInput(tokenDevice, token); + + if (co.Count== 0) + { + da_inserire = true; + } + else + { + //il token c'è. controllo che sia associato all'utente corretto + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + bool token_corretto_presente = false; + foreach(Token tt in co) + { + if (tt.usr is not null && tt.usr.Equals(tecnico) && tt.tenant is not null && tt.tenant.Equals(ten)) + { + token_corretto_presente = true; + } + else + { + using (var transaction = _tokens.Database.BeginTransaction()) + { + Token entitasViewModel = _tokens.tok.Where(p => p.Id == tt.Id).FirstOrDefault(); + _tokens.Entry(entitasViewModel).State = EntityState.Deleted; + await _tokens.SaveChangesAsync(); + transaction.Commit(); + } + } + } + if (!token_corretto_presente) + da_inserire = true; + } + if(da_inserire) + { + using (var transaction = _tokens.Database.BeginTransaction()) + { + await _tokens.tok.AddAsync(inp); + await _tokens.SaveChangesAsync(); + transaction.Commit(); + } + t.err_status_code = StatiRisposta.Ok; + } + return StatusCode(StatusCodes.Status200OK, t); + } + catch(Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + t.err_title = ex.Message; + t.err_detail = errmsg; + t.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, t); + } + + } + /// token salvataggio + [HttpPost] + [Route("token/sendMessage")] + public async Task> sendMessage(string tokenDevice,string _title, string _body) + { + Token_out t = new Token_out(); + //Token inp = fillTokenByInput(tokenDevice, tokenLogin); + + try + { + if (FirebaseApp.DefaultInstance == null) + { + FirebaseApp.Create(new AppOptions() + { + Credential = GoogleCredential.FromFile("private_key.json") + }); + } + //var registrationToken = "dDxUDIC3QcWytp6UeVMDyT:APA91bH9y0N7Iff39Ncv0m_EjJ-hv7YTWYaL_5P37-2dob2PRuArvpfl6kmrk10GO2eJiAQ2tVT3tZX9khUD-NPyfljGbpBn1iUyjbTpL6tDF-0IgJN960v95I4_2SWM_crtSH-ZrXAK"; + var registrationToken = tokenDevice; + var message = new Message() + { + Data = new Dictionary() + { + { "myData", "123457777" }, + }, + Token = registrationToken, + //Notification = new Notification() + //{ + // Title = _title+" "+getCpccchk(4), + // Body = _body + " "+ DateTime.Now.ToString("yyyyMMddHHmmss") + //} + }; + string response = FirebaseMessaging.DefaultInstance.SendAsync(message).Result; + t.response = response; + + //t.response= await SendNotificationAsync(tokenDevice,"titolo","corpo del messaggio"); + return StatusCode(StatusCodes.Status200OK, t); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + t.err_title = ex.Message; + t.err_detail = errmsg; + t.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, t); + } + } + + //SendNotificationAsync + private async Task SendNotificationAsync(string token, string title, string body) + { + using (var client = new HttpClient()) + { + //var firebaseOptionsServerId = _firebaseOptions.ServerApiKey; + //var firebaseOptionsSenderId = _firebaseOptions.SenderId; + var firebaseOptionsServerId = "AAAAGBwLmNY:APA91bG5GmgYcaxsU8HrOqvZbb9r82tH9RAEifgKhwoj_zwBe7qei8u3BSxMzFl9Dwykd0TWRuM7ffNe6ehhDDRUqaRPj_vKM9KreJnNrqB6f2hxjPAxzk5De2Ys437-dnSAuS_8SVJV"; + var firebaseOptionsSenderId = "103549737174"; + + + + client.BaseAddress = new Uri("https://fcm.googleapis.com"); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", + $"key={firebaseOptionsServerId}"); + client.DefaultRequestHeaders.TryAddWithoutValidation("Sender", $"id={firebaseOptionsSenderId}"); + + + var data = new + { + to = token, + + body = body, + title = title, + + priority = "high" + }; + + var json = JsonConvert.SerializeObject(data); + var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); + + var result = await client.PostAsync("/fcm/send", httpContent); + return result.ToString(); + } + } + #endregion + + #region LOGIN + /// Magazzini per login return:ActionResult + [HttpGet("magazzini")] + public async Task>> magazzini(string token) + { + List lst= new List(); + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenAdhoc = getClaimValueByToken(token, "tenantConfigurazioni"); + + if(string.IsNullOrEmpty(ten)) + { + ten = tenAdhoc; + } + _magazziniVT = _VT_Magazzini.Magazzini; + + List magaVTList = new List(); + magaVTList = await _magazziniVT.Where(x => x.Azienda.Equals(ten2)).ToListAsync(); + + foreach (var magVT in magaVTList) + { + Magazzini maga = new Magazzini(); + maga.mgcodmag = magVT.Mgcodmag.TrimEnd(); + maga.mgdesmag = magVT.Mgdesmag.TrimEnd(); + + lst.Add(maga); + } + + return lst; + + //if (ten.Equals(Clienti.VT)) + //{ + // _magazziniVT = _VT_Magazzini.Magazzini; + + // List magaVTList = new List(); + // magaVTList = await _magazziniVT.Where(x => x.Azienda.Equals(ten2)).ToListAsync(); + + // foreach (var magVT in magaVTList) + // { + // Magazzini maga = new Magazzini(); + // maga.mgcodmag = magVT.Mgcodmag.TrimEnd(); + // maga.mgdesmag = magVT.Mgdesmag.TrimEnd(); + + // lst.Add(maga); + // } + // return lst; + //} + //else + //{ + // _magazzini = getMagazziniByTenant(ten); + // return await _magazzini.ToListAsync(); + //} + + } + + /// Login iniziale return:ActionResult + [HttpPost("loginTechnical")] + public async Task< ActionResult> loginTechnical([FromBody] LoginModel model) + { + LoginOut o = new LoginOut(); + string tenAdHoc = string.Empty; + try + { + if (string.IsNullOrEmpty(model.Username) || string.IsNullOrEmpty(model.Password)) + { + o.err_detail = "Username e Password non possono essere vuoti."; + o.err_title = "Username e Password non possono essere vuoti."; + o.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status200OK, o); + } + else + { + var tecnico=new List(); + switch (model.Tenant) + { + case Clienti.VT: + _tecnici= _VT_tec.Tecnici; + tecnico = await _tecnici.Where(t => t.tcuser == model.Username && t.tcpwd == model.Password ).Take(1).ToListAsync(); + string ten2 = tecnico.First().tccodazi; + tenAdHoc = model.Tenant; + _confLette = await readConf(ten2); + break; + default: + //2024-11-26: leggo le configurazioni prima perchè come tenant non devo più leggere AZIENDA ma AZIENDA_ADHOC + _confLette = await readConf(model.Tenant); + + tenAdHoc = (_confLette != null && _confLette.azienda_adhoc!=null)? _confLette.azienda_adhoc:string.Empty; + _tecnici = getTecniciByTenant(tenAdHoc); + //model.Tenant = tenAdHoc;// lo valoriozzo con quello iniziale per non cambiare il passaggio nel token + + tecnico = await _tecnici.Where(t => t.tcuser == model.Username && t.tcpwd == model.Password && t.tccodazi == tenAdHoc).Take(1).ToListAsync(); + break; + } + + if (tecnico == null || (tecnico != null && tecnico.Count == 0)) + { + o.err_detail = "Username o Password non trovati."; + o.err_title = "Username o Password non trovati."; + o.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status404NotFound, o); + } + else + { + var authClaims = new List + { + //new Claim(ClaimTypes.Name, model.Username), + new Claim(ClaimTypes.Name,tecnico.First().tcuser), + new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), + new Claim("tenant", tenAdHoc),//questa è la vera azienda in AdHoc. Quella del model è quella che individua l'azienda nelle configurazioni (A0001 è sempre la stessa per tutte le installazioni di ADHOC WEB) + new Claim("tenantConfigurazioni", model.Tenant),//questa è l'azienda nelle configurazioni + new Claim("tenant2", tecnico.First().tccodazi), + new Claim("tccodice", tecnico.First().tccodice), + }; + var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"])); + var token = new JwtSecurityToken( + issuer: _configuration["JWT:ValidIssuer"], + audience: _configuration["JWT:ValidAudience"], + expires: DateTime.Now.AddMonths(3), + claims: authClaims, + signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256) + ); + string tok = new JwtSecurityTokenHandler().WriteToken(token); + _token = tok; + + + o.Tok = tok; + o.Tcdescri = tecnico.First().Tcdescri; + o.Tccodice = tecnico.First().tccodice; + Conf cc = new Conf(); + + //le configurazioni per VT vanno lette con il tenant generico VIRTU + //2024-05-16: tornati alla impostazione iniziale per poter gestite i pulsanti per ogni cliente di VT + //_confLette = await readConf(model.Tenant); + + cc.abilita_naviga = _confLette.abilita_naviga; + cc.abilita_telefona = _confLette.abilita_telefona; + cc.abilita_chiamate = _confLette.abilita_chiamate; + cc.abilita_barcode = _confLette.abilita_barcode; + + cc.abilita_manutenzioni = _confLette.abilita_manutenzioni; + cc.chiamate_accetta = _confLette.chiamate_accetta; + cc.chiamate_accetta_barcode = _confLette.chiamate_accetta_barcode; + cc.chiamate_accetta_offline = _confLette.chiamate_accetta_offline; + cc.chiamate_rifiuta = _confLette.chiamate_rifiuta; + cc.chiamate_rifiuta_barcode = _confLette.chiamate_rifiuta_barcode; + cc.chiamate_rifiuta_offline = _confLette.chiamate_rifiuta_offline; + cc.chiamate_chiudi_barcode = _confLette.chiamate_chiudi_barcode; + cc.chiamate_firma_barcode = _confLette.chiamate_firma_barcode; + cc.chiamate_chiudi_salva_barcode = _confLette.chiamate_chiudi_salva_barcode; + cc.chiamate_chiudi_salva_offline = _confLette.chiamate_chiudi_salva_offline; + + cc.manutenzioni_accetta = _confLette.manutenzioni_accetta; + cc.manutenzioni_rifiuta = _confLette.manutenzioni_rifiuta; + cc.manutenzioni_accetta_barcode = _confLette.manutenzioni_accetta_barcode; + cc.manutenzioni_accetta_offline = _confLette.manutenzioni_accetta_offline; + cc.manutenzioni_chiudi_barcode = _confLette.manutenzioni_chiudi_barcode; + cc.manutenzioni_firma_barcode = _confLette.manutenzioni_firma_barcode; + cc.manutenzioni_chiudi_salva_barcode = _confLette.manutenzioni_chiudi_salva_barcode; + cc.manutenzioni_chiudi_salva_offline = _confLette.manutenzioni_chiudi_salva_offline; + + cc.dpi_checkbox = _confLette.dpi_checkbox; + + cc.anagrafica = _confLette.anagrafica; + cc.stato_finale = _confLette.stato_finale; + cc.descrizione_intervento = _confLette.descrizione_intervento; + cc.composizione_impianto = _confLette.composizione_impianto; + cc.note_intervento = _confLette.note_intervento; + cc.esito_intervento = _confLette.esito_intervento; + cc.ora_inizio_fine = _confLette.ora_inizio_fine; + cc.materiali = _confLette.materiali; + cc.diritto_chiamata = _confLette.diritto_chiamata; + cc.manodopera = _confLette.manodopera; + cc.spese_viaggio = _confLette.spese_viaggio; + cc.tipo_pagamento = _confLette.tipo_pagamento; + cc.note_pagamento = _confLette.note_pagamento; + cc.causale = _confLette.causale; + + cc.time_sheet = _confLette.time_sheet; + cc.time_sheet_offline = _confLette.time_sheet_offline; + + //per VT il costo lo devo leggere dal profilo del tecnico + if (model.Tenant.Equals(Clienti.VT)) + { + string ten2 = tecnico.First().tccodazi; + string codTec = tecnico.First().tccodice; + _tecTable = _VT_tectable.Tectable; + var costo = _tecTable.Where(t => t.tccodazi.Equals(ten2) && t.tccodice.Equals(codTec)).First(); + cc.costo_orario = costo.tccoor; + } + else + { + cc.costo_orario = _confLette.costo_orario; + } + + + cc.ftp_port= _confLette.ftp_port; + cc.manutenzioni_rifiuta_barcode = _confLette.manutenzioni_rifiuta_barcode; + cc.storico = _confLette.storico; + cc.storico_tecnico = _confLette.storico_tecnico; + cc.storico_interventi = _confLette.storico_interventi; + cc.storico_impianto = _confLette.storico_impianto; + cc.ricerca_impianti = _confLette.ricerca_impianti; + + cc.ora_inizio_fine_automatica = _confLette.ora_inizio_fine_automatica; + cc.stampa_orario = _confLette.stampa_orario; + cc.intestazione_stampa = _confLette.intestazione_stampa; + cc.seriale_template_chi = _confLette.seriale_template_chi; + cc.abilita_inserimento_chiamate = _confLette.abilita_inserimento_chiamate; + cc.abilita_data_rapp_edit = _confLette.abilita_data_rapp_edit; + cc.numeri_decimali = _confLette.numeri_decimali; + cc.max_record = _confLette.max_record; + cc.prezzi_visibili = _confLette.prezzi_visibili; + cc.desc_supp_prodotti_visibile = _confLette.desc_supp_prodotti_visibile; + cc.azienda_adhoc = _confLette.azienda_adhoc; + cc.note_interv_stampa = _confLette.note_interv_stampa; + cc.desc_interv_stampa = _confLette.desc_interv_stampa; + + + o.Config = cc; + + //cerco le aziende collegate + List l = new List(); + string ten = model.Tenant; + bool bCercaAzcoll = false; + bool bCercaAziVT = false; + + bCercaAziVT = true; + + //switch (ten) + //{ + // case Clienti.Discovery: + // bCercaAzcoll = true; + // break; + // case Clienti.VT: + // bCercaAziVT = true; + // break; + + //} + if (bCercaAzcoll) + { + //_azi_coll = getAziendeRifByTenant(ten); + var a = await _azi_coll.Where(t => t.piazihoc != null && t.piazihoc.Equals(ten) && t.picodtec!=null && t.picodtec.Trim().Equals(o.Tccodice.Trim())).ToListAsync(); + if (a.Any()) + { + + foreach (AziendaRif appo in a) + { + string logo = !string.IsNullOrEmpty(appo.pilogurl) ? appo.pilogurl.Trim() : string.Empty; + //var uriBuilder = new UriBuilder(Request.Scheme, Request.Host.Host, Request.Host.Port ?? -1); + //logo = uriBuilder + logo; + appo.pilogurl = logo; + l.Add(appo); + } + } + } + if(bCercaAziVT) + { + + ten = model.Tenant; + string ten2 = tecnico.First().tccodazi; + string tecn= tecnico.First().tccodice; + _VT_DatiAzi = _VT_DatiAzienda.Dati; + var t = await _VT_DatiAzi.Where(t => t.azienda.Equals(ten2) && t.tecnico.Equals(tecn)).ToListAsync(); + if (t.Any()) + { + foreach (DatiAzienda appo in t) + { + AziendaRif ar = new AziendaRif(); + + //https://localhost:7068/VIRTU/AZI01/AZI01_LOGO.jpg + string logo = !string.IsNullOrEmpty(appo.url_logo) ? appo.url_logo.Trim() : string.Empty; + //var uriBuilder = new UriBuilder(Request.Scheme, Request.Host.Host, Request.Host.Port ?? -1); + //logo = uriBuilder + logo; + ar.pilogurl = logo; + ar.picodtec = appo.tecnico; + ar.pinomede = appo.ragsoc; + ar.pitextin = appo.testo_buono; + ar.pirifazi = appo.azienda; + ar.piazihoc = model.Tenant; + + l.Add(ar); + } + } + /* + _azi_coll = _VT_azi.Azi; + var a= await _azi_coll.Where(t => t.piazihoc != null && t.piazihoc.Equals(ten) + && t.picodtec != null && t.picodtec.Trim().Equals(o.Tccodice.Trim()) + && t.pirifazi!=null && t.pirifazi.Equals(ten2) + ).ToListAsync(); + + if(a.Any()) + { + foreach (AziendaRif appo in a) + { + + //https://localhost:7068/VIRTU/AZI01/AZI01_LOGO.jpg + string logo = !string.IsNullOrEmpty(appo.pilogurl) ? appo.pilogurl.Trim() : string.Empty; + //var uriBuilder = new UriBuilder(Request.Scheme, Request.Host.Host, Request.Host.Port ?? -1); + //logo = uriBuilder + logo; + appo.pilogurl = logo; + l.Add(appo); + } + } + */ + + } + o.aziende_coll = l; + } + return StatusCode(StatusCodes.Status200OK, o); + } + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + o.err_detail = err; + o.err_title = err; + o.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, o); + } + + } + + #endregion + + #region CHIAMATE + private async Task getSerBuonoChiamata(string ten,string pref, string ten2) + { + //inizializzo il buono nel caso non lo trovi in tabella (per Sicilia è stato così) + string seriale = pref+"00000"; + _rapp_new = _VT_rapptable.Rapps; + + //switch (ten) + //{ + // case Clienti.VT: + // ten = ten2; + + // break; + // default: + // _rapp_new = getRappNewByTenant(ten); + // break; + //} + + //var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten && t.ser_buono!=null && t.tipo_rapportino== TipoRapportino.ChiamataChiusa).OrderByDescending(t => t.ser_buono).Take(1).ToListAsync(); + //var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten && t.ser_buono != null && t.ser_buono.Trim().Contains(pref) && t.tipo_rapportino == TipoRapportino.ChiamataChiusa).OrderByDescending(t => t.ser_buono).Take(1).ToListAsync(); + //tolto filtro su tipo rapportino per gestire anche il tipo 4 =commessa + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten && t.ser_buono != null && t.ser_buono.Trim().Contains(pref)).OrderByDescending(t => t.ser_buono).Take(1).ToListAsync(); + + if (rapp != null && rapp.Count() > 0) + { + seriale = getNewSerialeBuono(rapp.First().ser_buono, pref); + } + else + { + seriale = getNewSerialeBuono(seriale, pref); + } + + return seriale; + } + private async Task fillRappNewByInput(Input i, string token, string newSerial,Configurazioni co) + { + Rapp_New r = new Rapp_New(); + DateTime dateIni = new DateTime(1900, 1, 1); + DateTime adesso = DateTime.Now; + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + switch (ten) + { + case Clienti.VT: + _chiamate = _VT_chia.Chiamate; + ten = getClaimValueByToken(token, "tenant2"); + + break; + default: + _chiamate = getChiamateByTenant(ten); + break; + } + //i = fakeInput(i,ten); + + var chia = await _chiamate.Where(t => t.chserial.Trim().Equals(i.seriale_chiamata.Trim())).OrderBy(t => t.chdtapp).ToListAsync(); + + r.seriale_rapportino = newSerial; + r.tipo_rapportino = string.Empty; + r.azienda_impianto = ten; + r.codice_impianto = chia.First().chcodimp; + r.azienda_chiamata = ten; + r.seriale_chiamata = i.seriale_chiamata; + r.seriale_commessa = string.Empty; + r.data_rapportino = adesso; + //r.ora_ini_rapportino = adesso.Hour.ToString(); + r.ora_ini_rapportino = i.ora_ini_rapportino; + r.ora_fin_rapportino = "01"; + r.min_ini_rapportino = i.min_ini_rapportino; + r.min_fin_rapportino = "00"; + r.codice_chiusura_1 = string.Empty; + r.codice_chiusura_2 = string.Empty; + r.codice_chiusura_3 = string.Empty; + r.codice_chiusura_4 = string.Empty; + r.codice_chiusura_5 = string.Empty; + r.codice_chiusura_6 = string.Empty; + r.codice_chiusura_7 = string.Empty; + r.codice_chiusura_8 = string.Empty; + r.codice_chiusura_9 = string.Empty; + r.codice_chiusura_10 = string.Empty; + r.descrizione_intervento = "ACCETTAZIONE chiamata " + i.seriale_chiamata; + r.stato_finale = string.Empty; + r.azienda_tecnico = ten; + r.codice_tecnico = tecnico; + r.rifiutata = "N"; + r.firma = string.Empty; + r.incarico = "S"; + r.data_validita = dateIni; + r.immagine = i.immagine; + r.ser_buono = string.Empty; + + + return r; + } + private async Task fillRappNewRifiutoByInput(Input i, string token, string newSerial, Configurazioni co) + { + Rapp_New r = new Rapp_New(); + DateTime dateIni = new DateTime(1900, 1, 1); + DateTime adesso = DateTime.Now; + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + switch (ten) + { + case Clienti.VT: + _chiamate = _VT_chia.Chiamate; + ten = getClaimValueByToken(token, "tenant2"); + + break; + default: + _chiamate = getChiamateByTenant(ten); + break; + } + + var chia = await _chiamate.Where(t => t.chserial == i.seriale_chiamata).OrderBy(t => t.chdtapp).ToListAsync(); + + r.seriale_rapportino = newSerial; + r.tipo_rapportino = string.Empty; + r.azienda_impianto = ten; + r.codice_impianto = chia.First().chcodimp; + r.azienda_chiamata = ten; + r.seriale_chiamata = i.seriale_chiamata; + r.seriale_commessa = string.Empty; + r.data_rapportino = adesso; + r.ora_ini_rapportino = adesso.Hour.ToString(); + r.ora_fin_rapportino = "01"; + r.min_ini_rapportino = adesso.Minute.ToString(); + r.min_fin_rapportino = "00"; + r.codice_chiusura_1 = string.Empty; + r.codice_chiusura_2 = string.Empty; + r.codice_chiusura_3 = string.Empty; + r.codice_chiusura_4 = string.Empty; + r.codice_chiusura_5 = string.Empty; + r.codice_chiusura_6 = string.Empty; + r.codice_chiusura_7 = string.Empty; + r.codice_chiusura_8 = string.Empty; + r.codice_chiusura_9 = string.Empty; + r.codice_chiusura_10 = string.Empty; + r.descrizione_intervento = "RIFIUTO chiamata " + i.seriale_chiamata; + r.stato_finale = string.Empty; + r.azienda_tecnico = ten; + r.codice_tecnico = tecnico; + r.rifiutata = "S"; + r.firma = string.Empty; + r.incarico = "N"; + r.data_validita = dateIni; + r.immagine = i.immagine; + r.ser_buono = string.Empty; + + return r; + } + private async Task fillRappNewChiudiByInput(Input i, string token, string newSerial, Configurazioni co) + { + Rapp_New r = new Rapp_New(); + DateTime dateIni = new DateTime(1900, 1, 1); + DateTime adesso = DateTime.Now; + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + var sBuono = await getSerBuonoChiamata(ten, co.prefisso_buoni_chia,ten2); + + + switch (ten) + { + case Clienti.VT: + _chiamate = _VT_chia.Chiamate; + ten = getClaimValueByToken(token, "tenant2"); + + break; + default: + _chiamate = getChiamateByTenant(ten); + break; + } + + + var chiam = await _chiamate.Where( + t => t.chserial.Equals(i.seriale_chiamata) + && t.chcodazi == ten && t.chtipo.Equals("X") + ).OrderByDescending(t => t.chdtapp).ToListAsync(); + if(chiam!=null && chiam.Count()>0) + { + r.tipo_rapportino = TipoRapportino.ChiamataDaCommessa; + r.seriale_commessa = chiam.FirstOrDefault().chrifer; + } + else + { + r.tipo_rapportino = TipoRapportino.ChiamataChiusa; + r.seriale_commessa = string.Empty; + } + + // MARROCCO se la chiamata è fatta da un capo tecnico che deve rendicontare l'attività delle squadra + // sulla chiamata nel campo CHMODRAC viene scritto COMME + var chiam2 = await _chiamate.Where( + t => t.chserial.Equals(i.seriale_chiamata) + && t.chcodazi == ten && t.chtipo.Equals("A") + ).OrderByDescending(t => t.chdtapp).ToListAsync(); + //if (chiam2 != null && chiam2.Count() > 0) + //{ + // if (ten.Equals(Clienti.Marrocco) && chiam2 != null && chiam2.FirstOrDefault().chmodrac != null && chiam2.FirstOrDefault().chmodrac.Equals("COMME")) + // { + // r.tipo_rapportino = TipoRapportino.ChiamataCapoTecnico; + // } + // if (ten.Equals(Clienti.Gitoga) && chiam2 != null && chiam2.FirstOrDefault().chmodrac != null && chiam2.FirstOrDefault().chmodrac.Equals("COMME")) + // { + // r.tipo_rapportino = TipoRapportino.ChiamataCapoTecnico; + // } + // if (ten.Equals(Clienti.Lifta) && chiam2 != null && chiam2.FirstOrDefault().chmodrac != null && chiam2.FirstOrDefault().chmodrac.Equals("COMME")) + // { + // r.tipo_rapportino = TipoRapportino.ChiamataCapoTecnico; + // } + //} + + r.seriale_rapportino = newSerial; + + r.azienda_impianto = ten; + r.codice_impianto = i.codice_impianto; + r.azienda_chiamata = ten; + r.seriale_chiamata = i.seriale_chiamata; + + + //2023-11-23: gestione data retrodatata. Se l'input è valorizzato vuol dire che l'ho editato dal campo, altrimenti passo la data di sistema + if(i.data_rapportino!=null) + r.data_rapportino = i.data_rapportino; + else + r.data_rapportino = adesso; + + //r.ora_ini_rapportino = adesso.Hour.ToString(); + r.ora_ini_rapportino = i.ora_ini_rapportino; + r.ora_fin_rapportino = i.ora_fin_rapportino; + //r.min_ini_rapportino = adesso.Minute.ToString(); + r.min_ini_rapportino = i.min_ini_rapportino; + r.min_fin_rapportino = i.min_fin_rapportino; + r.codice_chiusura_1 = i.codice_chiusura_1; + r.codice_chiusura_2 = i.codice_chiusura_2; + r.codice_chiusura_3 = i.codice_chiusura_3; + r.codice_chiusura_4 = i.codice_chiusura_4; + r.codice_chiusura_5 = i.codice_chiusura_5; + r.codice_chiusura_6 = i.codice_chiusura_6; + r.codice_chiusura_7 = i.codice_chiusura_7; + r.codice_chiusura_8 = i.codice_chiusura_8; + r.codice_chiusura_9 = i.codice_chiusura_9; + r.codice_chiusura_10 = i.codice_chiusura_10; + r.descrizione_intervento = i.descrizione_intervento; + r.stato_finale = string.Empty; + r.azienda_tecnico = ten; + r.codice_tecnico = tecnico.Trim(); + r.rifiutata = string.Empty; + r.firma = i.firma; + r.incarico = string.Empty; + r.data_validita = adesso; + //r.immagine = co.path_buoni + sBuono.ToString(); + + r.esito_intervento = i.esito_intervento; + r.note_intervento = i.note_intervento; + r.note_esito = i.note_esito; + r.difetti_riscontrati = i.difetti_riscontrati; + r.lavoro_eseguito = i.lavoro_eseguito; + r.nuovo_contratto = i.nuovo_contratto; + r.ore_lavoro = i.ore_lavoro; + r.causale = i.causale; + r.materiale = i.materiale; + r.diritto_chiamata = i.diritto_chiamata; + r.manodopera = i.manodopera; + r.spese_viaggio = i.spese_viaggio; + r.pagamento = i.pagamento; + r.anticipo = i.anticipo; + r.totale = i.totale; + r.note_pagamento = i.note_pagamento; + r.tipo_intervento = i.tipo_intervento; + r.rafoto1 = i.rafoto1; + r.rafoto2 = i.rafoto2; + r.rafoto3 = i.rafoto3; + r.rafoto4 = i.rafoto4; + r.rafoto5 = i.rafoto5; + r.rafoto6 = i.rafoto6; + r.rafoto7 = i.rafoto7; + r.rafoto8 = i.rafoto8; + r.rafoto9 = i.rafoto9; + r.rafoto10 = i.rafoto10; + r.codice_intervento = i.codice_intervento; + r.data_effettiva = i.data_effettiva; + //manca codice giro ? + + //r.immagine = i.immagine; + r.immagine = string.Format(@"{0}\{1}.jpg", co.path_buoni, sBuono.ToString()); + r.ser_buono = sBuono.ToString(); + Console.WriteLine(string.Format("*********** {2} metodo chiudi: tenant:{0} tenant2: {1} tenantConf: {5} buono: {3} tecnico:{4} ", ten, ten2, DateTime.Now.ToString(), r.ser_buono, r.codice_tecnico,tenConf)); + + return r; + } + 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; + chiamataItemList = formattaItemChiamateVT(i); + + //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 Chiamate_out fillChiamateOutVT(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; + sb.Append("SPETT.LE :"); + if (!string.IsNullOrEmpty(i.andescri)) + { + sb.Append(!string.IsNullOrEmpty(i.andescri) ? i.andescri.Trim() + " " : 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(); + + //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 + //} + chiamataItemList = formattaItemChiamateVT(i); + 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; + //} + + + //sb.AppendLine("N. Impianto: " + i.chcodimp); + if (!string.IsNullOrEmpty(i.imubicaz)) + sb.AppendLine("Ubicazione: " + i.imubicaz); + + rif_impianto = sb.ToString(); + + 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; + //} + + private Chiamate_out inputToChiamateOut(Input i) + { + Chiamate_out c = new Chiamate_out(); + c.chserial = i.seriale_chiamata; + c.chcodazi = i.azienda_chiamata; + c.chaziimp = i.codice_impianto; + c.tccodice = i.codice_tecnico; + c.chdata = i.data_rapportino; + return c; + } + + /// Codici di chiusura per scheda intevento return:ActionResult + [HttpGet("codici_chiusura")] + public async Task>> codiciChiusura(string token) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + _chiusure = _VT_chiu.Chiu; + + //switch (ten) + //{ + // case Clienti.VT: + // _chiusure = _VT_chiu.Chiu; + // ten = getClaimValueByToken(token, "tenant2"); + + // break; + // default: + // _chiusure = getChiusureByTenant(ten); + // break; + //} + + var l = await _chiusure.Where(c => c.cccodazi.Equals(ten)).ToListAsync(); + //per DISCOVERY devo riempire anche gli abbinamenti con il tipo manutenzione + //switch (ten) + //{ + // case Clienti.Discovery: + + // //_ccci = _Disco_ccci.ccci; + // _ccciView= _Disco_ccciView.ccciWiev; + // foreach (Chiusure t in l) + // { + // t.tipologieMan = new List(); + + + // string cod = t.cccodice; + // //logica per cercare nella tabella degli abbinamenti + + + // var appo= await _ccciView.Where(c => c.picodazi!=null && c.picodazi.Equals(ten) && c.picodchi != null && c.picodchi.Equals(cod)).ToListAsync(); + // if (appo != null && appo.Count() > 0) + // { + // //sono nel caso dei codici gestiti: nella lista metto solo quelli permessi + // foreach (CC_CIWiev c in appo) + // { + // t.tipologieMan.Add(c.picodint); + // } + // } + // else + // { + // //t.tipologieMan.Add("SEMESTRALE"); + // //t.tipologieMan.Add("ANN "); + // //t.tipologieMan.Add("BIMESTRALE"); + // //t.tipologieMan.Add("MENSILE "); + // //t.tipologieMan.Add("QUADRIMEST"); + // //t.tipologieMan.Add("TR "); + // //t.tipologieMan.Add("VERSEM "); + + // //Aggiungo tutti + // var result = _ccciView.GroupBy(test => test.cicodice) + // .Select(grp => grp.First()) + // .ToList(); + // foreach (CC_CIWiev c in result) + // { + // string codint = !string.IsNullOrEmpty(c.cicodice) ? c.cicodice : string.Empty; + // t.tipologieMan.Add(codint); + // } + + // //trovo tutti gli altri NON gestiti e li elimino dal totale + // var result2 = _ccciView.Where(p=>p.picodint!=null).GroupBy(test => test.cicodice) + // .Select(grp => grp.First()) + // .ToList(); + // foreach (CC_CIWiev c in result2) + // { + // string codint = !string.IsNullOrEmpty(c.cicodice)? c.cicodice:string.Empty; + // t.tipologieMan.Remove(codint); + // } + // } + // } + + // break; + // default: + + // break; + //} + + return StatusCode(StatusCodes.Status200OK, l); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + + } + + /// Chiamate per tecnico e azienda (tenant) in stato C=Assegnate return:ActionResult + [HttpGet("chiamate")] + 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 = _VT_chia.Chiamate; + ten = getClaimValueByToken(token, "tenant2"); + + //switch (ten) + //{ + // case Clienti.VT: + // _chiamate = _VT_chia.Chiamate; + // ten = getClaimValueByToken(token, "tenant2"); + + // break; + // default: + // _chiamate = getChiamateByTenant(ten); + // break; + //} + + 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(); + if (tenOut.Equals(Clienti.VT)) + { + o = fillChiamateOutVT(ch, ten); + } + else + { + 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); + } + } + + /// presaInCarico: 1) crea un nuovo seriale per RAPP_NEW 2)inserisce il primo record di una presa in carico su RAPP_NEW return:ActionResult + [HttpPost] + [Route("chiamate/prendi_in_carico")] + public async Task> prendiInCarico([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + Chiamate calltec=new Chiamate(); + Chiamate_out calltec_out = new Chiamate_out(); + string tec = string.Empty; + try { + tec = getClaimValueByToken(token, "tccodice"); + } + catch { } + Console.WriteLine(string.Format("*********** {2} metodo prendiInCarico1: tenant:{0} tenant2: {1} token: {3} tecnico:{4} ", ten, ten2, DateTime.Now.ToString(), token, tec)); + + try + { + if (await checkChiamataPresa(ten, model.seriale_chiamata,TipoRapportino.PresaInCarico,ten2) ==0) + { + + _confLette = await readConf(tenConf); + string newSerial = string.Empty; + newSerial = await getSeriale(token); + Rapp_New r = await fillRappNewByInput(model, token, newSerial, _confLette); + using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + { + await _VT_rapptable.Rapps.AddAsync(r); + await _VT_rapptable.SaveChangesAsync(); + transactionVT.Commit(); + } + //switch (ten) + // { + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // await _Marro_rapp.Rapps.AddAsync(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // await _Ferra_rapp.Rapps.AddAsync(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // await _Sicilia_rapp.Rapps.AddAsync(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Discovery: + // using (var transaction = _Disco_rapp.Database.BeginTransaction()) + // { + // await _Disco_rapp.Rapps.AddAsync(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // await _Sarom_rapp.Rapps.AddAsync(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // await _Gitoga_rapp.Rapps.AddAsync(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // await _Lifta_rapp.Rapps.AddAsync(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_rapp.Database.BeginTransaction()) + // { + // await _Siet_rapp.Rapps.AddAsync(r); + // await _Siet_rapp.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _Pms_rapp.Database.BeginTransaction()) + // { + // await _Pms_rapp.Rapps.AddAsync(r); + // await _Pms_rapp.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.VT: + // using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + // { + // await _VT_rapptable.Rapps.AddAsync(r); + // await _VT_rapptable.SaveChangesAsync(); + // transactionVT.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionLW = _LW_rapp.Database.BeginTransaction()) + // { + // await _LW_rapp.Rapps.AddAsync(r); + // await _LW_rapp.SaveChangesAsync(); + // transactionLW.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_rapp.Database.BeginTransaction()) + // { + // await _Tedes_rapp.Rapps.AddAsync(r); + // await _Tedes_rapp.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionSys = _Sys_rapp.Database.BeginTransaction()) + // { + // await _Sys_rapp.Rapps.AddAsync(r); + // await _Sys_rapp.SaveChangesAsync(); + // transactionSys.Commit(); + // } + // break; + // default: + // break; + // } + //restituisco la chiamata + Console.WriteLine(string.Format("*********** {2} metodo prendiInCarico2: tenant:{0} tenant2: {1} token: {3} tecnico:{4} ", ten, ten2, DateTime.Now.ToString(), token, tec)); + calltec = await getChiamataBySerial(model.seriale_chiamata, token); + calltec_out = fillChiamateOut(calltec, ten); + calltec_out.err_status_code = StatiRisposta.Ok; + + //2024-08-01: metto la lettura della chiamata in un try/catch per evitare l'errore casuale "sequence contains no element" + //nel catch faccio uscire un oggetto riempito con i valori dell'Input di ingresso + //try + //{ + // calltec = await getChiamataBySerial(model.seriale_chiamata, token); + // calltec_out = fillChiamateOut(calltec, ten); + // calltec_out.err_status_code = StatiRisposta.Ok; + //} + //catch(Exception ee) + //{ + // calltec_out = inputToChiamateOut(model); + //} + } + else + { + calltec_out.err_title = "Impossibile prendere in carico la chiamata"; + calltec_out.err_detail = "Chiamata precendentemente presa in carico: " + model.seriale_chiamata; + calltec_out.err_status_code = StatiRisposta.OperazioneNonAmmessa; + } + return StatusCode(StatusCodes.Status200OK, calltec_out); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + calltec_out.err_title = ex.Message; + calltec_out.err_detail = errmsg; + calltec_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + + } + + /// rifiuta: 1) crea un nuovo seriale per RAPP_NEW 2)inserisce record su RAPP_NEW con INCARICO=N e RIFIUTATA=S return:ActionResult + [HttpPost] + [Route("chiamate/rifiuta")] + public async Task> rifiuta([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + Chiamate calltec = new Chiamate(); + Chiamate_out calltec_out = new Chiamate_out(); + + try + { + if (await checkChiamataRifiutata(ten, model.seriale_chiamata, TipoRapportino.PresaInCarico,ten2) == 0) + { + _confLette = await readConf(tenConf); + string newSerial = string.Empty; + newSerial = await getSeriale(token); + Rapp_New r = await fillRappNewRifiutoByInput(model, token, newSerial, _confLette); + + using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + { + await _VT_rapptable.Rapps.AddAsync(r); + await _VT_rapptable.SaveChangesAsync(); + transactionVT.Commit(); + } + //switch (ten) + // { + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // await _Marro_rapp.Rapps.AddAsync(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // await _Ferra_rapp.Rapps.AddAsync(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // await _Sicilia_rapp.Rapps.AddAsync(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Discovery: + // using (var transaction = _Disco_rapp.Database.BeginTransaction()) + // { + // await _Disco_rapp.Rapps.AddAsync(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // await _Sarom_rapp.Rapps.AddAsync(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // await _Gitoga_rapp.Rapps.AddAsync(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // await _Lifta_rapp.Rapps.AddAsync(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_rapp.Database.BeginTransaction()) + // { + // await _Siet_rapp.Rapps.AddAsync(r); + // await _Siet_rapp.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _Pms_rapp.Database.BeginTransaction()) + // { + // await _Pms_rapp.Rapps.AddAsync(r); + // await _Pms_rapp.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.VT: + // using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + // { + // await _VT_rapptable.Rapps.AddAsync(r); + // await _VT_rapptable.SaveChangesAsync(); + // transactionVT.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionLW = _LW_rapp.Database.BeginTransaction()) + // { + // await _LW_rapp.Rapps.AddAsync(r); + // await _LW_rapp.SaveChangesAsync(); + // transactionLW.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_rapp.Database.BeginTransaction()) + // { + // await _Tedes_rapp.Rapps.AddAsync(r); + // await _Tedes_rapp.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionSys = _Sys_rapp.Database.BeginTransaction()) + // { + // await _Sys_rapp.Rapps.AddAsync(r); + // await _Sys_rapp.SaveChangesAsync(); + // transactionSys.Commit(); + // } + // break; + // default: + // break; + // } + calltec = await getChiamataBySerial(model.seriale_chiamata, token); + calltec_out = fillChiamateOut(calltec, ten); + calltec_out.err_status_code = StatiRisposta.Ok; + + } + else + { + calltec_out.err_title = "Impossibile rifiutare la chiamata"; + calltec_out.err_detail = "Chiamata precendentemente rifiutata: " + model.seriale_chiamata; + calltec_out.err_status_code = StatiRisposta.OperazioneNonAmmessa; + } + return StatusCode(StatusCodes.Status200OK, calltec_out); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + calltec_out.err_title = ex.Message; + calltec_out.err_detail = errmsg; + calltec_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + + //return calltec_out; + + } + + /// chiudi: 1) crea un nuovo seriale per RAPP_NEW 2)inserisce record su RAPP_NEW con i dati dell'intervento return:ActionResult + [HttpPost] + [Route("chiamate/chiudi")] + public async Task> chiudi([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf= getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + Chiamate calltec = new Chiamate(); + Chiamate_out calltec_out = new Chiamate_out(); + try + { + if (await checkChiamataChiusa(ten, model.seriale_chiamata, TipoRapportino.ChiamataChiusa) == 0) + { + int riga = 0; + if(ten.Equals(Clienti.VT)) + { + _confLette = await readConf(ten2); + } + else + { + + _confLette = await readConf(tenConf); + } + + string newSerial = string.Empty; + newSerial = await getSeriale(token); + + Rapp_New r = await fillRappNewChiudiByInput(model, token, newSerial, _confLette); + + using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + { + await _VT_rapptable.Rapps.AddAsync(r); + await _VT_rapptable.SaveChangesAsync(); + transactionVT.Commit(); + } + // 27/02/2025 agggiunta gestione Vt_MagNew + riga = 0; + if (model.compo_add != null && model.compo_add.Count() > 0) + { + using (var transactionVT2 = _VT_rapptable.Database.BeginTransaction()) + { + foreach (Saldiart co in model.compo_add) + { + Vt_Mag_New vtmn = new Vt_Mag_New(); + riga = riga + 1; + vtmn = SaldiArtToVtMag_New(co, riga, newSerial, tecnico, ten2); + + await _VT_MagNew.MagNewVt.AddAsync(vtmn); + await _VT_MagNew.SaveChangesAsync(); + } + transactionVT2.Commit(); + } + } + if (model.compo_del != null && model.compo_del.Count() > 0) + { + using (var transactionVt3 = _VT_rapptable.Database.BeginTransaction()) + { + foreach (Compo_Impia co in model.compo_del) + { + Vt_Mag_New vtmn = new Vt_Mag_New(); + riga = riga + 1; + vtmn = compo_ImpiaToVt_Mag_New(co, riga, newSerial, tecnico, ten2); + + await _VT_MagNew.MagNewVt.AddAsync(vtmn); + await _VT_MagNew.SaveChangesAsync(); + } + transactionVt3.Commit(); + } + } + + //switch (ten) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // await _Marro_rapp.Rapps.AddAsync(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // await _Ferra_rapp.Rapps.AddAsync(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // await _Sarom_rapp.Rapps.AddAsync(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // await _Gitoga_rapp.Rapps.AddAsync(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // await _Lifta_rapp.Rapps.AddAsync(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + + // break; + + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // await _Sicilia_rapp.Rapps.AddAsync(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add!=null && model.compo_add.Count()>0) + // { + // using (var transaction2 = _Sicilia_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Sicilia_mag.Mag.AddAsync(mn); + // await _Sicilia_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Sicilia_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Sicilia_mag.Mag.AddAsync(mn); + // await _Sicilia_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.Discovery: + + // using (var transaction = _Disco_rapp.Database.BeginTransaction()) + // { + // await _Disco_rapp.Rapps.AddAsync(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _Disco_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Disco_mag.Mag.AddAsync(mn); + // await _Disco_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Disco_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Disco_mag.Mag.AddAsync(mn); + // await _Disco_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.Siet: + + // using (var transaction = _Siet_rapp.Database.BeginTransaction()) + // { + // await _Siet_rapp.Rapps.AddAsync(r); + // await _Siet_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _Siet_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Siet_mag.Mag.AddAsync(mn); + // await _Siet_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Siet_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Siet_mag.Mag.AddAsync(mn); + // await _Siet_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.PMS: + + // using (var transaction = _Pms_rapp.Database.BeginTransaction()) + // { + // await _Pms_rapp.Rapps.AddAsync(r); + // await _Pms_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _PMS_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _PMS_mag.Mag.AddAsync(mn); + // await _PMS_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _PMS_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _PMS_mag.Mag.AddAsync(mn); + // await _PMS_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.VT: + // using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + // { + // await _VT_rapptable.Rapps.AddAsync(r); + // await _VT_rapptable.SaveChangesAsync(); + // transactionVT.Commit(); + // } + // // 27/02/2025 agggiunta gestione Vt_MagNew + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transactionVT2 = _VT_rapptable.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // Vt_Mag_New vtmn = new Vt_Mag_New(); + // riga = riga + 1; + // vtmn = SaldiArtToVtMag_New(co, riga, newSerial, tecnico, ten2); + + // await _VT_MagNew.MagNewVt.AddAsync(vtmn); + // await _VT_MagNew.SaveChangesAsync(); + // } + // transactionVT2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transactionVt3 = _VT_rapptable.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Vt_Mag_New vtmn = new Vt_Mag_New(); + // riga = riga + 1; + // vtmn = compo_ImpiaToVt_Mag_New(co, riga, newSerial, tecnico, ten2); + + // await _VT_MagNew.MagNewVt.AddAsync(vtmn); + // await _VT_MagNew.SaveChangesAsync(); + // } + // transactionVt3.Commit(); + // } + // } + // break; + // case Clienti.LW: + + // using (var transaction = _LW_rapp.Database.BeginTransaction()) + // { + // await _LW_rapp.Rapps.AddAsync(r); + // await _LW_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _LW_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _LW_mag.Mag.AddAsync(mn); + // await _LW_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _LW_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _LW_mag.Mag.AddAsync(mn); + // await _LW_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.Tedesco: + + // using (var transaction = _Tedes_rapp.Database.BeginTransaction()) + // { + // await _Tedes_rapp.Rapps.AddAsync(r); + // await _Tedes_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _Tedes_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Tedes_mag.Mag.AddAsync(mn); + // await _Tedes_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Tedes_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Tedes_mag.Mag.AddAsync(mn); + // await _Tedes_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + + // case Clienti.Syscom: + + // using (var transaction = _Sys_rapp.Database.BeginTransaction()) + // { + // await _Sys_rapp.Rapps.AddAsync(r); + // await _Sys_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + // using (var transaction2 = _Sys_mag.Database.BeginTransaction()) + // { + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Sys_mag.Mag.AddAsync(mn); + // await _Sys_mag.SaveChangesAsync(); + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Sys_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Sys_mag.Mag.AddAsync(mn); + // await _Sys_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + + // default: + // break; + //} + + calltec = await getChiamataBySerial(r.seriale_chiamata, token); + calltec_out = fillChiamateOut(calltec, ten); + calltec_out.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, calltec_out); + + } + else + { + calltec_out.err_title = "Impossibile chiudere la chiamata"; + calltec_out.err_detail = "Chiamata precendentemente chiusa: " + model.seriale_chiamata; + calltec_out.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + calltec_out.err_title = ex.Message; + calltec_out.err_detail = errmsg; + calltec_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + + //return calltec_out; + } + + /// rilascia: elimina record su RAPP_NEW con i dati dell'intervento return:ActionResult + [HttpPost] + [Route("chiamate/rilascia")] + public async Task> rilascia([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + Chiamate calltec = new Chiamate(); + Chiamate_out calltec_out = new Chiamate_out(); + Rapp_New r = null; + + try + { + if ((r=await checkChiamataDaRilasciare (ten, model.seriale_rapportino, TipoRapportino.PresaInCarico, ten2))!=null) + { + using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + { + _VT_rapptable.Rapps.Remove(r); + await _VT_rapptable.SaveChangesAsync(); + transactionVT.Commit(); + } + //switch (ten) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // _Marro_rapp.Rapps.Remove(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // _Ferra_rapp.Rapps.Remove(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // _Sarom_rapp.Rapps.Remove(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // _Gitoga_rapp.Rapps.Remove(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // _Lifta_rapp.Rapps.Remove(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + + // break; + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // _Sicilia_rapp.Rapps.Remove(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Discovery: + // using (var transaction = _Disco_rapp.Database.BeginTransaction()) + // { + // _Disco_rapp.Rapps.Remove(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + + // using (var transaction = _Siet_rapp.Database.BeginTransaction()) + // { + // _Siet_rapp.Rapps.Remove(r); + // await _Siet_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.PMS: + + // using (var transaction = _Pms_rapp.Database.BeginTransaction()) + // { + // _Pms_rapp.Rapps.Remove(r); + // await _Pms_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.VT: + // using (var transactionVT = _VT_rapptable.Database.BeginTransaction()) + // { + // _VT_rapptable.Rapps.Remove(r); + // await _VT_rapptable.SaveChangesAsync(); + // transactionVT.Commit(); + // } + // break; + // case Clienti.LW: + + // using (var transaction = _LW_rapp.Database.BeginTransaction()) + // { + // _LW_rapp.Rapps.Remove(r); + // await _LW_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Tedesco : + + // using (var transaction = _Tedes_rapp.Database.BeginTransaction()) + // { + // _Tedes_rapp.Rapps.Remove(r); + // await _Tedes_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Syscom: + + // using (var transaction = _Sys_rapp.Database.BeginTransaction()) + // { + // _Sys_rapp.Rapps.Remove(r); + // await _Sys_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // default: + // break; + //} + calltec = await getChiamataBySerial(r.seriale_chiamata, token); + calltec_out = fillChiamateOut(calltec, ten); + calltec_out.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, calltec_out); + + } + else + { + calltec_out.err_title = "Impossibile rilasciare la chiamata.Chiamata non trovata"; + StringBuilder sb = new StringBuilder(); + sb.AppendLine("seriale Chiamata : " + model.seriale_chiamata); + sb.AppendLine("seriale Rapportino : " + model.seriale_rapportino); + calltec_out.err_detail = sb.ToString(); + sb.Clear(); + calltec_out.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + calltec_out.err_title = ex.Message; + calltec_out.err_detail = errmsg; + calltec_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, calltec_out); + } + + //return calltec_out; + } + #endregion + + #region MANUTENZIONI + private Prese fillPreseByInput(Input i, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + Prese p = new Prese(); + p.picodazi = ten; + p.pimpianto = i.pimpianto; + p.picodint = i.picodint; + p.picodtec = tecnico; + p.pidatman = i.pidatman; + p.cpccchk = getCpccchk(10); + return p; + } + private async Task fillRappNewChiudiManByInput(Input model, string token, string newSerial,Configurazioni co) + { + Rapp_New r = new Rapp_New(); + //DateTime dateIni = new DateTime(1900, 1, 1); + DateTime adesso = DateTime.Now; + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + var sBuono = await getSerBuonoManutenzione(ten, co.prefisso_buoni_man); + + //model = fakeInputMan(model); + r.seriale_rapportino = newSerial; + + r.tipo_rapportino = TipoRapportino.ManutenzioneChiusa; + r.azienda_impianto = ten; + //r.codice_impianto = model.codice_impianto; + r.codice_impianto = model.pimpianto;//da tabella PIPRESA + r.azienda_chiamata = ten; + r.seriale_chiamata = String.Empty; + r.seriale_commessa = string.Empty; + + + //var time = "03/07/2023 00:00:00"; + //adesso = DateTime.ParseExact(time, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); + r.data_rapportino = adesso; + + + //r.ora_ini_rapportino = adesso.Hour.ToString(); + r.ora_ini_rapportino = model.ora_ini_rapportino; + r.ora_fin_rapportino = model.ora_fin_rapportino; + //r.min_ini_rapportino = adesso.Minute.ToString(); + r.min_ini_rapportino = model.min_ini_rapportino; + r.min_fin_rapportino = model.min_fin_rapportino; + r.codice_chiusura_1 = model.codice_chiusura_1; + r.codice_chiusura_2 = model.codice_chiusura_2; + r.codice_chiusura_3 = model.codice_chiusura_3; + r.codice_chiusura_4 = model.codice_chiusura_4; + r.codice_chiusura_5 = model.codice_chiusura_5; + r.codice_chiusura_6 = model.codice_chiusura_6; + r.codice_chiusura_7 = model.codice_chiusura_7; + r.codice_chiusura_8 = model.codice_chiusura_8; + r.codice_chiusura_9 = model.codice_chiusura_9; + r.codice_chiusura_10 = model.codice_chiusura_10; + r.descrizione_intervento = model.descrizione_intervento; + r.stato_finale = model.stato_finale; + r.azienda_tecnico = ten; + r.codice_tecnico = tecnico; + r.rifiutata = string.Empty; + r.firma = model.firma; + r.incarico = string.Empty; + r.data_validita = model.pidatman; + + //r.immagine = co.path_buoni + sBuono.ToString(); + + r.esito_intervento = model.esito_intervento; + r.note_intervento = model.note_intervento; + r.note_esito = model.note_esito; + r.difetti_riscontrati = model.difetti_riscontrati; + r.lavoro_eseguito = model.lavoro_eseguito; + r.nuovo_contratto = model.nuovo_contratto; + r.ore_lavoro = model.ore_lavoro; + r.causale = model.causale; + r.materiale = model.materiale; + r.diritto_chiamata = model.diritto_chiamata; + r.manodopera = model.manodopera; + r.spese_viaggio = model.spese_viaggio; + r.pagamento = model.pagamento; + r.anticipo = model.anticipo; + r.totale = model.totale; + r.note_pagamento = model.note_pagamento; + r.tipo_intervento = model.tipo_intervento; + r.rafoto1 = model.rafoto1; + r.rafoto2 = model.rafoto2; + r.rafoto3 = model.rafoto3; + r.rafoto4 = model.rafoto4; + r.rafoto5 = model.rafoto5; + r.rafoto6 = model.rafoto6; + r.rafoto7 = model.rafoto7; + r.rafoto8 = model.rafoto8; + r.rafoto9 = model.rafoto9; + r.rafoto10 = model.rafoto10; + //r.codice_intervento = model.codice_intervento; + r.codice_intervento = model.picodint;// da tabella PIPRESA + //r.data_effettiva = model.data_effettiva; + r.data_effettiva = model.pidatman;// da tabella PIPRESA + + + //r.immagine = model.immagine; + r.immagine = string.Format(@"{0}\{1}.jpg",co.path_buoni,sBuono.ToString()); + //string ts = DateTime.Now.ToString("yyyyMMddHHmmss"); + //r.immagine = string.Format(@"{0}\{1}_{2}.jpg", co.path_buoni, sBuono.ToString(),ts); + r.ser_buono = sBuono.ToString(); + Console.WriteLine(string.Format("*********** {2} metodo chiudi MAN: tenant:{0} tenant2: {1} tenantConf: {5} buono: {3} tecnico:{4} ", ten, ten2, DateTime.Now.ToString(), r.ser_buono, r.codice_tecnico, tenConf)); + + return r; + } + private async Task getSerBuonoManutenzione(string ten,string suff) + { + //inizializzo il buono nel caso non lo trovi in tabella (per Sicilia è stato così) + //TODO da togliere + //suff = "MAK"; + string seriale = suff+"00000"; + + //_rapp_new = getRappNewByTenant(ten); + //var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten && t.ser_buono != null && t.tipo_rapportino == TipoRapportino.ManutenzioneChiusa).OrderByDescending(t => t.seriale_rapportino).Take(1).ToListAsync(); + var rapp = await _rapp_new.Where(t => t.azienda_impianto == ten && t.ser_buono != null && t.ser_buono.Trim().Contains(suff) && t.tipo_rapportino == TipoRapportino.ManutenzioneChiusa).OrderByDescending(t => t.seriale_rapportino).Take(1).ToListAsync(); + + if (rapp != null && rapp.Count() > 0) + { + seriale = getNewSerialeBuonoMan(rapp.First().ser_buono, suff); + } + else + { + seriale = getNewSerialeBuonoMan(seriale, suff); + } + return seriale; + } + private Manprog_out fillManprogOut(Manprog m, string tenant) + { + Manprog_out o = new Manprog_out(); + o.ctcodint=m.ctcodint; + o.ctdatpro = m.ctdatpro; + o.ctdesint = m.ctdesint; + o.imindiri1 = m.imindiri1; + o.imindiri2 = m.imindiri2; + + o.imindiri3 = m.imindiri3; + o.imindiri4 = m.imindiri4; + o.imindiri5 = m.imindiri5; + o.imlocali = m.imlocali; + o.imcodcap = m.imcodcap; + + o.imcomune = m.imcomune; + o.improvin = m.improvin; + o.improvin = m.improvin; + + o.immatric = m.immatric; + o.imnumimp = m.imnumimp; + o.imubicaz = m.imubicaz; + + o.tccodice = m.tccodice; + o.seriale_rapportino = m.seriale_rapportino; + o.ser_buono = m.ser_buono; + o.generato = m.generato; + + + o.pimpianto = m.pimpianto; + o.picodint = m.picodint; + o.pidatman = m.pidatman; + o.err_title = m.err_title; + o.err_detail = m.err_detail; + o.err_status_code = m.err_status_code; + + o.telefono1 = m.telefono1; + o.telefono2 = m.telefono2; + o.cliente = m.cliente; + o.chiamata = m.chiamata; + o.spe_viaggio = m.spe_viaggio; + + //campi chiave + o.ctcodazi = tenant; + o.ctcodimp = m.ctcodimp; + o.ctdatpro = Convert.ToDateTime(m.ctdatpro); + o.ctcodint = m.ctcodint; + //FINE campi chiave + StringBuilder sb = new StringBuilder(); + Dictionary dic = new Dictionary(); + + string indStampa = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + + // dic.Add("Num. Impianto", !string.IsNullOrEmpty(m.imnumimp) ? m.imnumimp : String.Empty); + // dic.Add("Ubicazione", !string.IsNullOrEmpty(m.imubicaz) ? m.imubicaz : String.Empty); + // #endregion + // break; + // case Clienti.Gitoga: + // #region gitoga + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + + // dic.Add("Num. Impianto", !string.IsNullOrEmpty(m.imnumimp) ? m.imnumimp : String.Empty); + // dic.Add("Ubicazione", !string.IsNullOrEmpty(m.imubicaz) ? m.imubicaz : String.Empty); + // #endregion + // break; + // case Clienti.Lifta: + // #region lifta + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + + // dic.Add("Num. Impianto", !string.IsNullOrEmpty(m.imnumimp) ? m.imnumimp : String.Empty); + // dic.Add("Ubicazione", !string.IsNullOrEmpty(m.imubicaz) ? m.imubicaz : String.Empty); + // #endregion + // break; + // case Clienti.Sicilia: + // #region sicila dictionary + // dic.Add("Gennaio", !string.IsNullOrEmpty(m.mpmesgen) ? m.mpmesgen : String.Empty); + // dic.Add("Febbraio", !string.IsNullOrEmpty(m.mpmesfeb) ? m.mpmesfeb : String.Empty); + // dic.Add("Marzo", !string.IsNullOrEmpty(m.mpmesmar) ? m.mpmesmar : String.Empty); + // dic.Add("Aprile", !string.IsNullOrEmpty(m.mpmesapr) ? m.mpmesapr : String.Empty); + // dic.Add("Maggio", !string.IsNullOrEmpty(m.mpmesmag) ? m.mpmesmag : String.Empty); + // dic.Add("Giugno", !string.IsNullOrEmpty(m.mpmesgiu) ? m.mpmesgiu : String.Empty); + + // dic.Add("Luglio", !string.IsNullOrEmpty(m.mpmeslug) ? m.mpmeslug : String.Empty); + // dic.Add("Agosto", !string.IsNullOrEmpty(m.mpmesago) ? m.mpmesago : String.Empty); + // dic.Add("Settembre", !string.IsNullOrEmpty(m.mpmesset) ? m.mpmesset : String.Empty); + // dic.Add("Ottobre", !string.IsNullOrEmpty(m.mpmesott) ? m.mpmesott : String.Empty); + // dic.Add("Novembre", !string.IsNullOrEmpty(m.mpmesnov) ? m.mpmesnov : String.Empty); + // dic.Add("Dicembre", !string.IsNullOrEmpty(m.mpmesdic) ? m.mpmesdic : String.Empty); + // #endregion + + // #region sicilia indirizzo + // sb.Append("SPETT.LE :"); + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // indStampa = sb.ToString(); + // #endregion + // break; + // case Clienti.Discovery: + // #region discovery + // indStampa = formattaIndirizzoStampaManutDiscovery(m); + + // dic.Add("Num. Impianto", !string.IsNullOrEmpty(m.imnumimp) ? m.imnumimp : String.Empty); + // dic.Add("Ubicazione", !string.IsNullOrEmpty(m.imubicaz) ? m.imubicaz : String.Empty); + // #endregion + // break; + // default: + // sb.Append("SPETT.LE :"); + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // indStampa = sb.ToString(); + // break; + //} + o.altri = dic; + o.indirizzo_stampa = indStampa; + sb.Clear(); + + string itemList = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // itemList = formattaItemManutenzioniMarrocco(m); + // #endregion + // break; + + // case Clienti.Gitoga: + // #region gitoga + // itemList = formattaItemManutenzioniMarrocco(m); + // #endregion + // break; + + // case Clienti.Lifta: + // #region lifta + // itemList = formattaItemManutenzioniMarrocco(m); + // #endregion + // break; + + // case Clienti.Sicilia: + // #region sicilia lista man + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imcodcap) ? " " + m.imcodcap.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imlocali) ? " " + m.imlocali.Trim() : string.Empty); + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("
"); + // sb.Append("Impianto : " + m.ctcodimp.Trim()); + // } + // itemList = sb.ToString(); + // #endregion + // break; + + // case Clienti.Tedesco: + // #region Tedesco lista man + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // //var sBuono = await getSerBuonoManutenzione(ten, co.prefisso_buoni_man); + // var a = getDescrImpTedesco(m.ctcodimp, tenant); + // string appo = a.Result; + // sb.Append("N.pratica : " + appo); + // sb.Append("
"); + // } + + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imcodcap) ? " " + m.imcodcap.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imlocali) ? " " + m.imlocali.Trim() : string.Empty); + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("
"); + // sb.Append("Impianto : " + m.ctcodimp.Trim()); + // } + // if (!string.IsNullOrEmpty(m.imubicaz)) + // { + // sb.Append("
"); + // sb.Append("Ubicazione : " + m.imubicaz.Trim()); + // } + // if (!string.IsNullOrEmpty(m.immatric)) + // { + // sb.Append("
"); + // sb.Append("Matricola : " + m.immatric.Trim()); + // } + + // itemList = sb.ToString(); + // #endregion + // break; + + // default: + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imcodcap) ? " " + m.imcodcap.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imlocali) ? " " + m.imlocali.Trim() : string.Empty); + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("
"); + // sb.Append("Impianto : " + m.ctcodimp.Trim()); + // } + // if (!string.IsNullOrEmpty(m.imubicaz)) + // { + // sb.Append("
"); + // sb.Append("Ubicazione : " + m.imubicaz.Trim()); + // } + // if (!string.IsNullOrEmpty(m.immatric)) + // { + // sb.Append("
"); + // sb.Append("Matricola : " + m.immatric.Trim()); + // } + + // itemList = sb.ToString(); + + // break; + //} + o.impianto_list = itemList; + sb.Clear(); + + string rif_impianto = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Discovery: + // #region dicovery + // rif_impianto = formattaRifImpDiscovery(m); + // #endregion + // break; + + // case Clienti.Gitoga: + // #region gitoga + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Lifta: + // #region lifta + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Sicilia: + // #region sicilia lista man + + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + + // sb.AppendLine("Impianto : " + m.ctcodimp.Trim()); + // } + // rif_impianto = sb.ToString(); + // #endregion + // break; + + // default: + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("N. Impianto : " + m.ctcodimp.Trim()); + // } + // rif_impianto = sb.ToString(); + // break; + //} + o.riferimento_impianto = rif_impianto; + sb.Clear(); + + o.imazirif = m.imazirif; + o.imzonman = m.imzonman; + o.imrefref = m.imrefref; + + return o; + } + private Manprog_out fillManprogOut2(Manprog m, string tenant) + { + Manprog_out o = new Manprog_out(); + o.ctcodint = m.ctcodint; + o.ctdatpro = m.ctdatpro; + o.ctdesint = m.ctdesint; + o.imindiri1 = m.imindiri1; + o.imindiri2 = m.imindiri2; + + o.imindiri3 = m.imindiri3; + o.imindiri4 = m.imindiri4; + o.imindiri5 = m.imindiri5; + o.imlocali = m.imlocali; + o.imcodcap = m.imcodcap; + + o.imcomune = m.imcomune; + o.improvin = m.improvin; + + o.improvin = m.improvin; + o.improvin = m.improvin; + o.improvin = m.improvin; + + o.immatric = m.immatric; + o.imnumimp = m.imnumimp; + o.imubicaz = m.imubicaz; + + o.tccodice = m.tccodice; + o.seriale_rapportino = m.seriale_rapportino; + o.ser_buono = m.ser_buono; + o.generato = m.generato; + + + //o.pimpianto = m.pimpianto; + //questo è il campo che l'app deve avere per accorgersi del cambiamento di stato + //quindi gli passo, se lo trovo vuoto, quello riletto dalla manutenzione + string impianto = string.Empty; + if (!string.IsNullOrEmpty(m.pimpianto)) + impianto = m.pimpianto; + else + impianto = m.ctcodimp; + o.pimpianto = impianto; + + //o.picodint = m.picodint; + string codice_intervento = string.Empty; + if (!string.IsNullOrEmpty(m.picodint)) + codice_intervento = m.picodint; + else + codice_intervento = m.ctcodint; + o.picodint = codice_intervento; + + //o.pidatman = m.pidatman; + DateTime? data_manutenzione = null; + if (m.pidatman != null) + data_manutenzione = m.pidatman; + else + data_manutenzione = m.ctdatpro; + o.pidatman = data_manutenzione; + + + o.err_title = m.err_title; + o.err_detail = m.err_detail; + o.err_status_code = m.err_status_code; + + o.telefono1 = m.telefono1; + o.telefono2 = m.telefono2; + o.cliente = m.cliente; + o.chiamata = m.chiamata; + o.spe_viaggio = m.spe_viaggio; + + //campi chiave + o.ctcodazi = tenant; + o.ctcodimp = m.ctcodimp; + o.ctdatpro = Convert.ToDateTime(m.ctdatpro); + o.ctcodint = m.ctcodint; + //FINE campi chiave + StringBuilder sb = new StringBuilder(); + Dictionary dic = new Dictionary(); + + + + //posizione 1-questa stampa è quella che va sotto il numero del buono e + //ha l'indirizzo dell'impianto che comincia con spettabile + string indStampa = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + // #endregion + // break; + + // case Clienti.Discovery: + // #region discovery + // indStampa = formattaIndirizzoStampaManutDiscovery(m); + // #endregion + // break; + + // case Clienti.Gitoga: + // #region gitoga + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + // #endregion + // break; + + // case Clienti.Lifta: + // #region lifta + // indStampa = formattaIndirizzoStampaManutMarrocco(m); + // #endregion + // break; + + // case Clienti.Sicilia: + // #region sicila dictionary + // dic.Add("Gennaio", !string.IsNullOrEmpty(m.mpmesgen) ? m.mpmesgen : String.Empty); + // dic.Add("Febbraio", !string.IsNullOrEmpty(m.mpmesfeb) ? m.mpmesfeb : String.Empty); + // dic.Add("Marzo", !string.IsNullOrEmpty(m.mpmesmar) ? m.mpmesmar : String.Empty); + // dic.Add("Aprile", !string.IsNullOrEmpty(m.mpmesapr) ? m.mpmesapr : String.Empty); + // dic.Add("Maggio", !string.IsNullOrEmpty(m.mpmesmag) ? m.mpmesmag : String.Empty); + // dic.Add("Giugno", !string.IsNullOrEmpty(m.mpmesgiu) ? m.mpmesgiu : String.Empty); + + // dic.Add("Luglio", !string.IsNullOrEmpty(m.mpmeslug) ? m.mpmeslug : String.Empty); + // dic.Add("Agosto", !string.IsNullOrEmpty(m.mpmesago) ? m.mpmesago : String.Empty); + // dic.Add("Settembre", !string.IsNullOrEmpty(m.mpmesset) ? m.mpmesset : String.Empty); + // dic.Add("Ottobre", !string.IsNullOrEmpty(m.mpmesott) ? m.mpmesott : String.Empty); + // dic.Add("Novembre", !string.IsNullOrEmpty(m.mpmesnov) ? m.mpmesnov : String.Empty); + // dic.Add("Dicembre", !string.IsNullOrEmpty(m.mpmesdic) ? m.mpmesdic : String.Empty); + // #endregion + + // #region sicilia indirizzo + // sb.Append("SPETT.LE :"); + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // indStampa = sb.ToString(); + // #endregion + // break; + + // default: + // sb.Append("SPETT.LE :"); + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // indStampa = sb.ToString(); + // break; + //} + o.indirizzo_stampa = indStampa; + o.altri = dic; + sb.Clear(); + + //posizione 2 + string itemList = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // itemList = formattaItemManutenzioniMarrocco(m); + // #endregion + // break; + + // case Clienti.Gitoga: + // #region gitoga + // itemList = formattaItemManutenzioniMarrocco(m); + + // #endregion + // break; + + // case Clienti.Lifta: + // #region lifta + // itemList = formattaItemManutenzioniMarrocco(m); + // #endregion + // break; + + // case Clienti.Sicilia: + // #region sicilia lista man + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imcodcap) ? "," + m.imcodcap.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imlocali) ? "," + m.imlocali.Trim() : string.Empty); + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("
"); + // sb.Append("Impianto : " + m.ctcodimp.Trim()); + // } + // itemList = sb.ToString(); + // #endregion + // break; + + // default: + // sb.Append(!string.IsNullOrEmpty(m.imindiri1) ? m.imindiri1.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri2) ? m.imindiri2.Trim() + " " : string.Empty); + // sb.Append(m.imindiri3 != null ? m.imindiri3.ToString() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri4) ? m.imindiri4.Trim() + " " : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imindiri5) ? m.imindiri5.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imcodcap) ? "," + m.imcodcap.Trim() : string.Empty); + // sb.Append(!string.IsNullOrEmpty(m.imlocali) ? "," + m.imlocali.Trim() : string.Empty); + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("
"); + // sb.Append("Impianto : " + m.ctcodimp.Trim()); + // } + // itemList = sb.ToString(); + // break; + //} + o.impianto_list = itemList; + sb.Clear(); + + //posizione 3-questa stampa è quella che va a destra della posizione 1 + //contiene i dati (matricola, ubicazione, num impianto) + string rif_impianto = string.Empty; + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Gitoga: + // #region gitoga + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Discovery: + // #region discovery + // rif_impianto = formattaRifImpDiscovery(m); + // #endregion + // break; + // case Clienti.Lifta: + // #region lifta + // rif_impianto = formattaRifImpMarrocco(m); + // #endregion + // break; + + // case Clienti.Sicilia: + // #region sicilia lista man + + + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + + // sb.AppendLine("Impianto : " + m.ctcodimp.Trim()); + // } + // rif_impianto = sb.ToString(); + // #endregion + // break; + + // default: + // if (!string.IsNullOrEmpty(m.ctcodimp)) + // { + // sb.Append("N. Impianto : " + m.ctcodimp.Trim()); + // } + // rif_impianto = sb.ToString(); + // break; + //} + o.riferimento_impianto = rif_impianto; + sb.Clear(); + + o.imazirif = m.imazirif; + o.imzonman = m.imzonman; + o.imrefref = m.imrefref; + + return o; + } + + private async Task getDescrImpTedesco(string codimp, string ten) + { + string descImp = string.Empty; + //_impianto = _Tedes_impianti.Impia; + var l = await _impianto.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten) && t.imcodimp != null && t.imcodimp.Equals(codimp)).ToListAsync(); + if (l != null && l.Count()>0 ) + { + foreach(Impianto i in l) + { + descImp = i.imdescri; + } + } + return descImp; + } + + /// Manutenzioni per tecnico e azienda (tenant). Intervallo: 1 mese prima e 1 mese dopo rispetto a GETDATE() con GENERATO diverso da S return:ActionResult + [HttpGet("manutenzioni")] + public async Task>> manutenzioni(string token) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + //_manutprog = getManutenzioniByTenant(ten); + + //var manut = await _manutprog.Where(t => t.tccodice == tecnico && t.ctcodazi == ten && t.ctdatpro >= da && t.ctdatpro <= a).OrderBy(t => t.ctcodint).ToListAsync(); + var manut = await _manutprog.Where(t => t.tccodice == tecnico && t.ctcodazi == ten).OrderBy(t => t.ctcodint).ToListAsync(); + + List ilist = new List(); + foreach (Manprog ch in manut) + { + Manprog_out o = new Manprog_out(); + o = fillManprogOut(ch, ten); + ilist.Add(o); + } + + + // cerco le manutenzioni che devo fare per sostituzioni SE abilitate + 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; + //string zona = string.Empty; + //zona = ss.tscodzon != null ? ss.tscodzon : "zonavuota"; + + //step 2 : trovo tutte le manutenzioni del tecnico che sto sostitutendo e le aggiungo alla mie + var manutSost = await _manutprog.Where(t => t.tccodice == tecnico_sostituito + && t.ctcodazi == ten + //&& t.imzonman == zona + ).OrderBy(t => t.ctcodint).ToListAsync(); + + foreach (Manprog ch in manutSost) + { + Manprog_out o = new Manprog_out(); + o = fillManprogOut(ch, ten); + ilist.Add(o); + } + } + } + + IEnumerable enumerable = ilist as IEnumerable; + //return enumerable; + return StatusCode(StatusCodes.Status200OK, enumerable); + } + catch (Exception ex) + { + return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + + /// prendi_in_carico: inserisce record su Prese con i dati dell'intervento return:ActionResult TEDES_MAGAZZINIDbContext + [HttpPost] + [Route("manutenzioni/prendi_in_carico")] + public async Task> prendiInCaricoMan([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + Manprog man=new Manprog(); + Manprog_out output = new Manprog_out(); + + try + { + if (await checkManutenzionePresaInCarico(ten, model.pimpianto, model.picodint, model.pidatman) == 0) + { + Prese r = fillPreseByInput(model, token); + + //man = await getManutenzioneByChiave(model, token); + man = await getManutenzioneByChiave2(r, token); + + //output = fillManprogOut(man, ten); + output = fillManprogOut2(man, ten); + output.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, output); + } + else + { + output.err_title = "Impossibile prendere in carico"; + output.err_detail = "Manutenzione precedentemente presa in carico"; + output.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + output.err_title = ex.Message; + output.err_detail = errmsg; + output.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + + //return output; + } + + /// chiudi: 1) crea un nuovo seriale per RAPP_NEW 2)inserisce record su RAPP_NEW con i dati dell'intervento return:ActionResult + [HttpPost] + [Route("manutenzioni/chiudi")] + public async Task> chiudiMan([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + + Manprog man = new Manprog(); + Manprog_out output = new Manprog_out(); + try + { + if (await checkManutenzioneChiusa(ten,TipoRapportino.ManutenzioneChiusa,model.pimpianto,model.pidatman,model.picodint)==0) + { + _confLette = await readConf(tenConf); + string newSerial = string.Empty; + newSerial = await getSeriale(token); + Rapp_New r = await fillRappNewChiudiManByInput(model, token, newSerial, _confLette); + + //switch (ten) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // await _Marro_rapp.Rapps.AddAsync(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + + + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // await _Ferra_rapp.Rapps.AddAsync(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // await _Sarom_rapp.Rapps.AddAsync(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // await _Sicilia_rapp.Rapps.AddAsync(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // int riga = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _Sicilia_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // riga = riga + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, riga, newSerial, tecnico); + + // await _Sicilia_mag.Mag.AddAsync(mn); + // await _Sicilia_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + + + // using (var transaction3 = _Sicilia_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // riga = riga + 1; + // mn = compo_ImpiaToMag_New(co, riga, newSerial, tecnico); + + // await _Sicilia_mag.Mag.AddAsync(mn); + // await _Sicilia_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + // break; + // case Clienti.Discovery: + // using (var transaction4 = _Disco_rapp.Database.BeginTransaction()) + // { + // await _Disco_rapp.Rapps.AddAsync(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction4.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // await _Gitoga_rapp.Rapps.AddAsync(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // await _Lifta_rapp.Rapps.AddAsync(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + // break; + //case Clienti.Siet: + // using (var transactionSiet = _Siet_rapp.Database.BeginTransaction()) + // { + // await _Siet_rapp.Rapps.AddAsync(r); + // await _Siet_rapp.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // int rigaSiet = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _Siet_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // rigaSiet = rigaSiet + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, rigaSiet, newSerial, tecnico); + + // await _Siet_mag.Mag.AddAsync(mn); + // await _Siet_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Siet_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // rigaSiet = rigaSiet + 1; + // mn = compo_ImpiaToMag_New(co, rigaSiet, newSerial, tecnico); + + // await _Siet_mag.Mag.AddAsync(mn); + // await _Siet_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + + // break; + //case Clienti.PMS: + // using (var transactionPms = _Pms_rapp.Database.BeginTransaction()) + // { + // await _Pms_rapp.Rapps.AddAsync(r); + // await _Pms_rapp.SaveChangesAsync(); + // transactionPms.Commit(); + // } + // int rigapms = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _PMS_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // rigapms = rigapms + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, rigapms, newSerial, tecnico); + + // await _PMS_mag.Mag.AddAsync(mn); + // await _PMS_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _PMS_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // rigapms = rigapms + 1; + // mn = compo_ImpiaToMag_New(co, rigapms, newSerial, tecnico); + + // await _PMS_mag.Mag.AddAsync(mn); + // await _PMS_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + + // break; + + //case Clienti.LW: + // using (var transactionLW = _LW_rapp.Database.BeginTransaction()) + // { + // await _LW_rapp.Rapps.AddAsync(r); + // await _LW_rapp.SaveChangesAsync(); + // transactionLW.Commit(); + // } + // int rigalw = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _LW_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // rigalw = rigalw + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, rigalw, newSerial, tecnico); + + // await _LW_mag.Mag.AddAsync(mn); + // await _LW_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _LW_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // rigalw = rigalw + 1; + // mn = compo_ImpiaToMag_New(co, rigalw, newSerial, tecnico); + + // await _LW_mag.Mag.AddAsync(mn); + // await _LW_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + + // break; + + //case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_rapp.Database.BeginTransaction()) + // { + // await _Tedes_rapp.Rapps.AddAsync(r); + // await _Tedes_rapp.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // int rigatedes = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _Tedes_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // rigatedes = rigatedes + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, rigatedes, newSerial, tecnico); + + // await _Tedes_mag.Mag.AddAsync(mn); + // await _Tedes_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Tedes_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // rigatedes = rigatedes + 1; + // mn = compo_ImpiaToMag_New(co, rigatedes, newSerial, tecnico); + + // await _Tedes_mag.Mag.AddAsync(mn); + // await _Tedes_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + + // break; + + //case Clienti.Syscom: + // using (var transactionSys = _Sys_rapp.Database.BeginTransaction()) + // { + // await _Sys_rapp.Rapps.AddAsync(r); + // await _Sys_rapp.SaveChangesAsync(); + // transactionSys.Commit(); + // } + // int rigasys = 0; + // if (model.compo_add != null && model.compo_add.Count() > 0) + // { + + // using (var transaction2 = _Sys_mag.Database.BeginTransaction()) + // { + + // foreach (Saldiart co in model.compo_add) + // { + // rigasys = rigasys + 1; + // Mag_New mn = new Mag_New(); + // mn = saldiartToMag_New(co, rigasys, newSerial, tecnico); + + // await _Sys_mag.Mag.AddAsync(mn); + // await _Sys_mag.SaveChangesAsync(); + + // } + // transaction2.Commit(); + // } + // } + // if (model.compo_del != null && model.compo_del.Count() > 0) + // { + // using (var transaction3 = _Sys_mag.Database.BeginTransaction()) + // { + // foreach (Compo_Impia co in model.compo_del) + // { + // Mag_New mn = new Mag_New(); + // rigasys = rigasys + 1; + // mn = compo_ImpiaToMag_New(co, rigasys, newSerial, tecnico); + + // await _Sys_mag.Mag.AddAsync(mn); + // await _Sys_mag.SaveChangesAsync(); + // } + // transaction3.Commit(); + // } + // } + + // break; + //default: + // break; + //} + man = await getManutenzioneByChiaveOut(model, token,r); + output = fillManprogOut(man, ten); + output.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, output); + } + else + { + output.err_title = "Impossibile chiudere la manutenzione"; + output.err_detail = "Manutenzione precedentemente chiusa"; + output.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + output.err_title = ex.Message; + output.err_detail = errmsg; + output.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + + //return output; + } + + /// rilascia: elimina record su Prese con i dati dell'intervento return:ActionResult + [HttpPost] + [Route("manutenzioni/rilascia")] + public async Task> rilasciaMan([FromBody] Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + Manprog man = new Manprog(); + Manprog_out output = new Manprog_out(); + Prese pre = null; + try + { + if ((pre=await checkManutenzioneDaRilasciare(ten, model.pimpianto, model.picodint, model.pidatman)) !=null) + { + //_prese = getPreseByTenant(ten); + //var pre = _prese.SingleOrDefault(t => t.picodazi.Equals(ten) && t.pimpianto.Equals(model.pimpianto) && t.picodint.Equals(model.picodint) && t.pidatman == model.pidatman); + //switch (ten) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_prese.Database.BeginTransaction()) + // { + // _Marro_prese.Prese.Remove(pre); + // await _Marro_prese.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Ferrari: + // using (var transaction2 = _Ferra_prese.Database.BeginTransaction()) + // { + // _Ferra_prese.Prese.Remove(pre); + // await _Ferra_prese.SaveChangesAsync(); + // transaction2.Commit(); + // } + // break; + // case Clienti.Sarom: + // using (var transaction5 = _Sarom_prese.Database.BeginTransaction()) + // { + // _Sarom_prese.Prese.Remove(pre); + // await _Sarom_prese.SaveChangesAsync(); + // transaction5.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transaction3 = _Sicilia_prese.Database.BeginTransaction()) + // { + // _Sicilia_prese.Prese.Remove(pre); + // await _Sicilia_prese.SaveChangesAsync(); + // transaction3.Commit(); + // } + // break; + // case Clienti.Discovery: + // using (var transaction4 = _Disco_prese.Database.BeginTransaction()) + // { + // _Disco_prese.Prese.Remove(pre); + // await _Disco_prese.SaveChangesAsync(); + // transaction4.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_prese.Database.BeginTransaction()) + // { + // _Gitoga_prese.Prese.Remove(pre); + // await _Gitoga_prese.SaveChangesAsync(); + // transactionGit.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_prese.Database.BeginTransaction()) + // { + // _Lifta_prese.Prese.Remove(pre); + // await _Lifta_prese.SaveChangesAsync(); + // transactionLif.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_prese.Database.BeginTransaction()) + // { + // _Siet_prese.Prese.Remove(pre); + // await _Siet_prese.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPms = _PMS_prese.Database.BeginTransaction()) + // { + // _PMS_prese.Prese.Remove(pre); + // await _PMS_prese.SaveChangesAsync(); + // transactionPms.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionLW = _LW_prese.Database.BeginTransaction()) + // { + // _LW_prese.Prese.Remove(pre); + // await _LW_prese.SaveChangesAsync(); + // transactionLW.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_prese.Database.BeginTransaction()) + // { + // _Tedes_prese.Prese.Remove(pre); + // await _Tedes_prese.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom : + // using (var transactionSys = _Sys_prese.Database.BeginTransaction()) + // { + // _Sys_prese.Prese.Remove(pre); + // await _Sys_prese.SaveChangesAsync(); + // transactionSys.Commit(); + // } + // break; + // default: + // break; + //} + + //man = await getManutenzioneByChiave(model, token); + man = await getManutenzioneByChiave2(pre, token); + + output = fillManprogOut(man, ten); + //output = fillManprogOut2(man, ten); + + output.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, output); + } + else + { + output.err_title = "Impossibile rilasciare la manutenzione. Manutenzione non trovata"; + + StringBuilder sb = new StringBuilder(); + sb.AppendLine("pimpianto: "+model.pimpianto); + sb.AppendLine("picodint: " + model.picodint); + sb.AppendLine("pidatman: " + model.pidatman); + sb.AppendLine("tenant: " + ten); + output.err_detail = sb.ToString(); + sb.Clear(); + output.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + output.err_title = ex.Message; + output.err_detail = errmsg; + output.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, output); + } + + //return output; + } + #endregion + + #region UPLOAD FILE + private static void FtpSend(string url, string ftp_usr, string ftp_pwd, IFormFile files) + { + //string url = "ftp://10.0.0.10/LABSE/" + fileName; + //url = "ftp://poloinformatico41.clienti.init-s.it:6363/test.bmp"; + + //esempio Discovery + //url = "ftp://discoverylift.dyndns.org:21/test.jpg"; + + + //esempio SICILIA PROD + //url = "ftp://studioliuzzo.selfip.net:21/adhoc/bmp_24.bmp"; + + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url); + request.Credentials = new NetworkCredential(ftp_usr, ftp_pwd); + //request.Credentials = new NetworkCredential("anonymous", "janeDoe@contoso.com"); + request.Method = WebRequestMethods.Ftp.UploadFile; + using (Stream ftpStream = request.GetRequestStream()) + { + files.CopyTo(ftpStream); + } + } + private static string CheckFtp(string url, string ftp_usr, string ftp_pwd) + { + string _esito = "OK"; + //url = "ftp://10.0.0.10/PMS/cccetcwqsss.jpg"; + + var request = (FtpWebRequest)WebRequest.Create(url); + request.Credentials = new NetworkCredential(ftp_usr, ftp_pwd); + request.Method = WebRequestMethods.Ftp.GetFileSize; + + try + { + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + } + catch (WebException ex) + { + FtpWebResponse response = (FtpWebResponse)ex.Response; + if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable) + { + _esito = "KO"; + } + } + return _esito; + } + private static void SFtpSend(string url, string ftp_usr, string ftp_pwd, IFormFile files) + { + var connectionInfo = new Renci.SshNet.ConnectionInfo(url, "sftp", new PasswordAuthenticationMethod(ftp_usr, ftp_pwd)); + + // Upload File + using (var sftp = new SftpClient(connectionInfo)) + { + sftp.Connect(); + //sftp.ChangeDirectory("/MyFolder"); + using (var uplfileStream = System.IO.File.OpenRead(files.FileName)) + { + sftp.UploadFile(uplfileStream, files.FileName, true); + } + sftp.Disconnect(); + } + } + + /// + public static void FileUploadSFTP(IFormFile files,string ip,string usr,string pwd, int? sftp_port, string filename) + { + //var host = "37.159.179.14"; + //var port = 27000; + //var username = "apppolo"; + //var password = "utx3BizRykw1hdY"; + + var host = ip; + var port = sftp_port.Value; + var username = usr; + var password = pwd; + + // path for file you want to upload + //var uploadFile = @"C:\Zucchetti\b.bmp"; + var uploadFile = files.OpenReadStream(); + + using (var client = new SftpClient(host, port, username, password)) + { + client.Connect(); + using (var uplfileStream = files.OpenReadStream()) + { + client.UploadFile(uplfileStream, filename); + } + } + } + + /// Upload return:ActionResult + [HttpPost] + [Route("file/upload")] + public async Task OnPostUpload2Async(IFormFile files, string token, string nomefile) + { + + + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + string fileName = string.Empty; + + //Console.WriteLine(string.Format("*********** {2} metodo chiudi: tenant:{0} tenant2: {1} tenantConf: {5} buono: {3} tecnico:{4} ", ten, ten2, DateTime.Now.ToString(), r.ser_buono, r.codice_tecnico,tenConf)); + Console.WriteLine(string.Format("*********** {2} INIZIO Chiamata al metodo upload: tenant:{0} tenant2: {3} tenantConf: {4} file: {1} tecnico:{5}", ten, nomefile, DateTime.Now.ToString(),ten2,tenConf, tecnico)); + + if (ten.Equals(Clienti.VT)) + { + //ten2= getClaimValueByToken(token, "tenant2"); + _confLette = await readConf(ten2); + } + else + { + _confLette = await readConf(tenConf); + } + + try + { + long size = files.Length; + if(string.IsNullOrEmpty(nomefile)) + { + fileName = Path.GetFileName(files.FileName); + } + else + { + fileName = nomefile; + } + + string url = string.Empty; + string usr = string.Empty; + string pwd = string.Empty; + string ip = string.Empty; + int? port = 0; + + // per VT faccio solo il salvataggio in tabella + //2024-04-08: CONTRORDINE: devo salvare il file perchè il file deve essere depositato nella directory + //dove risiedono le API per poter essere esposto con un url pubblico in modo da poter essere utilizzato dall'app + //(questo per le Immagini azienda che vanno nel logo del buono) + + #region inserimento tabella + Buoni model = new Buoni(); + model.azienda = ten2; + if (nomefile.Length > 8) + nomefile = nomefile.Substring(0, 8); + model.ser_buono = nomefile; + model.dt_ins = DateTime.Now; + using (MemoryStream ms = new MemoryStream()) + { + files.CopyTo(ms); + byte[] array = ms.GetBuffer(); + model.immagine = array; + } + using (var transaction = _VT_Buoni.Database.BeginTransaction()) + { + await _VT_Buoni.buoni.AddAsync(model); + await _VT_Buoni.SaveChangesAsync(); + transaction.Commit(); + } + + #endregion + + //switch (ten) + //{ + // case Clienti.Marrocco: + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + + // break; + // case Clienti.Gitoga: + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + + // break; + // case Clienti.Lifta: + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + + // break; + + // case Clienti.Ferrari: + // ip = _confLette.ftp_url!=null ? _confLette.ftp_url : string.Empty; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // port = _confLette.ftp_port != null ? _confLette.ftp_port : 0; + + // FileUploadSFTP(files,ip,usr,pwd, port,fileName); + + // break; + // case Clienti.Sarom: + // ip = _confLette.ftp_url != null ? _confLette.ftp_url : string.Empty; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // port = _confLette.ftp_port != null ? _confLette.ftp_port : 0; + + // FileUploadSFTP(files, ip, usr, pwd, port, fileName); + + // break; + // case Clienti.Sicilia: + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + + // break; + // case Clienti.Discovery: + + // //ip = _confLette.ftp_url != null ? _confLette.ftp_url : string.Empty; + // //usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // //pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // //port = _confLette.ftp_port != null ? _confLette.ftp_port : 0; + // //FileUploadSFTP(files, ip, usr, pwd, port, fileName); + + + // //url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // port = _confLette.ftp_port != null ? _confLette.ftp_port : 0; + + // //ftp://discoverylift.dyndns.org:21/test.jpg; + // url = string.Format("{0}:{1}/{2}", _confLette.ftp_url, port, fileName); + // FtpSend(url, usr, pwd, files); + // break; + // case Clienti.Siet: + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + // break; + // case Clienti.PMS: + // //url = _confLette.ftp_url + fileName; + // //usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // //pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // //port = _confLette.ftp_port != null ? _confLette.ftp_port : 0; + // //ip = _confLette.ftp_url != null ? _confLette.ftp_url : string.Empty; + // //FileUploadSFTP(files, ip, usr, pwd, port, fileName); + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + + // FtpSend(url, usr, pwd, files); + // string _esito = CheckFtp(url, usr, pwd); + // if(_esito.Equals("KO")) + // { + // throw new Exception("Buono non depositato !!"+url); + // } + + // break; + // case Clienti.VT: + + // // per VT faccio solo il salvataggio in tabella + // //2024-04-08: CONTRORDINE: devo salvare il file perchè il file deve essere depositato nella directory + // //dove risiedono le API per poter essere esposto con un url pubblico in modo da poter essere utilizzato dall'app + // //(questo per le Immagini azienda che vanno nel logo del buono) + + + // #region inserimento tabella + // Buoni model = new Buoni(); + // model.azienda = ten2; + // if (nomefile.Length > 8) + // nomefile = nomefile.Substring(0, 8); + // model.ser_buono = nomefile; + // model.dt_ins = DateTime.Now; + // using (MemoryStream ms = new MemoryStream()) + // { + // files.CopyTo(ms); + // byte[] array = ms.GetBuffer(); + // model.immagine = array; + // } + // using (var transaction = _VT_Buoni.Database.BeginTransaction()) + // { + // await _VT_Buoni.buoni.AddAsync(model); + // await _VT_Buoni.SaveChangesAsync(); + // transaction.Commit(); + // } + // #endregion + + + + // break; + // case Clienti.LW: + + // #region inserimento tabella + // BuoniLW model2 = new BuoniLW(); + // model2.azienda = ten; + // if (nomefile.Length > 8) + // nomefile = nomefile.Substring(0, 8); + // model2.ser_buono = nomefile; + // model2.dt_ins = DateTime.Now; + // using (MemoryStream ms = new MemoryStream()) + // { + // files.CopyTo(ms); + // byte[] byteArray = ms.GetBuffer(); + // string base64String = Convert.ToBase64String(byteArray); + // model2.immagine = base64String; + // } + // //var result = new StringBuilder(); + // //using (var reader = new StreamReader(files.OpenReadStream())) + // //{ + // // while (reader.Peek() >= 0) + // // { + // // result.AppendLine(reader.ReadLine()); + // // } + // //} + // //model2.immagine = result.ToString(); + // using (var transaction = _LW_Buoni.Database.BeginTransaction()) + // { + // await _LW_Buoni.buoni.AddAsync(model2); + // await _LW_Buoni.SaveChangesAsync(); + // transaction.Commit(); + // } + // #endregion + // break; + // case Clienti.Tedesco: + + // url = _confLette.ftp_url + fileName; + // usr = _confLette.ftp_usr != null ? _confLette.ftp_usr : string.Empty; + // pwd = _confLette.ftp_pwd != null ? _confLette.ftp_pwd : string.Empty; + // FtpSend(url, usr, pwd, files); + // break; + // case Clienti.Syscom: + + // #region inserimento tabella + // BuoniLW modelsys = new BuoniLW(); + // modelsys.azienda = ten; + // if (nomefile.Length > 8) + // nomefile = nomefile.Substring(0, 8); + // modelsys.ser_buono = nomefile; + // modelsys.dt_ins = DateTime.Now; + // using (MemoryStream ms = new MemoryStream()) + // { + // files.CopyTo(ms); + // byte[] byteArray = ms.GetBuffer(); + // string base64String = Convert.ToBase64String(byteArray); + // modelsys.immagine = base64String; + // } + + // using (var transaction = _Sys_Buoni.Database.BeginTransaction()) + // { + // await _Sys_Buoni.buoni.AddAsync(modelsys); + // await _Sys_Buoni.SaveChangesAsync(); + // transaction.Commit(); + // } + // #endregion + // break; + // default: + // break; + //} + + Console.WriteLine(string.Format("*********** {2} FINE Chiamata al metodo upload: tenant:{0} tenant2: {3} tenantConf: {4} file: {1} tecnico:{5}", ten, nomefile, DateTime.Now.ToString(), ten2, tenConf, tecnico)); + return Ok(new { count = 1, size }); + } + catch (Exception ex) + { + StringBuilder sb = new StringBuilder(); + string errMsg = string.Empty; + if(ex.Message!=null) + { + sb.AppendLine(ex.Message); + } + if(ex.InnerException!=null) + { + sb.AppendLine(ex.InnerException.Message); + } + errMsg = sb.ToString(); + //Console.WriteLine(string.Format("*********** {2} ERRORE metodo upload: tenant:{0} file: {1} ==> {3}", ten, nomefile, DateTime.Now.ToString(),errMsg)); + Console.WriteLine(string.Format("*********** {2} ERRORE metodo upload: tenant:{0} tenant2: {3} tenantConf: {4} file: {1} tecnico:{5} ==> {6}", ten, nomefile, DateTime.Now.ToString(), ten2, tenConf, tecnico, errMsg)); + return StatusCode(StatusCodes.Status500InternalServerError, "Error: "+errMsg); + } + } + + #endregion + + #region IMPIANTI COMPONENTI + private async Task fillCompoImpiaByInput(Compo_Impia i, string token) + { + Compo_Impia_Table r = new Compo_Impia_Table(); + + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + //i = fakeInput(i, ten); + //_compoTable = getComponentiTableByTenant(ten); + var co = await _compoTable.Where(t => t.cocodimp == i.cocodimp).OrderByDescending(t => t.cprownum).ToListAsync(); + + int? row = 0; + if(co!=null && co.Count()>0) + { + row = co.First().cprownum; + } + row++; + + r.cocodimp = co.First().cocodimp; + r.cprownum = row; + r.cocodart = i.cocodart; + r.coqtaart = i.coqtaart; + r.co__note = i.co__note; + r.pilotto = i.lotto; + r.pimatric = i.matricola; + r.cocodazi = ten; + + return r; + } + private Compo_Impia_out fillCompoImpiaOUTByInput(Compo_Impia_Table i) + { + Compo_Impia_out r = new Compo_Impia_out(); + + r.cocodimp = i.cocodimp; + r.cprownum = i.cprownum; + r.cocodart = i.cocodart; + r.coqtaart = i.coqtaart; + r.co__note = i.co__note; + r.lotto = i.pilotto; + r.matricola = i.pimatric; + r.cocodazi = i.cocodazi; + + return r; + } + + /// Componenti impianto return:ActionResult + [HttpGet("componenti_impianto")] + public async Task>> componenti_impianto(string token, string codimp) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + List lst = new List(); + + if(!ten.Equals(Clienti.VT)) + { + //_compo = getComponentiByTenant(ten); + + var co = await _compo.Where( + t => t.cocodimp == codimp + ).ToListAsync(); + lst = co; + } + else + { + Compo_Impia ci = new Compo_Impia(); + ci.cocodimp = codimp; + ci.cprownum = 1; + ci.cocodart = "00001"; + ci.cocodazi = "AZI02"; + ci.ardesart = "Tubo in metallo"; + + + lst.Add(ci); + + } + return StatusCode(StatusCodes.Status200OK, lst); + } + catch (Exception ex) + { + return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + + /// aggiunge un componente all'impianto. Inserisce in LABSEMICOMIMP return:ActionResult + [HttpPost] + [Route("componenti_impianto/add")] + public async Task> addcomponente([FromBody] Compo_Impia model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + Compo_Impia_Table co = new Compo_Impia_Table(); + Compo_Impia_out co_out = new Compo_Impia_out(); + co = await fillCompoImpiaByInput(model, token); + co_out = fillCompoImpiaOUTByInput(co); + + try + { + //switch (ten) + //{ + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_compTable.Database.BeginTransaction()) + // { + // await _Sicilia_compTable.Componen.AddAsync(co); + // await _Sicilia_compTable.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_compTable.Database.BeginTransaction()) + // { + // await _Siet_compTable.Componen.AddAsync(co); + // await _Siet_compTable.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPms = _PMS_compTable.Database.BeginTransaction()) + // { + // await _PMS_compTable.Componen.AddAsync(co); + // await _PMS_compTable.SaveChangesAsync(); + // transactionPms.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionlw = _LW_compTable.Database.BeginTransaction()) + // { + // await _LW_compTable.Componen.AddAsync(co); + // await _LW_compTable.SaveChangesAsync(); + // transactionlw.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_compTable.Database.BeginTransaction()) + // { + // await _Tedes_compTable.Componen.AddAsync(co); + // await _Tedes_compTable.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionsys = _Sys_compTable.Database.BeginTransaction()) + // { + // await _Sys_compTable.Componen.AddAsync(co); + // await _Sys_compTable.SaveChangesAsync(); + // transactionsys.Commit(); + // } + // break; + // default: + // break; + //} + + co_out.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, co_out); + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + co_out.err_title = ex.Message; + co_out.err_detail = errmsg; + co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, co_out); + } + //return co_out; + } + + /// toglie un componente all'impianto. Cancella in LABSEMICOMIMP return:ActionResult + [HttpPost] + [Route("componenti_impianto/del")] + public async Task> delcomponente([FromBody] Compo_Impia model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + //_compoTable = getComponentiTableByTenant(ten); + var comp = await _compoTable.Where(t => t.cocodimp == model.cocodimp && t.cprownum == model.cprownum && t.cocodazi == ten).ToListAsync(); + Compo_Impia_out co_out = new Compo_Impia_out(); + + if (comp != null) + { + Compo_Impia_Table t = new Compo_Impia_Table(); + t = (Compo_Impia_Table)comp.First(); + co_out = fillCompoImpiaOUTByInput(t); + try + { + //switch (ten) + //{ + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_compTable.Database.BeginTransaction()) + // { + // _Sicilia_compTable.Entry(t).State = EntityState.Deleted; + // await _Sicilia_compTable.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_compTable.Database.BeginTransaction()) + // { + // _Siet_compTable.Entry(t).State = EntityState.Deleted; + // await _Siet_compTable.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _PMS_compTable.Database.BeginTransaction()) + // { + // _PMS_compTable.Entry(t).State = EntityState.Deleted; + // await _PMS_compTable.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionlw = _LW_compTable.Database.BeginTransaction()) + // { + // _LW_compTable.Entry(t).State = EntityState.Deleted; + // await _LW_compTable.SaveChangesAsync(); + // transactionlw.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_compTable.Database.BeginTransaction()) + // { + // _Tedes_compTable.Entry(t).State = EntityState.Deleted; + // await _Tedes_compTable.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionsys = _Sys_compTable.Database.BeginTransaction()) + // { + // _Sys_compTable.Entry(t).State = EntityState.Deleted; + // await _Sys_compTable.SaveChangesAsync(); + // transactionsys.Commit(); + // } + // break; + // default: + // break; + //} + + co_out.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, co_out); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + co_out.err_title = ex.Message; + co_out.err_detail = errmsg; + co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, co_out); + } + } + else + { + co_out.err_title = "Cancellazione fallita"; + co_out.err_detail = "record non trovato"; + co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, co_out); + } + //return co_out; + } + #endregion + + #region Saldi articoli + /// Ricerca articoli per impianto return:ActionResult + [HttpGet("saldi_articolo")] + public async Task>> saldi_articolo(string token, string? art, string? desart, string? matric, string? maga,string? codcli, string? codimp ) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + + //27/02/2025 aggiunta gestione Articoli + if (tenConf.Equals(Clienti.VT)) + { + _articoliTable = _VT_articoliTable.Articoli; + + var listaFiltro = new List(); + + listaFiltro = await _articoliTable.Where(x => x.Azienda.Equals(ten2)).ToListAsync(); + + if (!string.IsNullOrEmpty(art)) + { + listaFiltro = await _articoliTable.Where(x => x.SlCodice.Contains(art)).ToListAsync(); + } + + if (!string.IsNullOrEmpty(desart)) + { + listaFiltro = await _articoliTable.Where(x => x.ArDesArt.Contains(desart)).ToListAsync(); + } + + if (!string.IsNullOrEmpty(maga)) + { + listaFiltro = await _articoliTable.Where(x => x.SlCodMag.Contains(maga)).ToListAsync(); + } + + List listaSaldiArt = new List(); + + foreach (Articoli a in listaFiltro) + { + Saldiart saldo = new Saldiart(); + + saldo.slcodice = a.SlCodice.TrimEnd(); + saldo.ardesart = a.ArDesArt.TrimEnd(); + saldo.slcodmag = a.SlCodMag.TrimEnd(); + saldo.slqtaper = a.SlQtAper; + saldo.amcodice = !string.IsNullOrEmpty(a.AmCodice) ? a.AmCodice.TrimEnd():string.Empty; + saldo.locodice = !string.IsNullOrEmpty(a.LoCodice) ? a.LoCodice.TrimEnd() : string.Empty; + saldo.licodlis = !string.IsNullOrEmpty(a.LiCodLis) ? a.LiCodLis.TrimEnd() : string.Empty; + saldo.licodart = !string.IsNullOrEmpty(a.LiCodArt) ? a.LiCodArt.TrimEnd() : string.Empty; + saldo.lidatatt = a.LiDatAtt; + saldo.liquanti = a.LiQuanti; + saldo.liprezzo = a.LiPrezzo; + saldo.liscont1 = a.LiScont1; + saldo.liscont2 = a.LiScont2; + saldo.liscont3 = a.LiScont3; + saldo.liscont4 = a.LiScont4; + saldo.gest_matr = a.Gest_Matr.TrimEnd(); + saldo.gest_lotti = a.Gest_Lotti.TrimEnd(); + saldo.desc_sup = a.Desc_sup.TrimEnd(); + + listaSaldiArt.Add(saldo); + } + + return StatusCode(StatusCodes.Status200OK, listaSaldiArt); + } + else + { + //_saldi = getSaldiartByTenant(ten); + Configurazioni conf = await readConf(tenConf); + int max_record = 0; + max_record = conf.max_record != null ? conf.max_record.Value : 0; + string codlis = string.Empty; + //_clienti = getClientiByTenant(ten); + var a = await _clienti.Where(t => t.ancodice == codcli).ToListAsync(); + if (a != null && a.Count() == 0) + { + codlis = conf.listino; + } + else + { + codlis = string.IsNullOrEmpty(a.First().annumlis) ? conf.listino : a.First().annumlis; + } + var co = await _saldi.Where(t => t.slcodmag != null && t.slcodmag.Equals(maga) && t.licodlis != null && t.licodlis.Equals(codlis)).ToListAsync(); + + if (!string.IsNullOrEmpty(art)) + { + co = co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(art.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(desart)) + { + co = co.Where(t => t.ardesart != null && t.ardesart.ToUpper().Contains(desart.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(matric)) + { + //List lista = new List(); + //var codart = co.Where(m => m.amcodice != null && m.amcodice.ToUpper().Contains(matric.ToUpper())).ToList(); + //var query = co.Where(p => codart.Any(kw => p..StartsWith(kw))); + //if (codart != null && codart.Count() > 0) + //{ + // foreach(Saldiart sa in codart) + // { + // string artTrovato = sa.slcodice; + // co= co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(artTrovato.ToUpper()) + // && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList(); + // } + //} + //else + //{ + // // devo svuotare l'elenco articoli + // co = co.Take(0).ToList(); + //} + co = co.Where(t => t.amcodice != null && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList(); + + } + //2024-02-19: se l'articolo è gestito a matricole, la query restituisce tutte le righe splittate, + //in questo caso forzo la quantità a 1 + if (co != null && co.Count() > 0) + { + foreach (Saldiart s in co) + { + if (s.gest_matr != null && s.gest_matr.Equals("S")) + { + s.slqtaper = 1; + } + + } + } + co = co.Take(max_record).ToList(); + return StatusCode(StatusCodes.Status200OK, co); + } + + } + catch (Exception ex) + { + return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + #endregion + + #region Magazzino + private async Task fillMag_NewByInput(Mag_New i, string token) + { + Mag_New r = new Mag_New(); + + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + //i = fakeInput(i, ten); + //_mag = getMag_NewByTenant(ten); + var co = await _mag.Where(t => t.seriale_rapportino == i.seriale_rapportino).OrderByDescending(t => t.riga).ToListAsync(); + + int? row = 0; + if (co != null && co.Count() > 0) + { + row = co.First().riga; + row++; + } + else + { + row++; + } + + + r.seriale_rapportino = i.seriale_rapportino; + r.riga = row; + r.magazzino = i.magazzino; + r.articolo = i.articolo; + r.tipo_movimento = i.tipo_movimento; + r.quantita = i.quantita; + r.prezzo = i.prezzo; + r.codice_tecnico = i.codice_tecnico; + r.generato = i.generato; + r.codlotto = i.codlotto; + r.matricola = i.matricola; + r.cprownum = row; + + return r; + } + private Mag_New_out fillMag_NewOUTByInput(Mag_New i) + { + Mag_New_out r = new Mag_New_out(); + + r.seriale_rapportino = i.seriale_rapportino; + r.riga = i.riga; + r.magazzino = i.magazzino; + r.articolo = i.articolo; + r.tipo_movimento = i.tipo_movimento; + r.quantita = i.quantita; + r.prezzo = i.prezzo; + r.codice_tecnico = i.codice_tecnico; + r.generato = i.generato; + r.codlotto = i.codlotto; + r.matricola = i.matricola; + return r; + } + + /// rapportino per pezzi magazzino. Inserisce in LABSEMAG_NEW return:ActionResult + [HttpPost] + [Route("rapportini/add")] + public async Task> addrapportino([FromBody] Mag_New model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + Mag_New co = new Mag_New(); + Mag_New_out co_out = new Mag_New_out(); + co = await fillMag_NewByInput(model, token); + co_out = fillMag_NewOUTByInput(co); + + try + { + //switch (ten) + //{ + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_mag.Database.BeginTransaction()) + // { + // await _Sicilia_mag.Mag.AddAsync(co); + // await _Sicilia_mag.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_mag.Database.BeginTransaction()) + // { + // await _Siet_mag.Mag.AddAsync(co); + // await _Siet_mag.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _PMS_mag.Database.BeginTransaction()) + // { + // await _PMS_mag.Mag.AddAsync(co); + // await _PMS_mag.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionlw = _LW_mag.Database.BeginTransaction()) + // { + // await _LW_mag.Mag.AddAsync(co); + // await _LW_mag.SaveChangesAsync(); + // transactionlw.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_mag.Database.BeginTransaction()) + // { + // await _Tedes_mag.Mag.AddAsync(co); + // await _Tedes_mag.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionsys = _Sys_mag.Database.BeginTransaction()) + // { + // await _Sys_mag.Mag.AddAsync(co); + // await _Sys_mag.SaveChangesAsync(); + // transactionsys.Commit(); + // } + // break; + // default: + // break; + //} + + co_out.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, co_out); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + co_out.err_title = ex.Message; + co_out.err_detail = errmsg; + co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, co_out); + } + //return co_out; + } + + #endregion + + #region Storico rapportini + + private Sto_Rapp_out fillSto_Rapp_Out(Sto_Rapp i, string tenant) + { + Sto_Rapp_out o = new Sto_Rapp_out(); + + o.tccodice = !string.IsNullOrEmpty(i.tccodice) ? i.tccodice.Trim() : string.Empty; ; + o.tcdescri = !string.IsNullOrEmpty(i.tcdescri) ? i.tcdescri.Trim() : string.Empty; ; + o.note_esito = !string.IsNullOrEmpty(i.note_esito) ? i.note_esito.Trim():string.Empty ; + o.data_rapportino = i.data_rapportino; + + Dictionary dic = new Dictionary(); + string appo = string.Empty; + if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc1) ? " - " + i.cc1 : string.Empty; + dic.Add("Cod. Chiusura 1", i.codice_chiusura_1.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc2) ? " - " + i.cc2 : string.Empty; + dic.Add("Cod. Chiusura 2", i.codice_chiusura_2.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc3) ? " - " + i.cc3 : string.Empty; + dic.Add("Cod. Chiusura 3", i.codice_chiusura_3.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc4) ? " - " + i.cc4 : string.Empty; + dic.Add("Cod. Chiusura 4", i.codice_chiusura_4.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc5) ? " - " + i.cc5 : string.Empty; + dic.Add("Cod. Chiusura 5", i.codice_chiusura_5.Trim() + appo); + } + + + if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc6) ? " - " + i.cc6 : string.Empty; + dic.Add("Cod. Chiusura 6", i.codice_chiusura_6.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc7) ? " - " + i.cc7 : string.Empty; + dic.Add("Cod. Chiusura 7", i.codice_chiusura_7.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc8) ? " - " + i.cc8 : string.Empty; + dic.Add("Cod. Chiusura 8", i.codice_chiusura_8.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc9) ? " - " + i.cc9 : string.Empty; + dic.Add("Cod. Chiusura 9", i.codice_chiusura_9.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + { + appo = string.Empty; + appo = !string.IsNullOrEmpty(i.cc10) ? " - " + i.cc10 : string.Empty; + dic.Add("Cod. Chiusura 10", i.codice_chiusura_10.Trim() + appo); + } + if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + { + dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + } + if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + { + dic.Add("Note intervento", i.note_intervento.Trim()); + } + if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + { + dic.Add("Esito intervento", i.esito_intervento.Trim()); + } + //switch (tenant) + //{ + // case Clienti.Marrocco: + // #region marrocco + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // case Clienti.Gitoga: + // #region gitoga + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // case Clienti.Lifta: + // #region lifta + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // case Clienti.Ferrari: + // #region ferrari + + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if(!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - "+i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if(i.data_manutenzione!=null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if(!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - "+i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if(i.indirizzo_num!=null && i.indirizzo_num.Value>0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" "+indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ,"+num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio!=null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value>0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // case Clienti.Sicilia: + // #region sicilia + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + + // break; + // case Clienti.Discovery: + // #region discovery + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // case Clienti.Sarom: + // #region sarom + // //chiamata + // if (!string.IsNullOrEmpty(i.codice_segnalazione) && !i.codice_segnalazione.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice segnalazione", i.codice_segnalazione.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_chiamata) && !i.seriale_chiamata.Trim().Equals(string.Empty)) + // { + // dic.Add("N° Chiamata", i.seriale_chiamata.Trim()); + // } + // //manutenzione + // if (!string.IsNullOrEmpty(i.codice_intervento) && !i.codice_intervento.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_intervento.Trim()); + // if (!string.IsNullOrEmpty(i.cidescri) && !i.cidescri.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidescri.Trim()); + // } + // if (!string.IsNullOrEmpty(i.cidessup) && !i.cidessup.Trim().Equals(string.Empty)) + // { + // sb.Append(" - " + i.cidessup.Trim()); + // } + // dic.Add("Manutenzione", sb.ToString()); + // } + // if (i.data_manutenzione != null) + // { + // dic.Add("Data manutenzione", i.data_manutenzione.Value.ToString()); + // } + + // //dati intervento + // if (!string.IsNullOrEmpty(i.stato_finale) && !i.stato_finale.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.stato_finale) + // { + // case "1": + // st = "In Funzione"; + // dic.Add("Stato finale", st); + // break; + // case "0": + // st = "Fermo"; + // dic.Add("Stato finale", st); + // break; + // } + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.esito_intervento) + // { + // case "1": + // st = "Positivo"; + // break; + // case "P": + // st = "Positivo"; + // break; + // default: + // st = "Negativo"; + // break; + // } + // dic.Add("Esito intervento", st); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.difetti_riscontrati) && !i.difetti_riscontrati.Trim().Equals(string.Empty)) + // { + // dic.Add("Difetti riscontrati", i.difetti_riscontrati.Trim()); + // } + // if (!string.IsNullOrEmpty(i.lavoro_eseguito) && !i.lavoro_eseguito.Trim().Equals(string.Empty)) + // { + // dic.Add("Lavoro eseguito", i.lavoro_eseguito.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento); + // } + // if (!string.IsNullOrEmpty(i.tipo_intervento) && !i.tipo_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Tipo intervento", i.tipo_intervento.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_1.Trim()); + // if (!string.IsNullOrEmpty(i.cc1)) + // { + // sb.Append(" - " + i.cc1.Trim()); + // } + // sb.Append(i.ccds1); + // if (!string.IsNullOrEmpty(i.ccds1)) + // { + // sb.Append(" - " + i.ccds1.Trim()); + // } + // dic.Add("Codice Chiusura 1", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_2.Trim()); + // if (!string.IsNullOrEmpty(i.cc2)) + // { + // sb.Append(" - " + i.cc2.Trim()); + // } + // sb.Append(i.ccds2); + // if (!string.IsNullOrEmpty(i.ccds2)) + // { + // sb.Append(" - " + i.ccds2.Trim()); + // } + // dic.Add("Codice Chiusura 2", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_3.Trim()); + // if (!string.IsNullOrEmpty(i.cc3)) + // { + // sb.Append(" - " + i.cc3.Trim()); + // } + // sb.Append(i.ccds3); + // if (!string.IsNullOrEmpty(i.ccds3)) + // { + // sb.Append(" - " + i.ccds3.Trim()); + // } + // dic.Add("Codice Chiusura 3", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_4.Trim()); + // if (!string.IsNullOrEmpty(i.cc4)) + // { + // sb.Append(" - " + i.cc4.Trim()); + // } + // sb.Append(i.ccds4); + // if (!string.IsNullOrEmpty(i.ccds4)) + // { + // sb.Append(" - " + i.ccds4.Trim()); + // } + // dic.Add("Codice Chiusura 4", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_5.Trim()); + // if (!string.IsNullOrEmpty(i.cc5)) + // { + // sb.Append(" - " + i.cc5.Trim()); + // } + // sb.Append(i.ccds5); + // if (!string.IsNullOrEmpty(i.ccds5)) + // { + // sb.Append(" - " + i.ccds5.Trim()); + // } + // dic.Add("Codice Chiusura 5", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_6.Trim()); + // if (!string.IsNullOrEmpty(i.cc6)) + // { + // sb.Append(" - " + i.cc6.Trim()); + // } + // sb.Append(i.ccds6); + // if (!string.IsNullOrEmpty(i.ccds6)) + // { + // sb.Append(" - " + i.ccds6.Trim()); + // } + // dic.Add("Codice Chiusura 6", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_7.Trim()); + // if (!string.IsNullOrEmpty(i.cc7)) + // { + // sb.Append(" - " + i.cc7.Trim()); + // } + // sb.Append(i.ccds7); + // if (!string.IsNullOrEmpty(i.ccds7)) + // { + // sb.Append(" - " + i.ccds7.Trim()); + // } + // dic.Add("Codice Chiusura 7", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_8.Trim()); + // if (!string.IsNullOrEmpty(i.cc8)) + // { + // sb.Append(" - " + i.cc8.Trim()); + // } + // sb.Append(i.ccds8); + // if (!string.IsNullOrEmpty(i.ccds8)) + // { + // sb.Append(" - " + i.ccds8.Trim()); + // } + // dic.Add("Codice Chiusura 8", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_9.Trim()); + // if (!string.IsNullOrEmpty(i.cc9)) + // { + // sb.Append(" - " + i.cc9.Trim()); + // } + // sb.Append(i.ccds9); + // if (!string.IsNullOrEmpty(i.ccds9)) + // { + // sb.Append(" - " + i.ccds9.Trim()); + // } + // dic.Add("Codice Chiusura 9", sb.ToString()); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // string c = string.Empty; + // StringBuilder sb = new StringBuilder(); + // sb.Append(i.codice_chiusura_10.Trim()); + // if (!string.IsNullOrEmpty(i.cc10)) + // { + // sb.Append(" - " + i.cc10.Trim()); + // } + // sb.Append(i.ccds10); + // if (!string.IsNullOrEmpty(i.ccds10)) + // { + // sb.Append(" - " + i.ccds10.Trim()); + // } + // dic.Add("Codice Chiusura 10", sb.ToString()); + // } + + // if (!string.IsNullOrEmpty(i.firma) && !i.firma.Trim().Equals(string.Empty)) + // { + // dic.Add("Firma", i.firma.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.ser_buono) && !i.ser_buono.Trim().Equals(string.Empty)) + // { + // dic.Add("N° buono", i.ser_buono.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (!string.IsNullOrEmpty(i.pagamento) && !i.pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Pagamento", i.pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_pagamento) && !i.note_pagamento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note pagamento", i.note_pagamento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codice_impianto) && !i.codice_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Cod. impianto", i.codice_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.azienda_tecnico) && !i.azienda_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_tecnico); + // } + // if (!string.IsNullOrEmpty(i.generato) && !i.generato.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.generato) + // { + // case "S": + // st = "SI"; + // break; + // default: + // st = "NO"; + // break; + // } + // dic.Add("Rapportino importato", st); + // } + + // if (i.ore_lavoro != null && i.ore_lavoro.Value > 0) + // { + // dic.Add("Ore lavoro", i.ore_lavoro.Value.ToString()); + // } + // if (i.spese_viaggio != null && i.spese_viaggio.Value > 0) + // { + // dic.Add("Spese viaggio", i.spese_viaggio.Value.ToString()); + // } + // if (i.materiale != null && i.materiale.Value > 0) + // { + // dic.Add("Materiale", i.materiale.Value.ToString()); + // } + // if (i.anticipo != null && i.anticipo.Value > 0) + // { + // dic.Add("Anticipo", i.anticipo.Value.ToString()); + // } + // if (i.manodopera != null && i.manodopera.Value > 0) + // { + // dic.Add("Manodopera", i.manodopera.Value.ToString()); + // } + // if (i.diritto_chiamata != null && i.diritto_chiamata.Value > 0) + // { + // dic.Add("Diritto chiamata", i.diritto_chiamata.Value.ToString()); + // } + // if (i.totale != null && i.totale.Value > 0) + // { + // dic.Add("Totale", i.totale.Value.ToString()); + // } + // #endregion + // break; + // default: + // string appo = string.Empty; + // if (!string.IsNullOrEmpty(i.codice_chiusura_1) && !i.codice_chiusura_1.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc1) ? " - " + i.cc1 : string.Empty; + // dic.Add("Cod. Chiusura 1", i.codice_chiusura_1.Trim()+appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_2) && !i.codice_chiusura_2.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc2) ? " - " + i.cc2 : string.Empty; + // dic.Add("Cod. Chiusura 2", i.codice_chiusura_2.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_3) && !i.codice_chiusura_3.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc3) ? " - " + i.cc3 : string.Empty; + // dic.Add("Cod. Chiusura 3", i.codice_chiusura_3.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_4) && !i.codice_chiusura_4.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc4) ? " - " + i.cc4 : string.Empty; + // dic.Add("Cod. Chiusura 4", i.codice_chiusura_4.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_5) && !i.codice_chiusura_5.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc5) ? " - " + i.cc5 : string.Empty; + // dic.Add("Cod. Chiusura 5", i.codice_chiusura_5.Trim() + appo); + // } + + + // if (!string.IsNullOrEmpty(i.codice_chiusura_6) && !i.codice_chiusura_6.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc6) ? " - " + i.cc6 : string.Empty; + // dic.Add("Cod. Chiusura 6", i.codice_chiusura_6.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_7) && !i.codice_chiusura_7.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc7) ? " - " + i.cc7 : string.Empty; + // dic.Add("Cod. Chiusura 7", i.codice_chiusura_7.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_8) && !i.codice_chiusura_8.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc8) ? " - " + i.cc8 : string.Empty; + // dic.Add("Cod. Chiusura 8", i.codice_chiusura_8.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_9) && !i.codice_chiusura_9.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc9) ? " - " + i.cc9 : string.Empty; + // dic.Add("Cod. Chiusura 9", i.codice_chiusura_9.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.codice_chiusura_10) && !i.codice_chiusura_10.Trim().Equals(string.Empty)) + // { + // appo = string.Empty; + // appo = !string.IsNullOrEmpty(i.cc10) ? " - " + i.cc10 : string.Empty; + // dic.Add("Cod. Chiusura 10", i.codice_chiusura_10.Trim() + appo); + // } + // if (!string.IsNullOrEmpty(i.descrizione_intervento) && !i.descrizione_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione intervento", i.descrizione_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.note_intervento) && !i.note_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note_intervento.Trim()); + // } + // if (!string.IsNullOrEmpty(i.esito_intervento) && !i.esito_intervento.Trim().Equals(string.Empty)) + // { + // dic.Add("Esito intervento", i.esito_intervento.Trim()); + // } + + // break; + //} + o.dettaglio = dic; + return o; + } + private Impianto_out fillImpianto_out(Impianto i) + { + Impianto_out u = new Impianto_out(); + u.codimp = i.imcodimp; + u.descimp = i.imdescri; + StringBuilder sb = new StringBuilder(); + + string via = !string.IsNullOrEmpty(i.imindiri1) ? i.imindiri1.Trim() : string.Empty; + string indiri = !string.IsNullOrEmpty(i.imindiri2) ? i.imindiri2.Trim() : string.Empty; + string num = string.Empty; + if (i.imindiri3 != null && i.imindiri3.Value > 0) + { + num = i.imindiri3.ToString().Trim(); + } + string num2 = !string.IsNullOrEmpty(i.imindiri4) ? i.imindiri4.Trim() : string.Empty; + string sca = !string.IsNullOrEmpty(i.imindiri5) ? i.imindiri5.Trim() : string.Empty; + + + if (!string.IsNullOrEmpty(via)) sb.Append(via); + if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + u.indiri = sb.ToString(); + u.localita = i.imlocali; + u.cap = i.imcodcap; + u.comune = i.imcomune; + u.provin = i.improvin; + + return u; + } + + /// Ricerca Impianti return:ActionResult + [HttpGet("ricerca_impianti")] + public async Task>> ricerca_impianti(string token, string? codimp, string? indirizzo_imp) + { + try + { + if (string.IsNullOrEmpty(codimp) && string.IsNullOrEmpty(indirizzo_imp)) + { + Impianto_out e = new Impianto_out(); + e.err_title = "Errore in ricerca impianti."; + e.err_detail = "Immettere almeno un parametro di ricerca."; + e.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status400BadRequest, e); + } + else + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + + ten = ten2; + _impianto = _VT_impia.Impia; + + //if (ten.Equals(Clienti.VT)) + //{ + // ten = ten2; + // _impianto = _VT_impia.Impia; + //} + //else + //{ + // _impianto = getImpiantiByTenant(ten); + //} + + var l = await _impianto.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.Contains(codimp)).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + List lis = new List(); + foreach (Impianto i in l) + { + Impianto_out o = new Impianto_out(); + o = fillImpianto_out(i); + lis.Add(o); + } + return StatusCode(StatusCodes.Status200OK, lis); + } + } + catch(Exception ex) + { + Impianto_out e = new Impianto_out(); + e.err_title = "Errore in ricerca impianti."; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status428PreconditionRequired, e); + } + } + + /// Storico interventi return:ActionResult + [HttpGet("storico_interventi")] + public async Task>> storico_interventi(string token, string? codimp, bool rapp_tec=true) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + _sto_rapp = _VT_StoRapp.StoRapp; + ten = ten2; + + //if (ten.Equals(Clienti.VT)) + //{ + // _sto_rapp = _VT_StoRapp.StoRapp; + // ten = ten2; + //} + //else + //{ + // _sto_rapp = getSto_RappByTenant(ten); + //} + var l = await _sto_rapp.Where(t => t.azienda_impianto != null && t.azienda_impianto.Equals(ten)).ToListAsync(); + //var l = await _sto_rapp.Where(t => t.azienda_impianto != null && t.azienda_impianto.Equals(ten) && t.codice_impianto != null && t.codice_impianto.Equals(codimp)).ToListAsync(); + + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.codice_impianto != null && t.codice_impianto.Trim().Equals(codimp.Trim())).ToList(); + } + if(rapp_tec) + { + l = l.Where(t => t.tccodice != null && t.tccodice.Equals(tecnico)).ToList(); + } + + List lis = new List(); + foreach(Sto_Rapp s in l) + { + Sto_Rapp_out o = new Sto_Rapp_out(); + o = fillSto_Rapp_Out(s, ten); + lis.Add(o); + } + return StatusCode(StatusCodes.Status200OK, lis); + } + catch (Exception ex) + { + Sto_Rapp_out e = new Sto_Rapp_out(); + e.err_title = "Errore in storico interventi"; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, e); + } + } + #endregion + + #region Anagrafica clienti + /// Anagrafica return:ActionResult + [HttpGet("anagrafica")] + public async Task> anagrafica(string token, string codcli) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + Anag aa = new Anag(); + + string ten2 = getClaimValueByToken(token, "tenant2"); + _clientiVT = _VT_anag.Anag; + + var t = await _clientiVT.Where( + t => t.antipcon.Equals("C") + && t.andtobso == null + && t.ancodazi.Equals(ten2) + && t.ancodice.Equals(codcli) + ).ToListAsync(); + AnagVT a = t.First(); + aa.antipcon = a.antipcon; + aa.ancodice = a.ancodice; + aa.ancodfis = a.ancodfis; + aa.anpariva = a.anpariva; + aa.annumlis = a.annumlis; + aa.an_email = a.an_email; + aa.an_empec = a.an_empec; + aa.andescri = a.andescri; + aa.anindiri = a.anindiri; + aa.annumcel = a.annumcel; + aa.antelefo = a.antelefo; + aa.annumlis = a.annumlis; + + //switch (ten) + //{ + + // case Clienti.VT: + // //string ten2 = getClaimValueByToken(token, "tenant2"); + // //_clientiVT = _VT_anag.Anag; + + // //var t = await _clientiVT.Where( + // // t => t.antipcon.Equals("C") + // // && t.andtobso == null + // // && t.ancodazi.Equals(ten2) + // // && t.ancodice.Equals(codcli) + // // ).ToListAsync(); + // //AnagVT a = t.First(); + // //aa.antipcon = a.antipcon; + // //aa.ancodice = a.ancodice; + // //aa.ancodfis = a.ancodfis; + // //aa.anpariva = a.anpariva; + // //aa.annumlis = a.annumlis; + // //aa.an_email = a.an_email; + // //aa.an_empec = a.an_empec; + // //aa.andescri = a.andescri; + // //aa.anindiri = a.anindiri; + // //aa.annumcel = a.annumcel; + // //aa.antelefo = a.antelefo; + // //aa.annumlis = a.annumlis; + // break; + // default: + // _clienti = getClientiByTenant(ten); + // var an = await _clienti.Where(t => t.ancodice == codcli).ToListAsync(); + // aa = an.First(); + // break; + //} + + return StatusCode(StatusCodes.Status200OK, aa); + + } + catch (Exception ex) + { + return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + #endregion + + #region tabelle di dominio + /// Tabelle di dominio: causali pagamenti, causali rapportino, tipi esito, tipi intervento return:ActionResult + [HttpGet("tabelle_dominio")] + public async Task> tabelle_dominio(string token) + { + try + { + TabelleDominio td = new TabelleDominio(); + + string ten = getClaimValueByToken(token, "tenant"); + + //if(!ten.Equals(Clienti.VT)) + //{ + // _pagam = getPagamentiByTenant(ten); + // var a = await _pagam.ToListAsync(); + // td.cau_pag = a; + + // _cau_rapp = getCausaliRappByTenant(ten); + // var b = await _cau_rapp.ToListAsync(); + // td.cau_rapp = b; + //} + + _codSegnVT = getVTCodiciSegnalaz(ten); + var c = await _codSegnVT.Where(x => x.DataObso == null).ToListAsync(); + //td.statoImpianto = c; + + List si = new List(); + + foreach (var item in c) + { + ComboItem s1 = new ComboItem(); + + s1.chiave = item.cscodice.Trim(); + s1.valore = item.csdescr.Trim(); + si.Add(s1); + } + + td.statoImpianto = si; + + List e = new List(); + ComboItem c1 = new ComboItem(); + c1.chiave = "P"; + c1.valore = "Positivo"; + e.Add(c1); + + ComboItem c2 = new ComboItem(); + c2.chiave = "N"; + c2.valore = "Negativo"; + e.Add(c2); + + td.esito = e; + + + //List si = new List(); + //ComboItem s1 = new ComboItem(); + //s1.chiave = "1"; + //s1.valore = "In Funzione"; + //si.Add(s1); + + //ComboItem s2 = new ComboItem(); + //s2.chiave = "0"; + //s2.valore = "Fermo"; + //si.Add(s2); + + //td.statoImpianto = si; + + return StatusCode(StatusCodes.Status200OK, td); + + } + catch (Exception ex) + { + return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + #endregion + + #region timbrature + /// + private async Task fillTimbratura(Timbratura i, string token) + { + Timbratura r = new Timbratura(); + + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + if(ten.Equals(Clienti.VT)) + { + string ten2 = getClaimValueByToken(token, "tenant2"); + ten = ten2; + } + + int id=await getNewId(token); + + r.azienda = ten; + r.id = id; + r.ora_ini = i.ora_ini; + r.min_ini = i.min_ini; + r.ora_fin = i.ora_fin; + r.min_fin = i.min_fin; + 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); + //} + r.commessa = i.commessa; + r.tecnico = tecnico; + + TimeSpan ts = new TimeSpan(i.ora_ini, i.min_ini, 0); + DateTime da = Convert.ToDateTime( r.data_timbratura) + ts; + ts = new TimeSpan(i.ora_fin, i.min_fin, 0); + DateTime a = Convert.ToDateTime(r.data_timbratura) + ts; + ts = (a - da); + + if(ts.Minutes>0) + { + decimal decimali = Decimal.Divide(ts.Minutes, 100); + decimal totale = Convert.ToDecimal(ts.Hours) + decimali; + r.tot_ore = totale; + } + else + { + r.tot_ore = ts.Hours; + } + + + r.giorno =(int) Convert.ToDateTime(i.data_timbratura).DayOfWeek; + r.cpccchk = getCpccchk(10); + r.note = i.note; + + return r; + } + private Timbratura_out fillTimbraturaOut(Timbratura i, string token, int id) + { + Timbratura_out r = new Timbratura_out(); + + r.azienda = i.azienda; + r.id = id; + r.ora_ini = i.ora_ini; + r.min_ini = i.min_ini; + r.ora_fin = i.ora_fin; + r.min_fin = i.min_fin; + r.ore_viaggio = i.ore_viaggio; + r.data_timbratura = i.data_timbratura; + r.commessa = i.commessa; + r.tecnico = i.tecnico; + r.note = i.note; + return r; + } + private CommesseAdHoc_out formattaCommessa(Commessa commessa) + { + StringBuilder sb = new StringBuilder(); + string _item = string.Empty; + CommesseAdHoc_out co = new CommesseAdHoc_out(); + + if (!string.IsNullOrEmpty(commessa.imcodimp)) + { + sb.AppendLine("Imp: " + commessa.imcodimp); + + + string via = !string.IsNullOrEmpty(commessa.imindiri1) ? commessa.imindiri1.Trim() : string.Empty; + string indiri = !string.IsNullOrEmpty(commessa.imindiri2) ? commessa.imindiri2.Trim() : string.Empty; + string num = string.Empty; + if (commessa.imindiri3 != null && commessa.imindiri3.Value > 0) + { + num = commessa.imindiri3.ToString().Trim(); + } + string num2 = !string.IsNullOrEmpty(commessa.imindiri4) ? commessa.imindiri4.Trim() : string.Empty; + string sca = !string.IsNullOrEmpty(commessa.imindiri5) ? commessa.imindiri5.Trim() : string.Empty; + + string appo = string.Empty; + appo = via + indiri + num + num2 + sca; + + if (!string.IsNullOrEmpty(via)) appo = appo + via; + if (!string.IsNullOrEmpty(indiri)) appo = appo + " " + indiri; + if (!string.IsNullOrEmpty(num)) appo = appo + " ," + num; + if (!string.IsNullOrEmpty(num2)) appo = appo + " Int: " + num2; + if (!string.IsNullOrEmpty(sca)) appo = appo + " Scala: " + sca; + sb.AppendLine(appo); + + co.itemList = sb.ToString(); + } + sb = null; + + //copio anche gli altri campi della commessa + co.andescri = commessa.andescri; + co.imindiri1 = commessa.imindiri1; + co.imindiri2 = commessa.imindiri2; + co.imindiri3 = commessa.imindiri3; + co.imindiri4 = commessa.imindiri4; + co.imindiri5 = commessa.imindiri5; + co.imcodcap = commessa.imcodcap; + co.imcodimp = commessa.imcodimp; + co.imlocali = commessa.imlocali; + co.improvin = commessa.improvin; + co.lacodcli = commessa.lacodcli; + co.lacodcom = commessa.lacodcom; + co.ladatchi = commessa.ladatchi; + co.ladeslav = commessa.ladeslav; + co.laserial = commessa.laserial; + co.latipcli = commessa.latipcli; + + return co; + } + private CommesseAdHoc_out formattaCommessaMarrocco(Commessa commessa) + { + StringBuilder sb = new StringBuilder(); + string _item = string.Empty; + CommesseAdHoc_out co = new CommesseAdHoc_out(); + + if (!string.IsNullOrEmpty(commessa.imcodimp)) + { + sb.AppendLine("Comm: " + commessa.lacodcom); + + + string via = !string.IsNullOrEmpty(commessa.imindiri1) ? commessa.imindiri1.Trim() : string.Empty; + string indiri = !string.IsNullOrEmpty(commessa.imindiri2) ? commessa.imindiri2.Trim() : string.Empty; + string num = string.Empty; + if (commessa.imindiri3 != null && commessa.imindiri3.Value > 0) + { + num = commessa.imindiri3.ToString().Trim(); + } + string num2 = !string.IsNullOrEmpty(commessa.imindiri4) ? commessa.imindiri4.Trim() : string.Empty; + string sca = !string.IsNullOrEmpty(commessa.imindiri5) ? commessa.imindiri5.Trim() : string.Empty; + + string appo = string.Empty; + //appo = via + indiri + num + num2 + sca; + + if (!string.IsNullOrEmpty(via)) appo = appo + via; + if (!string.IsNullOrEmpty(indiri)) appo = appo + " " + indiri; + if (!string.IsNullOrEmpty(num)) appo = appo + " ," + num; + if (!string.IsNullOrEmpty(num2)) appo = appo + " Int: " + num2; + if (!string.IsNullOrEmpty(sca)) appo = appo + " Scala: " + sca; + sb.AppendLine(appo); + + co.itemList = sb.ToString(); + } + sb = null; + + //copio anche gli altri campi della commessa + co.andescri = commessa.andescri; + co.imindiri1 = commessa.imindiri1; + co.imindiri2 = commessa.imindiri2; + co.imindiri3 = commessa.imindiri3; + co.imindiri4 = commessa.imindiri4; + co.imindiri5 = commessa.imindiri5; + co.imcodcap = commessa.imcodcap; + co.imcodimp = commessa.imcodimp; + co.imlocali = commessa.imlocali; + co.improvin = commessa.improvin; + co.lacodcli = commessa.lacodcli; + co.lacodcom = commessa.lacodcom; + co.ladatchi = commessa.ladatchi; + co.ladeslav = commessa.ladeslav; + co.laserial = commessa.laserial; + co.latipcli = commessa.latipcli; + + return co; + } + private CommesseAdHoc_out formattaCommessaVT(CommesseVT commessa) + { + StringBuilder sb = new StringBuilder(); + string _item = string.Empty; + CommesseAdHoc_out co = new CommesseAdHoc_out(); + + if (!string.IsNullOrEmpty(commessa.imcodimp)) + { + sb.AppendLine("Imp: " + commessa.imcodimp); + + + string via = !string.IsNullOrEmpty(commessa.imindiri1) ? commessa.imindiri1.Trim() : string.Empty; + string indiri = !string.IsNullOrEmpty(commessa.imindiri2) ? commessa.imindiri2.Trim() : string.Empty; + string num = string.Empty; + if (commessa.imindiri3 != null && commessa.imindiri3.Value > 0) + { + num = commessa.imindiri3.ToString().Trim(); + } + string num2 = !string.IsNullOrEmpty(commessa.imindiri4) ? commessa.imindiri4.Trim() : string.Empty; + string sca = !string.IsNullOrEmpty(commessa.imindiri5) ? commessa.imindiri5.Trim() : string.Empty; + + string appo = string.Empty; + appo = via + indiri + num + num2 + sca; + + if (!string.IsNullOrEmpty(via)) appo = appo + via; + if (!string.IsNullOrEmpty(indiri)) appo = appo + " " + indiri; + if (!string.IsNullOrEmpty(num)) appo = appo + " ," + num; + if (!string.IsNullOrEmpty(num2)) appo = appo + " Int: " + num2; + if (!string.IsNullOrEmpty(sca)) appo = appo + " Scala: " + sca; + sb.AppendLine(appo); + + co.itemList = sb.ToString(); + } + sb = null; + + //copio anche gli altri campi della commessa + co.andescri = commessa.andescri; + co.imindiri1 = commessa.imindiri1; + co.imindiri2 = commessa.imindiri2; + co.imindiri3 = commessa.imindiri3; + co.imindiri4 = commessa.imindiri4; + co.imindiri5 = commessa.imindiri5; + co.imcodcap = commessa.imcodcap; + co.imcodimp = commessa.imcodimp; + co.imlocali = commessa.imlocali; + co.improvin = commessa.improvin; + co.lacodcli = commessa.lacodcli; + co.lacodcom = commessa.lacodcom; + co.ladatchi = commessa.ladatchi; + co.ladeslav = commessa.ladeslav; + co.laserial = commessa.laserial; + co.latipcli = commessa.latipcli; + + return co; + } + + /// Commesse return:ActionResult IEnumerable Commessa + [HttpGet("timbrature/commesse")] + public async Task>> commesse(string token) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + List ll = new List(); + if (ten.Equals(Clienti.VT)) + { + DbSet? _VT_CommesseAppo; + _VT_CommesseAppo = _VT_Comm.Comm; + var lst = _VT_CommesseAppo.Where(t => t.lacodazi != null && t.lacodazi.Equals(ten2)).ToList(); + + foreach (CommesseVT a in lst) + { + CommesseAdHoc_out c = new CommesseAdHoc_out(); + c = formattaCommessaVT(a); + ll.Add(c); + } + } + //else if(ten.Equals(Clienti.Marrocco)) + //{ + // _comm = getCommesseByTenant(ten); + // var l = await _comm.OrderByDescending(t => t.ladatchi).ToListAsync(); + // List commesse_filtrate = new List(); + // _commDesc = _Marro_commDesc.Commdesc; + // var commesse_tecnico = _commDesc.Where((t => t.latecsup!=null && t.latecsup.Equals(tecnico))).ToList(); + // foreach(CommessaDesc c in commesse_tecnico) + // { + // var co = _comm.Where(t => t.laserial.Equals(c.laserial)).ToList(); + // if(co!=null && co.Count > 0) + // { + // commesse_filtrate.Add(co.First()); + // } + // } + // foreach(Commessa c in commesse_filtrate) + // { + // CommesseAdHoc_out co = new CommesseAdHoc_out(); + // co= formattaCommessa(c); + // ll.Add(co); + // } + //} + //else if (ten.Equals(Clienti.Gitoga)) + //{ + // _comm = getCommesseByTenant(ten); + // var l = await _comm.OrderByDescending(t => t.ladatchi).ToListAsync(); + // List commesse_filtrate = new List(); + // _commDesc = _Gitoga_commDesc.Commdesc; + // var commesse_tecnico = _commDesc.Where((t => t.latecsup != null && t.latecsup.Equals(tecnico))).ToList(); + // foreach (CommessaDesc c in commesse_tecnico) + // { + // var co = _comm.Where(t => t.laserial.Equals(c.laserial)).ToList(); + // if (co != null && co.Count > 0) + // { + // commesse_filtrate.Add(co.First()); + // } + // } + // foreach (Commessa c in commesse_filtrate) + // { + // CommesseAdHoc_out co = new CommesseAdHoc_out(); + // co = formattaCommessaMarrocco(c); + // ll.Add(co); + // } + //} + //else if ( ten.Equals(Clienti.Lifta)) + //{ + // _comm = getCommesseByTenant(ten); + // var l = await _comm.OrderByDescending(t => t.ladatchi).ToListAsync(); + // foreach (Commessa c in l) + // { + // CommesseAdHoc_out co = new CommesseAdHoc_out(); + // co = formattaCommessaMarrocco(c); + // ll.Add(co); + // } + //} + //else + //{ + // _comm = getCommesseByTenant(ten); + // var l = await _comm.OrderByDescending(t => t.ladatchi).ToListAsync(); + + // foreach (Commessa c in l) + // { + // CommesseAdHoc_out co = new CommesseAdHoc_out(); + // co = formattaCommessaMarrocco(c); + // ll.Add(co); + // } + //} + + return StatusCode(StatusCodes.Status200OK, ll); + } + catch (Exception ex) + { + CommesseAdHoc_out err = new CommesseAdHoc_out(); + err.err_title = "Errore in timbrature/commesse"; + err.err_detail = ex.Message; + err.err_status_code = "500"; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// Salva la timbratuta in tabella Timbrature return:ActionResult Timbratura_out + [HttpPost] + [Route("timbrature/salva")] + public async Task> timbrature_salva([FromBody] Timbratura model, string token) + { + Timbratura_out tOut = new Timbratura_out(); + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + if (await checkTimbraturaPresente(ten, model) == 0) + { + Timbratura t = await fillTimbratura(model, token); + + using (var transactionVT = _VT_timbr.Database.BeginTransaction()) + { + await _VT_timbr.Timbr.AddAsync(t); + await _VT_timbr.SaveChangesAsync(); + transactionVT.Commit(); + } + + //switch (ten) + //{ + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_timbr.Database.BeginTransaction()) + // { + // await _Sicilia_timbr.Timbr.AddAsync(t); + // await _Sicilia_timbr.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sinergo: + // using (var transaction2 = _Sinergo_timbr.Database.BeginTransaction()) + // { + // await _Sinergo_timbr.Timbr.AddAsync(t); + // await _Sinergo_timbr.SaveChangesAsync(); + // transaction2.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_timbr.Database.BeginTransaction()) + // { + // await _Siet_timbr.Timbr.AddAsync(t); + // await _Siet_timbr.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _PMS_timbr.Database.BeginTransaction()) + // { + // await _PMS_timbr.Timbr.AddAsync(t); + // await _PMS_timbr.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionlw = _LW_timbr.Database.BeginTransaction()) + // { + // await _LW_timbr.Timbr.AddAsync(t); + // await _LW_timbr.SaveChangesAsync(); + // transactionlw.Commit(); + // } + // break; + // case Clienti.Tedesco: + // using (var transactionTedes = _Tedes_timbr.Database.BeginTransaction()) + // { + // await _Tedes_timbr.Timbr.AddAsync(t); + // await _Tedes_timbr.SaveChangesAsync(); + // transactionTedes.Commit(); + // } + // break; + // case Clienti.VT: + // using (var transactionVT = _VT_timbr.Database.BeginTransaction()) + // { + // await _VT_timbr.Timbr.AddAsync(t); + // await _VT_timbr.SaveChangesAsync(); + // transactionVT.Commit(); + // } + // break; + // case Clienti.Syscom : + // using (var transactionsys = _Sys_timbr.Database.BeginTransaction()) + // { + // await _Sys_timbr.Timbr.AddAsync(t); + // await _Sys_timbr.SaveChangesAsync(); + // transactionsys.Commit(); + // } + // break; + // case Clienti.Marrocco: + // using (var transactionMarro = _Marro_timbr.Database.BeginTransaction()) + // { + // await _Marro_timbr.Timbr.AddAsync(t); + // await _Marro_timbr.SaveChangesAsync(); + // transactionMarro.Commit(); + // } + // break; + // default: + // break; + //} + tOut = fillTimbraturaOut(model, ten, t.id); + tOut.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, tOut); + } + else + { + return StatusCode(StatusCodes.Status500InternalServerError, "timbratura presente."); + } + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + tOut.err_title = ex.Message; + tOut.err_detail = errmsg; + tOut.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, tOut); + } + //return tOut; + } + #endregion + + #region storico impianto + + private Sto_Imp_out fillSto_Imp_Out(Sto_Imp i, string tenant) + { + Sto_Imp_out o = new Sto_Imp_out(); + + + o.tipo_movimento = !string.IsNullOrEmpty(i.tipo_movimento) ? i.tipo_movimento.Trim() : string.Empty; ; + o.articolo = !string.IsNullOrEmpty(i.articolo) ? i.articolo.Trim() : string.Empty; + o.data_rapportino = i.data_rapportino; + + Dictionary dic = new Dictionary(); + //switch (tenant) + //{ + // case Clienti.Marrocco: + + // break; + // case Clienti.Ferrari: + + // break; + // case Clienti.Sicilia: + // #region sicilia + // if (!string.IsNullOrEmpty(i.codimp) && !i.codimp.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice Impianto", i.codimp.Trim()); + // } + // if (!string.IsNullOrEmpty(i.desc_impianto) && !i.desc_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione impianto", i.desc_impianto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.indirizzo) && !i.indirizzo.Trim().Equals(string.Empty)) + // { + // StringBuilder sb = new StringBuilder(); + // string ind = string.Empty; + // string via = !string.IsNullOrEmpty(i.indirizzo_tipo) ? i.indirizzo_tipo.Trim() : string.Empty; + // string indiri = !string.IsNullOrEmpty(i.indirizzo) ? i.indirizzo.Trim() : string.Empty; + // string num = string.Empty; + // if (i.indirizzo_num != null && i.indirizzo_num.Value > 0) + // { + // num = i.indirizzo_num.ToString().Trim(); + // } + // string num2 = !string.IsNullOrEmpty(i.indirizzo_num2) ? i.indirizzo_num2.Trim() : string.Empty; + // string sca = !string.IsNullOrEmpty(i.indirizzo_scala) ? i.indirizzo_scala.Trim() : string.Empty; + + // //ind = string.Concat("{0} {1} num {2} interno {3} scala {4}",via,indiri,num,num2,sca); + // if (!string.IsNullOrEmpty(via)) sb.Append(via); + // if (!string.IsNullOrEmpty(indiri)) sb.Append(" " + indiri); + // if (!string.IsNullOrEmpty(num)) sb.Append(" ," + num); + // if (!string.IsNullOrEmpty(num2)) sb.Append(" Int: " + num2); + // if (!string.IsNullOrEmpty(sca)) sb.Append(" Scala: " + sca); + // dic.Add("Indirizzo imp", sb.ToString()); + + // } + // if (!string.IsNullOrEmpty(i.codice_tecnico) && !i.codice_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice tecnico", i.codice_tecnico.Trim()); + // } + // if (!string.IsNullOrEmpty(i.desc_tecnico) && !i.desc_tecnico.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione tecnico", i.desc_tecnico.Trim()); + // } + // if (!string.IsNullOrEmpty(i.seriale_rapportino) && !i.seriale_rapportino.Trim().Equals(string.Empty)) + // { + // dic.Add("Seriale rapportino", i.seriale_rapportino.Trim()); + // } + // if (i.data_rapportino != null) + // { + // dic.Add("Data rapportino", i.data_rapportino.Value.ToString()); + // } + // if (!string.IsNullOrEmpty(i.magazzino) && !i.magazzino.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice magazzino", i.magazzino.Trim()); + // } + + // if (!string.IsNullOrEmpty(i.tipo_movimento) && !i.tipo_movimento.Trim().Equals(string.Empty)) + // { + // string st = string.Empty; + // switch (i.tipo_movimento) + // { + // case "E": + // st = "Eliminato da impianto"; + + // break; + // case "A": + // st = "Aggiunto a impianto"; + + // break; + // case "S": + // st = "Sostituito a impianto"; + + // break; + // } + // dic.Add("Operazione", st); + // } + // if (!string.IsNullOrEmpty(i.articolo) && !i.articolo.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice articolo", i.articolo.Trim()); + // } + // if (!string.IsNullOrEmpty(i.desc_art) && !i.desc_art.Trim().Equals(string.Empty)) + // { + // dic.Add("Descrizione articolo", i.desc_art.Trim()); + // } + // if (!string.IsNullOrEmpty(i.codlotto) && !i.codlotto.Trim().Equals(string.Empty)) + // { + // dic.Add("Codice lotto", i.codlotto.Trim()); + // } + // if (!string.IsNullOrEmpty(i.matricola) && !i.matricola.Trim().Equals(string.Empty)) + // { + // dic.Add("Matricola", i.matricola.Trim()); + // } + + // if (i.quantita != null && i.quantita.Value > 0) + // { + // dic.Add("Qta", i.quantita.Value.ToString()); + // } + // if (i.prezzo != null && i.prezzo.Value > 0) + // { + // dic.Add("Prezzo", i.prezzo.Value.ToString()); + // } + // if (!string.IsNullOrEmpty(i.note) && !i.note.Trim().Equals(string.Empty)) + // { + // dic.Add("Note intervento", i.note.Trim()); + // } + // if (!string.IsNullOrEmpty(i.azienda_impianto) && !i.azienda_impianto.Trim().Equals(string.Empty)) + // { + // dic.Add("Azienda", i.azienda_impianto.Trim()); + // } + + + // #endregion + + // break; + // case Clienti.Discovery: + + // break; + // case Clienti.Sarom: + + // break; + // default: + + // break; + //} + o.dettaglio = dic; + return o; + } + + /// Storico rapportini tecnico return:ActionResult di Sto_Imp_out + [HttpGet("storico_impianto")] + public async Task>> storico_impianto(string token, string? codimp /*,bool rapp_tec = true*/) + { + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + //_sto_imp = getStoricoImpiantoByTenant(ten); + //var l = await _rapportini.Where(t => t.raaziimp != null && t.raaziimp.Equals(ten) && t.racodte1 != null && t.racodte1.Trim().Equals(tecnico.Trim())).ToListAsync(); + var l = await _sto_imp.Where(t => t.azienda_impianto != null && t.azienda_impianto.Equals(ten)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.codimp != null && t.codimp.Equals(codimp)).ToList(); + } + + + List lis = new List(); + foreach (Sto_Imp s in l) + { + Sto_Imp_out o = new Sto_Imp_out(); + o = fillSto_Imp_Out(s, ten); + lis.Add(o); + } + + return StatusCode(StatusCodes.Status200OK, lis); + } + catch (Exception ex) + { + Sto_Imp_out e = new Sto_Imp_out(); + e.err_title = "Errore in Storico impianto"; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, e); + } + } + + #endregion + + #region Rapportini da commessa + + public string _tablecode; + public string _warncode; + + /// Ricerca Commessa return:ActionResult + [HttpGet("ricerca_commessa_impianto")] + public async Task>> ricerca_commessa_impianto(int tipo,string token, string? codimp, string? indirizzo_imp, string? cli, string? comm) + { + Output_Ricerca uscita = new Output_Ricerca(); + //tipo 1: ricerca commessa - tipo2: ricerca impianto + + var st = StatusCodes.Status200OK; + List lis = new List(); + switch (tipo) + { + case 1: + #region ricerca commessa + try + { + //if (string.IsNullOrEmpty(codimp) && string.IsNullOrEmpty(indirizzo_imp) && string.IsNullOrEmpty(cli) && string.IsNullOrEmpty(comm)) + //{ + + // uscita.err_title = "Errore in ricerca Commesse/Impianto."; + // uscita.err_detail = "Immettere almeno un parametro di ricerca."; + // uscita.err_status_code = StatiRisposta.OperazioneNonAmmessa; + // //return StatusCode(StatusCodes.Status400BadRequest, uscita); + // st = StatusCodes.Status400BadRequest; + // lis.Add(uscita); + //} + //else + //{ + string ten = getClaimValueByToken(token, "tenant"); + if (ten.Equals(Clienti.VT)) + { + + string ten2= getClaimValueByToken(token, "tenant2"); + _VT_Commesse = _VT_Comm.Comm; + var l = await _VT_Commesse.Where(t=>t.lacodazi.Equals(ten2)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.Contains(codimp)).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(cli)) + { + l = l.Where(t => t.andescri != null && t.andescri.ToUpper().Contains(cli.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(comm)) + { + l = l.Where(t => t.lacodcom != null && t.lacodcom.ToUpper().Contains(comm.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + + foreach (CommesseVT i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaVT(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + + } + else + { + //string ten = getClaimValueByToken(token, "tenant"); + //_comm = getCommesseByTenant(ten); + var l = await _comm.ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.Contains(codimp)).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(cli)) + { + l = l.Where(t => t.andescri != null && t.andescri.ToUpper().Contains(cli.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(comm)) + { + l = l.Where(t => t.lacodcom != null && t.lacodcom.ToUpper().Contains(comm.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + + foreach (Commessa i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicerca(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + //} + + + //return StatusCode(StatusCodes.Status200OK, lis); + } + } + catch (Exception ex) + { + + uscita.err_title = "Errore in ricerca_impianti_chiamata."; + uscita.err_detail = ex.Message; + uscita.err_status_code = StatiRisposta.ErroreInterno; + //return StatusCode(StatusCodes.Status500InternalServerError, uscita); + st = StatusCodes.Status500InternalServerError; + lis.Add(uscita); + + } + #endregion + break; + case 2: + #region ricerca Impianto + try + { + //if (string.IsNullOrEmpty(codimp) && string.IsNullOrEmpty(indirizzo_imp)) + //{ + + // uscita.err_title = "Errore in ricerca_commessa_impianto."; + // uscita.err_detail = "Immettere almeno un parametro di ricerca."; + // uscita.err_status_code = StatiRisposta.OperazioneNonAmmessa; + // //return StatusCode(StatusCodes.Status400BadRequest, uscita); + // st = StatusCodes.Status400BadRequest; + // lis.Add(uscita); + //} + //else + //{ + string ten = getClaimValueByToken(token, "tenant"); + if (ten.Equals(Clienti.VT)) + { + string ten2 = getClaimValueByToken(token, "tenant2"); + var l = await _VT_impia.Impia.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten2)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.Contains(codimp)).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + else + { + //_impianto = getImpiantiByTenant(ten); + var l = await _impianto.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.Contains(codimp)).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + //} + } + catch (Exception ex) + { + Impianto_out e = new Impianto_out(); + e.err_title = "Errore in ricerca impianti."; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + //return StatusCode(StatusCodes.Status428PreconditionRequired, e); + st = StatusCodes.Status500InternalServerError; + lis.Add(uscita); + } + #endregion + break; + default: + uscita.err_title = "Errore in ricerca_commessa_impianto."; + uscita.err_detail = "Tipo Ricerca non corretto"; + uscita.err_status_code = StatiRisposta.OperazioneNonAmmessa; + //return StatusCode(StatusCodes.Status400BadRequest, uscita); + st = StatusCodes.Status400BadRequest; + lis.Add(uscita); + break; + } + + return StatusCode(st, lis); + } + + /// Ricerca Commessa NUOVAreturn:ActionResult + [HttpGet("ricerca_commessa_impianto2")] + public async Task>> ricerca_commessa_impianto2(int tipo, string token, string? codimp, string? indirizzo_imp, string? cli, string? comm) + { + Output_Ricerca uscita = new Output_Ricerca(); + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + string tecnico = getClaimValueByToken(token, "tccodice"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + //Console.WriteLine(string.Format("*********** {2} INIZIO Chiamata al metodo ricerca_commessa_impianto2: tipo:{0} file: {1} ", ten, tipo, DateTime.Now.ToString())); + //Radio Commessa, tipo 1 , campi cli e comm + //Radio Cliente, tipo 2, campi cli + //Radio Impianto, tipo 3, campi codimp e indirizzoImp + + + + var st = StatusCodes.Status200OK; + List lis = new List(); + switch (tipo) + { + case 1: + #region ricerca commessa + try + { + + if (ten.Equals(Clienti.VT)) + { + _VT_Commesse = _VT_Comm.Comm; + var l = await _VT_Commesse.Where(t => t.lacodazi.Equals(ten2)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.ToUpper().Contains(codimp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(cli)) + { + l = l.Where(t => t.andescri != null && t.andescri.ToUpper().Contains(cli.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(comm)) + { + l = l.Where(t => t.lacodcom != null && t.lacodcom.ToUpper().Contains(comm.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + + foreach (CommesseVT i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaVT(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + + } + //else if(ten.Equals(Clienti.Marrocco)) + //{ + + // // qui devo filtrare per tecnico capoogruppo come faccio nella ricerca commesse del timesheet + // _comm = getCommesseByTenant(ten); + // var l = await _comm.OrderByDescending(t => t.ladatchi).ToListAsync(); + // List commesse_filtrate = new List(); + // _commDesc = _Marro_commDesc.Commdesc; + // var commesse_tecnico = _commDesc.Where((t => t.latecsup != null && t.latecsup.Equals(tecnico))).ToList(); + // foreach (CommessaDesc c in commesse_tecnico) + // { + // var co = _comm.Where(t => t.laserial.Equals(c.laserial)).ToList(); + // if (co != null && co.Count > 0) + // { + // commesse_filtrate.Add(co.First()); + // } + // } + // if(commesse_filtrate.Count()==0) + // { + // commesse_filtrate = l; + // } + // if (!string.IsNullOrEmpty(codimp)) + // { + // commesse_filtrate = commesse_filtrate.Where(t => t.imcodimp != null && t.imcodimp.ToUpper().Contains(codimp.ToUpper())).ToList(); + // } + // if (!string.IsNullOrEmpty(indirizzo_imp)) + // { + // commesse_filtrate = commesse_filtrate.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + // } + // if (!string.IsNullOrEmpty(cli)) + // { + // commesse_filtrate = commesse_filtrate.Where(t => t.andescri != null && t.andescri.ToUpper().Contains(cli.ToUpper())).ToList(); + // } + // if (!string.IsNullOrEmpty(comm)) + // { + // commesse_filtrate = commesse_filtrate.Where(t => t.lacodcom != null && t.lacodcom.ToUpper().Contains(comm.ToUpper())).ToList(); + // } + // commesse_filtrate = commesse_filtrate.Take(300).ToList(); + + // foreach (Commessa i in commesse_filtrate) + // { + // Output_Ricerca o = new Output_Ricerca(); + // o = fillOutputRicerca(i); + // lis.Add(o); + // } + // st = StatusCodes.Status200OK; + //} + else + { + //string ten = getClaimValueByToken(token, "tenant"); + //_comm = getCommesseByTenant(ten); + var l = await _comm.ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.ToUpper().Contains(codimp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(cli)) + { + l = l.Where(t => t.andescri != null && t.andescri.ToUpper().Contains(cli.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(comm)) + { + l = l.Where(t => t.lacodcom != null && t.lacodcom.ToUpper().Contains(comm.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + + foreach (Commessa i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicerca(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + //} + + + //return StatusCode(StatusCodes.Status200OK, lis); + } + } + catch (Exception ex) + { + + uscita.err_title = "Errore in ricerca_commessa_impianto2."; + uscita.err_detail = ex.Message; + uscita.err_status_code = StatiRisposta.ErroreInterno; + //return StatusCode(StatusCodes.Status500InternalServerError, uscita); + st = StatusCodes.Status500InternalServerError; + lis.Add(uscita); + + } + #endregion + break; + case 3: + #region ricerca IMPIANTO + //Radio Cliente, tipo 2, campi codimp e indirizzoImp + try + { + //string ten = getClaimValueByToken(token, "tenant"); + if (ten.Equals(Clienti.VT)) + { + var l = await _VT_impia.Impia.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten2)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.ToUpper().Contains(codimp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + else + { + //_impianto = getImpiantiByTenant(ten); + var l = await _impianto.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten)).ToListAsync(); + if (!string.IsNullOrEmpty(codimp)) + { + l = l.Where(t => t.imcodimp != null && t.imcodimp.ToUpper().Contains(codimp.ToUpper())).ToList(); + } + if (!string.IsNullOrEmpty(indirizzo_imp)) + { + l = l.Where(t => t.imindiri2 != null && t.imindiri2.ToUpper().Contains(indirizzo_imp.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + //} + } + catch (Exception ex) + { + Impianto_out e = new Impianto_out(); + e.err_title = "Errore in ricerca impianti2."; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + //return StatusCode(StatusCodes.Status428PreconditionRequired, e); + st = StatusCodes.Status500InternalServerError; + lis.Add(uscita); + } + #endregion + break; + case 2: + #region ricerca CLIENTE + try + { + //Radio Cliente, tipo 2, campi cli + if (ten.Equals(Clienti.VT)) + { + var l = await _VT_impia.Impia.Where(t => t.imcodazi != null && t.imcodazi.Equals(ten2)).ToListAsync(); + + if (!string.IsNullOrEmpty(cli)) + { + l = l.Where(t => t.descCliente != null && t.descCliente.ToUpper().Contains(cli.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + else + { + //_impianto = getImpiantiByTenant(ten); + 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.ToUpper().Contains(cli.ToUpper())).ToList(); + } + l = l.Take(300).ToList(); + foreach (Impianto i in l) + { + Output_Ricerca o = new Output_Ricerca(); + o = fillOutputRicercaByImpianto(i); + lis.Add(o); + } + st = StatusCodes.Status200OK; + } + } + catch (Exception ex) + { + Impianto_out e = new Impianto_out(); + e.err_title = "Errore in ricerca impianti2."; + e.err_detail = ex.Message; + e.err_status_code = StatiRisposta.ErroreInterno; + //return StatusCode(StatusCodes.Status428PreconditionRequired, e); + st = StatusCodes.Status500InternalServerError; + lis.Add(uscita); + } + #endregion + break; + default: + uscita.err_title = "Errore in ricerca_commessa_impianto2."; + uscita.err_detail = "Tipo Ricerca non corretto"; + uscita.err_status_code = StatiRisposta.OperazioneNonAmmessa; + st = StatusCodes.Status400BadRequest; + lis.Add(uscita); + break; + } + + return StatusCode(st, lis); + } + + /// Salva la timbratuta in tabella Timbrature return:ActionResult Timbratura_out + [HttpPost] + [Route("chiamata/inserisci")] + public async Task> Chiamata_Insert(string token, string codimp, string? codice_commessa) + { + Output_Chiamate tOut = new Output_Chiamate(); + tOut.uscita = new Chiamate_out(); + Input i = new Input(); + try + { + string ten = getClaimValueByToken(token, "tenant"); + string tecnico = getClaimValueByToken(token, "tccodice"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + + Chiamate_out o = new Chiamate_out(); + Prog cpwarnNumChiamata=new Prog(); + Prog cpwarnSeriale = new Prog(); + + Prog2 cpwarnNumChiamataDecimal = new Prog2(); + Prog2 cpwarnSerialeDecimal = new Prog2(); + + string serialeChiamata = string.Empty; + string progChiamata = string.Empty; + string tablecodeProg = string.Empty; + string warncodeProg = string.Empty; + string tablecodeSer = string.Empty; + string warncodeSer = string.Empty; + decimal? serialeLetto = 0; + decimal? progressivoLetto = 0; + string esercizio = Convert.ToString(DateTime.Today.Year); + + //lettura seriali e progressivi + + //string ten2 = getClaimValueByToken(token, "tenant2"); + _VT_prog = _VT_progtable.progr; + var t = await _VT_prog.Where(t => t.azienda.Equals(ten2)).ToListAsync(); + foreach (Progressivo ch in t) + { + string tipoprog = string.Empty; + tipoprog = ch.tipo_prog; + int? val = 0; + val = ch.val_prog; + if (!string.IsNullOrEmpty(tipoprog) && tipoprog.Equals("NUM_CHIAMA")) + { + progChiamata = Convert.ToString(val); + progressivoLetto = val; + } + if (!string.IsNullOrEmpty(tipoprog) && tipoprog.Equals("SER_CHIAMA")) + { + serialeChiamata = Convert.ToString(val); + serialeLetto = val; + } + } + //switch (ten) + //{ + // case Clienti.VT: + // //string ten2 = getClaimValueByToken(token, "tenant2"); + // _VT_prog = _VT_progtable.progr; + // var t = await _VT_prog.Where(t => t.azienda.Equals(ten2)).ToListAsync(); + // foreach (Progressivo ch in t) + // { + // string tipoprog = string.Empty; + // tipoprog = ch.tipo_prog; + // int? val = 0; + // val = ch.val_prog; + // if (!string.IsNullOrEmpty(tipoprog) && tipoprog.Equals("NUM_CHIAMA")) + // { + // progChiamata = Convert.ToString(val); + // progressivoLetto = val; + // } + // if (!string.IsNullOrEmpty(tipoprog) && tipoprog.Equals("SER_CHIAMA")) + // { + // serialeChiamata = Convert.ToString(val); + // serialeLetto = val; + // } + // } + // break; + //} + + //inserisco + //2024-04-23: codice_commessa posto a nullable (quando inserisco una chiamata selezionando solo l'impianto) + //gestisco la ricerca del seriale + string serial_comm = string.Empty; + + if (!string.IsNullOrEmpty(codice_commessa)) + { + serial_comm = await leggiSerialeByCodCommessaVT(ten2, codice_commessa); + } + tOut.uscita = await inserimentoChiamata2(ten, tecnico, codimp, serialeChiamata, progChiamata, serial_comm, ten2, tenConf); + + //switch (ten) + //{ + // case Clienti.VT: + // if (!string.IsNullOrEmpty(codice_commessa)) + // { + // serial_comm = await leggiSerialeByCodCommessaVT(ten2, codice_commessa); + // } + // tOut.uscita = await inserimentoChiamata2(ten, tecnico, codimp, serialeChiamata, progChiamata, serial_comm,ten2, tenConf); + // break; + // default: + // if(!string.IsNullOrEmpty(codice_commessa)) + // { + // serial_comm = await leggiSerialeByCodCommessa(ten, codice_commessa); + // } + + + // //tOut.uscita = await inserimentoChiamata2(ten, tecnico, codimp, serialeChiamata, progChiamata, serial_comm,ten); + // tOut.uscita = await inserimentoChiamata2(tenConf, tecnico, codimp, serialeChiamata, progChiamata, serial_comm, ten, tenConf); + // break; + //} + + //aggiornamento seriali e progressivi + string serialeUpdate = string.Empty; + float numeroUpdate = 0; + + serialeLetto = serialeLetto + 1; + int val2 = Convert.ToInt32(serialeLetto); + await aggiornaprogressivoVT(ten2, "SER_CHIAMA", val2); + serialeUpdate = tOut.uscita.chserial; + + progressivoLetto = progressivoLetto + 1; + val2 = Convert.ToInt32(progressivoLetto); + await aggiornaprogressivoVT(ten2, "NUM_CHIAMA", val2); + + //switch (ten) + //{ + // case Clienti.VT: + // serialeLetto = serialeLetto + 1; + // int val = Convert.ToInt32(serialeLetto); + // await aggiornaprogressivoVT(ten2, "SER_CHIAMA", val); + // serialeUpdate = tOut.uscita.chserial; + + // progressivoLetto = progressivoLetto + 1; + // val = Convert.ToInt32(progressivoLetto); + // await aggiornaprogressivoVT(ten2, "NUM_CHIAMA", val); + + // break; + //} + + i.codice_impianto = tOut.uscita.chcodimp; + i.seriale_chiamata = tOut.uscita.chserial; + i.ora_ini_rapportino = Convert.ToString(tOut.uscita.chora); + i.min_ini_rapportino = Convert.ToString(tOut.uscita.chmin); + + tOut.chiamate_Out = await presaInCarico(i, token); + + _chiamate = getChiamateByTenant(ten); + + var callNew = await _chiamate.Where( + t => t.chserial.Equals(serialeUpdate) + ).FirstAsync(); + + o = fillChiamateOut(callNew, ten); + + tOut.err_status_code = StatiRisposta.Ok; + return StatusCode(StatusCodes.Status200OK, o); + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + tOut.uscita.err_title = ex.Message; + tOut.uscita.err_detail = errmsg; + tOut.uscita.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, tOut.uscita); + } + //return tOut; + } + + private Output_Ricerca fillOutputRicerca(Commessa i) + { + Output_Ricerca r = new Output_Ricerca(); + + r.codice_commessa = i.lacodcom; + r.desc_commessa = i.lacodcom; + + r.tipo_cliente_comm = i.latipcli; + r.cliente_comm = i.lacodcli; + r.dt_fine_validita = i.ladatchi; + r.codice_impianto = i.imcodimp; + r.imindiri1 = i.imindiri1; + r.imindiri2 = i.imindiri2; + r.imindiri3 = i.imindiri3; + r.imindiri4 = i.imindiri4; + r.imindiri5 = i.imindiri5; + r.desc_cliente_comm = i.andescri; + r.cap_impianto = i.imcodcap; + r.provincia_impianto = i.improvin; + + StringBuilder sb = new StringBuilder(); + string commessa = !string.IsNullOrEmpty(i.lacodcom) ? i.lacodcom.Trim() : string.Empty; + if(!string.IsNullOrEmpty(i.ladeslav)) + { + commessa = commessa + " - " +i.ladeslav.Trim(); + } + + sb.AppendLine("Comm: " + commessa); + + if (!string.IsNullOrEmpty(i.imcodimp)) + { + sb.AppendLine("Imp: " + i.imcodimp); + } + + if (!string.IsNullOrEmpty(i.andescri)) + { + string appoCli = i.andescri; + if(appoCli.Length>25) + { + appoCli = appoCli.Substring(0, 25); + } + sb.AppendLine("Cli " + appoCli); + } + r.itemList = sb.ToString(); + sb.Clear(); + + return r; + } + private Output_Ricerca fillOutputRicercaVT(CommesseVT i) + { + Output_Ricerca r = new Output_Ricerca(); + + r.codice_commessa = i.lacodcom; + r.desc_commessa = i.lacodcom; + + r.tipo_cliente_comm = i.latipcli; + r.cliente_comm = i.lacodcli; + r.dt_fine_validita = i.ladatchi; + r.codice_impianto = i.imcodimp; + r.imindiri1 = i.imindiri1; + r.imindiri2 = i.imindiri2; + r.imindiri3 = i.imindiri3; + r.imindiri4 = i.imindiri4; + r.imindiri5 = i.imindiri5; + r.desc_cliente_comm = i.andescri; + r.cap_impianto = i.imcodcap; + r.provincia_impianto = i.improvin; + + StringBuilder sb = new StringBuilder(); + string commessa = !string.IsNullOrEmpty(i.lacodcom) ? i.lacodcom.Trim() : string.Empty; + if (!string.IsNullOrEmpty(i.ladeslav)) + { + commessa = commessa + " - " + i.ladeslav.Trim(); + } + + sb.AppendLine("Comm: " + commessa); + + if (!string.IsNullOrEmpty(i.imcodimp)) + { + sb.AppendLine("Imp: " + i.imcodimp); + } + + if (!string.IsNullOrEmpty(i.andescri)) + { + string appoCli = i.andescri; + appoCli = appoCli.Substring(0, 25); + sb.AppendLine("Cli " + appoCli); + } + r.itemList = sb.ToString(); + sb.Clear(); + + return r; + } + private Output_Ricerca fillOutputRicercaByImpianto(Impianto i) + { + Output_Ricerca r = new Output_Ricerca(); + + r.codice_impianto = i.imcodimp; + r.descrizione_impianto = i.imdescri; + r.imindiri1 = i.imindiri1; + r.imindiri2 = i.imindiri2; + r.imindiri3 = i.imindiri3; + r.imindiri4 = i.imindiri4; + r.imindiri5 = i.imindiri5; + r.cap_impianto = i.imcodcap; + r.provincia_impianto = i.improvin; + + StringBuilder sb = new StringBuilder(); + + sb.AppendLine("Imp: " + i.imcodimp); + + if (!string.IsNullOrEmpty(i.imdescri)) + { + sb.AppendLine( i.imdescri); + } + string via = !string.IsNullOrEmpty(i.imindiri1) ? i.imindiri1.Trim() : string.Empty; + string indiri = !string.IsNullOrEmpty(i.imindiri2) ? i.imindiri2.Trim() : string.Empty; + string num = string.Empty; + if (i.imindiri3 != null && i.imindiri3.Value > 0) + { + num = i.imindiri3.ToString().Trim(); + } + string num2 = !string.IsNullOrEmpty(i.imindiri4) ? i.imindiri4.Trim() : string.Empty; + string sca = !string.IsNullOrEmpty(i.imindiri5) ? i.imindiri5.Trim() : string.Empty; + + string appo = string.Empty; + appo = via + indiri + num + num2 + sca; + + if (!string.IsNullOrEmpty(via)) appo=appo+via; + if (!string.IsNullOrEmpty(indiri)) appo = appo + " "+indiri; + if (!string.IsNullOrEmpty(num)) appo = appo + " ," + num; + if (!string.IsNullOrEmpty(num2)) appo = appo + " Int: " + num2; + if (!string.IsNullOrEmpty(sca)) appo = appo + " Scala: " + sca; + + + sb.AppendLine(appo); + if (!string.IsNullOrEmpty( i.imrefref)) + { + sb.AppendLine(i.imrefref); + } + r.itemList = sb.ToString(); + sb.Clear(); + + return r; + } + private ChiamateTable fillChiamateTableInput(ChiamateTable i, string codimp, string tecnico, string tenant, string serialeLetto, string progLetto, string seriale_commessa) + { + + DateTime adesso = DateTime.Now; + ChiamateTable o = new ChiamateTable(); + 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; + + 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 + string new_serial = string.Empty; + + int ser = int.Parse(lastSerial); + ser++; + new_serial = ser.ToString(); + new_serial = new_serial.PadLeft(10, '0'); + + return new_serial; + } + private async Task inserimentoChiamata2(string ten, string tecnico, string codimp, string serLetto, string progLetto, string codice_commessa, string ten2,string tenConf) + { + Chiamate_out c = new Chiamate_out(); + + + 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; + } + if (!ten.Equals(ten2)) + { + ten = ten2; + } + _chiatable = getChiamateTableByTenant(ten); + //_chiatableTaskManager = getChiamateTableTaskManagerByTenant(ten); + + _confLette = await readConf(ten2); + 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(); + + //switch (ten) + //{ + // case Clienti.VT: + // _confLette = await readConf(ten2); + // 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; + // tt = await _chiatable.Where(t => t.chcodazi != null && t.chcodazi.Equals(ten) && t.chserial != null && t.chserial.Equals(serialeTemplate)).ToListAsync(); + // break; + //} + + t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + using (var tranVT = _VT_chiatable.Database.BeginTransaction()) + { + await _VT_chiatable.Chi.AddAsync(t); + await _VT_chiatable.SaveChangesAsync(); + tranVT.Commit(); + } + + //switch (ten) + //{ + // case Clienti.Marrocco: + // case Clienti.Gitoga: + // case Clienti.Lifta: + // //GITOGA e LIFTA sono comunque dentro il db di Marrocco + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten,serLetto,progLetto, codice_commessa); + // using (var tranMarro = _Marro_chiatable.Database.BeginTransaction()) + // { + // await _Marro_chiatable.Chi.AddAsync(t); + // await _Marro_chiatable.SaveChangesAsync(); + // tranMarro.Commit(); + // } + // break; + + // case Clienti.Siet: + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + // using (var tranSiet = _Siet_chiatable.Database.BeginTransaction()) + // { + // await _Siet_chiatable.Chi.AddAsync(t); + // await _Siet_chiatable.SaveChangesAsync(); + // tranSiet.Commit(); + // } + // break; + // case Clienti.Sicilia: + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var tranSicilia = _Sicilia_chiatable.Database.BeginTransaction()) + // { + // await _Sicilia_chiatable.Chi.AddAsync(t); + // await _Sicilia_chiatable.SaveChangesAsync(); + // tranSicilia.Commit(); + // } + // break; + // case Clienti.PMS: + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var tranPMS = _Pms_chiatable.Database.BeginTransaction()) + // { + // await _Pms_chiatable.Chi.AddAsync(t); + // await _Pms_chiatable.SaveChangesAsync(); + // tranPMS.Commit(); + // } + // break; + // case Clienti.VT: + + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var tranVT = _VT_chiatable.Database.BeginTransaction()) + // { + // await _VT_chiatable.Chi.AddAsync(t); + // await _VT_chiatable.SaveChangesAsync(); + // tranVT.Commit(); + // } + // break; + // case Clienti.Tedesco: + // t = fillChiamateTableInput(tt.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var tranTedes = _Tedes_chiatable.Database.BeginTransaction()) + // { + // await _Tedes_chiatable.Chi.AddAsync(t); + // await _Tedes_chiatable.SaveChangesAsync(); + // tranTedes.Commit(); + // } + // break; + // case Clienti.LW: + + // tm = await fillChiamateTableTaskManagerInput(ttTaskManager.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var tranLW = _LW_chiatable.Database.BeginTransaction()) + // { + // await _LW_chiatable.Chi.AddAsync(tm); + // await _LW_chiatable.SaveChangesAsync(); + // tranLW.Commit(); + // } + // break; + // case Clienti.Syscom: + // tm = await fillChiamateTableTaskManagerInput(ttTaskManager.FirstOrDefault(), codimp, tecnico, ten, serLetto, progLetto, codice_commessa); + + // using (var transys = _Sys_chiatable.Database.BeginTransaction()) + // { + // await _Sys_chiatable.Chi.AddAsync(tm); + // await _Sys_chiatable.SaveChangesAsync(); + // transys.Commit(); + // } + // break; + + // default: + + // break; + //} + + _chiamate = getChiamateByTenant(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; + } + private async Task presaInCarico(Input model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + Chiamate_out calltec_out = new Chiamate_out(); + Chiamate calltec = new Chiamate(); + if (await checkChiamataPresa(ten, model.seriale_chiamata, TipoRapportino.PresaInCarico,ten2) == 0) + { + + _confLette = await readConf(tenConf); + string newSerial = string.Empty; + newSerial = await getSeriale(token); + Rapp_New r = await fillRappNewByInput(model, token, newSerial, _confLette); + + //switch (ten) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_rapp.Database.BeginTransaction()) + // { + // await _Marro_rapp.Rapps.AddAsync(r); + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Ferrari: + // using (var transaction = _Ferra_rapp.Database.BeginTransaction()) + // { + // await _Ferra_rapp.Rapps.AddAsync(r); + // await _Ferra_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transaction = _Sicilia_rapp.Database.BeginTransaction()) + // { + // await _Sicilia_rapp.Rapps.AddAsync(r); + // await _Sicilia_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Discovery: + // using (var transaction = _Disco_rapp.Database.BeginTransaction()) + // { + // await _Disco_rapp.Rapps.AddAsync(r); + // await _Disco_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Sarom: + // using (var transaction = _Sarom_rapp.Database.BeginTransaction()) + // { + // await _Sarom_rapp.Rapps.AddAsync(r); + // await _Sarom_rapp.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transactionGit = _Gitoga_rapp.Database.BeginTransaction()) + // { + // await _Gitoga_rapp.Rapps.AddAsync(r); + // await _Gitoga_rapp.SaveChangesAsync(); + // transactionGit.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transactionLif = _Lifta_rapp.Database.BeginTransaction()) + // { + // await _Lifta_rapp.Rapps.AddAsync(r); + // await _Lifta_rapp.SaveChangesAsync(); + // transactionLif.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_rapp.Database.BeginTransaction()) + // { + // await _Siet_rapp.Rapps.AddAsync(r); + // await _Siet_rapp.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _Pms_rapp.Database.BeginTransaction()) + // { + // await _Pms_rapp.Rapps.AddAsync(r); + // await _Pms_rapp.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.VT: + // using (var transactionvt = _VT_rapptable.Database.BeginTransaction()) + // { + // await _VT_rapptable.Rapps.AddAsync(r); + // await _VT_rapptable.SaveChangesAsync(); + // transactionvt.Commit(); + // } + // break; + // default: + // break; + //} + + using (var transactionvt = _VT_rapptable.Database.BeginTransaction()) + { + await _VT_rapptable.Rapps.AddAsync(r); + await _VT_rapptable.SaveChangesAsync(); + transactionvt.Commit(); + } + + //restituisco la chiamata + calltec = await getChiamataBySerial(model.seriale_chiamata, token); + calltec_out = fillChiamateOut(calltec, ten); + calltec.err_status_code = StatiRisposta.Ok; + + } + else + { + calltec_out.err_title = "Impossibile prendere in carico la chiamata"; + calltec_out.err_detail = "Chiamata precendentemente presa in carico: " + model.seriale_chiamata; + calltec_out.err_status_code = StatiRisposta.OperazioneNonAmmessa; + } + return calltec_out; + } + private async Task aggiornaSeriale(string tenant, string nuovoSeriale) + { + ChiamataSeriale_out cso = new ChiamataSeriale_out(); + + string cpcccchk = getCpccchk(10); + //switch (tenant) + //{ + // case Clienti.Marrocco: + // using (var transaction = _Marro_chiaser.Database.BeginTransaction()) + // { + // ChiamataSeriale entitasViewModel = _chiamateser.Where(p => p.piditta.Equals(tenant)).FirstOrDefault(); + // entitasViewModel.pinumero = nuovoSeriale; + // entitasViewModel.cpccchk = cpcccchk; + // _Marro_chiaser.Entry(entitasViewModel).State = EntityState.Modified; + // await _Marro_chiaser.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Gitoga: + // using (var transaction = _Gitoga_chiaser.Database.BeginTransaction()) + // { + // ChiamataSeriale entitasViewModel = _chiamateser.Where(p => p.piditta.Equals(tenant)).FirstOrDefault(); + // entitasViewModel.pinumero = nuovoSeriale; + // entitasViewModel.cpccchk = cpcccchk; + // _Gitoga_chiaser.Entry(entitasViewModel).State = EntityState.Modified; + // await _Gitoga_chiaser.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Lifta: + // using (var transaction = _Lifta_chiaser.Database.BeginTransaction()) + // { + // ChiamataSeriale entitasViewModel = _chiamateser.Where(p => p.piditta.Equals(tenant)).FirstOrDefault(); + // entitasViewModel.pinumero = nuovoSeriale; + // entitasViewModel.cpccchk = cpcccchk; + // _Lifta_chiaser.Entry(entitasViewModel).State = EntityState.Modified; + // await _Lifta_chiaser.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_chiaser.Database.BeginTransaction()) + // { + // ChiamataSeriale entitasViewModel = _chiamateser.Where(p => p.piditta.Equals(tenant)).FirstOrDefault(); + // entitasViewModel.pinumero = nuovoSeriale; + // entitasViewModel.cpccchk = cpcccchk; + // _Siet_chiaser.Entry(entitasViewModel).State = EntityState.Modified; + // await _Siet_chiaser.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transactionSicilia = _Sicilia_chiaser.Database.BeginTransaction()) + // { + // ChiamataSeriale entitasViewModel = _chiamateser.Where(p => p.piditta.Equals(tenant)).FirstOrDefault(); + // entitasViewModel.pinumero = nuovoSeriale; + // entitasViewModel.cpccchk = cpcccchk; + // _Sicilia_chiaser.Entry(entitasViewModel).State = EntityState.Modified; + // await _Sicilia_chiaser.SaveChangesAsync(); + // transactionSicilia.Commit(); + // } + // break; + + //default: + // break; + //} + return cso; + } + private async Task aggiornaprogressivo(string tenant, float nuovoProg,string tablecode,string warncode) + { + Prog_out cso = new Prog_out(); + + string cpcccchk = getCpccchk(10); + //switch (tenant) + //{ + // case Clienti.Marrocco: + // case Clienti.Gitoga: + // case Clienti.Lifta: + // using (var transaction = _Marro_chiaprog.Database.BeginTransaction()) + // { + // Prog entitasViewModel = _chiamateprogr.Where(p => p.tablecode.Equals(tablecode)&& p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _Marro_chiaprog.Entry(entitasViewModel).State = EntityState.Modified; + // await _Marro_chiaprog.SaveChangesAsync(); + // transaction.Commit(); + // } + // break; + // case Clienti.Siet: + // using (var transactionSiet = _Siet_chiaprog.Database.BeginTransaction()) + // { + // Prog entitasViewModel = _chiamateprogr.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _Siet_chiaprog.Entry(entitasViewModel).State = EntityState.Modified; + // await _Siet_chiaprog.SaveChangesAsync(); + // transactionSiet.Commit(); + // } + // break; + // case Clienti.Sicilia: + // using (var transactionSicilia = _Sicilia_cpwarn.Database.BeginTransaction()) + // { + // _cpwarns = getCpwarnByTenant(tenant); + // Prog2 entitasViewModel = _cpwarns.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = Convert.ToDecimal( nuovoProg); + // entitasViewModel.cpccchk = cpcccchk; + + // _Sicilia_cpwarn.Entry(entitasViewModel).State = EntityState.Modified; + // await _Sicilia_cpwarn.SaveChangesAsync(); + // transactionSicilia.Commit(); + // } + // break; + + // default: + // break; + //} + return cso; + } + private async Task aggiornaprogressivoDecimal(string tenant, decimal? nuovoProg, string tablecode, string warncode) + { + Prog_out cso = new Prog_out(); + + string cpcccchk = getCpccchk(10); + //switch (tenant) + //{ + // case Clienti.Sicilia: + // using (var transactionSicilia = _Sicilia_cpwarn.Database.BeginTransaction()) + // { + // _cpwarns = getCpwarnByTenant(tenant); + // Prog2 entitasViewModel = _cpwarns.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _Sicilia_cpwarn.Entry(entitasViewModel).State = EntityState.Modified; + // await _Sicilia_cpwarn.SaveChangesAsync(); + // transactionSicilia.Commit(); + // } + // break; + // case Clienti.PMS: + // using (var transactionPMS = _PMS_cpwarn.Database.BeginTransaction()) + // { + // _cpwarns = getCpwarnByTenant(tenant); + // Prog2 entitasViewModel = _cpwarns.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _PMS_cpwarn.Entry(entitasViewModel).State = EntityState.Modified; + // await _PMS_cpwarn.SaveChangesAsync(); + // transactionPMS.Commit(); + // } + // break; + // case Clienti.Syscom: + // using (var transactionSys = _Sys_cpwarn.Database.BeginTransaction()) + // { + // _cpwarns = getCpwarnByTenant(tenant); + // Prog2 entitasViewModel = _cpwarns.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _Sys_cpwarn.Entry(entitasViewModel).State = EntityState.Modified; + // await _Sys_cpwarn.SaveChangesAsync(); + // transactionSys.Commit(); + // } + // break; + // case Clienti.LW: + // using (var transactionLW = _LW_cpwarn.Database.BeginTransaction()) + // { + // _cpwarns = getCpwarnByTenant(tenant); + // Prog2 entitasViewModel = _cpwarns.Where(p => p.tablecode.Equals(tablecode) && p.warncode.Equals(warncode)).FirstOrDefault(); + // entitasViewModel.autonum = nuovoProg; + // entitasViewModel.cpccchk = cpcccchk; + + // _LW_cpwarn.Entry(entitasViewModel).State = EntityState.Modified; + // await _LW_cpwarn.SaveChangesAsync(); + // transactionLW.Commit(); + // } + // break; + // default: + // break; + //} + return cso; + } + private async Task aggiornaprogressivoVT(string tenant, string tipoProg, int valore) + { + Progressivo_out cso = new Progressivo_out(); + + string cpcccchk = getCpccchk(10); + Progressivo model = new Progressivo(); + //model.tipo_prog = tipoProg; + //model.azienda = tenant; + //model.val_prog = valore; + var p =await _VT_progtable.progr.Where(t => t.azienda.Equals(tenant) && t.tipo_prog.Equals(tipoProg)).ToListAsync(); + model = p.FirstOrDefault(); + model.val_prog = valore; + try + { + + using (var transaction = _VT_progtable.Database.BeginTransaction()) + { + _VT_progtable.Entry(model).State = EntityState.Modified; + await _VT_progtable.SaveChangesAsync(); + transaction.Commit(); + } + + cso.azienda = model.azienda; + cso.tipo_prog = model.tipo_prog; + cso.val_prog = model.val_prog; + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + cso.err_detail = errmsg; + + } + return cso; + } + private async Task leggiCpwarnSeriale(string tenant, string tablecode) + { + //autorun float + //_chiamateprogr = getChiamateProgressiviByTenant(tenant); + var cpwarn = await _chiamateprogr.Where(p => p.tablecode != null && p.tablecode.Contains(tablecode) && p.tablecode.Contains(tenant)).FirstAsync(); + return cpwarn; + } + private async Task leggiCpwarnProg(string tenant, string tablecode, string codiceEsercizio) + { + //autorun float + //_chiamateprogr = getChiamateProgressiviByTenant(tenant); + var cpwarn = await _chiamateprogr.Where(p => p.tablecode != null && p.tablecode.Contains(tablecode) && p.tablecode.Contains(codiceEsercizio) && p.tablecode.Contains(tenant)).FirstAsync(); + return cpwarn; + } + private async Task leggiCpwarnProgDecimal(string tenant, string tablecode, string codiceEsercizio) + { + string _ten = tenant; + var str = tenant; + str = Regex.Replace(str, @" ", ""); + //autorun decimal + //_cpwarns = getCpwarnByTenant(tenant); + var cpwarn = await _cpwarns.Where(p => p.tablecode != null && p.tablecode.Contains(tablecode) && p.tablecode.Contains(codiceEsercizio) && p.tablecode.Contains(tenant.TrimEnd())).FirstAsync(); + return cpwarn; + } + private async Task leggiCpwarnSerialeDecimal(string tenant, string tablecode) + { + //autorun decimal + //_cpwarns = getCpwarnByTenant(tenant); + var cpwarn = await _cpwarns.Where(p => p.tablecode != null && p.tablecode.Contains(tablecode) && p.tablecode.Contains(tenant.TrimEnd())).FirstAsync(); + return cpwarn; + } + private async Task leggiSerialeByCodCommessa(string tenant, string codice_commessa) + { + string serial = string.Empty; + //_comm = getCommesseByTenant(tenant); + var ser = await _comm.Where(p => p.lacodcom!=null && p.lacodcom.Equals(codice_commessa)).FirstAsync(); + serial = ser.laserial; + return serial; + } + private async Task leggiSerialeByCodCommessaVT(string tenant, string codice_commessa) + { + string serial = string.Empty; + _VT_Commesse = _VT_Comm.Comm; + + //var t = await _VT_Commesse.Where(t => t.lacodazi.Equals(tenant)).ToListAsync(); + var ser = await _VT_Commesse.Where(p => p.lacodcom != null && p.lacodcom.Equals(codice_commessa) && p.lacodazi.Equals(tenant)).FirstAsync(); + serial = ser.laserial; + return serial; + } + #endregion + + #region VIRTUAL TASK + /// Login iniziale return:ActionResult + [HttpPost("loginTechnicalVT")] + public async Task> loginTechnicalVT([FromBody] LoginModel model) + { + LoginOut o = new LoginOut(); + try + { + if (string.IsNullOrEmpty(model.Username) || string.IsNullOrEmpty(model.Password)) + { + o.err_detail = "Username e Password non possono essere vuoti."; + o.err_title = "Username e Password non possono essere vuoti."; + o.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status200OK, o); + } + else + { + _tecnici = _VT_tecnici.Tecnici; + + //var tecnico = await _tecnici.Where(t => t.tcuser.Trim() == model.Username.Trim() && t.tcpwd.Trim() == model.Password.Trim() && t.tccodazi == model.Tenant).Take(1).ToListAsync(); + //var tecnico = await _tecnici.Where(t => t.tcuser == model.Username && t.tcpwd == model.Password && t.tccodazi == model.Tenant).Take(1).ToListAsync(); + var tecnico = await _tecnici.Where(t => t.tcuser == model.Username && t.tcpwd == model.Password && t.tccodute==1).Take(1).ToListAsync(); + if (tecnico == null || (tecnico != null && tecnico.Count == 0)) + { + o.err_detail = "Username o Password non trovati."; + o.err_title = "Username o Password non trovati."; + o.err_status_code = StatiRisposta.OperazioneNonAmmessa; + return StatusCode(StatusCodes.Status404NotFound, o); + } + else + { + var authClaims = new List + { + new Claim(ClaimTypes.Name, model.Username), + new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), + new Claim("tenant", model.Tenant), + new Claim("tenant2", tecnico.First().tccodazi), + new Claim("tccodice", tecnico.First().tccodice), + new Claim("superAdmin", !string.IsNullOrEmpty (tecnico.First().tcsuper)?tecnico.First().tcsuper:"N"), + }; + var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"])); + var token = new JwtSecurityToken( + issuer: _configuration["JWT:ValidIssuer"], + audience: _configuration["JWT:ValidAudience"], + expires: DateTime.Now.AddMonths(3), + claims: authClaims, + signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256) + ); + string tok = new JwtSecurityTokenHandler().WriteToken(token); + _token = tok; + + + o.Tok = tok; + o.Tcdescri = tecnico.First().Tcdescri; + o.Tccodice = tecnico.First().tccodice; + o.Tcsuper = tecnico.First().tcsuper; + o.Tenant = tecnico.First().tccodazi; + //o.tciden = tecnico.First().tciden; + + Conf cc = new Conf(); + //le configurazioni devono essere lette per tenant 2 non per VIRTU + //_confLette = await readConf(model.Tenant); + _confLette = await readConf(tecnico.First().tccodazi); + + cc.abilita_naviga = _confLette.abilita_naviga; + cc.abilita_telefona = _confLette.abilita_telefona; + cc.abilita_chiamate = _confLette.abilita_chiamate; + cc.abilita_barcode = _confLette.abilita_barcode; + + cc.abilita_manutenzioni = _confLette.abilita_manutenzioni; + cc.chiamate_accetta = _confLette.chiamate_accetta; + cc.chiamate_accetta_barcode = _confLette.chiamate_accetta_barcode; + cc.chiamate_accetta_offline = _confLette.chiamate_accetta_offline; + cc.chiamate_rifiuta = _confLette.chiamate_rifiuta; + cc.chiamate_rifiuta_barcode = _confLette.chiamate_rifiuta_barcode; + cc.chiamate_rifiuta_offline = _confLette.chiamate_rifiuta_offline; + cc.chiamate_chiudi_barcode = _confLette.chiamate_chiudi_barcode; + cc.chiamate_firma_barcode = _confLette.chiamate_firma_barcode; + cc.chiamate_chiudi_salva_barcode = _confLette.chiamate_chiudi_salva_barcode; + cc.chiamate_chiudi_salva_offline = _confLette.chiamate_chiudi_salva_offline; + + cc.manutenzioni_accetta = _confLette.manutenzioni_accetta; + cc.manutenzioni_rifiuta = _confLette.manutenzioni_rifiuta; + cc.manutenzioni_accetta_barcode = _confLette.manutenzioni_accetta_barcode; + cc.manutenzioni_accetta_offline = _confLette.manutenzioni_accetta_offline; + cc.manutenzioni_chiudi_barcode = _confLette.manutenzioni_chiudi_barcode; + cc.manutenzioni_firma_barcode = _confLette.manutenzioni_firma_barcode; + cc.manutenzioni_chiudi_salva_barcode = _confLette.manutenzioni_chiudi_salva_barcode; + cc.manutenzioni_chiudi_salva_offline = _confLette.manutenzioni_chiudi_salva_offline; + + cc.dpi_checkbox = _confLette.dpi_checkbox; + + cc.anagrafica = _confLette.anagrafica; + cc.stato_finale = _confLette.stato_finale; + cc.descrizione_intervento = _confLette.descrizione_intervento; + cc.composizione_impianto = _confLette.composizione_impianto; + cc.note_intervento = _confLette.note_intervento; + cc.esito_intervento = _confLette.esito_intervento; + cc.ora_inizio_fine = _confLette.ora_inizio_fine; + cc.materiali = _confLette.materiali; + cc.diritto_chiamata = _confLette.diritto_chiamata; + cc.manodopera = _confLette.manodopera; + cc.spese_viaggio = _confLette.spese_viaggio; + cc.tipo_pagamento = _confLette.tipo_pagamento; + cc.note_pagamento = _confLette.note_pagamento; + cc.causale = _confLette.causale; + + cc.time_sheet = _confLette.time_sheet; + cc.time_sheet_offline = _confLette.time_sheet_offline; + cc.costo_orario = _confLette.costo_orario; + cc.ftp_port = _confLette.ftp_port; + cc.manutenzioni_rifiuta_barcode = _confLette.manutenzioni_rifiuta_barcode; + cc.storico = _confLette.storico; + cc.storico_tecnico = _confLette.storico_tecnico; + cc.storico_interventi = _confLette.storico_interventi; + cc.storico_impianto = _confLette.storico_impianto; + cc.ricerca_impianti = _confLette.ricerca_impianti; + + cc.ora_inizio_fine_automatica = _confLette.ora_inizio_fine_automatica; + cc.stampa_orario = _confLette.stampa_orario; + cc.intestazione_stampa = _confLette.intestazione_stampa; + cc.seriale_template_chi = _confLette.seriale_template_chi; + cc.abilita_inserimento_chiamate = _confLette.abilita_inserimento_chiamate; + + o.Config = cc; + + //cerco le aziende collegate + List l = new List(); + string ten = model.Tenant; + bool bCercaAzcoll = false; + //switch (ten) + //{ + // case Clienti.Discovery: + // bCercaAzcoll = true; + // break; + //} + if (bCercaAzcoll) + { + //_azi_coll = getAziendeRifByTenant(ten); + var a = await _azi_coll.Where(t => t.piazihoc != null && t.piazihoc.Equals(ten) && t.picodtec != null && t.picodtec.Trim().Equals(o.Tccodice.Trim())).ToListAsync(); + if (a.Any()) + { + + foreach (AziendaRif appo in a) + { + string logo = !string.IsNullOrEmpty(appo.pilogurl) ? appo.pilogurl.Trim() : string.Empty; + //var uriBuilder = new UriBuilder(Request.Scheme, Request.Host.Host, Request.Host.Port ?? -1); + //logo = uriBuilder + logo; + appo.pilogurl = logo; + l.Add(appo); + } + + } + } + o.aziende_coll = l; + } + return StatusCode(StatusCodes.Status200OK, o); + } + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + o.err_detail = err; + o.err_title = err; + o.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, o); + } + + } + + /// VIRTUAL TASK: Tecnici per azienda + [HttpGet("tecniciList")] + public async Task>> tecniciList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _tecTable = _VT_tectable.Tectable; + + + var t = await _tecTable.Where( + t => t.tccodazi.Equals(ten) + && t.tcuser != null + ).ToListAsync(); + + foreach (TecniciTable ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + /// VIRTUAL TASK: Tecnici per azienda + [HttpGet("tecniciListAll")] + public async Task>> tecniciListAll(string usr,string pwd) + { + try + { + List ilist = new List(); + _tecTable = _VT_tectable.Tectable; + var t = await _tecTable.Where( + t => t.tcpwd.Equals(pwd) + && t.tcuser.Equals(usr) + ).ToListAsync(); + + foreach (TecniciTable ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + /// VIRTUAL TASK: crea un tecnico return:ActionResult + [HttpPost] + [Route("tecnici/add")] + public async Task> addtecnico([FromBody] TecniciTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.tccodazi = ten; + try + { + using (var transaction = _VT_tectable.Database.BeginTransaction()) + { + await _VT_tectable.Tectable.AddAsync(model); + await _VT_tectable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un tecnico return:ActionResult + [HttpPost] + [Route("tecnici/del")] + public async Task> deltecnico(string codice, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _tecTable = _VT_tectable.Tectable; + var t = await _tecTable.Where(t => t.tccodice == codice && t.tccodazi == ten).ToListAsync(); + + TecniciTable model = t.First(); + model.tcdatobs = DateTime.Now; + try + { + using (var transaction = _VT_tectable.Database.BeginTransaction()) + { + _VT_tectable.Entry(model).State = EntityState.Modified; + await _VT_tectable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica un tecnico return:ActionResult + [HttpPost] + [Route("tecnici/mod")] + public async Task> modtecnico([FromBody] TecniciTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.tccodazi = ten; + try + { + using (var transaction = _VT_tectable.Database.BeginTransaction()) + { + _VT_tectable.Entry(model).State = EntityState.Modified; + await _VT_tectable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + + /// VIRTUAL TASK: Codici di chiusura + [HttpGet("chiusureVtList")] + public async Task>> chiusureVtList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + _chiuTable = _VT_chiutable.Chiutable; + + var t = await _chiuTable.Where(t => t.cccodazi.Equals(ten) && t.codtobso==null).ToListAsync(); + + foreach (ChiusureTable ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea un codice chiusura return:ActionResult + [HttpPost] + [Route("chiusure/add")] + public async Task> addchiusura([FromBody] ChiusureTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.cccodazi = ten; + try + { + using (var transaction = _VT_chiutable.Database.BeginTransaction()) + { + await _VT_chiutable.Chiutable.AddAsync(model); + await _VT_chiutable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un codice chiusura return:ActionResult + [HttpPost] + [Route("chiusure/del")] + public async Task> delchiusura(string codice, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _chiuTable = _VT_chiutable.Chiutable; + var cod = await _chiuTable.Where(t => t.cccodice == codice && t.cccodazi == ten ).ToListAsync(); + + ChiusureTable model = cod.First(); + model.codtobso = DateTime.Now; + try + { + //using (var transaction = _VT_chiutable.Database.BeginTransaction()) + //{ + // _VT_chiutable.Entry(model).State = EntityState.Deleted; + // await _VT_chiutable.SaveChangesAsync(); + // transaction.Commit(); + //} + using (var transaction = _VT_chiutable.Database.BeginTransaction()) + { + _VT_chiutable.Entry(model).State = EntityState.Modified; + await _VT_chiutable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica un codice chiusura return:ActionResult + [HttpPost] + [Route("chiusure/mod")] + public async Task> modchiusura([FromBody] ChiusureTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.cccodazi = ten; + try + { + using (var transaction = _VT_chiutable.Database.BeginTransaction()) + { + _VT_chiutable.Entry(model).State = EntityState.Modified; + await _VT_chiutable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: anagrafiche clienti per azienda + [HttpGet("anagraficheList")] + public async Task>> anagraficheList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _clientiVT = _VT_anag.Anag; + + var t = await _clientiVT.Where( + t => t.antipcon.Equals("C") + && t.andtobso == null + && t.ancodazi.Equals(ten) + ).ToListAsync(); + + foreach (AnagVT ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una anagrafica return:ActionResult + [HttpPost] + [Route("anagrafiche/add")] + public async Task> addAnagrafica([FromBody] AnagTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + + model.annumlis = null; + model.andtobso = null; + model.ancodazi = ten; + try + { + using (var transaction = _VT_anagtable.Database.BeginTransaction()) + { + await _VT_anagtable.Anagtable.AddAsync(model); + await _VT_anagtable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + /// VIRTUAL TASK: crea una anagrafica return:ActionResult + [HttpPost] + [Route("anagrafiche/addCommImp")] + public async Task> addAnagraficaCommessaImpianto([FromBody] AnagCommImp model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + + model.cli.annumlis = null; + model.cli.andtobso = null; + model.cli.ancodazi = ten; + model.cli.antipcon = "C"; + model.imp.imcodazi = ten; + string ten2 = getClaimValueByToken(token, "tenant2"); + model.comm.latipcli = "C"; + model.comm.lacodazi = ten2; + + + try + { + + var strategy = _VT_anagtable.Database.CreateExecutionStrategy(); + await strategy.ExecuteAsync(async () => + { + + using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + await _VT_anagtable.Anagtable.AddAsync(model.cli); + await _VT_impiatable.Impia.AddAsync(model.imp); + await _VT_CommTable.CommTable.AddAsync(model.comm); + + await _VT_anagtable.SaveChangesAsync(); + await _VT_impiatable.SaveChangesAsync(); + await _VT_CommTable.SaveChangesAsync(); + + scope.Complete(); + }); + + + //await _VT_anagtable.Anagtable.AddAsync(model.cli); + //await _VT_anagtable.SaveChangesAsync(); + + ////step 1: INSERISCO IMPIANTO + //_VT_impiatable.Database.UseTransaction(transaction.GetDbTransaction()); + //await _VT_impiatable.Impia.AddAsync(model.imp); + //await _VT_impiatable.SaveChangesAsync(); + + ////step 2: inserimento commessa + //_VT_CommTable.Database.UseTransaction(transaction.GetDbTransaction()); + //await _VT_CommTable.CommTable.AddAsync(model.comm); + //await _VT_CommTable.SaveChangesAsync(); + + //transaction.Commit(); + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + /// VIRTUAL TASK: modifica una anagrafica return:ActionResult + [HttpPost] + [Route("anagrafiche/mod")] + public async Task> modAnagrafica([FromBody] AnagTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.ancodazi = ten; + try + { + using (var transaction = _VT_anagtable.Database.BeginTransaction()) + { + _VT_anagtable.Entry(model).State = EntityState.Modified; + await _VT_anagtable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una anagrafica (valorizza data obsolescenza) return:ActionResult + [HttpPost] + [Route("anagrafiche/del")] + public async Task> delAnagrafica([FromBody] AnagTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.ancodazi = ten; + model.andtobso = DateTime.Now; + try + { + using (var transaction = _VT_anagtable.Database.BeginTransaction()) + { + _VT_anagtable.Entry(model).State = EntityState.Modified; + await _VT_anagtable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: rapp_new per azienda + [HttpGet("rappnewList")] + public async Task>> rappnewList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _rapp_new_view = _VT_rapp.Rapps; + + var t = await _rapp_new_view.Where(t => t.azienda_chiamata.Equals(ten)).Take(100).ToListAsync(); + + foreach (Rapp_New_View ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una rappnew return:ActionResult + [HttpPost] + [Route("rappnew/add")] + public async Task> addRappnew([FromBody] Rapp_New model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.azienda_chiamata = ten; + model.azienda_impianto = ten; + model.azienda_tecnico = ten; + try + { + using (var transaction = _VT_rapptable.Database.BeginTransaction()) + { + await _VT_rapptable.Rapps.AddAsync(model); + await _VT_rapptable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica una anagrafica return:ActionResult + [HttpPost] + [Route("rappnew/mod")] + public async Task> modRappnew([FromBody] Rapp_New model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.azienda_chiamata = ten; + model.azienda_impianto = ten; + model.azienda_tecnico = ten; + try + { + using (var transaction = _VT_rapptable.Database.BeginTransaction()) + { + _VT_rapptable.Entry(model).State = EntityState.Modified; + await _VT_rapptable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una rapp_new return:ActionResult + [HttpPost] + [Route("rappnew/del")] + public async Task> delRappnew(string serialeRapportino, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _rapp_new = _VT_rapptable.Rapps; + var t = await _rapp_new.Where(t => t.seriale_rapportino.Equals(serialeRapportino) && t.azienda_chiamata.Equals(ten)).ToListAsync(); + + Rapp_New model = t.First(); + try + { + //using (var transaction = _Marro_rapp.Database.BeginTransaction()) + //{ + // _Marro_rapp.Entry(model).State = EntityState.Deleted; + // await _Marro_rapp.SaveChangesAsync(); + // transaction.Commit(); + //} + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: impianti per azienda + [HttpGet("impiantiList")] + public async Task>> impiantiList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _impianto = _VT_impia.Impia; + + var t = await _impianto.Where(t => t.imcodazi.Equals(ten)).ToListAsync(); + + foreach (Impianto ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: impianti per azienda + [HttpGet("impiantiListMngr")] + public async Task>> impiantiListMngr(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _impianto = _VT_impiaMngr.Impia; + + var t = await _impianto.Where(t => t.imcodazi.Equals(ten)).ToListAsync(); + + foreach (Impianto ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea un impianto return:ActionResult + [HttpPost] + [Route("impianti/add")] + public async Task> addImpianto([FromBody] ImpiantoTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.imcodazi = ten; + + try + { + using (var transaction = _VT_impiatable.Database.BeginTransaction()) + { + await _VT_impiatable.Impia.AddAsync(model); + await _VT_impiatable.SaveChangesAsync(); + transaction.Commit(); + } + + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + //co_out.err_title = ex.Message; + //co_out.err_detail = errmsg; + //co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + //return co_out; + } + + /// VIRTUAL TASK: modifica un impianto return:ActionResult + [HttpPost] + [Route("impianto/mod")] + public async Task> modImpianto([FromBody] ImpiantoTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.imcodazi = ten; + + try + { + using (var transaction = _VT_impiatable.Database.BeginTransaction()) + { + _VT_impiatable.Entry(model).State = EntityState.Modified; + await _VT_impiatable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un impianto return:ActionResult + [HttpPost] + [Route("impianto/del")] + public async Task> delImpianto(string imcodimp, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _impiaTable = _VT_impiatable.Impia; + var t = await _impiaTable.Where(t => t.imcodimp.Equals(imcodimp) && t.imcodazi.Equals(ten)).ToListAsync(); + + ImpiantoTable model = t.First(); + model.imfinatt = DateTime.Now; + try + { + using (var transaction = _VT_impiatable.Database.BeginTransaction()) + { + _VT_impiatable.Entry(model).State = EntityState.Modified; + await _VT_impiatable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: chiamate per azienda + [HttpGet("chiamateList")] + public async Task>> chiamateList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _chiamate = _VT_chia.Chiamate; + + var t = await _chiamate.Where(t => t.chcodazi.Equals(ten)).ToListAsync(); + + foreach (Chiamate ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: chiamate per azienda + [HttpGet("chiamateListMngr")] + public async Task>> chiamateListMngr(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _chiamate = _VT_chiaMngr.Chiamate; + + var t = await _chiamate.Where(t => t.chcodazi.Equals(ten)).ToListAsync(); + + foreach (Chiamate ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una chiamata return:ActionResult + [HttpPost] + [Route("chiamata/add")] + public async Task> addChiamata([FromBody] ChiamateTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.chcodazi = ten; + try + { + using (var transaction = _VT_chiatable.Database.BeginTransaction()) + { + await _VT_chiatable.Chi.AddAsync(model); + await _VT_chiatable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica una chiamata return:ActionResult + [HttpPost] + [Route("chiamata/mod")] + public async Task> modChiamata([FromBody] ChiamateTable model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.chcodazi = ten; + + try + { + using (var transaction = _VT_chiatable.Database.BeginTransaction()) + { + _VT_chiatable.Entry(model).State = EntityState.Modified; + await _VT_chiatable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + //co_out.err_title = ex.Message; + //co_out.err_detail = errmsg; + //co_out.err_status_code = StatiRisposta.ErroreInterno; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + //return co_out; + } + + /// VIRTUAL TASK: cancella una chiamata return:ActionResult + [HttpPost] + [Route("chiamata/del")] + public async Task> delChiamata(string chserial, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _chiatable = _VT_chiatable.Chi; + var t = await _chiatable.Where(t => t.chserial.Equals(chserial) && t.chcodazi.Equals(ten)).ToListAsync(); + + ChiamateTable model = t.First(); + try + { + using (var transaction = _VT_chiatable.Database.BeginTransaction()) + { + _VT_chiatable.Entry(model).State = EntityState.Deleted; + await _VT_chiatable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: progressivi per azienda + [HttpGet("progressiviList")] + public async Task>> progressiviList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_prog = _VT_progtable.progr; + + var t = await _VT_prog.Where(t => t.azienda.Equals(ten)).ToListAsync(); + + foreach (Progressivo ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: modifica un progressivo return:ActionResult + [HttpPost] + [Route("progressivo/mod")] + public async Task> modProgressivo([FromBody] Progressivo model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.azienda = ten; + try + { + using (var transaction = _VT_progtable.Database.BeginTransaction()) + { + _VT_progtable.Entry(model).State = EntityState.Modified; + await _VT_progtable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: dati azienda + [HttpGet("aziendeList")] + public async Task>> aziendeList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _azi_coll = _VT_azi.Azi; + + var t = await _azi_coll.Where(t => t.pirifazi.Equals(ten)).ToListAsync(); + + foreach (AziendaRif ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una azienda return:ActionResult + [HttpPost] + [Route("azienda/add")] + public async Task> addAzienda([FromBody] AziendaRif model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + model.piazihoc = ten; + model.pirifazi = ten2; + _confLette = await readConf(ten2); + try + { + using (var transaction = _VT_azi.Database.BeginTransaction()) + { + await _VT_azi.Azi.AddAsync(model); + await _VT_azi.SaveChangesAsync(); + transaction.Commit(); + } + + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica un progressivo return:ActionResult + [HttpPost] + [Route("azienda/mod")] + public async Task> modAzienda([FromBody] AziendaRif model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + model.piazihoc = ten; + model.pirifazi = ten2; + try + { + using (var transaction = _VT_azi.Database.BeginTransaction()) + { + _VT_azi.Entry(model).State = EntityState.Modified; + await _VT_azi.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una azienda return:ActionResult + [HttpPost] + [Route("azienda/del")] + public async Task> delAzienda(string picodtec, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + + _azi_coll = _VT_azi.Azi; + var t = await _azi_coll.Where(t => t.piazihoc.Equals(ten) && t.pirifazi.Equals(ten2) && t.picodtec.Equals(picodtec)).ToListAsync(); + + AziendaRif model = t.First(); + try + { + using (var transaction = _VT_azi.Database.BeginTransaction()) + { + _VT_azi.Entry(model).State = EntityState.Deleted; + await _VT_azi.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + + /// VIRTUAL TASK: registrazioni + [HttpGet("registrazioniList")] + public async Task>> registrazioniList() + { + try + { + List ilist = new List(); + //string ten = getClaimValueByToken(token, "tenant2"); + //string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_regi = _VT_reg.Reg; + + //var t = await _azi_coll.Where(t => t.pirifazi.Equals(ten)).ToListAsync(); + + foreach (Registrazione ch in _VT_regi) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una registrazione return:ActionResult + [HttpPost] + [Route("registrazioni/add")] + public async Task> addRegistrazione([FromBody] Registrazione model) + { + try + { + using (var transaction = _VT_reg.Database.BeginTransaction()) + { + await _VT_reg.Reg.AddAsync(model); + await _VT_reg.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica una registrazione return:ActionResult + [HttpPost] + [Route("registrazioni/mod")] + public async Task> modregistrazione([FromBody] Registrazione model) + { + //string ten = getClaimValueByToken(token, "tenant"); + //string ten2 = getClaimValueByToken(token, "tenant2"); + //model.piazihoc = ten; + //model.pirifazi = ten2; + try + { + using (var transaction = _VT_reg.Database.BeginTransaction()) + { + _VT_reg.Entry(model).State = EntityState.Modified; + await _VT_reg.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una registrazione return:ActionResult + [HttpPost] + [Route("registrazioni/del")] + public async Task> delRegistrazione(int Id) + { + //string ten = getClaimValueByToken(token, "tenant"); + //string ten2 = getClaimValueByToken(token, "tenant2"); + + _VT_regi = _VT_reg.Reg; + var t = await _VT_regi.Where(t => t.Id==Id ).ToListAsync(); + + Registrazione model = t.First(); + try + { + using (var transaction = _VT_reg.Database.BeginTransaction()) + { + _VT_reg.Entry(model).State = EntityState.Deleted; + await _VT_reg.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: registrazioni + [HttpGet("AziendePresentiList")] + public async Task>> AziendePresentiList() + { + try + { + List ilist = new List(); + //string ten = getClaimValueByToken(token, "tenant2"); + //string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_AziPresenti = _VT_AziPres.Aziende; + + //var t = await _azi_coll.Where(t => t.pirifazi.Equals(ten)).ToListAsync(); + + foreach (AziendaPres ch in _VT_AziPresenti) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + + /// VIRTUAL TASK: commesse + [HttpGet("commesseList")] + public async Task>> commesseList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + //string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_Commesse = _VT_Comm.Comm; + + var t = await _VT_Commesse.Where(t => t.lacodazi.Equals(ten)).ToListAsync(); + + foreach (CommesseVT ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea una commessa return:ActionResult + [HttpPost] + [Route("commesseVT/add")] + public async Task> addCommessaVT([FromBody] CommesseVT_Table model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + model.latipcli = "C"; + model.lacodazi = ten2; + try + { + using (var transaction = _VT_CommTable.Database.BeginTransaction()) + { + await _VT_CommTable.CommTable.AddAsync(model); + await _VT_CommTable.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica una commessa return:ActionResult + [HttpPost] + [Route("commesseVT/mod")] + public async Task> modCommessaVT([FromBody] CommesseVT_Table model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + + try + { + using (var transaction = _VT_CommTable.Database.BeginTransaction()) + { + _VT_CommTable.Entry(model).State = EntityState.Modified; + await _VT_CommTable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una commessa (valorizza data obsolescenza) return:ActionResult + [HttpPost] + [Route("commesseVT/del")] + public async Task> delCommessaVT([FromBody] CommesseVT_Table model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + + model.ladatchi = DateTime.Now; + try + { + using (var transaction = _VT_CommTable.Database.BeginTransaction()) + { + _VT_CommTable.Entry(model).State = EntityState.Modified; + await _VT_CommTable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + + /// VIRTUAL TASK: dati Azienda + [HttpGet("datiaziendaList")] + public async Task>> datiaziendaList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + //string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_DatiAzi =_VT_DatiAzienda.Dati; + + var t = await _VT_DatiAzi.Where(t => t.azienda.Equals(ten)).ToListAsync(); + + foreach (DatiAzienda ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: crea dati azienda return:ActionResult + [HttpPost] + [Route("datiazienda/add")] + public async Task> addDatiAzienda([FromBody] DatiAzienda model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + _confLette = await readConf(ten2); + //model.latipcli = "C"; + //model.lacodazi = ten2; + try + { + using (var transaction = _VT_DatiAzienda.Database.BeginTransaction()) + { + await _VT_DatiAzienda.Dati.AddAsync(model); + await _VT_DatiAzienda.SaveChangesAsync(); + transaction.Commit(); + } + //devo fare la copia del logo e metterlo nella cartella del server a partire dal logo scritto in tabella + model = await readImgAndSave(model.azienda, model.tecnico, _confLette.path_buoni); + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: modifica una commessa return:ActionResult + [HttpPost] + [Route("datiazienda/mod")] + public async Task> modDatiAzienda([FromBody] DatiAzienda model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + + try + { + using (var transaction = _VT_DatiAzienda.Database.BeginTransaction()) + { + _VT_DatiAzienda.Entry(model).State = EntityState.Modified; + await _VT_DatiAzienda.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una dati azienda return:ActionResult + [HttpPost] + [Route("datiazienda/del")] + public async Task> delDatiAzienda(string azienda, string tecnico) + { + //string ten = getClaimValueByToken(token, "tenant"); + //string ten2 = getClaimValueByToken(token, "tenant2"); + + _VT_DatiAzi = _VT_DatiAzienda.Dati; + var t = await _VT_DatiAzi.Where(t => t.azienda.Equals(azienda) && t.tecnico.Equals(tecnico)).ToListAsync(); + + DatiAzienda model = t.First(); + try + { + using (var transaction = _VT_DatiAzienda.Database.BeginTransaction()) + { + _VT_DatiAzienda.Entry(model).State = EntityState.Deleted; + await _VT_DatiAzienda.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella una dati azienda return:ActionResult + [HttpPost] + [Route("datiazienda/saveFile")] + public async Task> saveFileDatiAzienda(string azienda, string tecnico, string pathSrv) + { + DatiAzienda model=new DatiAzienda(); + try + { + model = await readImgAndSave(azienda,tecnico,pathSrv); + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: legge e salva su server return:ActionResult + private async Task readImgAndSave(string azienda, string tecnico, string pathSrv) + { + _VT_DatiAzi = _VT_DatiAzienda.Dati; + var t = await _VT_DatiAzi.Where(t => t.azienda.Equals(azienda) && t.tecnico.Equals(tecnico)).ToListAsync(); + + DatiAzienda model = t.First(); + + string path = string.Empty; + string nomeFile = string.Empty; + nomeFile = getNomeFile(model.url_logo); + + path = pathSrv; + path = path +@"\"+azienda+ @"\" + nomeFile; + SaveByteArrayToFileWithBinaryWriter(model.logo, path); + return model; + } + + /// VIRTUAL TASK: salvataggio su disco + public static void SaveByteArrayToFileWithBinaryWriter(byte[] data, string filePath) + { + using var writer = new BinaryWriter(System.IO.File.OpenWrite(filePath)); + writer.Write(data); + //System.IO.File.WriteAllBytes("Foo.txt", data); + } + + /// VIRTUAL TASK: ricava il nome del file a partire dal path web + public static string getNomeFile(string path) + { + string nome = string.Empty; + string[] words = path.Split('/'); + int l = words.Length; + nome = words[l - 1]; + return nome; + } + + /// VIRTUAL TASK: dati Azienda + [HttpGet("rapportiniList")] + public async Task>> rapportiniList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + //string tecnico = getClaimValueByToken(token, "tccodice"); + _VT_rapport = _VT_Rapportini.Rapportini; + + var t = await _VT_rapport.Where(t => t.azienda_impianto.Equals(ten)).ToListAsync(); + + foreach (Rapportino ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: inserisce buono + [HttpGet("buoni/add")] + public async Task> addBuoni([FromBody] Buoni model, string token) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + model.dt_ins = DateTime.Now; + //model.lacodazi = ten2; + try + { + using (var transaction = _VT_Buoni.Database.BeginTransaction()) + { + await _VT_Buoni.buoni.AddAsync(model); + await _VT_Buoni.SaveChangesAsync(); + transaction.Commit(); + } + + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: Timbrature da App + [HttpGet("timbratureList")] + public async Task>> timbratureList(string token) + { + try + { + List ilist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _timbr = _VT_timbr.Timbr; + + + var t = await _timbr.Where( + t => t.azienda.Equals(ten) + ).ToListAsync(); + + foreach (Timbratura ch in t) + { + ilist.Add(ch); + } + return StatusCode(StatusCodes.Status200OK, ilist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); + } + } + + /// VIRTUAL TASK: lista articoli per azienda + [HttpGet("articoliList")] + public async Task>> ArticoliList(string token) + { + try + { + List alist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _articoliTable = _VT_articoliTable.Articoli; + + var art = await _articoliTable.Where(x => x.Azienda.Equals(ten)).ToListAsync(); + + foreach (Articoli a in art) + { + alist.Add(a); + } + return StatusCode(StatusCodes.Status200OK, alist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); ; + } + } + + /// VIRTUAL TASK : crea nuovo articolo return: ActionResult + [HttpPost] + [Route("articolo/add")] + public async Task> addArticolo([FromBody] Articoli model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.Azienda = ten; + try + { + using (var transaction = _VT_articoliTable.Database.BeginTransaction()) + { + await _VT_articoliTable.Articoli.AddAsync(model); + await _VT_articoliTable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); ; + } + } + + /// VIRTUAL TASK : modifica articolo return: ActionResult + [HttpPost] + [Route("articolo/mod")] + public async Task> modArticolo([FromBody] Articoli model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.Azienda = ten; + + try + { + using (var transaction = _VT_articoliTable.Database.BeginTransaction()) + { + _VT_articoliTable.Entry(model).State = EntityState.Modified; + await _VT_articoliTable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un articolo return:ActionResult + [HttpPost] + [Route("articolo/del")] + public async Task> delArticolo(string artcodice, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _articoliTable = _VT_articoliTable.Articoli; + var art = await _articoliTable.Where(a => a.SlCodice.Equals(artcodice) && a.Azienda.Equals(ten)).ToListAsync(); + + Articoli model = art.First(); + model.DataObso = DateTime.Now; + + try + { + using (var transaction = _VT_articoliTable.Database.BeginTransaction()) + { + _VT_articoliTable.Entry(model).State = EntityState.Modified; + await _VT_articoliTable.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: lista mag_new per azienda + [HttpGet("VTMagNewList")] + public async Task>> VTMagNewList(string token) + { + try + { + List mnlist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _magNewVT = _VT_MagNew.MagNewVt; + + var listaMn = await _magNewVT.Where(x => x.Azienda.Equals(ten)).ToListAsync(); + foreach (Vt_Mag_New mg in listaMn) + { + mnlist.Add(mg); + } + return StatusCode(StatusCodes.Status200OK, mnlist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); ; + } + } + + /// VIRTUAL TASK: lista Magazzini per azienda + [HttpGet("magazziniVTList")] + public async Task>> MagazziniVTList(string token) + { + try + { + List maglist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _magazziniVT = _VT_Magazzini.Magazzini; + + var magazziniList = await _magazziniVT.Where(x => x.Azienda.Equals(ten)).ToListAsync(); + foreach (MagazziniVT magaz in magazziniList) + { + maglist.Add(magaz); + } + return StatusCode(StatusCodes.Status200OK, maglist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); ; + } + } + + /// VIRTUAL TASK : crea nuovo magazzino return: ActionResult + [HttpPost] + [Route("magazziniVT/add")] + public async Task> addMagazzinoVT([FromBody] MagazziniVT model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.Azienda = ten; + try + { + using (var transaction = _VT_Magazzini.Database.BeginTransaction()) + { + await _VT_Magazzini.Magazzini.AddAsync(model); + await _VT_Magazzini.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); ; + } + } + + /// VIRTUAL TASK : modifica magazzino return: ActionResult + [HttpPost] + [Route("magazziniVT/mod")] + public async Task> modMagazzino([FromBody] MagazziniVT model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.Azienda = ten; + + try + { + using (var transaction = _VT_Magazzini.Database.BeginTransaction()) + { + _VT_Magazzini.Entry(model).State = EntityState.Modified; + await _VT_Magazzini.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un magazzino return:ActionResult + [HttpPost] + [Route("magazziniVT/del")] + public async Task> delMagazzino(string magCodice, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _magazziniVT = _VT_Magazzini.Magazzini; + var art = await _magazziniVT.Where(a => a.Mgcodmag.Equals(magCodice) && a.Azienda.Equals(ten)).ToListAsync(); + + MagazziniVT model = art.First(); + model.DataObso = DateTime.Now; + + try + { + using (var transaction = _VT_Magazzini.Database.BeginTransaction()) + { + _VT_Magazzini.Entry(model).State = EntityState.Modified; + await _VT_Magazzini.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: lista Codici segnalazioni per azienda + [HttpGet("CodiciSegnalazioniVTList")] + public async Task>> CodSegnVTList(string token) + { + try + { + List codSegnlist = new List(); + string ten = getClaimValueByToken(token, "tenant2"); + string tecnico = getClaimValueByToken(token, "tccodice"); + _codSegnVT = _VT_CodSegn.CodSegn; + + var codiciSegnList = await _codSegnVT.Where(x => x.cscodazi.Equals(ten)).ToListAsync(); + foreach (CodiceSegnalazione codS in codiciSegnList) + { + codSegnlist.Add(codS); + } + return StatusCode(StatusCodes.Status200OK, codSegnlist); + } + catch (Exception ex) + { + string err = "Errore: " + ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, err); ; + } + } + + /// VIRTUAL TASK : crea nuovo codice segnalazione return: ActionResult + [HttpPost] + [Route("CodiciSegnalazioniVT/add")] + public async Task> addCodSegnVT([FromBody] CodiceSegnalazione model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.cscodazi = ten; + try + { + using (var transaction = _VT_CodSegn.Database.BeginTransaction()) + { + await _VT_CodSegn.CodSegn.AddAsync(model); + await _VT_CodSegn.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); ; + } + } + + /// VIRTUAL TASK : modifica codice segnalazione return: ActionResult + [HttpPost] + [Route("CodiciSegnalazioniVT/mod")] + public async Task> modCodSegnVT([FromBody] CodiceSegnalazione model, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + model.cscodazi = ten; + try + { + using (var transaction = _VT_CodSegn.Database.BeginTransaction()) + { + _VT_CodSegn.Entry(model).State = EntityState.Modified; + await _VT_CodSegn.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + /// VIRTUAL TASK: cancella un codice segnalazione return:ActionResult + [HttpPost] + [Route("CodiciSegnalazioniVT/del")] + public async Task> delCodSegn(string codSegn, string token) + { + string ten = getClaimValueByToken(token, "tenant2"); + _codSegnVT = _VT_CodSegn.CodSegn; + var art = await _codSegnVT.Where(a => a.cscodice.Equals(codSegn) && a.cscodazi.Equals(ten)).ToListAsync(); + + CodiceSegnalazione model = art.First(); + model.DataObso = DateTime.Now; + + try + { + using (var transaction = _VT_CodSegn.Database.BeginTransaction()) + { + _VT_CodSegn.Entry(model).State = EntityState.Modified; + await _VT_CodSegn.SaveChangesAsync(); + transaction.Commit(); + } + return StatusCode(StatusCodes.Status200OK, model); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + return StatusCode(StatusCodes.Status500InternalServerError, errmsg); + } + } + + #endregion + + #region Logging + /// Upload return:ActionResult + [HttpPost] + [Route("log/scrivi")] + public async Task scriviLog( string token, string mex) + { + string ten = getClaimValueByToken(token, "tenant"); + string ten2 = getClaimValueByToken(token, "tenant2"); + string tenConf = getClaimValueByToken(token, "tenantConfigurazioni"); + string tecnico = getClaimValueByToken(token, "tccodice"); + + if (string.IsNullOrEmpty(ten)) + { + ten = tenConf; + } + string dataLog = DateTime.Now.ToString(); + + try + { + string ver = Request.Headers["X-App-Version"]; + var re = Request; + var headers = re.Headers; + StringValues x = default(StringValues); + if (headers.ContainsKey("X-App-Version")) + { + var m = headers.TryGetValue("X-App-Version", out x); + } + + Console.WriteLine(string.Format("*********** {0} LOG: tenant:{1} tenant2: {2} tenantConf: {3} tecnico:{4}", dataLog,ten, ten2, tenConf, tecnico)); + if (!string.IsNullOrEmpty(ver)) + { + Console.WriteLine(string.Format("versione app: {0} ", ver)); + } + Console.WriteLine(string.Format("{0} ", mex)); + Console.WriteLine(string.Format("*********** {0} FINE LOG: tenant:{1} tenant2: {2} tenantConf: {3} tecnico:{4}", dataLog,ten, ten2, tenConf, tecnico)); + return Ok(new { count = 1, mex.Length }); + } + catch (Exception ex) + { + StringBuilder sb = new StringBuilder(); + string errMsg = string.Empty; + if (ex.Message != null) + { + sb.AppendLine(ex.Message); + } + if (ex.InnerException != null) + { + sb.AppendLine(ex.InnerException.Message); + } + errMsg = sb.ToString(); + + + Console.WriteLine(string.Format("*********** {0} ERRORE LOG: tenant:{1} tenant2: {2} tenantConf: {3} tecnico:{4}", dataLog, ten, ten2, tenConf, tecnico)); + Console.WriteLine(string.Format("{0} ", errMsg)); + Console.WriteLine(string.Format("*********** {0} Fine ERRORE LOG: tenant:{1} tenant2: {2} tenantConf: {3} tecnico:{4}", dataLog, ten, ten2, tenConf, tecnico)); + return StatusCode(StatusCodes.Status500InternalServerError, "Error: " + errMsg); + } + } + #endregion + } +} diff --git a/ApiPolo/Interfaces/ITenantDbContext.cs b/ApiPolo/Interfaces/ITenantDbContext.cs new file mode 100644 index 0000000..c4025ab --- /dev/null +++ b/ApiPolo/Interfaces/ITenantDbContext.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using ApiPolo.Models; + +namespace ApiPolo.Interfaces +{ + public interface ITenantDbContext + { + DbSet? Causali { get; set; } + DbSet? Commesse { get; set; } + DbSet? Chiusure { get; set; } + DbSet? Azi { get; set; } + DbSet? ccci { get; set; } + DbSet? ccciWiev { get; set; } + DbSet? Chiamate { get; set; } + DbSet? Clienti { get; set; } + DbSet? Componen { get; set; } + DbSet? Impia { get; set; } + DbSet? Mag { get; set; } + DbSet? Magaz { get; set; } + DbSet? Manutenzioni { get; set; } + DbSet? Pagamenti { get; set; } + DbSet? Prese { get; set; } + DbSet? Rapps { get; set; } + DbSet? rapp { get; set; } + DbSet? Sost { get; set; } + DbSet? Saldi { get; set; } + DbSet? StoRapp { get; set; } + DbSet? Tecnici { get; set; } + DbSet? Timbr { get; set; } + DbSet? StoImp { get; set; } + } +} diff --git a/ApiPolo/Interfaces/ITenantDbContextFactory.cs b/ApiPolo/Interfaces/ITenantDbContextFactory.cs new file mode 100644 index 0000000..f5054e1 --- /dev/null +++ b/ApiPolo/Interfaces/ITenantDbContextFactory.cs @@ -0,0 +1,9 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Interfaces +{ + public interface ITenantDbContextFactory + { + ITenantDbContext GetDbContext(string tenant); + } +} diff --git a/ApiPolo/Interfaces/TenantDbContextFactory.cs b/ApiPolo/Interfaces/TenantDbContextFactory.cs new file mode 100644 index 0000000..7b7dbc7 --- /dev/null +++ b/ApiPolo/Interfaces/TenantDbContextFactory.cs @@ -0,0 +1,28 @@ +//using ApiPolo.Data; +using ApiPolo.Interfaces; +using static ApiPolo.Controllers.PoloController; + +public class TenantDbContextFactory : ITenantDbContextFactory +{ + private readonly IServiceProvider _serviceProvider; + + public TenantDbContextFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public ITenantDbContext GetDbContext(string tenant) + { + // Create a scope to resolve DbContext + var scope = _serviceProvider.CreateScope(); + + return tenant switch + { + //Clienti.Maras => scope.ServiceProvider.GetRequiredService(), + //Clienti.Marrocco => scope.ServiceProvider.GetRequiredService(), + //// Add other tenants as needed + //// Clienti.AnotherTenant => scope.ServiceProvider.GetRequiredService(), + //_ => throw new KeyNotFoundException($"No DbContext found for tenant: {tenant}") + }; + } +} diff --git a/ApiPolo/Models/Anag.cs b/ApiPolo/Models/Anag.cs new file mode 100644 index 0000000..508e42a --- /dev/null +++ b/ApiPolo/Models/Anag.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di SALDIART + /// + [Keyless] + public class Anag + { + /// tipo + public string? antipcon { get; set; } + + /// codice + public string? ancodice { get; set; } + + /// email + public string? an_email { get; set; } + + /// codice fiscale + public string? ancodfis { get; set; } + + /// partita iva + public string? anpariva { get; set; } + + /// indirizzo + public string? anindiri { get; set; } + + /// telefono + public string? antelefo { get; set; } + + /// cellulare + public string? annumcel { get; set; } + + /// pec + public string? an_empec { get; set; } + + /// descrizione + public string? andescri { get; set; } + + /// listino cliente + public string? annumlis { get; set; } + + + } +} diff --git a/ApiPolo/Models/AnagCommImp.cs b/ApiPolo/Models/AnagCommImp.cs new file mode 100644 index 0000000..8d0aed4 --- /dev/null +++ b/ApiPolo/Models/AnagCommImp.cs @@ -0,0 +1,15 @@ +namespace ApiPolo.Models +{ + /// + public class AnagCommImp + { + /// + public AnagTable? cli { get; set; } + + /// + public CommesseVT_Table? comm { get; set; } + + /// + public ImpiantoTable? imp { get; set; } + } +} diff --git a/ApiPolo/Models/AnagTable.cs b/ApiPolo/Models/AnagTable.cs new file mode 100644 index 0000000..1dd6389 --- /dev/null +++ b/ApiPolo/Models/AnagTable.cs @@ -0,0 +1,50 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class AnagTable + { + /// tipo + [Key] + public string? antipcon { get; set; } + + /// codice + [Key] + public string? ancodice { get; set; } + + /// codice azienda + [Key] + public string? ancodazi { get; set; } + + /// email + public string? an_email { get; set; } + + /// codice fiscale + public string? ancodfis { get; set; } + + /// partita iva + public string? anpariva { get; set; } + + /// indirizzo + public string? anindiri { get; set; } + + /// telefono + public string? antelefo { get; set; } + + /// cellulare + public string? annumcel { get; set; } + + /// pec + public string? an_empec { get; set; } + + /// descrizione + public string? andescri { get; set; } + + /// listino cliente + public string? annumlis { get; set; } + + /// cliente eliminato + public DateTime? andtobso { get; set; } + } +} diff --git a/ApiPolo/Models/AnagVT.cs b/ApiPolo/Models/AnagVT.cs new file mode 100644 index 0000000..126f41b --- /dev/null +++ b/ApiPolo/Models/AnagVT.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di API_CLIENTI + /// + [Keyless] + public class AnagVT + { + /// tipo + public string? antipcon { get; set; } + + /// codice + public string? ancodice { get; set; } + + /// email + public string? an_email { get; set; } + + /// codice fiscale + public string? ancodfis { get; set; } + + /// partita iva + public string? anpariva { get; set; } + + /// indirizzo + public string? anindiri { get; set; } + + /// telefono + public string? antelefo { get; set; } + + /// cellulare + public string? annumcel { get; set; } + + /// pec + public string? an_empec { get; set; } + + /// descrizione + public string? andescri { get; set; } + + /// listino cliente + public string? annumlis { get; set; } + + /// cliente eliminato + public DateTime? andtobso { get; set; } + + /// azienda (tenant2) + public string? ancodazi { get; set; } + } +} diff --git a/ApiPolo/Models/Articoli.cs b/ApiPolo/Models/Articoli.cs new file mode 100644 index 0000000..6c5f212 --- /dev/null +++ b/ApiPolo/Models/Articoli.cs @@ -0,0 +1,37 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace ApiPolo.Models +{ + public class Articoli + { + [Key] + public string Azienda { get; set; } + [Key] + public string SlCodice { get; set; } + public string? ArDesArt { get; set; } + public string? SlCodMag { get; set; } + [Column(TypeName = "decimal(13,3)")] + public decimal? SlQtAper { get; set; } + public string? AmCodice { get; set; } + public string? LoCodice { get; set; } + public string? LiCodLis { get; set; } + public string? LiCodArt { get; set; } + public DateTime? LiDatAtt { get; set; } + [Column(TypeName = "decimal(12,3)")] + public decimal? LiQuanti { get; set; } + [Column(TypeName = "decimal(18,5)")] + public decimal? LiPrezzo { get; set; } + [Column(TypeName = "decimal(6,2)")] + public decimal? LiScont1 { get; set; } + [Column(TypeName = "decimal(6,2)")] + public decimal? LiScont2 { get; set; } + [Column(TypeName = "decimal(6,2)")] + public decimal? LiScont3 { get; set; } + [Column(TypeName = "decimal(6,2)")] + public decimal? LiScont4 { get; set; } + public string? Gest_Matr { get; set; } + public string? Gest_Lotti { get; set; } + public string? Desc_sup { get; set; } + public DateTime? DataObso { get; set; } + } +} diff --git a/ApiPolo/Models/AziendaPres.cs b/ApiPolo/Models/AziendaPres.cs new file mode 100644 index 0000000..706dc61 --- /dev/null +++ b/ApiPolo/Models/AziendaPres.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// Azienda prsente + /// + [Keyless] + public class AziendaPres + { + /// + /// Azienda tecnico + /// + public string? tccodazi { get; set; } + } +} diff --git a/ApiPolo/Models/AziendaRif.cs b/ApiPolo/Models/AziendaRif.cs new file mode 100644 index 0000000..0c4b8a4 --- /dev/null +++ b/ApiPolo/Models/AziendaRif.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Azienda collegata all'azienda principale + public class AziendaRif + { + /// azienda + [Key] + public string? piazihoc { get; set; } + + /// tecnico + [Key] + public string? picodtec { get; set; } + + /// tecnico + [Key] + public string? pirifazi { get; set; } + + /// Nome azienda collegata + public string? pinomede { get; set; } + + /// url logo + public string? pilogurl { get; set; } + + /// Testo rapportino + public string? pitextin { get; set; } + } +} diff --git a/ApiPolo/Models/Buoni.cs b/ApiPolo/Models/Buoni.cs new file mode 100644 index 0000000..327e57a --- /dev/null +++ b/ApiPolo/Models/Buoni.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// buoni rapportini + public class Buoni + { + /// azienda + [Key] + public string? azienda { get; set; } + + /// seriale buono + [Key] + public string? ser_buono { get; set; } + + /// immagine + public byte[]? immagine { get; set; } + + /// data inserimento + public DateTime? dt_ins { get; set; } + } +} diff --git a/ApiPolo/Models/BuoniLW.cs b/ApiPolo/Models/BuoniLW.cs new file mode 100644 index 0000000..6f030a0 --- /dev/null +++ b/ApiPolo/Models/BuoniLW.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Buono per Lift web + public class BuoniLW + { + /// azienda + [Key] + public string? azienda { get; set; } + + /// seriale buono + [Key] + public string? ser_buono { get; set; } + + /// immagine + public string? immagine { get; set; } + + /// data inserimento + public DateTime? dt_ins { get; set; } + } +} diff --git a/ApiPolo/Models/CC_CI.cs b/ApiPolo/Models/CC_CI.cs new file mode 100644 index 0000000..30c22b7 --- /dev/null +++ b/ApiPolo/Models/CC_CI.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class CC_CI + { + /// codice azienda + [Key] + public string? picodazi { get; set; } + + /// codice di chiusura + [Key] + public string? picodchi { get; set; } + + /// codice intervento + [Key] + public string? picodint { get; set; } + } +} diff --git a/ApiPolo/Models/CC_CIWiev.cs b/ApiPolo/Models/CC_CIWiev.cs new file mode 100644 index 0000000..7e139e1 --- /dev/null +++ b/ApiPolo/Models/CC_CIWiev.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// Oggetto Vista abbinamento codice chiusura-codice intervento + [Keyless] + public class CC_CIWiev + { + /// Azienda + public string? picodazi { get; set; } + + /// codice di chiusura PIASSCHIU + public string? picodchi { get; set; } + + /// codice intervento PIASSCHIU + public string? picodint { get; set; } + + /// codice intervento CODINTE + public string? cicodice { get; set; } + + /// descrizione intervento CODINTE + public string? cidescri { get; set; } + } +} diff --git a/ApiPolo/Models/Caus_Rapp.cs b/ApiPolo/Models/Caus_Rapp.cs new file mode 100644 index 0000000..bd43a4c --- /dev/null +++ b/ApiPolo/Models/Caus_Rapp.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// Causali rapportino + /// + [Keyless] + public class Caus_Rapp + { + /// codice causale + public string? crcodice { get; set; } + + /// descrizione causale + public string? crdescri { get; set; } + + /// flag fatturazione + public string? crrifatt { get; set; } + } +} diff --git a/ApiPolo/Models/ChiamataSeriale.cs b/ApiPolo/Models/ChiamataSeriale.cs new file mode 100644 index 0000000..68abbf7 --- /dev/null +++ b/ApiPolo/Models/ChiamataSeriale.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class ChiamataSeriale + { + /// + [Key] + public string? piditta { get; set; } + + /// + public string? pinumero { get; set; } + + /// + public string? cpccchk { get; set; } + } +} diff --git a/ApiPolo/Models/ChiamataSeriale_out.cs b/ApiPolo/Models/ChiamataSeriale_out.cs new file mode 100644 index 0000000..cf73afe --- /dev/null +++ b/ApiPolo/Models/ChiamataSeriale_out.cs @@ -0,0 +1,24 @@ +namespace ApiPolo.Models +{ + /// + public class ChiamataSeriale_out + { + /// + public string? piditta { get; set; } + + /// + public string? pinumero { get; set; } + + /// + public string? cpccchk { get; set; } + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Chiamate.cs b/ApiPolo/Models/Chiamate.cs new file mode 100644 index 0000000..ec25d48 --- /dev/null +++ b/ApiPolo/Models/Chiamate.cs @@ -0,0 +1,410 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// ViSTA Chiamate + [Keyless] + public class Chiamate + { + /// Azienda + public string? chcodazi { get; set; } + + /// + /// Seriale Chiamata + /// + public string? chserial { get; set; } + + /// + /// Stato chiamata + /// + public string? chstato { get; set; } + + /// + /// Codice Chiamatista assegnato + /// + public string? chtchiam { get; set; } + + /// + /// Data appuntamento chiamata + /// + public DateTime? chdtapp { get; set; } + + /// + /// Ora appuntamento inizio + /// + public int? choraaPI { get; set; } + + /// + /// Minuti appuntamento inizio + /// + public int? chminapi { get; set; } + + /// + /// Note appuntamento + /// + public string? chnote { get; set; } + + /// + /// Codice Impianto chiamata + /// + public string? chcodimp { get; set; } + + /// + /// Descrizione codice segnalazione + /// + public string? csdescr { get; set; } + + /// + /// Telefono cliente + /// + public string? antelefo { get; set; } + + /// + /// descrizione cliente + /// + public string? andescri { get; set; } + + /// + /// Indirizzo impianto tipo + /// + /// Via,Piazza, + public string? imindiri1 { get; set; } + + /// + /// Indirizzo impianto nome + /// + public string? imindiri2 { get; set; } + + /// + /// Indirizzo impianto numero + /// + public int? imindiri3 { get; set; } + + /// + /// Indirizzo impianto sottonumero + /// + public string? imindiri4 { get; set; } + + /// + /// Indirizzo impianto Scala + /// + public string? imindiri5 { get; set; } + + /// + /// Indirizzo impianto località + /// + public string? imlocali { get; set; } + + /// + /// Indirizzo impianto Cap + /// + public string? imcodcap { get; set; } + + /// + /// Indirizzo impianto comune + /// + public string? imcomune { get; set; } + + /// + /// Indirizzo impianto provincia + /// + public string? improvin { get; set; } + + /// + /// Indirizzo impianto nazione + /// + public string? imcodnaz { get; set; } + + /// + /// MANPROG: matricola impianto + /// + public string? immatric { get; set; } + + /// + /// MANPROG: numero impianto + /// + public string? imnumimp { get; set; } + + /// + /// MANPROG: ubicazione impianto + /// + public string? imubicaz { get; set; } + + /// + /// Tecnico descrizione + /// + public string? tcdescri { get; set; } + + /// + /// Tecnico codice + /// + public string? tccodice { get; set; } + + /*campi di RAPP_NEW*/ + + + /// + /// RAPP_NEW: seriale rapp_new preso in carico + /// + public string? ser_rapp_ic { get; set; } + + /// + /// RAPP_NEW: tipo rapp_new preso in carico (valore vuoto) + /// + public string? tipo_rapp_ic { get; set; } + + /// + /// RAPP_NEW: preso in carico (S o NULL) + /// + public string? ic { get; set; } + + /// + /// RAPP_NEW: seriale rapp_new rifiutata + /// + public string? ser_rapp_rif { get; set; } + + /// + /// RAPP_NEW: tipo rapp rifiutata (valore vuoto) + /// + public string? tipo_rapp_rif { get; set; } + + /// + /// RAPP_NEW: rifiutato (S o null) + /// + public string? rif { get; set; } + + /// + /// RAPP_NEW: seriale chiamata chiusa + /// + public string? ser_rapp_chiu { get; set; } + + /// + /// RAPP_NEW: tipo chiamata chiusa (3 o null) + /// + public string? tipo_rapp_chiu { get; set; } + + /// + /// RAPP_NEW: seriale buono chiamata chiusa + /// + public string? ser_buono_chiu { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + + + //ALTRI + /// Esercizio + public string? chcodese { get; set; } + + /// Tipo + public string? chtipo { get; set; } + + /// numero chiamata + [Column(TypeName = "decimal(10, 0)")] + public decimal? chnumero { get; set; } + + /// Data inserimento chiamata + public DateTime? chdata { get; set; } + + /// Ora inserimento chiamata + public int? chora { get; set; } + + /// Minuti inserimento chiamata + public int? chmin { get; set; } + + /// operatore assegnazione + public int? chopass { get; set; } + + /// operatore di chiusura + public int? chopchi { get; set; } + + /// azienda impianto + public string? chaziimp { get; set; } + + /// ora appuntamento fine + public int? choraapf { get; set; } + + /// minuto appuntamento fine + public int? chminapf { get; set; } + + /// Riferimento chiamata + public string? chrifer { get; set; } + + /// telefono riferimento + public string? chtelef { get; set; } + + /// tcodice segnalazione + public string? chcodseg { get; set; } + + + + + /// Fermo impianto S/N + public string? chstopi { get; set; } + + /// Data assegnazione chiamata + public DateTime? chdtass { get; set; } + + /// Ora assegnazione chiamata + public int? chorass { get; set; } + + /// Min assegnazione chiamata + public int? chminass { get; set; } + + /// Data chiusura chiamata + public DateTime? chdtchi { get; set; } + + /// Ora chiusura chiamata + public int? chorachi { get; set; } + + /// Min chiusura chiamata + public int? chminchi { get; set; } + + /// Data inizio intervento + public DateTime? chdtlin { get; set; } + + /// Ora inizio intervento + public int? chorali { get; set; } + + /// Min inizio intervento + public int? chminli { get; set; } + + /// Data fine intervento + public DateTime? chdtlfi { get; set; } + + /// Ora fine intervento + public int? choralf { get; set; } + + /// Min fine intervento + public int? chminlf { get; set; } + + /// Numero 1 rapportino futuro + public int? chnrap1 { get; set; } + + /// Serie 1 rapportino futuro + public string? chsrap1 { get; set; } + + /// Numero 2 rapportino futuro + public int? chnrap2 { get; set; } + + /// Modalità raccolta chiamata + public string? chmodrac { get; set; } + + /// Numero chiamata per impianto per anno + public int? chprgann { get; set; } + + + /// Importo manodopera + [Column(TypeName = "decimal(18, 4)")] + public decimal? chimpman { get; set; } + + /// Percentuale manodopera + [Column(TypeName = "decimal(6, 2)")] + public decimal? chperman { get; set; } + + /// Stampa manodopera + public string? chflstim { get; set; } + + /// Chiusura da remoto + public string? chfleste { get; set; } + + /// Riferimento seriale importazione + public string? chserext { get; set; } + + /// Descrizione + public string? imdescri { get; set; } + + /// Tipo impianto + public string? imtipoim { get; set; } + + /// Ultimo amministratore + public string? imultamm { get; set; } + + /// Descrizione Ult. Amministratore + public string? imultdam { get; set; } + + /// Telefono Ult. Amministratore + public string? imulttam { get; set; } + + /// Zona manutenzione + public string? imzonman { get; set; } + + /// Pubblico/privato + public string? imflpupr { get; set; } + + /// Zona chiamate + public string? imzonchi { get; set; } + + /// Zona supervisione + public string? imzonsup { get; set; } + + /// Data inizio manutenzione + public DateTime? imdainma { get; set; } + + /// Data fine manutenzione + public DateTime? imdafima { get; set; } + + /// Data costruzione + public DateTime? imdatcos { get; set; } + + /// Numero telesoccorso + public string? imteleso { get; set; } + + /// Email cliente + public string? an_email { get; set; } + + /// Ultimo cliente + public string? imultcli { get; set; } + + /// codice cliente + public string? ancodice { get; set; } + + /// tipo anagrafica + public string? antipcon { get; set; } + + /// costo chiamata + [Column(TypeName = "decimal(18, 4)")] + public decimal? chiamata { get; set; } + + /// spese viaggio + [Column(TypeName = "decimal(18, 4)")] + public decimal? spe_viaggio { get; set; } + + /// costo orario ordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_ordinario { get; set; } + + /// costo orario notturno + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_notturno { get; set; } + + /// costo orario straordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_straordinario { get; set; } + + /// costo orario festivo + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_festivo { get; set; } + + /// Azienda di riferimento associata all'impianto (gestione loghi differenti) + public string? imazirif { get; set; } + + /// riferimento impianto (va su rapportino) + public string? imrefref { get; set; } + + + } +} diff --git a/ApiPolo/Models/ChiamateTable.cs b/ApiPolo/Models/ChiamateTable.cs new file mode 100644 index 0000000..9071426 --- /dev/null +++ b/ApiPolo/Models/ChiamateTable.cs @@ -0,0 +1,211 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Tabella CHIAMATE (insert da app) + public class ChiamateTable + { + /// + [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; } + + ///// + //public string? chtelesan { get; set; } + + } +} diff --git a/ApiPolo/Models/ChiamateTableOut.cs b/ApiPolo/Models/ChiamateTableOut.cs new file mode 100644 index 0000000..b49b857 --- /dev/null +++ b/ApiPolo/Models/ChiamateTableOut.cs @@ -0,0 +1,212 @@ + + +namespace ApiPolo.Models +{ + /// Tabella CHIAMATE (insert da app) - Output + public class ChiamateTableOut + { + /// + public string? chcodazi { get; set; } + + /// + 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; } + + /// + public string? chtelesan { get; set; } + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + + } +} 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/Chiamate_out.cs b/ApiPolo/Models/Chiamate_out.cs new file mode 100644 index 0000000..61db271 --- /dev/null +++ b/ApiPolo/Models/Chiamate_out.cs @@ -0,0 +1,305 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// ViSTA Chiamate + [Keyless] + public class Chiamate_out + { + /// Azienda + public string? chcodazi { get; set; } + + /// + /// Seriale Chiamata + /// + public string? chserial { get; set; } + + /// + /// Stato chiamata + /// + public string? chstato { get; set; } + + /// + /// Codice Chiamatista assegnato + /// + public string? chtchiam { get; set; } + + /// + /// Data appuntamento chiamata + /// + public DateTime? chdtapp { get; set; } + + /// + /// Ora appuntamento inizio + /// + public int? choraaPI { get; set; } + + /// + /// Minuti appuntamento inizio + /// + public int? chminapi { get; set; } + + /// + /// Note appuntamento + /// + public string? chnote { get; set; } + + /// + /// Codice Impianto chiamata + /// + public string? chcodimp { get; set; } + + /// + /// Descrizione codice segnalazione + /// + public string? csdescr { get; set; } + + /// + /// Telefono cliente + /// + public string? antelefo { get; set; } + + /// + /// descrizione cliente + /// + public string? andescri { get; set; } + + /// + /// Indirizzo impianto tipo + /// + /// Via,Piazza, + public string? imindiri1 { get; set; } + + /// + /// Indirizzo impianto nome + /// + public string? imindiri2 { get; set; } + + /// + /// Indirizzo impianto numero + /// + public int? imindiri3 { get; set; } + + /// + /// Indirizzo impianto sottonumero + /// + public string? imindiri4 { get; set; } + + /// + /// Indirizzo impianto Scala + /// + public string? imindiri5 { get; set; } + + /// + /// Indirizzo impianto località + /// + public string? imlocali { get; set; } + + /// + /// Indirizzo impianto Cap + /// + public string? imcodcap { get; set; } + + /// + /// Indirizzo impianto comune + /// + public string? imcomune { get; set; } + + /// + /// Indirizzo impianto provincia + /// + public string? improvin { get; set; } + + /// + /// Indirizzo impianto nazione + /// + public string? imcodnaz { get; set; } + + /// + /// matricola impianto + /// + public string? immatric { get; set; } + + /// + /// numero impianto + /// + public string? imnumimp { get; set; } + + /// + /// ubicazione impianto + /// + public string? imubicaz { get; set; } + + /// + /// Tecnico descrizione + /// + public string? tcdescri { get; set; } + + /// + /// Tecnico codice + /// + public string? tccodice { get; set; } + + /*campi di RAPP_NEW*/ + + + /// + /// RAPP_NEW: seriale rapp_new preso in carico + /// + public string? ser_rapp_ic { get; set; } + + /// + /// RAPP_NEW: tipo rapp_new preso in carico (valore vuoto) + /// + public string? tipo_rapp_ic { get; set; } + + /// + /// RAPP_NEW: preso in carico (S o NULL) + /// + public string? ic { get; set; } + + /// + /// RAPP_NEW: seriale rapp_new rifiutata + /// + public string? ser_rapp_rif { get; set; } + + /// + /// RAPP_NEW: tipo rapp rifiutata (valore vuoto) + /// + public string? tipo_rapp_rif { get; set; } + + /// + /// RAPP_NEW: rifiutato (S o null) + /// + public string? rif { get; set; } + + /// + /// RAPP_NEW: seriale chiamata chiusa + /// + public string? ser_rapp_chiu { get; set; } + + /// + /// RAPP_NEW: tipo chiamata chiusa (3 o null) + /// + public string? tipo_rapp_chiu { get; set; } + + /// + /// RAPP_NEW: seriale buono chiamata chiusa + /// + public string? ser_buono_chiu { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + + /// + /// altri dati chiamata + /// + + + /// Esercizio + public string? chcodese { get; set; } + + /// Tipo + public string? chtipo { get; set; } + + /// numero chiamata + [Column(TypeName = "decimal(10, 0)")] + public decimal? chnumero { get; set; } + + /// Data inserimento chiamata + public DateTime? chdata { get; set; } + + /// Ora inserimento chiamata + public int? chora { get; set; } + + /// Minuti inserimento chiamata + public int? chmin { get; set; } + + /// operatore assegnazione + public int? chopass { get; set; } + + /// operatore di chiusura + public int? chopchi { get; set; } + + /// azienda impianto + public string? chaziimp { get; set; } + + /// ora appuntamento fine + public int? choraapf { get; set; } + + /// minuto appuntamento fine + public int? chminapf { get; set; } + + /// Riferimento chiamata + public string? chrifer { get; set; } + + /// telefono riferimento + public string? chtelef { get; set; } + + /// tcodice segnalazione + public string? chcodseg { get; set; } + + /// altri campi + public Dictionary? altri { get; set; } + + /// Codice cliente + public string? ancodice { get; set; } + + /// costo chiamata + [Column(TypeName = "decimal(18, 4)")] + public decimal? chiamata { get; set; } + + /// spese viaggio + [Column(TypeName = "decimal(18, 4)")] + public decimal? spe_viaggio { get; set; } + + /// costo orario ordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_ordinario { get; set; } + + /// costo orario notturno + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_notturno { get; set; } + + /// costo orario straordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_straordinario { get; set; } + + /// costo orario festivo + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_festivo { get; set; } + + /// Azienda di riferimento associata all'impianto (gestione loghi differenti) + public string? imazirif { get; set; } + + /// riferimento impianto (va su rapportino) + public string? imrefref { get; set; } + + /// indirizzo stampa (html) su buono + public string? indirizzo_stampa { get; set; } + + /// impianto per lista (html) + public string? impianto_list { get; set; } + + /// riferimento impianto (html) su buono + public string? riferimento_impianto { get; set; } + + + + } +} + + diff --git a/ApiPolo/Models/Chiusure.cs b/ApiPolo/Models/Chiusure.cs new file mode 100644 index 0000000..505ef9c --- /dev/null +++ b/ApiPolo/Models/Chiusure.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// Chiusure + [Keyless] + public class Chiusure + { + /// codice chiusura + public string? cccodice { get; set; } + + /// descrizione + public string? ccdescr { get; set; } + + /// ccrapabi + public int ccrapabi { get; set; } + + /// obbligatoria + public int ccrapobb { get; set; } + + /// ccchiint + public string? ccchiint { get; set; } + + /// azienda + public string? cccodazi { get; set; } + + /// Descrizione supplementare da mettere sul rapportino + public string? ccdessup { get; set; } + + /// Contiena la lista di tipologie di manutenzione associate a quel codice + public List? tipologieMan { get; set; } + + } + +} diff --git a/ApiPolo/Models/ChiusureTable.cs b/ApiPolo/Models/ChiusureTable.cs new file mode 100644 index 0000000..96d496a --- /dev/null +++ b/ApiPolo/Models/ChiusureTable.cs @@ -0,0 +1,80 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// (Virtual Task) Contiene i campi di CCHIUSA + /// + public class ChiusureTable + { + /// + [Key] + public string? cccodazi { get; set; } + + /// + [Key] + public string? cccodice { get; set; } + + /// + public string? ccdescr { get; set; } + + /// + public string? ccflfatt { get; set; } + + /// + public string? ccflrep { get; set; } + + /// + public string? ccdessup { get; set; } + + /// + public string? cctipcod { get; set; } + + /// + public string? ccgruppo { get; set; } + + /// + [Column(TypeName = "decimal(18, 4)")] + public decimal? ccimpint { get; set; } + + /// + [Column(TypeName = "decimal(18, 4)")] + public decimal? ccimpman { get; set; } + + /// + public string? ccserint { get; set; } + + /// + public string? ccserman { get; set; } + + /// + [Column(TypeName = "decimal(4, 1)")] + public decimal? ccnumore { get; set; } + + /// + [Column(TypeName = "decimal(6, 2)")] + public decimal? ccperman { get; set; } + + /// + [Column(TypeName = "decimal(4, 1)")] + public decimal? corecom { get; set; } + + /// + public DateTime? codtobso { get; set; } + + /// + public int? ccrapabi { get; set; } + + /// + public int? ccrapobb { get; set; } + + /// + public string? ccriapre { get; set; } + + /// + public string? ccchiint { get; set; } + + } +} diff --git a/ApiPolo/Models/CodiceSegnalazione.cs b/ApiPolo/Models/CodiceSegnalazione.cs new file mode 100644 index 0000000..abc1d5d --- /dev/null +++ b/ApiPolo/Models/CodiceSegnalazione.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; + +namespace Api_VT.Models +{ + public class CodiceSegnalazione + { + /// codice segnalazione + [Key] + public string? cscodice { get; set; } + /// descrizione + public string? csdescr { get; set; } + public string? csferimp { get; set; } + /// azienda + [Key] + public string? cscodazi { get; set; } + /// tipo segnalazione + public string? cstipseg { get; set; } + + public DateTime? DataObso { get; set; } + } +} diff --git a/ApiPolo/Models/Commessa.cs b/ApiPolo/Models/Commessa.cs new file mode 100644 index 0000000..8cd2bfb --- /dev/null +++ b/ApiPolo/Models/Commessa.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// ViSTA API_COMMESSE + [Keyless] + public class Commessa + { + /// seriale Commessa + public string? laserial { get; set; } + + /// Codice Commessa + public string? lacodcom { get; set; } + + /// Fase Commessa + public string? ladeslav { get; set; } + + /// data fine validita Commessa + public DateTime? ladatchi { get; set; } + + /// tipo + public string? latipcli { get; set; } + + /// codice cliente + public string? lacodcli { get; set; } + + /// descrizione cliente + public string? andescri { get; set; } + + /// impianto + public string? imcodimp { get; set; } + + /// tipo ind + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero + public int? imindiri3 { get; set; } + + /// lettera + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// CAP + public string? imcodcap { get; set; } + + /// provincia + public string? improvin { get; set; } + + } +} diff --git a/ApiPolo/Models/CommessaDesc.cs b/ApiPolo/Models/CommessaDesc.cs new file mode 100644 index 0000000..9729b75 --- /dev/null +++ b/ApiPolo/Models/CommessaDesc.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Descrizione commessa per SIET + public class CommessaDesc + { + /// seriale Commessa + [Key] + public string? laserial { get; set; } + + /// tipo lavorazione + public string? latiplav { get; set; } + + /// centro di costo - ticket + public string? lacodcen { get; set; } + + /// Codice commessa + public string? lacodcom { get; set; } + + /// Codice tecnico associato alla commessa + public string? latecsup { get; set; } + } +} diff --git a/ApiPolo/Models/Commessa_out.cs b/ApiPolo/Models/Commessa_out.cs new file mode 100644 index 0000000..23e0eb1 --- /dev/null +++ b/ApiPolo/Models/Commessa_out.cs @@ -0,0 +1,66 @@ +namespace ApiPolo.Models +{ + /// ViSTA API_COMMESSE + public class Commessa_out + { + /// Codice Commessa + public string? cncodcan { get; set; } + + /// Descrizione Commessa + public string? cndescan { get; set; } + + /// data fine validita Commessa + public DateTime? cndatfin { get; set; } + + /// tipo + public string? cntipcon { get; set; } + + /// codice cliente + public string? cncodcon { get; set; } + + /// descrizione cliente + public string? andescri { get; set; } + + /// impianto + public string? imcodimp { get; set; } + + /// tipo ind + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero + public int? imindiri3 { get; set; } + + /// lettera + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// CAP + public string? imcodcap { get; set; } + + /// provincia + public string? improvin { get; set; } + + + + + /// elemento lista formato html + public string? itemList { get; set; } + + /// Error title + public string? err_title { get; set; } + + /// Error deatail + public string? err_detail { get; set; } + + /// Error code + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/CommesseAdHoc_out.cs b/ApiPolo/Models/CommesseAdHoc_out.cs new file mode 100644 index 0000000..7cb55c6 --- /dev/null +++ b/ApiPolo/Models/CommesseAdHoc_out.cs @@ -0,0 +1,67 @@ +namespace ApiPolo.Models +{ + /// Oggetto uscita Commessa Lift + public class CommesseAdHoc_out + { + /// seriale Commessa + public string? laserial { get; set; } + + /// Codice Commessa + public string? lacodcom { get; set; } + + /// Fase Commessa + public string? ladeslav { get; set; } + + /// data fine validita Commessa + public DateTime? ladatchi { get; set; } + + /// tipo + public string? latipcli { get; set; } + + /// codice cliente + public string? lacodcli { get; set; } + + /// descrizione cliente + public string? andescri { get; set; } + + /// impianto + public string? imcodimp { get; set; } + + /// tipo ind + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero + public int? imindiri3 { get; set; } + + /// lettera + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// CAP + public string? imcodcap { get; set; } + + /// provincia + public string? improvin { get; set; } + + + /// elemento lista formato html + public string? itemList { get; set; } + + /// Error title + public string? err_title { get; set; } + + /// Error deatail + public string? err_detail { get; set; } + + /// Error code + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/CommesseVT.cs b/ApiPolo/Models/CommesseVT.cs new file mode 100644 index 0000000..8b46b41 --- /dev/null +++ b/ApiPolo/Models/CommesseVT.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// ViSTA API_COMMESSE - VT + [Keyless] + public class CommesseVT + { + /// seriale Commessa + public string? laserial { get; set; } + + /// Azienda + public string? lacodazi { get; set; } + + /// Codice Commessa + public string? lacodcom { get; set; } + + /// Fase Commessa + public string? ladeslav { get; set; } + + /// data fine validita Commessa + public DateTime? ladatchi { get; set; } + + /// tipo + public string? latipcli { get; set; } + + /// codice cliente + public string? lacodcli { get; set; } + + /// descrizione cliente + public string? andescri { get; set; } + + /// impianto + public string? imcodimp { get; set; } + + /// tipo ind + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero + public int? imindiri3 { get; set; } + + /// lettera + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// CAP + public string? imcodcap { get; set; } + + /// provincia + public string? improvin { get; set; } + + /// codice impianto - commesse + public string? lacodimp { get; set; } + + /// flag commessa generica cliente + public string? lacomgen { get; set; } + } +} diff --git a/ApiPolo/Models/CommesseVT_Table.cs b/ApiPolo/Models/CommesseVT_Table.cs new file mode 100644 index 0000000..df17a9a --- /dev/null +++ b/ApiPolo/Models/CommesseVT_Table.cs @@ -0,0 +1,37 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// seriale Commessa + public class CommesseVT_Table + { + /// seriale Commessa + [Key] + public string? laserial { get; set; } + + /// Azienda + [Key] + public string? lacodazi { get; set; } + + /// Codice Commessa + public string? lacodcom { get; set; } + + /// Fase Commessa + public string? ladeslav { get; set; } + + /// data fine validita Commessa + public DateTime? ladatchi { get; set; } + + /// tipo + public string? latipcli { get; set; } + + /// codice cliente + public string? lacodcli { get; set; } + + /// codice impianto + public string? lacodimp { get; set; } + + /// flag commessa generica cliente + public string? lacomgen { get; set; } + } +} diff --git a/ApiPolo/Models/Compo_Impia.cs b/ApiPolo/Models/Compo_Impia.cs new file mode 100644 index 0000000..829c903 --- /dev/null +++ b/ApiPolo/Models/Compo_Impia.cs @@ -0,0 +1,63 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di xxxMICOMIMP (componenti impianto) + /// + [Keyless] + public class Compo_Impia + { + /// + /// codice impianto + /// + public string? cocodimp { get; set; } + + /// + /// codice impianto + /// + public string? cocodazi { get; set; } + + /// + /// indice riga + /// + public int? cprownum { get; set; } + + /// + /// quantità + /// + [Column(TypeName = "decimal(10, 6)")] + public decimal? coqtaart { get; set; } + + /// + /// codice articolo + /// + public string? cocodart { get; set; } + + /// + /// note + /// + public string? co__note { get; set; } + + /// + /// lotto articolo + /// + public string? lotto { get; set; } + + /// + /// matricola articolo + /// + public string? matricola { get; set; } + + /// + /// descrizione articolo + /// + /// + public string? ardesart { get; set; } + + /// descrizione per ogni articolo (se abilitata da configurazioni) + public string? desc_sup { get; set; } + } +} diff --git a/ApiPolo/Models/Compo_Impia_Table.cs b/ApiPolo/Models/Compo_Impia_Table.cs new file mode 100644 index 0000000..87bfec3 --- /dev/null +++ b/ApiPolo/Models/Compo_Impia_Table.cs @@ -0,0 +1,55 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + /// Classe componenti per scrittura db + /// + public class Compo_Impia_Table + { + /// + /// codice impianto + /// + [Key] + public string? cocodimp { get; set; } + + /// + /// codice impianto + /// + [Key] + public string? cocodazi { get; set; } + + /// + /// indice riga + /// + [Key] + public int? cprownum { get; set; } + + /// + /// codice articolo + /// + [Column(TypeName = "decimal(10, 6)")] + public decimal? coqtaart { get; set; } + + /// + /// codice articolo + /// + public string? cocodart { get; set; } + + /// + /// note + /// + public string? co__note { get; set; } + + /// + /// lotto articolo + /// + public string? pilotto { get; set; } + + /// + /// matricola articolo + /// + public string? pimatric { get; set; } + } +} diff --git a/ApiPolo/Models/Compo_Impia_out.cs b/ApiPolo/Models/Compo_Impia_out.cs new file mode 100644 index 0000000..12c5b0b --- /dev/null +++ b/ApiPolo/Models/Compo_Impia_out.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di xxxMICOMIMP (componenti impianto) oggetto di output + /// + [Keyless] + public class Compo_Impia_out + { + /// + /// codice impianto + /// + public string? cocodimp { get; set; } + + /// + /// codice impianto + /// + public string? cocodazi { get; set; } + + /// + /// indice riga + /// + public int? cprownum { get; set; } + + /// + /// codice articolo + /// + [Column(TypeName = "decimal(10, 6)")] + public decimal? coqtaart { get; set; } + + /// + /// codice articolo + /// + public string? cocodart { get; set; } + + /// + /// note + /// + public string? co__note { get; set; } + + /// + /// lotto articolo + /// + public string? lotto { get; set; } + + /// + /// matricola articolo + /// + public string? matricola { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + + } +} diff --git a/ApiPolo/Models/Configurazione_out.cs b/ApiPolo/Models/Configurazione_out.cs new file mode 100644 index 0000000..2fb3523 --- /dev/null +++ b/ApiPolo/Models/Configurazione_out.cs @@ -0,0 +1,216 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class Configurazione_out + { + /// azienda + public string? azienda { get; set; } + + /// path file buoni (immagini rapportini) + public string? path_buoni { get; set; } + + /// prefisso dei buoni da chiamata + public string? prefisso_buoni_chia { get; set; } + + /// prefisso dei buoni da mauntenzione + public string? prefisso_buoni_man { get; set; } + + /// url ftp per upload delle immagini + public string? ftp_url { get; set; } + + /// utente ftp per upload delle immagini + public string? ftp_usr { get; set; } + + /// password ftp per upload delle immagini + public string? ftp_pwd { get; set; } + + /// Listino articoli per magazzino + public string? listino { get; set; } + + /// pulsante naviga nelle liste + public bool? abilita_naviga { get; set; } + + /// pulsante telefona nelle liste + public bool? abilita_telefona { get; set; } + + /// abilita funzione + public bool? abilita_chiamate { get; set; } + + /// abilita funzione + public bool? abilita_manutenzioni { get; set; } + + /// barcode abilitato opzionalmente in varie sezioni. Per renderlo obbligatorio vedi flag sott + public bool? abilita_barcode { get; set; } + + /// + public bool? chiamate_accetta { get; set; } + + /// barcode obbligatorio + public bool? chiamate_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_accetta_offline { get; set; } + + /// abilita funzione + public bool? chiamate_rifiuta { get; set; } + + /// hiamate_rifiuta_barcode + public bool? chiamate_rifiuta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_rifiuta_offline { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_salva_barcode { get; set; } + + /// abilita funzione + public bool? manutenzioni_accetta { get; set; } + + /// funziona anche offline + public bool? chiamate_chiudi_salva_offline { get; set; } + + /// abilita funzione + public bool? manutenzioni_rifiuta { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_accetta_offline { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_salva_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_chiudi_salva_offline { get; set; } + + /// chiede presena DPI prima di scheda + public bool? dpi_checkbox { get; set; } + + /// visualizza anagrafica + public bool? anagrafica { get; set; } + + /// abilita stato impianto + public bool? stato_finale { get; set; } + + /// abilita + public bool? descrizione_intervento { get; set; } + + /// abilita + public bool? composizione_impianto { get; set; } + + /// abilita + public bool? note_intervento { get; set; } + + /// abilita + public bool? esito_intervento { get; set; } + + /// abilita + public bool? ora_inizio_fine { get; set; } + + /// abilita + public bool? materiali { get; set; } + + /// abilita + public bool? diritto_chiamata { get; set; } + + /// abilita + public bool? manodopera { get; set; } + + /// abilita + public bool? spese_viaggio { get; set; } + + /// abilita + public bool? tipo_pagamento { get; set; } + + /// abilita + public bool? note_pagamento { get; set; } + + /// abilita + public bool? causale { get; set; } + + /// abilita + public bool? time_sheet { get; set; } + + /// abilita + public bool? time_sheet_offline { get; set; } + + /// Costo orario intervento + [Column(TypeName = "decimal(8, 3)")] + public decimal? costo_orario { get; set; } + + /// porta ftp + public int? ftp_port { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_rifiuta_barcode { get; set; } + + /// storico rapportini + public bool? storico { get; set; } + + /// storico impianto + public bool? storico_tecnico { get; set; } + + /// Abilita link storico interventi + public bool? storico_interventi { get; set; } + + /// Abilita link ricerca impianti + public bool? ricerca_impianti { get; set; } + + /// Abilita link storico impianto (solo per chi gestisce il magazzino) + public bool? storico_impianto { get; set; } + + /// Calcolo tempo rapportino automatico + public bool? ora_inizio_fine_automatica { get; set; } + + /// Stampa ora inizio-fine su buono + public bool? stampa_orario { get; set; } + + /// Stampa intestazione su buono + public string? intestazione_stampa { get; set; } + + + /// Seriale chiamata da usare come teplate per inserire chiamata da app (commessa o normale) + public string? seriale_template_chi { get; set; } + + /// 0=non abilitata 1,2,3=abilitata + public Int16? abilita_inserimento_chiamate { get; set; } + + /// Data rapportino editabile + public bool? abilita_data_rapp_edit { get; set; } + + /// articoli impianto in forma decimale + public Int16? numeri_decimali { get; set; } + + /// max num record in ricerca + public int? max_record { get; set; } + + /// storico impianto + public List? aziende_coll { get; set; } + + /// Error Message + public string? err_title { get; set; } + + /// Error Message detail + public string? err_detail { get; set; } + + /// Status + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Configurazioni.cs b/ApiPolo/Models/Configurazioni.cs new file mode 100644 index 0000000..a50ec5f --- /dev/null +++ b/ApiPolo/Models/Configurazioni.cs @@ -0,0 +1,223 @@ +using Microsoft.AspNetCore.Components.RenderTree; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// Configurazioni + public class Configurazioni + { + /// azienda + [Key] + public string? azienda { get; set; } + + /// path file buoni (immagini rapportini) + public string? path_buoni { get; set; } + + /// prefisso dei buoni da chiamata + public string? prefisso_buoni_chia { get; set; } + + /// prefisso dei buoni da mauntenzione + public string? prefisso_buoni_man { get; set; } + + /// url ftp per upload delle immagini + public string? ftp_url { get; set; } + + /// utente ftp per upload delle immagini + public string? ftp_usr { get; set; } + + /// password ftp per upload delle immagini + public string? ftp_pwd { get; set; } + + /// Listino articoli per magazzino + public string? listino { get; set; } + + /// pulsante naviga nelle liste + public bool? abilita_naviga { get; set; } + + /// pulsante telefona nelle liste + public bool? abilita_telefona { get; set; } + + /// abilita funzione + public bool? abilita_chiamate { get; set; } + + /// abilita funzione + public bool? abilita_manutenzioni { get; set; } + + /// barcode abilitato opzionalmente in varie sezioni. Per renderlo obbligatorio vedi flag sott + public bool? abilita_barcode { get; set; } + + /// + public bool? chiamate_accetta { get; set; } + + /// barcode obbligatorio + public bool? chiamate_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_accetta_offline { get; set; } + + /// abilita funzione + public bool? chiamate_rifiuta { get; set; } + + /// hiamate_rifiuta_barcode + public bool? chiamate_rifiuta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_rifiuta_offline { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_salva_barcode { get; set; } + + /// abilita funzione + public bool? manutenzioni_accetta { get; set; } + + /// funziona anche offline + public bool? chiamate_chiudi_salva_offline { get; set; } + + /// abilita funzione + public bool? manutenzioni_rifiuta { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_accetta_offline { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_salva_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_chiudi_salva_offline { get; set; } + + /// chiede presena DPI prima di scheda + public bool? dpi_checkbox { get; set; } + + /// visualizza anagrafica + public bool? anagrafica { get; set; } + + /// abilita stato impianto + public bool? stato_finale { get; set; } + + /// abilita + public bool? descrizione_intervento { get; set; } + + /// abilita + public bool? composizione_impianto { get; set; } + + /// abilita + public bool? note_intervento { get; set; } + + /// abilita + public bool? esito_intervento { get; set; } + + /// abilita + public bool? ora_inizio_fine { get; set; } + + /// abilita + public bool? materiali { get; set; } + + /// abilita + public bool? diritto_chiamata { get; set; } + + /// abilita + public bool? manodopera { get; set; } + + /// abilita + public bool? spese_viaggio { get; set; } + + /// abilita + public bool? tipo_pagamento { get; set; } + + /// abilita + public bool? note_pagamento { get; set; } + + /// abilita + public bool? causale { get; set; } + + /// abilita + public bool? time_sheet { get; set; } + + /// abilita + public bool? time_sheet_offline { get; set; } + + /// Costo orario intervento + [Column(TypeName = "decimal(8, 3)")] + public decimal? costo_orario { get; set; } + + /// porta ftp + public int? ftp_port { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_rifiuta_barcode { get; set; } + + /// OBSOLETO + public bool? storico { get; set; } + + /// OBSOLETO + public bool? storico_tecnico { get; set; } + + + + + /// Abilita link storico interventi + public bool? storico_interventi { get; set; } + + /// Abilita link ricerca impianti + public bool? ricerca_impianti { get; set; } + + /// Abilita link storico impianto (solo per chi gestisce il magazzino) + public bool? storico_impianto { get; set; } + + /// Calcolo tempo rapportino automatico + public bool? ora_inizio_fine_automatica { get; set; } + + /// Stampa ora inizio-fine su buono + public bool? stampa_orario { get; set; } + + /// Stampa intestazione su buono + public string? intestazione_stampa { get; set; } + + /// Seriale chiamata da usare come teplate per inserire chiamata da app (commessa o normale) + public string? seriale_template_chi { get; set; } + + /// 0=non abilitata 1,2,3=abilitata + public Int16? abilita_inserimento_chiamate { get; set; } + + /// data rapportino editabile + public bool? abilita_data_rapp_edit { get; set; } + + /// articoli impianto in forma decimale se valore maggiore di 1 e la cifra indica il numero di cifre decimali, altrimenti sono numeri interi + public Int16? numeri_decimali { get; set; } + + /// max num record in ricerca + public int? max_record { get; set; } + + /// rende visibile la riga dei prezzi sul rapportino + public bool? prezzi_visibili { get; set; } + + /// rende visibile la riga dei prezzi sul rapportino + public bool? desc_supp_prodotti_visibile { get; set; } + + /// Azienda adhoc + public string? azienda_adhoc { get; set; } + + /// stampa note intervento nel buono + public bool? note_interv_stampa { get; set; } + + /// stampa note intervento nel buono + public bool? desc_interv_stampa { get; set; } + + } +} diff --git a/ApiPolo/Models/ConfigurazioniDbContext.cs b/ApiPolo/Models/ConfigurazioniDbContext.cs new file mode 100644 index 0000000..6992a47 --- /dev/null +++ b/ApiPolo/Models/ConfigurazioniDbContext.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// ConfigurazioniDbContext + public class ConfigurazioniDbContext : DbContext + { + /// conf + public DbSet? conf { get; set; } + + /// ConfigurazioniDbContext + public ConfigurazioniDbContext(DbContextOptions options) : base(options) + { + } + /// OnModelCreating + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("Configurazioni"); + } + } +} diff --git a/ApiPolo/Models/DatiAzienda.cs b/ApiPolo/Models/DatiAzienda.cs new file mode 100644 index 0000000..455da9f --- /dev/null +++ b/ApiPolo/Models/DatiAzienda.cs @@ -0,0 +1,31 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + public class DatiAzienda + { + /// azienda + [Key] + public string? azienda { get; set; } + + /// tecnico + [Key] + public string? tecnico { get; set; } + + /// Denominazione + public string? ragsoc { get; set; } + + /// url del logo esposto + public string? url_logo { get; set; } + + /// logo + //[NotMapped] + //public IFormFile? logo { get; set; } + public byte[]? logo { get; set; } + + /// testo azienda rapportino + public string? testo_buono { get; set; } + } +} diff --git a/ApiPolo/Models/Error.cs b/ApiPolo/Models/Error.cs new file mode 100644 index 0000000..090fd6f --- /dev/null +++ b/ApiPolo/Models/Error.cs @@ -0,0 +1,15 @@ +namespace ApiPolo.Models +{ + /// Error + public class Error + { + /// Error title + public string? err_title { get; set; } + + /// Error deatail + public string? err_detail { get; set; } + + /// Error code + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Impianto.cs b/ApiPolo/Models/Impianto.cs new file mode 100644 index 0000000..1dbd476 --- /dev/null +++ b/ApiPolo/Models/Impianto.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// Impianto + [Keyless] + public class Impianto + { + /// Codice Impianto + public string? imcodimp { get; set; } + + /// Descrizione Impianto + public string? imdescri { get; set; } + + /// Tipo indirizzo (Via, piazza..) + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero civico + public int? imindiri3 { get; set; } + + /// sottonumero + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// Cap + public string? imcodcap { get; set; } + + /// Comune + public string? imcomune { get; set; } + + /// Provincia + public string? improvin { get; set; } + + /// Azienda + public string? imcodazi { get; set; } + + /// cod cliente + public string? imultcli { get; set; } + + /// descrizione cliente + public string? descCliente { get; set; } + + /// Data cancellazione + public DateTime? imfinatt { get; set; } + + /// rif impianto + public string? imrefref { get; set; } + } +} diff --git a/ApiPolo/Models/ImpiantoTable.cs b/ApiPolo/Models/ImpiantoTable.cs new file mode 100644 index 0000000..29b28cf --- /dev/null +++ b/ApiPolo/Models/ImpiantoTable.cs @@ -0,0 +1,52 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class ImpiantoTable + { + /// Codice Impianto + [Key] + public string? imcodimp { get; set; } + + /// Azienda + [Key] + public string? imcodazi { get; set; } + + /// Descrizione Impianto + public string? imdescri { get; set; } + + /// Tipo indirizzo (Via, piazza..) + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero civico + public int? imindiri3 { get; set; } + + /// sottonumero + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? imlocali { get; set; } + + /// Cap + public string? imcodcap { get; set; } + + /// Comune + public string? imcomune { get; set; } + + /// Provincia + public string? improvin { get; set; } + + /// cliente associato + public string? imultcli { get; set; } + + /// Data cancellazione + public DateTime? imfinatt { get; set; } + } +} diff --git a/ApiPolo/Models/Impianto_out.cs b/ApiPolo/Models/Impianto_out.cs new file mode 100644 index 0000000..9d7d921 --- /dev/null +++ b/ApiPolo/Models/Impianto_out.cs @@ -0,0 +1,36 @@ +namespace ApiPolo.Models +{ + /// Impianto out + public class Impianto_out + { + /// Codice Impianto + public string? codimp { get; set; } + + /// Codice Impianto + public string? descimp { get; set; } + + /// Indirizzo Impianto + public string? indiri { get; set; } + + /// Cap + public string? cap { get; set; } + + /// Comune + public string? comune { get; set; } + + /// Provincia + public string? provin { get; set; } + + /// Località + public string? localita { get; set; } + + /// Error title + public string? err_title { get; set; } + + /// Error deatail + public string? err_detail { get; set; } + + /// Error code + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Input.cs b/ApiPolo/Models/Input.cs new file mode 100644 index 0000000..896a67b --- /dev/null +++ b/ApiPolo/Models/Input.cs @@ -0,0 +1,313 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di input sia per RAPP_NEW che per PRESE + /// + public class Input + { + #region RAPPNEW + + /// + /// Tabella RAPP_NEW: Seriale rapportini + /// + public string? seriale_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Tipo rapportini + /// + public string? tipo_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Azienda + /// + public string? azienda_impianto { get; set; } + + /// + /// Tabella RAPP_NEW: Codice Impianto + /// + public string? codice_impianto { get; set; } + + /// + /// Tabella RAPP_NEW: Azienda su cui è la chiamata + /// + public string? azienda_chiamata { get; set; } + + /// + /// Tabella RAPP_NEW: Seriale chiamata + /// + public string? seriale_chiamata { get; set; } + + /// + /// Tabella RAPP_NEW: Seriale chiamata + /// + public string? seriale_commessa { get; set; } + + /// + /// Tabella RAPP_NEW: Data rapportino + /// + public DateTime? data_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Ora inizio + /// + public string? ora_ini_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Tabella RAPP_NEW: minuto inizio + /// + public string? min_ini_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Ora fine + /// + public string? ora_fin_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: Minuto fine + /// + public string? min_fin_rapportino { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_1 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_2 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_3 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_4 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_5 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_6 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_7 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_8 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_9 { get; set; } + + /// + /// Tabella RAPP_NEW: codice chiusura + /// + public string? codice_chiusura_10 { get; set; } + + /// + /// Tabella RAPP_NEW: descrizione intervento + /// + public string? descrizione_intervento { get; set; } + + /// + /// Tabella RAPP_NEW: stato + /// + public string? stato_finale { get; set; } + + /// + /// Tabella RAPP_NEW: generato + /// + public string? generato { get; set; } + + /// + /// Tabella RAPP_NEW: azienda tecnico + /// + public string? azienda_tecnico { get; set; } + + /// + /// Tabella RAPP_NEW: codice tecnico + /// + public string? codice_tecnico { get; set; } + + /// + /// Tabella RAPP_NEW: flag rifiutata + /// + public string? rifiutata { get; set; } + + /// + ///Tabella RAPP_NEW: nominativo firma + /// + public string? firma { get; set; } + + /// + /// Tabella RAPP_NEW: flag stato In Carico + /// + public string? incarico { get; set; } + + /// + /// Tabella RAPP_NEW: data validità + /// + public DateTime? data_validita { get; set; } + + /// + /// Tabella RAPP_NEW: pathg immagine buono o firma + /// + public string? immagine { get; set; } + + /// + /// Tabella RAPP_NEW: seriale del buono + /// + public string? ser_buono { get; set; } + + /// + /// Tabella RAPP_NEW: seriale del buono + /// + public string? codice_intervento { get; set; } + + /// + /// Tabella RAPP_NEW: data/ora effettiva del lavoro (nel caso dispositivo offline) + /// + public DateTime? data_effettiva { get; set; } + #endregion + + #region PRESE + /// Tabella PRESE: Azienda + public string? picodazi { get; set; } + + /// Tabella PRESE: Impianto + public string? pimpianto { get; set; } + + /// Tabella PRESE: Codice intervento QUI=? SEM=SEMESTRALE + public string? picodint { get; set; } + + /// Tabella PRESE: Tecnico + public string? picodtec { get; set; } + + /// Tabella PRESE: data della manutenzione + public DateTime? pidatman { get; set; } + + /// Tabella PRESE: Zona manutenzione + public string? pizona { get; set; } + + /// Tabella PRESE: check presa + public string? pichkpre { get; set; } + #endregion + + #region Campi aggiunti + /// + public string? difetti_riscontrati { get; set; } + + /// + public string? lavoro_eseguito { get; set; } + + /// + public string? esito_intervento { get; set; } + + /// + public string? note_intervento { get; set; } + + /// + public string? note_esito { get; set; } + + /// + public string? nuovo_contratto { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public int? ore_lavoro { get; set; } + + /// + public string? causale { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// + public string? pagamento { get; set; } + + /// + [Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// + [Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } + + /// + public string? note_pagamento { get; set; } + + /// + public string? tipo_intervento { get; set; } + + /// + public string? rafoto1 { get; set; } + + /// + public string? rafoto2 { get; set; } + + /// + public string? rafoto3 { get; set; } + + /// + public string? rafoto4 { get; set; } + + /// + public string? rafoto5 { get; set; } + + /// + public string? rafoto6 { get; set; } + + /// + public string? rafoto7 { get; set; } + + /// + public string? rafoto8 { get; set; } + + /// + public string? rafoto9 { get; set; } + + /// + public string? rafoto10 { get; set; } + + + #endregion + + #region Componenti impianto + /// Componenti impianto aggiunti + public List? compo_add { get; set; } + + /// Componenti impianto eliminati + public List? compo_del { get; set; } + #endregion + + + } +} diff --git a/ApiPolo/Models/LoginModel.cs b/ApiPolo/Models/LoginModel.cs new file mode 100644 index 0000000..059fd98 --- /dev/null +++ b/ApiPolo/Models/LoginModel.cs @@ -0,0 +1,15 @@ +namespace ApiPolo.Models +{ + /// LoginModel + public class LoginModel + { + /// Username + public string? Username { get; set; } + + /// Password + public string? Password { get; set; } + + /// Tenant + public string? Tenant { get; set; } + } +} diff --git a/ApiPolo/Models/LoginOut.cs b/ApiPolo/Models/LoginOut.cs new file mode 100644 index 0000000..0834a98 --- /dev/null +++ b/ApiPolo/Models/LoginOut.cs @@ -0,0 +1,231 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// Conf (configurazioni app) + public class Conf + { + /// pulsante naviga nelle liste + public bool? abilita_naviga { get; set; } + + /// pulsante telefona nelle liste + public bool? abilita_telefona { get; set; } + + /// abilita funzione + public bool? abilita_chiamate { get; set; } + + /// abilita funzione + public bool? abilita_manutenzioni { get; set; } + + /// barcode abilitato opzionalmente in varie sezioni. Per renderlo obbligatorio vedi flag sott + public bool? abilita_barcode { get; set; } + + /// + public bool? chiamate_accetta { get; set; } + + /// barcode obbligatorio + public bool? chiamate_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_accetta_offline { get; set; } + + /// abilita funzione + public bool? chiamate_rifiuta { get; set; } + + /// hiamate_rifiuta_barcode + public bool? chiamate_rifiuta_barcode { get; set; } + + /// funziona anche offline + public bool? chiamate_rifiuta_offline { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? chiamate_chiudi_salva_barcode { get; set; } + + /// abilita funzione + public bool? manutenzioni_accetta { get; set; } + + /// funziona anche offline + public bool? chiamate_chiudi_salva_offline { get; set; } + + /// abilita funzione + public bool? manutenzioni_rifiuta { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_accetta_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_accetta_offline { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_firma_barcode { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_chiudi_salva_barcode { get; set; } + + /// funziona anche offline + public bool? manutenzioni_chiudi_salva_offline { get; set; } + + /// chiede presena DPI prima di scheda + public bool? dpi_checkbox { get; set; } + + /// anagrafica visualizza anagrafica + public bool? anagrafica { get; set; } + + /// abilita stato impianto + public bool? stato_finale { get; set; } + + /// abilita + public bool? descrizione_intervento { get; set; } + + /// abilita + public bool? composizione_impianto { get; set; } + + /// abilita + public bool? note_intervento { get; set; } + + /// abilita + public bool? esito_intervento { get; set; } + + /// abilita + public bool? ora_inizio_fine { get; set; } + + /// abilita + public bool? materiali { get; set; } + + /// abilita + public bool? diritto_chiamata { get; set; } + + /// abilita + public bool? manodopera { get; set; } + + /// abilita + public bool? spese_viaggio { get; set; } + + /// abilita + public bool? tipo_pagamento { get; set; } + + /// abilita + public bool? note_pagamento { get; set; } + + /// abilita + public bool? causale { get; set; } + + /// abilita + public bool? time_sheet { get; set; } + + /// abilita + public bool? time_sheet_offline { get; set; } + + /// Costo orario intervento + [Column(TypeName = "decimal(8, 3)")] + public decimal? costo_orario { get; set; } + + /// porta ftp + public int? ftp_port { get; set; } + + /// barcode obbligatorio + public bool? manutenzioni_rifiuta_barcode { get; set; } + + /// storico rapportini abilita + public bool? storico { get; set; } + + /// storico impianto + public bool? storico_tecnico { get; set; } + + /// Abilita link storico interventi + public bool? storico_interventi { get; set; } + + /// Abilita link ricerca impianti + public bool? ricerca_impianti { get; set; } + + /// Abilita link storico impianto (solo per chi gestisce il magazzino) + public bool? storico_impianto { get; set; } + + /// Calcolo tempo rapportino automatico + public bool? ora_inizio_fine_automatica { get; set; } + + /// Stampa ora inizio-fine su buono + public bool? stampa_orario { get; set; } + + /// Stampa intestazione su buono + public string? intestazione_stampa { get; set; } + + /// Seriale chiamata da usare come teplate per inserire chiamata da app (commessa o normale) + public string? seriale_template_chi { get; set; } + + /// 0=non abilitata 1,2,3=abilitata + public Int16? abilita_inserimento_chiamate { get; set; } + + /// data rapportino editabile + public bool? abilita_data_rapp_edit { get; set; } + + /// articoli impianto in forma decimale + public Int16? numeri_decimali { get; set; } + + /// max num record in ricerca + public int? max_record { get; set; } + + /// rende visibile la riga dei prezzi sul rapportino + public bool? prezzi_visibili { get; set; } + + /// rende visibile la riga dei prezzi sul rapportino + public bool? desc_supp_prodotti_visibile { get; set; } + + /// Azienda adhoc + public string? azienda_adhoc { get; set; } + + /// stampa note intervento nel buono + public bool? note_interv_stampa { get; set; } + + /// stampa note intervento nel buono + public bool? desc_interv_stampa { get; set; } + + + } + /// LoginOut (token+user) + public class LoginOut + { + /// token + public string? Tok { get; set; } + + /// token + public string? Tccodice { get; set; } + + /// token + public string? Tcdescri { get; set; } + + /// token + public Conf? Config { get; set; } + + /// storico impianto + public List? aziende_coll { get; set; } + + /// Error Message + public string? err_title { get; set; } + + /// Error Message detail + public string? err_detail { get; set; } + + /// Status + public string? err_status_code { get; set; } + + /// flag admin + public string? Tcsuper { get; set; } + + /// tenant + public string? Tenant { get; set; } + + /// Identifica un utente abilitato al download dell'app + public string? tciden { get; set; } + } +} diff --git a/ApiPolo/Models/Mag_New.cs b/ApiPolo/Models/Mag_New.cs new file mode 100644 index 0000000..1b8e667 --- /dev/null +++ b/ApiPolo/Models/Mag_New.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di MAG_NEW + /// + public class Mag_New + { + /// + [Key] + public string? seriale_rapportino { get; set; } + + /// + [Key] + public int? riga { get; set; } + + /// + public string? magazzino { get; set; } + + /// + public string? articolo { get; set; } + + /// + public string? tipo_movimento { get; set; } + + /// + [Column(TypeName = "decimal(8, 3)")] + public decimal? quantita { get; set; } + + /// + [Column(TypeName = "decimal(10, 2)")] + public decimal? prezzo { get; set; } + + /// + public string? codice_tecnico { get; set; } + + /// + public string? generato { get; set; } + + /// + public string? codlotto { get; set; } + + /// + public string? matricola { get; set; } + + /// descrizione articolo + public string? desc_art { get; set; } + + /// riga impianto + public int? cprownum { get; set; } + + /// codice impianto + public string? codimp { get; set; } + + /// note + public string? note { get; set; } + + /// cpccchk + public string? cpccchk { get; set; } + + /// descrizione per ogni articolo (se abilitata da configurazioni) + public string? desc_sup { get; set; } + } +} diff --git a/ApiPolo/Models/Mag_New_out.cs b/ApiPolo/Models/Mag_New_out.cs new file mode 100644 index 0000000..e97c5ba --- /dev/null +++ b/ApiPolo/Models/Mag_New_out.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + [Keyless] + public class Mag_New_out + { + /// + public string? seriale_rapportino { get; set; } + + /// + public int? riga { get; set; } + + /// + public string? magazzino { get; set; } + + /// + public string? articolo { get; set; } + + /// + public string? tipo_movimento { get; set; } + + /// + [Column(TypeName = "decimal(10, 6)")] + public decimal? quantita { get; set; } + + /// + public decimal? prezzo { get; set; } + + /// + public string? codice_tecnico { get; set; } + + /// + public string? generato { get; set; } + + /// + public string? codlotto { get; set; } + + /// + public string? matricola { get; set; } + + /// descrizione articolo + public string? desc_art { get; set; } + + /// riga impianto + public int? cprownum { get; set; } + + /// codice impianto + public string? codimp { get; set; } + + /// note + public string? note { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Magazzini.cs b/ApiPolo/Models/Magazzini.cs new file mode 100644 index 0000000..2b03a04 --- /dev/null +++ b/ApiPolo/Models/Magazzini.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +namespace ApiPolo.Models +{ + /// + /// Magazzini azienda + /// + public class Magazzini + { + /// + /// codice magazzino + /// + [Key] + public string? mgcodmag { get; set; } + + /// + /// descrizione + /// + public string? mgdesmag { get; set; } + } +} diff --git a/ApiPolo/Models/MagazziniVT.cs b/ApiPolo/Models/MagazziniVT.cs new file mode 100644 index 0000000..a989d50 --- /dev/null +++ b/ApiPolo/Models/MagazziniVT.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + public class MagazziniVT + { + /// + /// Azienda + /// + [Key] + public string? Azienda { get; set; } + + /// + /// codice magazzino + /// + [Key] + public string? Mgcodmag { get; set; } + + /// + /// descrizione + /// + public string? Mgdesmag { get; set; } + + /// + /// descrizione + /// + public DateTime? DataObso { get; set; } + } +} diff --git a/ApiPolo/Models/Manprog.cs b/ApiPolo/Models/Manprog.cs new file mode 100644 index 0000000..3375e6e --- /dev/null +++ b/ApiPolo/Models/Manprog.cs @@ -0,0 +1,238 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Manutenzioni Programmate + /// + [Keyless] + public class Manprog + { + /// + /// MANPROG: codice intervento (BIM=bimestrale, SEM=semestarle,..) + /// + public string? ctcodint { get; set; } + + /// + /// MANPROG: data prossima manutenzione + /// + public DateTime ctdatpro { get; set; } + + /// + /// MANPROG: descrizione intervento + /// + public string? ctdesint { get; set; } + + /// + /// MANPROG: indirizzo 1 impianto + /// + public string? imindiri1 { get; set; } + + /// + /// MANPROG: indirizzo 2 impianto + /// + public string? imindiri2 { get; set; } + + /// + /// MANPROG: indirizzo 3 impianto + /// + public int? imindiri3 { get; set; } + + /// + /// MANPROG: indirizzo 4 impianto + /// + public string? imindiri4 { get; set; } + + /// + /// MANPROG: indirizzo 5 impianto + /// + public string? imindiri5 { get; set; } + + /// + /// MANPROG: localita impianto + /// + public string? imlocali { get; set; } + + /// + /// MANPROG: cap impianto + /// + public string? imcodcap { get; set; } + + /// + /// MANPROG: comune impianto + /// + public string? imcomune { get; set; } + + /// + /// MANPROG: matricola impianto + /// + public string? immatric { get; set; } + + /// + /// MANPROG: numero impianto + /// + public string? imnumimp { get; set; } + + /// + /// MANPROG: ubicazione impianto + /// + public string? imubicaz { get; set; } + + /// + /// MANPROG: provincia 5 impianto + /// + public string? improvin { get; set; } + + /// + /// MANPROG: nazione impianto + /// + public string? ctcodazi { get; set; } + + /// + /// MANPROG: codice impianto + /// + public string? ctcodimp { get; set; } + + /// + /// MANPROG: tecnico descrizione + /// + public string? tcdescri { get; set; } + + /// + /// MANPROG: tecnico codice + /// + public string? tccodice { get; set; } + + + /*RAPP_NEW*/ + /// + /// RAPP_NEW: seriale rapportino + /// + public string? seriale_rapportino { get; set; } + + /// + /// RAPP_NEW: seriale buono + /// + public string? ser_buono { get; set; } + + /// + /// RAPP_NEW: flag generato. Rapportino importato in AdHoc + /// + public string? generato { get; set; } + + /*PRESE*/ + /// + /// PRESE: codice impianto + /// + public string? pimpianto { get; set; } + + /// + /// PRESE: codice intervento (BIM=bimestrale,SEM=semestrale) + /// + public string? picodint { get; set; } + + /// + /// PRESE: data manutenzione + /// + public DateTime? pidatman { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + + /// + /// Manutenzioni: telefono 1 impianto + /// + public string? telefono1 { get; set; } + + /// + /// Manutenzioni: telefono 1 impianto + /// + public string? telefono2 { get; set; } + + /// + public string? mpmesgen { get; set; } + + /// + public string? mpmesfeb { get; set; } + + /// + public string? mpmesmar { get; set; } + + /// + public string? mpmesapr { get; set; } + + /// + public string? mpmesmag { get; set; } + + /// + public string? mpmesgiu { get; set; } + + /// + public string? mpmeslug { get; set; } + + /// + public string? mpmesago { get; set; } + + /// + public string? mpmesset { get; set; } + + /// + public string? mpmesott { get; set; } + + /// + public string? mpmesnov { get; set; } + + /// + public string? mpmesdic { get; set; } + + /// + public string? cliente { get; set; } + + /// costo chiamata + [Column(TypeName = "decimal(18, 4)")] + public decimal? chiamata { get; set; } + + /// spese viaggio + [Column(TypeName = "decimal(18, 4)")] + public decimal? spe_viaggio { get; set; } + + /// costo orario ordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_ordinario { get; set; } + + /// costo orario notturno + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_notturno { get; set; } + + /// costo orario straordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_straordinario { get; set; } + + /// costo orario festivo + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_festivo { get; set; } + + /// Azienda di riferimento associata all'impianto (gestione loghi differenti) + public string? imazirif { get; set; } + + /// Zona Impianto + public string? imzonman { get; set; } + + /// Riferimento Impianto + public string? imrefref { get; set; } + + } +} diff --git a/ApiPolo/Models/Manprog_out.cs b/ApiPolo/Models/Manprog_out.cs new file mode 100644 index 0000000..de4a266 --- /dev/null +++ b/ApiPolo/Models/Manprog_out.cs @@ -0,0 +1,216 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Manutenzioni Programmate uscita + /// + [Keyless] + public class Manprog_out + { + /// + /// MANPROG: codice intervento (BIM=bimestrale, SEM=semestarle,..) + /// + public string? ctcodint { get; set; } + + /// + /// MANPROG: data prossima manutenzione + /// + public DateTime ctdatpro { get; set; } + + /// + /// MANPROG: descrizione intervento + /// + public string? ctdesint { get; set; } + + /// + /// MANPROG: indirizzo 1 impianto + /// + public string? imindiri1 { get; set; } + + /// + /// MANPROG: indirizzo 2 impianto + /// + public string? imindiri2 { get; set; } + + /// + /// MANPROG: indirizzo 3 impianto + /// + public int? imindiri3 { get; set; } + + /// + /// MANPROG: indirizzo 4 impianto + /// + public string? imindiri4 { get; set; } + + /// + /// MANPROG: indirizzo 5 impianto + /// + public string? imindiri5 { get; set; } + + /// + /// MANPROG: localita impianto + /// + public string? imlocali { get; set; } + + /// + /// MANPROG: cap impianto + /// + public string? imcodcap { get; set; } + + /// + /// MANPROG: comune impianto + /// + public string? imcomune { get; set; } + + /// + /// MANPROG: provincia 5 impianto + /// + public string? improvin { get; set; } + + /// + /// matricola impianto + /// + public string? immatric { get; set; } + + /// + /// numero impianto + /// + public string? imnumimp { get; set; } + + /// + /// ubicazione impianto + /// + public string? imubicaz { get; set; } + + /// + /// MANPROG: nazione impianto + /// + public string? ctcodazi { get; set; } + + /// + /// MANPROG: codice impianto + /// + public string? ctcodimp { get; set; } + + /// + /// MANPROG: tecnico descrizione + /// + public string? tcdescri { get; set; } + + /// + /// MANPROG: tecnico codice + /// + public string? tccodice { get; set; } + + + /*RAPP_NEW*/ + /// + /// RAPP_NEW: seriale rapportino + /// + public string? seriale_rapportino { get; set; } + + /// + /// RAPP_NEW: seriale buono + /// + public string? ser_buono { get; set; } + + /// + /// RAPP_NEW: flag generato. Rapportino importato in AdHoc + /// + public string? generato { get; set; } + + /*PRESE*/ + /// + /// PRESE: codice impianto + /// + public string? pimpianto { get; set; } + + /// + /// PRESE: codice intervento (BIM=bimestrale,SEM=semestrale) + /// + public string? picodint { get; set; } + + /// + /// PRESE: data manutenzione + /// + public DateTime? pidatman { get; set; } + + /// + /// errore titolo + /// + public string? err_title { get; set; } + + /// + /// errore dettaglio + /// + public string? err_detail { get; set; } + + /// + /// errore status code (200, 500) + /// + public string? err_status_code { get; set; } + + /// + /// Manutenzioni: telefono 1 impianto + /// + public string? telefono1 { get; set; } + + /// + /// Manutenzioni: telefono 1 impianto + /// + public string? telefono2 { get; set; } + + /// + /// Manutenzioni: cliente + /// + public string? cliente { get; set; } + + /// costo chiamata + [Column(TypeName = "decimal(18, 4)")] + public decimal? chiamata { get; set; } + + /// spese viaggio + [Column(TypeName = "decimal(18, 4)")] + public decimal? spe_viaggio { get; set; } + + /// costo orario ordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_ordinario { get; set; } + + /// costo orario notturno + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_notturno { get; set; } + + /// costo orario straordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_straordinario { get; set; } + + /// costo orario festivo + [Column(TypeName = "decimal(18, 4)")] + public decimal? costo_festivo { get; set; } + + /// altri dati Manutenzione + public Dictionary? altri { get; set; } + + /// Azienda di riferimento associata all'impianto (gestione loghi differenti) + public string? imazirif { get; set; } + + /// Zona Impianto + public string? imzonman { get; set; } + + /// Riferimento Impianto + public string? imrefref { get; set; } + + /// indirizzo stampa (html) + public string? indirizzo_stampa { get; set; } + + /// impianto per lista (html) + public string? impianto_list { get; set; } + + /// riferimento impianto (html) su buono + public string? riferimento_impianto { get; set; } + + } +} diff --git a/ApiPolo/Models/Notifiche.cs b/ApiPolo/Models/Notifiche.cs new file mode 100644 index 0000000..302a042 --- /dev/null +++ b/ApiPolo/Models/Notifiche.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// ViSTA Chiamate + [Keyless] + public class Notifiche + { + /// Azienda + public string? picodazi { get; set; } + + /// utente destinastario notifica + public string? picodtec { get; set; } + + /// seriale della chiamata + public string? piserial { get; set; } + + /// data di invio della notifica + public DateTime? pidattim { get; set; } + + + } +} diff --git a/ApiPolo/Models/Output_Chiamate.cs b/ApiPolo/Models/Output_Chiamate.cs new file mode 100644 index 0000000..ce92c52 --- /dev/null +++ b/ApiPolo/Models/Output_Chiamate.cs @@ -0,0 +1,31 @@ +namespace ApiPolo.Models +{ + /// Uscita chiamataTable+chiamate + public class Output_Chiamate + { + /// output di chiamataTable (inserimento in tabella Chiamate) + public ChiamateTableOut? chiamataTable { get; set; } + + /// output di Chiamate_out (inserimento in tabella Rapp_new) + public Chiamate_out? chiamate_Out { get; set; } + + /// output di ChiamateSeriale_out (aggiornamento in tabella in tabella PINUMCHI) + public ChiamataSeriale_out? chiaser_Out { get; set; } + + /// output di ChiamateSeriale_out (aggiornamento in tabella in tabella cpwarn) + public Prog_out? prog_Out { get; set; } + + /// output di ChiamateSeriale_out (aggiornamento in tabella in tabella cpwarn) + public Chiamate_out? uscita { get; set; } + + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Output_Ricerca.cs b/ApiPolo/Models/Output_Ricerca.cs new file mode 100644 index 0000000..180b29b --- /dev/null +++ b/ApiPolo/Models/Output_Ricerca.cs @@ -0,0 +1,70 @@ +namespace ApiPolo.Models +{ + /// Output ricerca impianti e di ricerca commesse + public class Output_Ricerca + { + /// Codice Commessa + public string? codice_commessa { get; set; } + + /// Descrizione Commessa + public string? desc_commessa { get; set; } + + /// data fine validita Commessa + public DateTime? dt_fine_validita { get; set; } + + /// tipo + public string? tipo_cliente_comm { get; set; } + + /// codice cliente + public string? cliente_comm { get; set; } + + /// descrizione cliente + public string? desc_cliente_comm { get; set; } + + /// impianto + public string? codice_impianto { get; set; } + + /// tipo ind + public string? imindiri1 { get; set; } + + /// indirizzo + public string? imindiri2 { get; set; } + + /// numero + public int? imindiri3 { get; set; } + + /// lettera + public string? imindiri4 { get; set; } + + /// scala + public string? imindiri5 { get; set; } + + /// localita + public string? localita_impianto { get; set; } + + /// CAP + public string? cap_impianto { get; set; } + + /// provincia + public string? provincia_impianto { get; set; } + + /// descrizione + public string? descrizione_impianto { get; set; } + + + + /// elemento lista formato html + public string? itemList { get; set; } + + /// Error title + public string? err_title { get; set; } + + /// Error deatail + public string? err_detail { get; set; } + + /// Error code + public string? err_status_code { get; set; } + + + } +} diff --git a/ApiPolo/Models/Pagam.cs b/ApiPolo/Models/Pagam.cs new file mode 100644 index 0000000..eb89459 --- /dev/null +++ b/ApiPolo/Models/Pagam.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// Causali pagamento + /// + [Keyless] + public class Pagam + { + /// codice pagamento + public string? pacodice { get; set; } + + /// descrizione pagamento + public string? padescri { get; set; } + } +} diff --git a/ApiPolo/Models/Prese.cs b/ApiPolo/Models/Prese.cs new file mode 100644 index 0000000..5bd28f9 --- /dev/null +++ b/ApiPolo/Models/Prese.cs @@ -0,0 +1,38 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + /// Tabella PRESA + /// + public class Prese + { + /// Azienda + [Key] + public string? picodazi { get; set; } + + /// Impianto + [Key] + public string? pimpianto { get; set; } + + /// Codice intervento QUI=? SEM=SEMESTRALE + [Key] + public string? picodint { get; set; } + + /// Tecnico + public string? picodtec { get; set; } + + /// data della manutenzione + [Key] + public DateTime? pidatman { get; set; } + + /// Zona manutenzione + public string? pizona { get; set; } + + /// check presa + public string? pichkpre { get; set; } + + /// cpccchk + public string? cpccchk { get; set; } + } +} diff --git a/ApiPolo/Models/Prog.cs b/ApiPolo/Models/Prog.cs new file mode 100644 index 0000000..3087805 --- /dev/null +++ b/ApiPolo/Models/Prog.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// + public class Prog + { + /// + [Key] + public string? tablecode { get; set; } + + /// + [Key] + public string? warncode { get; set; } + + /// + public double? autonum { get; set; } + + /// + public string? cpccchk { get; set; } + + /// + public string? autonum_name { get; set; } + } +} diff --git a/ApiPolo/Models/Prog2.cs b/ApiPolo/Models/Prog2.cs new file mode 100644 index 0000000..a78066b --- /dev/null +++ b/ApiPolo/Models/Prog2.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + public class Prog2 + { + /// + [Key] + public string? tablecode { get; set; } + + /// + [Key] + public string? warncode { get; set; } + + /// + [Column(TypeName = "decimal(15, 0)")] /// + public decimal? autonum { get; set; } + + /// + public string? cpccchk { get; set; } + + /// + public string? autonum_name { get; set; } + } +} diff --git a/ApiPolo/Models/Prog_out.cs b/ApiPolo/Models/Prog_out.cs new file mode 100644 index 0000000..40543ae --- /dev/null +++ b/ApiPolo/Models/Prog_out.cs @@ -0,0 +1,33 @@ + +namespace ApiPolo.Models +{ + /// + public class Prog_out + { + /// + public string? tablecode { get; set; } + + /// + public string? warncode { get; set; } + + /// + public float? autonum { get; set; } + + /// + public string? cpccchk { get; set; } + + /// + public string? autonum_name { get; set; } + + + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Progressivo.cs b/ApiPolo/Models/Progressivo.cs new file mode 100644 index 0000000..4073468 --- /dev/null +++ b/ApiPolo/Models/Progressivo.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// tabella progressivi + public class Progressivo + { + /// Azienda + [Key] + public string? azienda { get; set; } + + /// stringa definisce il tipo di progressivo da gestire + [Key] + public string? tipo_prog { get; set; } + + /// valore progressivo + public int? val_prog { get; set; } + } +} diff --git a/ApiPolo/Models/Progressivo_out.cs b/ApiPolo/Models/Progressivo_out.cs new file mode 100644 index 0000000..e3490c5 --- /dev/null +++ b/ApiPolo/Models/Progressivo_out.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + public class Progressivo_out + { + /// Azienda + public string? azienda { get; set; } + + /// stringa definisce il tipo di progressivo da gestire + public string? tipo_prog { get; set; } + + /// valore progressivo + public int? val_prog { get; set; } + + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/Rapp_New.cs b/ApiPolo/Models/Rapp_New.cs new file mode 100644 index 0000000..2a2a8a3 --- /dev/null +++ b/ApiPolo/Models/Rapp_New.cs @@ -0,0 +1,286 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Rapp_New + public class Rapp_New + { + /// + /// Seriale rapportini + /// + [Key] + public string? seriale_rapportino { get; set; } + + /// + /// Tipo rapportini + /// + public string? tipo_rapportino { get; set; } + + /// + /// Azienda + /// + public string? azienda_impianto { get; set; } + + /// + /// Codice Impianto + /// + public string? codice_impianto { get; set; } + + /// + /// Azienda su cui è la chiamata + /// + public string? azienda_chiamata { get; set; } + + /// + /// Seriale chiamata + /// + public string? seriale_chiamata { get; set; } + + /// + /// Seriale chiamata + /// + public string? seriale_commessa { get; set; } + + /// + /// Data rapportino + /// + public DateTime? data_rapportino { get; set; } + + /// + /// Ora inizio + /// + public string? ora_ini_rapportino { get; set; } + + /// + /// minuto inizio + /// + public string? min_ini_rapportino { get; set; } + + /// + /// Ora fine + /// + public string? ora_fin_rapportino { get; set; } + + /// + /// Minuto fine + /// + public string? min_fin_rapportino { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_1 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_2 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_3 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_4 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_5 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_6 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_7 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_8 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_9 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_10 { get; set; } + + /// + /// descrizione intervento + /// + public string? descrizione_intervento { get; set; } + + /// + /// stato + /// + public string? stato_finale { get; set; } + + /// + /// generato + /// + public string? generato { get; set; } + + /// + /// azienda tecnico + /// + public string? azienda_tecnico { get; set; } + + /// + /// codice tecnico + /// + public string? codice_tecnico { get; set; } + + /// + /// flag rifiutata + /// + public string? rifiutata { get; set; } + + /// + /// nminativo firma + /// + public string? firma { get; set; } + + /// + /// flag stato In Carico + /// + public string? incarico { get; set; } + + /// + /// data validità + /// + public DateTime? data_validita { get; set; } + + /// + /// pathg immagine buono o firma + /// + public string? immagine { get; set; } + + /// + /// seriale del buono + /// + public string? ser_buono { get; set; } + + /// + /// data/ora effettiva del lavoro (nel caso dispositivo offline) + /// + public DateTime? data_effettiva { get; set; } + /* + public string? CODICE_GIRO { get; set; } + public string? CODICE_INTERVENTO { get; set; } + */ + + /// + /// codice_intervento (valido per manutenzioni. Esempio: SEM=semestrale) + /// + public string? codice_intervento { get; set; } + + + //Zucchetti sicila + //DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + //PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10, + + /// + public string? difetti_riscontrati { get; set; } + + /// + public string? lavoro_eseguito { get; set; } + + /// + public string? esito_intervento { get; set; } + + /// + public string? note_intervento { get; set; } + + /// + public string? note_esito { get; set; } + + /// + public string? nuovo_contratto { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_lavoro { get; set; } + + //public int? ore_lavoro { get; set; } + + /// + public string? causale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// + public string? pagamento { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } + + /// + public string? note_pagamento { get; set; } + + /// + public string? tipo_intervento { get; set; } + + /// + public string? rafoto1 { get; set; } + + /// + public string? rafoto2 { get; set; } + + /// + public string? rafoto3 { get; set; } + + /// + public string? rafoto4 { get; set; } + + /// + public string? rafoto5 { get; set; } + + /// + public string? rafoto6 { get; set; } + + /// + public string? rafoto7 { get; set; } + + /// + public string? rafoto8 { get; set; } + + /// + public string? rafoto9 { get; set; } + + /// + public string? rafoto10 { get; set; } + + + + } +} diff --git a/ApiPolo/Models/Rapp_New_View.cs b/ApiPolo/Models/Rapp_New_View.cs new file mode 100644 index 0000000..05cda46 --- /dev/null +++ b/ApiPolo/Models/Rapp_New_View.cs @@ -0,0 +1,286 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Vista Rapp_New + [Keyless] + public class Rapp_New_View + { + /// Seriale rapportini + public string? seriale_rapportino { get; set; } + + /// + /// Tipo rapportini + /// + public string? tipo_rapportino { get; set; } + + /// + /// Azienda + /// + public string? azienda_impianto { get; set; } + + /// + /// Codice Impianto + /// + public string? codice_impianto { get; set; } + + /// + /// Azienda su cui è la chiamata + /// + public string? azienda_chiamata { get; set; } + + /// + /// Seriale chiamata + /// + public string? seriale_chiamata { get; set; } + + /// + /// Seriale chiamata + /// + public string? seriale_commessa { get; set; } + + /// + /// Data rapportino + /// + public DateTime? data_rapportino { get; set; } + + /// + /// Ora inizio + /// + public string? ora_ini_rapportino { get; set; } + + /// + /// minuto inizio + /// + public string? min_ini_rapportino { get; set; } + + /// + /// Ora fine + /// + public string? ora_fin_rapportino { get; set; } + + /// + /// Minuto fine + /// + public string? min_fin_rapportino { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_1 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_2 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_3 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_4 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_5 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_6 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_7 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_8 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_9 { get; set; } + + /// + /// codice chiusura + /// + public string? codice_chiusura_10 { get; set; } + + /// + /// descrizione intervento + /// + public string? descrizione_intervento { get; set; } + + /// + /// stato + /// + public string? stato_finale { get; set; } + + /// + /// generato + /// + public string? generato { get; set; } + + /// + /// azienda tecnico + /// + public string? azienda_tecnico { get; set; } + + /// + /// codice tecnico + /// + public string? codice_tecnico { get; set; } + + /// + /// flag rifiutata + /// + public string? rifiutata { get; set; } + + /// + /// nminativo firma + /// + public string? firma { get; set; } + + /// + /// flag stato In Carico + /// + public string? incarico { get; set; } + + /// + /// data validità + /// + public DateTime? data_validita { get; set; } + + /// + /// pathg immagine buono o firma + /// + public string? immagine { get; set; } + + /// + /// seriale del buono + /// + public string? ser_buono { get; set; } + + /// + /// data/ora effettiva del lavoro (nel caso dispositivo offline) + /// + public DateTime? data_effettiva { get; set; } + /* + public string? CODICE_GIRO { get; set; } + public string? CODICE_INTERVENTO { get; set; } + */ + + /// + /// codice_intervento (valido per manutenzioni. Esempio: SEM=semestrale) + /// + public string? codice_intervento { get; set; } + + + //Zucchetti sicila + //DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + //PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10, + + /// + public string? difetti_riscontrati { get; set; } + + /// + public string? lavoro_eseguito { get; set; } + + /// + public string? esito_intervento { get; set; } + + /// + public string? note_intervento { get; set; } + + /// + public string? note_esito { get; set; } + + /// + public string? nuovo_contratto { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_lavoro { get; set; } + + //public int? ore_lavoro { get; set; } + + /// + public string? causale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// + public string? pagamento { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } + + /// + public string? note_pagamento { get; set; } + + /// + public string? tipo_intervento { get; set; } + + /// + public string? rafoto1 { get; set; } + + /// + public string? rafoto2 { get; set; } + + /// + public string? rafoto3 { get; set; } + + /// + public string? rafoto4 { get; set; } + + /// + public string? rafoto5 { get; set; } + + /// + public string? rafoto6 { get; set; } + + /// + public string? rafoto7 { get; set; } + + /// + public string? rafoto8 { get; set; } + + /// + public string? rafoto9 { get; set; } + + /// + public string? rafoto10 { get; set; } + + /// + public byte[]? img2 { get; set; } + + } +} diff --git a/ApiPolo/Models/Rappmast.cs b/ApiPolo/Models/Rappmast.cs new file mode 100644 index 0000000..e24d427 --- /dev/null +++ b/ApiPolo/Models/Rappmast.cs @@ -0,0 +1,515 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Rappmast: storico interventi per tecnico + public class Rappmast + { + //raserial, racaurap, raaziimp, racodimp, racodlav, rafaslav, ratipcli, racodcli, racontma, racodver, raazichi, racodchi, racodese, rasergir, raintgir, ranumrap, raalfrap, + //radatrap, raflafat, raflfatt, rautefat, radatfat, racodpag, raazite1, racodte1, raazite2, racodte2, raazite3, racodte3, ranumtec, raorefat, raggfatt, raimpuni, raserint, + //raimptot, radescri, radessup, raserfis, radesfis, raimpfis, rakmvia, raservia, radesvia, raimpuvi, ratotvia, radesmat, rasupmat, raimpmat, radesint, ranotint, rarifcli, ralisrif, + + //racencos, racodcom, racodzon, raseratt, raserpas, radatvis, rastato, ratipint, ramodfat, rascorp, ralcorp, raimpcor, rariclis, radecor, radscor, raflnume, raumvia, raumass, + //cpccchk, raflbloc, raperman, raimpman, raimpmtc, utcc, utcv, utdc, utdv, rascorap, raorefata, raimpunia, raserinta, raimptota, radescria, rastrass, rastrfis, rastrvia, rastrima, + //rastrimv, rastrimf, rastrorf, rastrimat, rastrimvt, rastrda, rastrdf, rastrdv, ranotass, ranotfis, ranotvia, ranotima, ranotimv, ranotimf, ranotorf, ranotimat, ranotimvt, + // ranotda, ranotdf, ranotdv, rafesass, rafesfis, rafesvia, rafesima, rafesimv, rafesimf, rafesorf, rafesimat, rafesimvt, rafesda, rafesdf, rafesdv, raimpuvi2, ratotvia2, raumvia2, + //rakmvia2, racodinte, ranrordi, rastrorfa, ranotorfa, rafesorfa, rastrimaa, ranotimaa, rafesimaa, rastrassa, rastrdaa, ranotassa, ranotdaa, rafesassa, rafesdaa, rastrimata, + // ranotimata, rafesimata, rperiodo, ranumpas, raimppas, raimp_od, raflfoor, piforimp + + /// Seriale rapportini + [Key] + public string? raserial { get; set; } + + /// Causale + public string? racaurap { get; set; } + + /// Azienda + public string? raaziimp { get; set; } + + /// Impianto + public string? racodimp { get; set; } + + /// Lavoro + public string? racodlav { get; set; } + + /// fase Lavoro + public int? rafaslav { get; set; } + + /// tipo cliente + public string? ratipcli { get; set; } + + /// codice cliente + public string? racodcli { get; set; } + + /// contratto manutenzione + public string? racontma { get; set; } + + /// verbale + public string? racodver { get; set; } + + /// azienda chiamata + public string? raazichi { get; set; } + + /// chiamata + public string? racodchi { get; set; } + + /// esercizio + public string? racodese { get; set; } + + /// codice giro + public string? rasergir { get; set; } + + /// intervento giro + public string? raintgir { get; set; } + + /// numero rapportino + public int? ranumrap { get; set; } + + /// serie rapportino + public string? raalfrap { get; set; } + + + // , , , , , , , , , , + /// data rapportino + public DateTime? radatrap { get; set; } + + /// flag da fatturare + public string? raflafat { get; set; } + + /// flag fatturabile + public string? raflfatt { get; set; } + + /// utente fatturabile + public int? rautefat { get; set; } + + /// data fatturabilità + public DateTime? radatfat { get; set; } + + /// codice pagamento + public string? racodpag { get; set; } + + /// azienda tecnico 1 + public string? raazite1 { get; set; } + + /// tecnico 1 + public string? racodte1 { get; set; } + + /// azienda tecnico 2 + public string? raazite2 { get; set; } + + /// tecnico 2 + public string? racodte2 { get; set; } + + /// azienda tecnico 3 + public string? raazite3 { get; set; } + + /// tecnico 3 + public string? racodte3 { get; set; } + + /// tecnici fatturabili + public int? ranumtec { get; set; } + + //11111111111111111111 + + + /// Ore fatturabili + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? raorefat { get; set; } + + /// giornate fatturabili + public int? raggfatt { get; set; } + + /// Importo unitario + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpuni { get; set; } + + /// servizio assistenza + public string? raserint { get; set; } + + // , , , , , , , , , , , , , , , , , + + /// Importo totale + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimptot { get; set; } + + /// descrizione + public string? radescri { get; set; } + + /// Note + public string? radessup { get; set; } + + /// Servizio dir. fisso + public string? raserfis { get; set; } + + /// descrizione dir. fisso + public string? radesfis { get; set; } + + /// Importo dir. fisso + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpfis { get; set; } + + //2222222222222222 + + /// Importo dir. fisso + public int? rakmvia { get; set; } + + /// servizio viaggio + public string? raservia { get; set; } + + /// descrizione viaggio + public string? radesvia { get; set; } + + /// Importo viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpuvi { get; set; } + + /// Totale viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ratotvia { get; set; } + + /// descrizione meteriale + public string? radesmat { get; set; } + + /// Note meteriale + public string? rasupmat { get; set; } + + /// Importo materiali + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpmat { get; set; } + + /// Descrizione intervento + public string? radesint { get; set; } + + /// Note intervento + public string? ranotint { get; set; } + + /// Riferimento cliente + public string? rarifcli { get; set; } + + /// Listino costi + public string? ralisrif { get; set; } + + + + //, , , , , , , , , , , , , , , , , , + + /// centro di costo + public string? racencos { get; set; } + + /// commessa + public string? racodcom { get; set; } + + /// Zona analitica + public string? racodzon { get; set; } + + /// Seriale doc attivo + public string? raseratt { get; set; } + + /// Seriale doc passivo + public string? raserpas { get; set; } + + /// Seriale doc passivo + public DateTime? radatvis { get; set; } + + /// Stato rapportino (Controllato S/N) + public string? rastato { get; set; } + + /// Tipo intervento (Reperibile S/N) + public string? ratipint { get; set; } + + /// Modalita fatturazione + public string? ramodfat { get; set; } + + /// Servizio per fatture a corpo + public string? rascorp { get; set; } + + /// Listino per fatture a corpo + public string? ralcorp { get; set; } + + + //44444444444444444444444444444 + + /// Importo servizio a corpo + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpcor { get; set; } + + /// percentuale ricarico costi materiali + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")] + public decimal? rariclis { get; set; } + + /// descrizione servizio a corpo + public string? radecor { get; set; } + + /// descrizione suppl servizio a corpo + public string? radscor { get; set; } + + /// Numerazione automatica + public string? raflnume { get; set; } + + /// U.M. viaggio + public string? raumvia { get; set; } + + /// U.M. assistenza + public string? raumass { get; set; } + + //, , , , , , , , , , , , , , , , , , + + /// flag assegnazione tecnico da blocchetto + public string? raflbloc { get; set; } + + /// percentuale manodopera + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")] + public decimal? raperman { get; set; } + + /// importo manodopera a corpo + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpman { get; set; } + + /// importo materiale a corpo + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpmtc { get; set; } + + + + //cpccchk, , , , , utcc, utcv, utdc, utdv, rascorap, raorefata, raimpunia, raserinta, raimptota, radescria, + + /// Servizio assistenza ore straordinario + public string? rastrass { get; set; } + + /// Servizio dir. fisso ore straordinario + public string? rastrfis { get; set; } + + /// Servizio viaggio straordinario + public string? rastrvia { get; set; } + + /// importo straord assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrima { get; set; } + //, , , , + + /// importo straord viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimv { get; set; } + + /// importo straord dir. fisso + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimf { get; set; } + + /// ore fatturabili straordinario + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? rastrorf { get; set; } + + /// importo totale straord assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimat { get; set; } + + /// importo totale straord viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimvt { get; set; } + + /// Desc assistenza straordinario + public string? rastrda { get; set; } + + //66666666666666 + + /// Desc dir. fisso straordinario + public string? rastrdf { get; set; } + + /// Desc viaggio straordinario + public string? rastrdv { get; set; } + + /// Servizio assistenza ore notturno + public string? ranotass { get; set; } + + /// Servizio dir. fisso ore notturno + public string? ranotfis { get; set; } + + /// Servizio viaggio notturno + public string? ranotvia { get; set; } + + /// importo notturno assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotima { get; set; } + + /// importo notturno viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimv { get; set; } + + /// importo notturno dir.fisso + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimf { get; set; } + + /// Ore fatturabili notturno + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? ranotorf { get; set; } + + /// importo totale notturno assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimat { get; set; } + + /// importo totale notturno viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimvt { get; set; } + // , , , , , , , , , , , , , , , , , + + ///77777777 + + /// Desc assistenza notturno + public string? ranotda { get; set; } + + /// Desc dir fisso notturno + public string? ranotdf { get; set; } + + /// Desc viaggio notturno + public string? ranotdv { get; set; } + + /// servizio assistenza ore festivo + public string? rafesass { get; set; } + + /// servizio dir. fisso ore festivo + public string? rafesfis { get; set; } + + /// servizio viaggio festivo + public string? rafesvia { get; set; } + + /// importo festivo assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesima { get; set; } + + /// importo festivo viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimv { get; set; } + + /// importo festivo dir. fisso + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimf { get; set; } + + /// ore fatturabili festivo + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? rafesorf { get; set; } + + /// importo totale festivo assistenza + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimat { get; set; } + + /// importo totale festivo viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimvt { get; set; } + + /// desc assistenza festivo + public string? rafesda { get; set; } + + /// desc dir fisso festivo + public string? rafesdf { get; set; } + + /// desc viaggio festivo + public string? rafesdv { get; set; } + + //888888888888888888888 + + /// importo unitario viaggio 2 + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimpuvi2 { get; set; } + + /// importo totale viaggio 2 + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ratotvia2 { get; set; } + + /// U.M. viaggio 2 + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raumvia2 { get; set; } + // , , , , , , , , , , , , , , , , , , + + /// Km totali viaggio 2 + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")] + public decimal? rakmvia2 { get; set; } + + /// codice intervento + public string? racodinte { get; set; } + + /// Numero ordine + public string? ranrordi { get; set; } + + /// ore fatturabili starordinario aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? rastrorfa { get; set; } + + /// ore fatturabili notturne aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? ranotorfa { get; set; } + + /// ore fatturabili festive aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 4)")] + public decimal? rafesorfa { get; set; } + + /// importo straordinario aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimaa { get; set; } + + /// importo notte aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimaa { get; set; } + + /// importo festivo aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimaa { get; set; } + + /// servizio assistenza straordinario aiutante + public string? rastrassa { get; set; } + + /// descrizione servizio assistenza aiutante + public string? rastrdaa { get; set; } + + /// descrizione servizio notte aiutante + public string? ranotassa { get; set; } + + /// descrizione servizio festivo aiutante + public string? ranotdaa { get; set; } + + /// servizio festivo aiutante + public string? rafesassa { get; set; } + + /// descrizione festivo aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesdaa { get; set; } + + /// importo ore straordinario aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rastrimata { get; set; } + + //99999999999999999999999999999999 + + // , , , , , , , , , , , , , , , , + + /// importo ore notturne aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? ranotimata { get; set; } + + /// importo ore festive aiutante + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? rafesimata { get; set; } + + /// periodo + public string? rperiodo { get; set; } + + /// numero pasti + public int? ranumpas { get; set; } + + /// importo pasti + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimppas { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")] + public decimal? raimp_od { get; set; } + + /// flag forza ore lavoro + public string? raflfoor { get; set; } + + /// flag forza impianto + public string? piforimp { get; set; } + + + // , , , , , , , + } +} diff --git a/ApiPolo/Models/Rapportino.cs b/ApiPolo/Models/Rapportino.cs new file mode 100644 index 0000000..2c8a47d --- /dev/null +++ b/ApiPolo/Models/Rapportino.cs @@ -0,0 +1,132 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + /// + [Keyless] + public class Rapportino + { + /// + /// Seriale + /// + public string? seriale_rapportino { get; set; } + + /// + /// Azienda + /// + public string? azienda_impianto { get; set; } + + /// + /// Codice Impianto + /// + public string? codice_impianto { get; set; } + + + /// + /// Seriale chiamata + /// + public string? seriale_chiamata { get; set; } + + /// + /// Seriale chiamata + /// + public string? seriale_commessa { get; set; } + + /// + /// Data rapportino + /// + public DateTime? data_rapportino { get; set; } + + /// Codice Cliente + public string? ancodice { get; set; } + + /// Ragione Sociale + public string? andescri { get; set; } + + /// ora inizio rapportino + public string? ora_ini_rapportino { get; set; } + + /// ora inizio rapportino + public string? ora_fin_rapportino { get; set; } + + /// min inizio rapportino + public string? min_ini_rapportino { get; set; } + + /// min inizio rapportino + public string? min_fin_rapportino { get; set; } + + /// codice chiusura 1 + public string? codice_chiusura_1 { get; set; } + + /// codice chiusura 2 + public string? codice_chiusura_2 { get; set; } + + /// codice chiusura 3 + public string? codice_chiusura_3 { get; set; } + + /// codice chiusura 4 + public string? codice_chiusura_4 { get; set; } + + /// codice chiusura 5 + public string? codice_chiusura_5 { get; set; } + + /// codice chiusura 6 + public string? codice_chiusura_6 { get; set; } + + /// codice chiusura 7 + public string? codice_chiusura_7 { get; set; } + + /// codice chiusura 8 + public string? codice_chiusura_8 { get; set; } + + /// codice chiusura 9 + public string? codice_chiusura_9 { get; set; } + + /// codice chiusura 10 + public string? codice_chiusura_10 { get; set; } + + /// descrizione int + public string? descrizione_intervento { get; set; } + + /// tecnico + public string? codice_tecnico { get; set; } + + /// firma + public string? firma { get; set; } + + /// cod intervento + public string? codice_intervento { get; set; } + + /// + public string? note_intervento { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_lavoro { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } + } +} diff --git a/ApiPolo/Models/Registrazione.cs b/ApiPolo/Models/Registrazione.cs new file mode 100644 index 0000000..820050d --- /dev/null +++ b/ApiPolo/Models/Registrazione.cs @@ -0,0 +1,75 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Form di registrazione + public class Registrazione + { + /// tipo + [Key] + public int Id { get; set; } + + /// Nome + public string? Nome { get; set; } + + /// Cognome + public string? Cognome { get; set; } + + /// Telefono + public string? Telefono { get; set; } + + /// Cellulare + public string? Cellulare { get; set; } + + /// Email + public string? Email { get; set; } + + /// Email di conferma + public string? EmailConf { get; set; } + + /// Azienda + public string? Azienda { get; set; } + + /// Username + public string? Username { get; set; } + + /// Password + public string? Passwd { get; set; } + + /// Città + public string? Citta { get; set; } + + /// Provincia (sigla) + public string? Provincia { get; set; } + + /// Nazione (sigla) + public string? Nazione { get; set; } + + /// Attivato (S/N) + public string? Attivato { get; set; } + + /// Token registrazione + public string? Token { get; set; } + + /// Form registrazione: check 1 + public bool privacy1 { get; set; } + + /// Form registrazione: check 2 + public bool privacy2 { get; set; } + + /// Form registrazione: check 3 + public bool privacy3 { get; set; } + + /// Form registrazione: check 4 + public bool privacy4 { get; set; } + + /// Richiesta del moduulo Timesheet + public bool ModuloTimesheet { get; set; } + + /// Richiesta del moduulo Rapportini + public bool ModuloRapportini { get; set; } + + /// Ragione sociale + public string? RagioneSociale { get; set; } + } +} diff --git a/ApiPolo/Models/Saldiart.cs b/ApiPolo/Models/Saldiart.cs new file mode 100644 index 0000000..a91004b --- /dev/null +++ b/ApiPolo/Models/Saldiart.cs @@ -0,0 +1,73 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// Contiene i campi di SALDIART + /// + [Keyless] + public class Saldiart + { + /// articolo + public string? slcodice { get; set; } + + /// descrizione articolo + public string? ardesart { get; set; } + + /// magazzino + public string? slcodmag { get; set; } + + /// quantita + [Column(TypeName = "decimal(13, 3)")] + public decimal? slqtaper { get; set; } + + /// matricola + public string? amcodice { get; set; } + + /// lotto + public string? locodice { get; set; } + + /// listino + public string? licodlis { get; set; } + + /// articolo del listino + public string? licodart { get; set; } + + /// data validità listino + public DateTime? lidatatt { get; set; } + + /// quantita + [Column(TypeName = "decimal(12, 3)")] + public decimal? liquanti { get; set; } + + /// prezzo + [Column(TypeName = "decimal(18, 5)")] + public decimal? liprezzo { get; set; } + + /// sconto1 + [Column(TypeName = "decimal(6, 2)")] + public decimal? liscont1 { get; set; } + + /// sconto2 + [Column(TypeName = "decimal(6, 2)")] + public decimal? liscont2 { get; set; } + + /// sconto3 + [Column(TypeName = "decimal(6, 2)")] + public decimal? liscont3 { get; set; } + + /// sconto4 + [Column(TypeName = "decimal(6, 2)")] + public decimal? liscont4 { get; set; } + + /// articolo gestito a matricole(S/N) + public string? gest_matr { get; set; } + + /// articolo gestito a lotti (S e C=si, N=no) + public string? gest_lotti { get; set; } + + /// descrizione per ogni articolo (se abilitata da configurazioni) + public string? desc_sup { get; set; } + } +} diff --git a/ApiPolo/Models/Sostituzione.cs b/ApiPolo/Models/Sostituzione.cs new file mode 100644 index 0000000..614c3c0 --- /dev/null +++ b/ApiPolo/Models/Sostituzione.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +namespace ApiPolo.Models +{ + /// + [Keyless] + public class Sostituzione + { + /// azienda + public string? tscodazi { get; set; } + + /// tecnico + public string? tscodtec { get; set; } + + /// zona + public string? tscodzon { get; set; } + + /// Inizio sostituzione + public DateTime? tsdatain { get; set; } + + /// Fine sostituzione + public DateTime? tsdatafi { get; set; } + + /// codice sostituzione + public string? tscodsos { get; set; } + + } +} diff --git a/ApiPolo/Models/Sto_Imp.cs b/ApiPolo/Models/Sto_Imp.cs new file mode 100644 index 0000000..f39b887 --- /dev/null +++ b/ApiPolo/Models/Sto_Imp.cs @@ -0,0 +1,86 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// Storico impianti + [Keyless] + public class Sto_Imp + { + /// seriale rapportino + public string? seriale_rapportino { get; set; } + + /// seriale rapportino + public DateTime? data_rapportino { get; set; } + + /// indice riga + public int? riga { get; set; } + + /// codice magazzino + public string? magazzino { get; set; } + + /// codice articolo + public string? articolo { get; set; } + + /// descrizione articolo + public string? desc_art { get; set; } + + /// tipologia movimento (E=eliminato,A=aggiunto,S=sotituito) + public string? tipo_movimento { get; set; } + + /// quantità articolo + [Column(TypeName = "decimal(7, 2)")] + public decimal? quantita { get; set; } + + /// prezzo articolo + [Column(TypeName = "decimal(10, 2)")] + public decimal? prezzo { get; set; } + + /// codice tecnico + public string? codice_tecnico { get; set; } + + /// descrizione tecnico + public string? desc_tecnico { get; set; } + + /// documento generato + public string? generato { get; set; } + + /// note + public string? note { get; set; } + + /// codice lotto articolo + public string? codlotto { get; set; } + + /// matricola articolo + public string? matricola { get; set; } + + /// + public int? cprownum { get; set; } + + /// codice impianto + public string? codimp { get; set; } + + /// descrizione impianto + public string? desc_impianto { get; set; } + + /// azienda impianto + public string? azienda_impianto { get; set; } + + /// tipo indirizzo (via, strada) + public string? indirizzo_tipo { get; set; } + + /// indirizzo + public string? indirizzo { get; set; } + + /// indirizzo numero + public int? indirizzo_num { get; set; } + + /// indirizzo scala + public string? indirizzo_scala { get; set; } + + /// indirizzo sottonumero + public string? indirizzo_num2 { get; set; } + + } +} diff --git a/ApiPolo/Models/Sto_Imp_out.cs b/ApiPolo/Models/Sto_Imp_out.cs new file mode 100644 index 0000000..824e313 --- /dev/null +++ b/ApiPolo/Models/Sto_Imp_out.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// Storico impianti- output + [Keyless] + public class Sto_Imp_out + { + /// (LISTA)data rapportino + public DateTime? data_rapportino { get; set; } + + /// (LISTA) codice articolo + public string? articolo { get; set; } + + /// (LISTA) tipologia movimento (E=eliminato,A=aggiunto,S=sotituito) + public string? tipo_movimento { get; set; } + + /// dettaglio movimento impianto + public Dictionary? dettaglio { get; set; } + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + + } +} diff --git a/ApiPolo/Models/Sto_Rapp.cs b/ApiPolo/Models/Sto_Rapp.cs new file mode 100644 index 0000000..9677120 --- /dev/null +++ b/ApiPolo/Models/Sto_Rapp.cs @@ -0,0 +1,234 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; + +namespace ApiPolo.Models +{ + /// + /// Storico interventi New + /// + [Keyless] + public class Sto_Rapp + { + + + /// (LISTA) codice tecnico + public string? tccodice { get; set; } + + /// (LISTA) descrizione tecnico + public string? tcdescri { get; set; } + + /// (LISTA) note esito + public string? note_esito { get; set; } + + /// (LISTA) note esito + public DateTime? data_rapportino { get; set; } + + /// stato finale + public string? stato_finale { get; set; } + + /// esito intervento + public string? esito_intervento { get; set; } + + /// descrizione intervento + public string? descrizione_intervento { get; set; } + + /// firma rapportino + public string? firma { get; set; } + + /// seriale chiamata (se chiamata, altrimenti null + public string? seriale_chiamata { get; set; } + + /// seriale buono + public string? ser_buono { get; set; } + + /// difetti riscontrati + public string? difetti_riscontrati { get; set; } + + /// lavoro eseguito + public string? lavoro_eseguito { get; set; } + + /// note intervento + public string? note_intervento { get; set; } + + /// ore lavoro + [Column(TypeName = "decimal(7, 2)")] + public decimal? ore_lavoro { get; set; } + + /// costo materiale + [Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// diritto chiamata + [Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// anticipo + [Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// manodopera + [Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// spese viaggio + [Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// pagamento + public string? pagamento { get; set; } + + /// codice impianto + public string? codice_impianto { get; set; } + + /// totale + [Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } + + /// note pagamento + public string? note_pagamento { get; set; } + + /// tipo intervento + public string? tipo_intervento { get; set; } + + /// rapportino generato in adhoc S/N + public string? generato { get; set; } + + /// azienda tecnico + public string? azienda_tecnico { get; set; } + + /// azienda impianto + public string? azienda_impianto { get; set; } + + /// azienda chiamata + public string? azienda_chiamata { get; set; } + + /// cod chiusura 1 + public string? codice_chiusura_1 { get; set; } + + /// cod chiusura 2 + public string? codice_chiusura_2 { get; set; } + + /// cod chiusura 3 + public string? codice_chiusura_3 { get; set; } + + /// cod chiusura 4 + public string? codice_chiusura_4 { get; set; } + + /// cod chiusura 5 + public string? codice_chiusura_5 { get; set; } + + /// cod chiusura 6 + public string? codice_chiusura_6 { get; set; } + + /// cod chiusura 7 + public string? codice_chiusura_7 { get; set; } + + /// cod chiusura 8 + public string? codice_chiusura_8 { get; set; } + + /// cod chiusura 9 + public string? codice_chiusura_9 { get; set; } + + /// cod chiusura 10 + public string? codice_chiusura_10 { get; set; } + + /// des cod chiusura 1 + public string? cc1 { get; set; } + + /// des cod chiusura 2 + public string? cc2 { get; set; } + + /// des cod chiusura 3 + public string? cc3 { get; set; } + + /// des cod chiusura 4 + public string? cc4 { get; set; } + + /// des cod chiusura 5 + public string? cc5 { get; set; } + + /// des cod chiusura 6 + public string? cc6 { get; set; } + + /// des cod chiusura 7 + public string? cc7 { get; set; } + + /// des cod chiusura 8 + public string? cc8 { get; set; } + + /// des cod chiusura 9 + public string? cc9 { get; set; } + + /// des cod chiusura 10 + public string? cc10 { get; set; } + + + /// des supp cod chiusura 1 + public string? ccds1 { get; set; } + + /// des supp cod chiusura 2 + public string? ccds2 { get; set; } + + /// des supp cod chiusura 3 + public string? ccds3 { get; set; } + + /// des supp cod chiusura 4 + public string? ccds4 { get; set; } + + /// des supp cod chiusura 5 + public string? ccds5 { get; set; } + + /// des supp cod chiusura 6 + public string? ccds6 { get; set; } + + /// des supp cod chiusura 7 + public string? ccds7 { get; set; } + + /// des supp cod chiusura 8 + public string? ccds8 { get; set; } + + /// des supp cod chiusura 9 + public string? ccds9 { get; set; } + + /// des supp cod chiusura 10 + public string? ccds10 { get; set; } + + /// seriale rapportino + public string? seriale_rapportino { get; set; } + + + /// codice intervento manutenzione + public string? codice_intervento { get; set; } + + /// descrizione intervento manutenzione + public string? cidescri { get; set; } + + /// descrizione suppl. intervento manutenzione + public string? cidessup { get; set; } + + /// descrizione suppl. codice intervento manutenzione + public DateTime? data_manutenzione { get; set; } + + /// codice segnalazione chiamata + public string? codice_segnalazione { get; set; } + + /// tipo indirizzo (via, strada) + public string? indirizzo_tipo { get; set; } + + /// indirizzo + public string? indirizzo { get; set; } + + /// indirizzo numero + public int? indirizzo_num { get; set; } + + /// indirizzo scala + public string? indirizzo_scala { get; set; } + + /// indirizzo sottonumero + public string? indirizzo_num2 { get; set; } + + + } +} diff --git a/ApiPolo/Models/Sto_Rapp_out.cs b/ApiPolo/Models/Sto_Rapp_out.cs new file mode 100644 index 0000000..7d6193c --- /dev/null +++ b/ApiPolo/Models/Sto_Rapp_out.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// ViSTA Chiamate + [Keyless] + public class Sto_Rapp_out + { + /// (LISTA) codice tecnico + public string? tccodice { get; set; } + + /// (LISTA) descrizione tecnico + public string? tcdescri { get; set; } + + /// (LISTA) note esito + public string? note_esito { get; set; } + + /// (LISTA) note esito + public DateTime? data_rapportino { get; set; } + + /// dettaglio rapportino + public Dictionary? dettaglio { get; set; } + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + } +} diff --git a/ApiPolo/Models/TabelleDominio.cs b/ApiPolo/Models/TabelleDominio.cs new file mode 100644 index 0000000..c162afb --- /dev/null +++ b/ApiPolo/Models/TabelleDominio.cs @@ -0,0 +1,33 @@ +using Api_VT.Models; + +namespace ApiPolo.Models +{ + /// Tabelle di Dominio + public class TabelleDominio + { + /// lista causali rapportino + public List? cau_rapp { get; set; } + + /// lista causali pagamento + public List? cau_pag { get; set; } + + /// stati impianto + public List? statoImpianto { get; set; } + //public List? statoImpianto { get; set; } + + /// esito intervento + public List? esito { get; set; } + + + } + /// + public class ComboItem + { + /// + public string? chiave { get; set; } + + /// + public string? valore { get; set; } + } + +} diff --git a/ApiPolo/Models/Tecnici.cs b/ApiPolo/Models/Tecnici.cs new file mode 100644 index 0000000..5b9d4d1 --- /dev/null +++ b/ApiPolo/Models/Tecnici.cs @@ -0,0 +1,79 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// tecnici + [Keyless] + public class Tecnici + { + /// + /// Codice tecnico + /// + public string? tccodice { get; set; } + + /// + /// Descrizione tecnico + /// + public string? Tcdescri { get; set; } + + /// + /// telefono tecnico + /// + public string? tctelef1 { get; set; } + + /// + /// Qualifica tecnico chiamatista + /// + public string? tcchiam { get; set; } + + /// + /// Qualifica tecnico manutentore + /// + public string? tcmanut { get; set; } + + /// + /// Azienda tecnico + /// + public string? tccodazi { get; set; } + + /// + /// Qualifica tecnico supervisore + /// + public string? tcsuper { get; set; } + + /// + /// Username tecnico + /// + public string? tcuser { get; set; } + + /// + /// Password tecnico + /// + public string? tcpwd { get; set; } + + /// + /// Zona tecnico + /// + public string? tdcodzon { get; set; } + + /// + /// data inizio attività tecnico + /// + public DateTime? tddatain { get; set; } + + /// + /// data fine attività tecnico + /// + public DateTime? tddatafi { get; set; } + + /// + /// Flag utente Amministratore per Azienda. Se 1 Amministratore e entra in VT, 0 non entra + /// + public int tccodute { get; set; } + + /// Identifica un utente abilitato al download dell'app + //public string? tciden { get; set; } + + + } +} diff --git a/ApiPolo/Models/TecniciTable.cs b/ApiPolo/Models/TecniciTable.cs new file mode 100644 index 0000000..205e63a --- /dev/null +++ b/ApiPolo/Models/TecniciTable.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// + /// (Virtual Task) Contiene i campi di TECNICI + /// + public class TecniciTable + { + /// + [Key] + public string? tccodazi { get; set; } + + /// + [Key] + public string? tccodice { get; set; } + + /// + public string? tcdescri { get; set; } + + /// + public string? tctelef1 { get; set; } + + /// + public string? tcuser { get; set; } + + /// + public string? tcpwd { get; set; } + + /// costo ordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? tccoor { get; set; } + + /// costo notturno + [Column(TypeName = "decimal(18, 4)")] + public decimal? tccono { get; set; } + + /// costo straordinario + [Column(TypeName = "decimal(18, 4)")] + public decimal? tccost { get; set; } + + /// costo festivo + [Column(TypeName = "decimal(18, 4)")] + public decimal? tccofe { get; set; } + + /// data cancellazione + public DateTime? tcdatobs { get; set; } + } +} diff --git a/ApiPolo/Models/Timbratura.cs b/ApiPolo/Models/Timbratura.cs new file mode 100644 index 0000000..df93760 --- /dev/null +++ b/ApiPolo/Models/Timbratura.cs @@ -0,0 +1,55 @@ +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + /// Tabella Timbrature + public class Timbratura + { + /// chiave primaria + [Key] + public int id { get; set; } + + /// data + public DateTime? data_timbratura { get; set; } + + /// ora inizio + public int ora_ini { get; set; } + + /// minuto inizio + public int min_ini { get; set; } + + /// ora fine + public int ora_fin { get; set; } + + /// minuto fine + public int min_fin { get; set; } + + /// SERIALE commessa + public string? commessa { get; set; } + + /// ore viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_viaggio { get; set; } + + /// totale ore + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? tot_ore { get; set; } + + /// giorno settimana + public int? giorno { get; set; } + + /// azienda + public string? azienda { get; set; } + + /// tecnico + public string? tecnico { get; set; } + + /// cpccchk + public string? cpccchk { get; set; } + + /// note + public string? note { get; set; } + + + } +} diff --git a/ApiPolo/Models/Timbratura_out.cs b/ApiPolo/Models/Timbratura_out.cs new file mode 100644 index 0000000..9dc0ebb --- /dev/null +++ b/ApiPolo/Models/Timbratura_out.cs @@ -0,0 +1,52 @@ +namespace ApiPolo.Models +{ + /// Timbrature OUT + public class Timbratura_out + { + /// id: chiave + public int id { get; set; } + + /// data + public DateTime? data_timbratura { get; set; } + + /// ora inizio + public int ora_ini { get; set; } + + /// minuto inizio + public int min_ini { get; set; } + + /// ora fine + public int ora_fin { get; set; } + + /// minuto fine + public int min_fin { get; set; } + + /// commessa + public string? commessa { get; set; } + + /// ore viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_viaggio { get; set; } + + /// giorno settimana + public int? giorno { get; set; } + + /// azienda + public string? azienda { get; set; } + + /// tecnico + public string? tecnico { get; set; } + + /// errore titolo + public string? err_title { get; set; } + + /// errore dettaglio + public string? err_detail { get; set; } + + /// errore status code (200, 500) + public string? err_status_code { get; set; } + + /// note + public string? note { get; set; } + } +} diff --git a/ApiPolo/Models/Token.cs b/ApiPolo/Models/Token.cs new file mode 100644 index 0000000..b47798a --- /dev/null +++ b/ApiPolo/Models/Token.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// token di login sul device + public class Token + { + /// id + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Key] + public int Id { get; set; } + + /// tenant azienda + public string? tenant { get; set; } + + /// utente login + public string? usr { get; set; } + + /// token device + public string? token { get; set; } + + /// timestamp inserimento + public DateTime? ts { get; set; } + + + } +} diff --git a/ApiPolo/Models/TokenDbContext.cs b/ApiPolo/Models/TokenDbContext.cs new file mode 100644 index 0000000..b362e44 --- /dev/null +++ b/ApiPolo/Models/TokenDbContext.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ApiPolo.Models +{ + /// TokenDbContext + public class TokenDbContext : DbContext + { + /// conf + public DbSet? tok { get; set; } + + /// ConfigurazioniDbContext + public TokenDbContext(DbContextOptions options) : base(options) + { + } + /// OnModelCreating + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("Token"); + //modelBuilder.Entity().Property(p => p.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + } + } +} diff --git a/ApiPolo/Models/Token_out.cs b/ApiPolo/Models/Token_out.cs new file mode 100644 index 0000000..e8730aa --- /dev/null +++ b/ApiPolo/Models/Token_out.cs @@ -0,0 +1,30 @@ +namespace ApiPolo.Models +{ + /// token di login sul device- output + public class Token_out + { + /// tenant azienda + public string? tenant { get; set; } + + /// utente login + public string? usr { get; set; } + + /// token device + public string? token { get; set; } + + /// timestamp inserimento + public DateTime? ts { get; set; } + + /// Error Message + public string? err_title { get; set; } + + /// Error Message detail + public string? err_detail { get; set; } + + /// Status + public string? err_status_code { get; set; } + + /// response + public string? response { get; set; } + } +} diff --git a/ApiPolo/Models/VT_Buoni_DbContext.cs b/ApiPolo/Models/VT_Buoni_DbContext.cs new file mode 100644 index 0000000..726b093 --- /dev/null +++ b/ApiPolo/Models/VT_Buoni_DbContext.cs @@ -0,0 +1,27 @@ +using ApiPolo.Models.VT_dbcontext; +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models +{ + /// + public class VT_Buoni_DbContext : DbContext + { + /// + public DbSet? buoni { get; set; } + + /// + public VT_Buoni_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("BUONI"); + modelBuilder.Entity().HasKey(table => new + { + table.azienda, + table.ser_buono + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_ARTICOLI_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_ARTICOLI_TABLE_DbContext.cs new file mode 100644 index 0000000..d04cf7b --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_ARTICOLI_TABLE_DbContext.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.Collections.Generic; + +namespace ApiPolo.Models.VT_dbcontext +{ + public class VT_ARTICOLI_TABLE_DbContext : DbContext + { + + public DbSet Articoli { get; set; } + + + public VT_ARTICOLI_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("ARTICOLI"); + modelBuilder.Entity().HasKey(Table => new + { + Table.Azienda, + Table.SlCodice + }); // Definizione della chiave primaria composta + //base.OnModelCreating(modelBuilder); + } + } + +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_AZIENDA_RIF_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_AZIENDA_RIF_DbContext.cs new file mode 100644 index 0000000..5a9e195 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_AZIENDA_RIF_DbContext.cs @@ -0,0 +1,28 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_AZIENDA_RIF_DbContext : DbContext + { + /// + public DbSet? Azi { get; set; } + + /// + public VT_AZIENDA_RIF_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("PIAZIRIF"); + modelBuilder.Entity().HasKey(table => new + { + table.piazihoc, + table.picodtec, + table.pirifazi + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_AZIENDE_PRESENTI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_AZIENDE_PRESENTI_DbContext.cs new file mode 100644 index 0000000..240b5e7 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_AZIENDE_PRESENTI_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_AZIENDE_PRESENTI_DbContext : DbContext + { + /// + public DbSet? Aziende { get; set; } + + /// + public VT_AZIENDE_PRESENTI_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_AZIENDE_PRESENTI"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_DbContext.cs new file mode 100644 index 0000000..2e43dab --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_DbContext.cs @@ -0,0 +1,23 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CHIAMATE_DbContext : DbContext + { + /// + public DbSet? Chiamate { get; set; } + + /// + public VT_CHIAMATE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_CHIAMATE"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_MANAGER_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_MANAGER_DbContext.cs new file mode 100644 index 0000000..435a362 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_MANAGER_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CHIAMATE_MANAGER_DbContext : DbContext + { + /// + public DbSet? Chiamate { get; set; } + + /// + public VT_CHIAMATE_MANAGER_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_CHIAMATE_VT"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_TABLE_DbContext.cs new file mode 100644 index 0000000..833e7a8 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CHIAMATE_TABLE_DbContext.cs @@ -0,0 +1,27 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CHIAMATE_TABLE_DbContext : DbContext + { + /// + public DbSet? Chi { get; set; } + + /// + public VT_CHIAMATE_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("CHIAMATE"); + modelBuilder.Entity().HasKey(table => new { + table.chcodazi, + table.chserial + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_DbContext.cs new file mode 100644 index 0000000..cdd734d --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_DbContext.cs @@ -0,0 +1,23 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CHIUSURE_DbContext : DbContext + { + /// + public DbSet? Chiu { get; set; } + + /// + public VT_CHIUSURE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_CHIUSURE"); + + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_TABLE_DbContext.cs new file mode 100644 index 0000000..857c3f2 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CHIUSURE_TABLE_DbContext.cs @@ -0,0 +1,27 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CHIUSURE_TABLE_DbContext : DbContext + { + /// + public DbSet? Chiutable { get; set; } + + /// + public VT_CHIUSURE_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("CCHIUSA"); + modelBuilder.Entity().HasKey(table => new + { + table.cccodazi, + table.cccodice + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CODICE_SEGNALAZIONE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CODICE_SEGNALAZIONE_DbContext.cs new file mode 100644 index 0000000..85c9b37 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CODICE_SEGNALAZIONE_DbContext.cs @@ -0,0 +1,26 @@ +using ApiPolo.Models; +using ApiPolo.Models.VT_dbcontext; +using Microsoft.EntityFrameworkCore; + +namespace Api_VT.Models.VT_dbcontext +{ + public class VT_CODICE_SEGNALAZIONE_DbContext : DbContext + { + public DbSet CodSegn { get; set; } + + public VT_CODICE_SEGNALAZIONE_DbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("CODSEGN"); + modelBuilder.Entity().HasKey(Table => new + { + Table.cscodice, + Table.cscodazi + }); // Definizione della chiave primaria composta + + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_APP_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_APP_DbContext.cs new file mode 100644 index 0000000..9bcef32 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_APP_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// Questo db context serve per creare l'eleco delle commesse da fornire all'APP + public class VT_COMMESSE_APP_DbContext : DbContext + { + /// + public DbSet? Comm { get; set; } + + /// + public VT_COMMESSE_APP_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_COMMESSE"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_DbContext.cs new file mode 100644 index 0000000..5c71a24 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_COMMESSE_DbContext : DbContext + { + /// + public DbSet? Comm { get; set; } + + /// + public VT_COMMESSE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_COMMESSE"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_TABLE_DbContext.cs new file mode 100644 index 0000000..afee5a0 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_COMMESSE_TABLE_DbContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_COMMESSE_TABLE_DbContext : DbContext + { + /// + public DbSet? CommTable { get; set; } + + /// + public VT_COMMESSE_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("COMMESSE"); + modelBuilder.Entity().HasKey(table => new { + table.laserial, + table.lacodazi + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CONTI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CONTI_DbContext.cs new file mode 100644 index 0000000..f310e13 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CONTI_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CONTI_DbContext : DbContext + { + /// + public DbSet? Anag { get; set; } + + /// + public VT_CONTI_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_CLIENTI"); + + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_CONTI_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_CONTI_TABLE_DbContext.cs new file mode 100644 index 0000000..17d17c2 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_CONTI_TABLE_DbContext.cs @@ -0,0 +1,28 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_CONTI_TABLE_DbContext : DbContext + { + /// + public DbSet? Anagtable { get; set; } + + /// + public VT_CONTI_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("CONTI"); + modelBuilder.Entity().HasKey(table => new + { + table.antipcon, + table.ancodice, + table.ancodazi + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_DATI_AZIENDA_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_DATI_AZIENDA_DbContext.cs new file mode 100644 index 0000000..6fe6935 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_DATI_AZIENDA_DbContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_DATI_AZIENDA_DbContext : DbContext + { + /// + public DbSet? Dati { get; set; } + + /// + public VT_DATI_AZIENDA_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("DATI_AZIENDA"); + modelBuilder.Entity().HasKey(table => new + { + table.azienda, + table.tecnico + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_DbContext.cs new file mode 100644 index 0000000..93b0fb5 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_DbContext.cs @@ -0,0 +1,22 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_IMPIANTI_DbContext : DbContext + { + /// + public DbSet? Impia { get; set; } + + /// + public VT_IMPIANTI_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_IMPIANTI"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_MANAGER_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_MANAGER_DbContext.cs new file mode 100644 index 0000000..250e16b --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_MANAGER_DbContext.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_IMPIANTI_MANAGER_DbContext : DbContext + { + /// + public DbSet? Impia { get; set; } + + /// + public VT_IMPIANTI_MANAGER_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_IMPIANTI_VT"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_TABLE_DbContext.cs new file mode 100644 index 0000000..44d47f8 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_IMPIANTI_TABLE_DbContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_IMPIANTI_TABLE_DbContext : DbContext + { + /// + public DbSet? Impia { get; set; } + + /// + public VT_IMPIANTI_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("MIMPIANTI"); + modelBuilder.Entity().HasKey(table => new + { + table.imcodimp, + table.imcodazi + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs new file mode 100644 index 0000000..4b81a3e --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + public class VT_MAGAZZINI_DbContext :DbContext + { + public DbSet Magazzini { get; set; } + + + public VT_MAGAZZINI_DbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("MAGAZZINI"); + modelBuilder.Entity().HasKey(Table => new + { + Table.Azienda, + Table.Mgcodmag + }); // Definizione della chiave primaria composta + //base.OnModelCreating(modelBuilder); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_MAG_NEW_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_MAG_NEW_DbContext.cs new file mode 100644 index 0000000..967266a --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_MAG_NEW_DbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; + +namespace ApiPolo.Models.VT_dbcontext +{ + public class VT_MAG_NEW_DbContext : DbContext + { + public DbSet MagNewVt { get; set; } + + public VT_MAG_NEW_DbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("MAG_NEW_VT"); + modelBuilder.Entity() + .HasKey(Table => new { + Table.Azienda, + Table.Seriale_Rapportino, + Table.Riga + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_PROGRESSIVI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_PROGRESSIVI_DbContext.cs new file mode 100644 index 0000000..476913a --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_PROGRESSIVI_DbContext.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_PROGRESSIVI_DbContext: DbContext + { + /// + public DbSet? progr { get; set; } + + /// + public VT_PROGRESSIVI_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("PROGRESSIVI"); + modelBuilder.Entity().HasKey(table => new + { + table.azienda, + table.tipo_prog + }); + + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_RAPPORTINI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_RAPPORTINI_DbContext.cs new file mode 100644 index 0000000..a6d307d --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_RAPPORTINI_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_RAPPORTINI_DbContext : DbContext + { + /// + public DbSet? Rapportini { get; set; } + + /// + public VT_RAPPORTINI_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_RAPPORTINI"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_DbContext.cs new file mode 100644 index 0000000..34ebbc9 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_DbContext.cs @@ -0,0 +1,23 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_RAPP_NEW_DbContext : DbContext + { + /// + public DbSet? Rapps { get; set; } + + /// + public VT_RAPP_NEW_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_RAPP_NEW"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_TABLE_DbContext.cs new file mode 100644 index 0000000..8167e1c --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_RAPP_NEW_TABLE_DbContext.cs @@ -0,0 +1,27 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_RAPP_NEW_TABLE_DbContext : DbContext + { + /// + public DbSet? Rapps { get; set; } + + /// + public VT_RAPP_NEW_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("RAPP_NEW"); + modelBuilder.Entity().HasKey(table => new + { + table.seriale_rapportino + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_REGISTRAZIONE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_REGISTRAZIONE_DbContext.cs new file mode 100644 index 0000000..1c94d2f --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_REGISTRAZIONE_DbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_REGISTRAZIONE_DbContext : DbContext + { + /// + public DbSet? Reg { get; set; } + + /// + public VT_REGISTRAZIONE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("REGISTRAZIONI"); + modelBuilder.Entity().HasKey(table => new + { + table.Id + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_SALDIART_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_SALDIART_DbContext.cs new file mode 100644 index 0000000..aeab8a7 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_SALDIART_DbContext.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + public class VT_SALDIART_DbContext : DbContext + { + public DbSet? SaldiArt_VT { get; set; } + + public VT_SALDIART_DbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_SALDIART_PREZZI"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_STO_RAPP_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_STO_RAPP_DbContext.cs new file mode 100644 index 0000000..f49a282 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_STO_RAPP_DbContext.cs @@ -0,0 +1,23 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_STO_RAPP_DbContext : DbContext + { + /// + public DbSet? StoRapp { get; set; } + + /// + public VT_STO_RAPP_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_STO_RAPP"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_TECNICI_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_TECNICI_DbContext.cs new file mode 100644 index 0000000..531f5c3 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_TECNICI_DbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_TECNICI_DbContext : DbContext + { + /// + public DbSet? Tecnici { get; set; } + + /// + public VT_TECNICI_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToView("API_TECNICI"); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_TECNICI_TABLE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_TECNICI_TABLE_DbContext.cs new file mode 100644 index 0000000..eb2b54c --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_TECNICI_TABLE_DbContext.cs @@ -0,0 +1,27 @@ + +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_TECNICI_TABLE_DbContext : DbContext + { + /// + public DbSet? Tectable { get; set; } + + /// + public VT_TECNICI_TABLE_DbContext(DbContextOptions options) : base(options) + { + } + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("TECNICI"); + modelBuilder.Entity().HasKey(table => new + { + table.tccodazi, + table.tccodice + }); + } + } +} diff --git a/ApiPolo/Models/VT_dbcontext/VT_TIMBRATURE_DbContext.cs b/ApiPolo/Models/VT_dbcontext/VT_TIMBRATURE_DbContext.cs new file mode 100644 index 0000000..7025000 --- /dev/null +++ b/ApiPolo/Models/VT_dbcontext/VT_TIMBRATURE_DbContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace ApiPolo.Models.VT_dbcontext +{ + /// + public class VT_TIMBRATURE_DbContext : DbContext + { + /// + public DbSet? Timbr { get; set; } + + /// + public VT_TIMBRATURE_DbContext(DbContextOptions options) : base(options) + { + } + + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("TIMBRATURE"); + modelBuilder.Entity().HasKey(table => new + { + table.id + }); + } + } +} diff --git a/ApiPolo/Models/Vt_Mag_New.cs b/ApiPolo/Models/Vt_Mag_New.cs new file mode 100644 index 0000000..79efc63 --- /dev/null +++ b/ApiPolo/Models/Vt_Mag_New.cs @@ -0,0 +1,34 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace ApiPolo.Models +{ + public class Vt_Mag_New + { + [Key] + [Required] + public string? Azienda { get; set; } + [Key] + [Required] + public string? Seriale_Rapportino { get; set; } + [Key] + [Required] + public int? Riga { get; set; } + public string? Magazzino { get; set; } + public string? Articolo { get; set; } + public string Tipo_Movimento { get; set; } + public decimal? Quantita { get; set; } + public decimal? Prezzo { get; set; } + public string? Codice_Tecnico { get; set; } + public string? Generato { get; set; } + public string? Note { get; set; } + public string? CodLotto { get; set; } + public string? Matricola { get; set; } + public int? Cprownum { get; set; } + public string? Desc_Art { get; set; } + public string? CodImp { get; set; } + public string? Desc_Sup { get; set; } + public string? Cpccchk { get; set; } + + } +} diff --git a/ApiPolo/Program.cs b/ApiPolo/Program.cs new file mode 100644 index 0000000..b52b560 --- /dev/null +++ b/ApiPolo/Program.cs @@ -0,0 +1,65 @@ +/*using Microsoft.AspNetCore.Authentication.Negotiate; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme) + .AddNegotiate(); + +builder.Services.AddAuthorization(options => +{ + // By default, all incoming requests will be authorized according to the default policy. + options.FallbackPolicy = options.DefaultPolicy; +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); +*/ + +namespace ApiPolo +{ + /// + public class Program + { + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + webBuilder.ConfigureKestrel(options => + { + options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(5); + }); + //webBuilder.UseUrls("http://10.0.0.187:5000").UseStartup(); + }); + } +} + diff --git a/ApiPolo/Properties/launchSettings.json b/ApiPolo/Properties/launchSettings.json new file mode 100644 index 0000000..3c7651a --- /dev/null +++ b/ApiPolo/Properties/launchSettings.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": true, + "anonymousAuthentication": false, + "iisExpress": { + "applicationUrl": "http://localhost:15743", + "sslPort": 44322 + } + }, + "profiles": { + "ApiPolo": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + //"applicationUrl": "https://localhost:7068;http://localhost:5068;http://10.0.0.187:5068;https://10.0.0.187:7068", + "applicationUrl": "https://localhost:7068;http://localhost:5068", + + + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/ApiPolo/SQL/CreaVisteGitoga.txt b/ApiPolo/SQL/CreaVisteGitoga.txt new file mode 100644 index 0000000..9d59fcf --- /dev/null +++ b/ApiPolo/SQL/CreaVisteGitoga.txt @@ -0,0 +1,273 @@ +USE [R80_GITSR] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 01/02/2023 15:02:43 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from [R80_MARROCCO_TEST].dbo.GITSRCAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 01/02/2023 15:08:38 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM [R80_MARROCCO_TEST].dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' and CCCODAZI='GITSR' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 01/02/2023 16:53:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +CREATE VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM [R80_MARROCCO_TEST].dbo.GITSRCONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 01/02/2023 15:10:15 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from [R80_MARROCCO_TEST].dbo.GITSRPAG_AMEN +GO + + + +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 01/02/2023 16:55:27 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +CREATE VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM [R80_MARROCCO_TEST].dbo.RAPP_NEW where AZIENDA_IMPIANTO='GITSR' +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 01/02/2023 15:13:05 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_STO_RAPP] +AS +select + +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,/*RAPPMAST.NOTE_ESITO,*/'' as NOTE_ESITO,DATA_RAPPORTINO +, STATO_FINALE,/*RAPPMAST.ESITO_INTERVENTO,*/'' as ESITO_INTERVENTO,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO,DIFETTI_RISCONTRATI,LAVORO_ESEGUITO,NOTE_INTERVENTO +,ORE_LAVORO,MATERIALE,DIRITTO_CHIAMATA,ANTICIPO, MANODOPERA, SPESE_VIAGGIO,pagamento,CODICE_IMPIANTO, +TOTALE,NOTE_PAGAMENTO,TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from [R80_MARROCCO_TEST].dbo.GITSRRAPPMAST RAPPMAST left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join [R80_MARROCCO_TEST].dbo.TECNICI on RACODTE1=TCCODICE +left outer join [R80_MARROCCO_TEST].dbo.CHIAMATE on CHCODAZI='GITSR' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +left outer join [R80_MARROCCO_TEST].dbo.PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='GITSR' +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.CODINTE ON PICODINT = [R80_MARROCCO_TEST].dbo.CODINTE.CICODICE +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.MIMPIANTI ON AZIENDA_IMPIANTO = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 01/02/2023 15:24:18 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_IMPIANTI] +AS +SELECT +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDCL, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTAMM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTTAM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI3, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI4, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODCAP, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCOMUNE, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODNAZ, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONMAN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMFLPUPR, [R80_MARROCCO_TEST].dbo.MIMPIANTI.UTDC, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.UTDV, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPIAMAN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDATATT, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONCHI, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONSUP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDAINMA, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDAFIMA, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDATCOS, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTELESO, [R80_MARROCCO_TEST].dbo.API_CLIENTI.AN_EMAIL,'' as IMAZIRIF +FROM +[R80_MARROCCO_TEST].dbo.MIMPIANTI INNER JOIN +[R80_MARROCCO_TEST].dbo.API_CLIENTI ON [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI = [R80_MARROCCO_TEST].dbo.API_CLIENTI.ANCODICE +where [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI='GITSR' +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 01/02/2023 15:31:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_TECNICI] +AS +SELECT +[R80_MARROCCO_TEST].dbo.TECNICI.TCCODICE, [R80_MARROCCO_TEST].dbo.TECNICI.TCDESCRI, [R80_MARROCCO_TEST].dbo.TECNICI.TCTELEF1, [R80_MARROCCO_TEST].dbo.TECNICI.TCCHIAM, [R80_MARROCCO_TEST].dbo.TECNICI.TCMANUT, +[R80_MARROCCO_TEST].dbo.TECNICI.TCCODAZI, [R80_MARROCCO_TEST].dbo.TECNICI.TCSUPER, [R80_MARROCCO_TEST].dbo.TECNICI.TCUSER, [R80_MARROCCO_TEST].dbo.TECNICI.TCPWD, +[R80_MARROCCO_TEST].dbo.TECDISP.TDCODZON, [R80_MARROCCO_TEST].dbo.TECDISP.TDDATAIN, [R80_MARROCCO_TEST].dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno, +TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM +[R80_MARROCCO_TEST].dbo.TECNICI INNER JOIN +[R80_MARROCCO_TEST].dbo.TECDISP ON [R80_MARROCCO_TEST].dbo.TECNICI.TCCODICE = [R80_MARROCCO_TEST].dbo.TECDISP.TDCODTEC AND [R80_MARROCCO_TEST].dbo.TECNICI.TCCODAZI = [R80_MARROCCO_TEST].dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 01/02/2023 15:38:15 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSERIAL, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODESE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTIPO, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHNUMERO, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORA, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMIN, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHOPASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHOPCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODIMP, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHAZIIMP, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTATO, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTAPP, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORAAPI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINAPI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHORAAPF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINAPF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHRIFER, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTELEF, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODSEG, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTOPI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHNOTE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTASS, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHORASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORACHI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTLIN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORALI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINLI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTLFI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORALF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINLF, [R80_MARROCCO_TEST].dbo.CHIAMATE.cpccchk, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHNRAP1, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSRAP1, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHNRAP2, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSRAP2, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHMODRAC, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHPRGANN, [R80_MARROCCO_TEST].dbo.CHIAMATE.UTCC, [R80_MARROCCO_TEST].dbo.CHIAMATE.UTCV, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHIMPMAN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHPERMAN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHFLSTIM, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHFLESTE, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHTCHIAM as TCCODICE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSEREXT, API_IMPIANTI.IMDESCRI, API_IMPIANTI.IMTIPOIM, +API_IMPIANTI.IMMATRIC, API_IMPIANTI.IMNUMIMP, API_IMPIANTI.IMULTAMM, API_IMPIANTI.IMULTDAM, +API_IMPIANTI.IMULTTAM, API_IMPIANTI.IMINDIRI1, API_IMPIANTI.IMINDIRI2, API_IMPIANTI.IMINDIRI3, +API_IMPIANTI.IMINDIRI4, API_IMPIANTI.IMINDIRI5, API_IMPIANTI.IMLOCALI, +API_IMPIANTI.IMCODCAP, API_IMPIANTI.IMCOMUNE, API_IMPIANTI.IMPROVIN, API_IMPIANTI.IMCODNAZ, +API_IMPIANTI.IMUBICAZ, API_IMPIANTI.IMZONMAN, API_IMPIANTI.IMFLPUPR, API_IMPIANTI.IMZONCHI, +API_IMPIANTI.IMZONSUP, API_IMPIANTI.IMDAINMA, API_IMPIANTI.IMDAFIMA, API_IMPIANTI.IMDATCOS, +API_IMPIANTI.IMTELESO, API_IMPIANTI.AN_EMAIL,API_IMPIANTI.IMULTCLI, [R80_MARROCCO_TEST].dbo.GITSRCONTI.ANCODICE, +[R80_MARROCCO_TEST].dbo.GITSRCONTI.ANTIPCON, [R80_MARROCCO_TEST].dbo.GITSRCONTI.ANDESCRI, [R80_MARROCCO_TEST].dbo.GITSRCONTI.ANTELEFO, [R80_MARROCCO_TEST].dbo.CODSEGN.CSDESCR, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTCHIAM +,'' as IMAZIRIF +,(select top 1 tcdescri from dbo.API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from [R80_MARROCCO_TEST].dbo.GITSRMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO_TEST].dbo.GITSRMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from [R80_MARROCCO_TEST].dbo.CHIAMATE +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join [R80_MARROCCO_TEST].dbo.CODSEGN ON [R80_MARROCCO_TEST].dbo.CODSEGN.CSCODICE = [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODSEG AND [R80_MARROCCO_TEST].dbo.CODSEGN.CSCODAZI = [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.GITSRCONTI +INNER JOIN dbo.API_IMPIANTI ON [R80_MARROCCO_TEST].dbo.GITSRCONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND [R80_MARROCCO_TEST].dbo.GITSRCONTI.ANTIPCON = 'C' ON [R80_MARROCCO_TEST].dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTATO = 'C' +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI='GITSR' +GO + +/****** Object: View [dbo].[API_MANPROG] Script Date: 01/02/2023 15:43:35 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_MANPROG] +AS + +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,[R80_MARROCCO_TEST].dbo.MANPROG.MPCODAZI AS CTCODAZI, [R80_MARROCCO_TEST].dbo.MANPROG.MPCODIMP AS CTCODIMP, [R80_MARROCCO_TEST].dbo.MANPROG.MPCODINT AS CTCODINT, +[R80_MARROCCO_TEST].dbo.CODINTE.CIDESCRI AS CTDESINT, [R80_MARROCCO_TEST].dbo.MANPROG.MPDATPRO AS CTDATPRO, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTAMM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI3, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI4, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODCAP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCOMUNE, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODNAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONMAN, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMRIFERI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONCHI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONSUP,[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTTAM as TELEFONO1, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTFAM as TELEFONO2,[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI as CLIENTE,[R80_MARROCCO_TEST].dbo.MANPROG.MPMESGEN, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESFEB, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESMAR, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESAPR, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESMAG, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESLUG, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESGIU, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESAGO, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESSET, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESOTT, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESNOV, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESDIC,T.TCDESCRI,T.TCCODICE,'' as IMAZIRIF +,(select top 1 CTIMPCHI from [R80_MARROCCO_TEST].dbo.GITSRMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO_TEST].dbo.GITSRMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM [R80_MARROCCO_TEST].dbo.MANPROG INNER JOIN [R80_MARROCCO_TEST].dbo.MIMPIANTI ON [R80_MARROCCO_TEST].dbo.MANPROG.MPCODAZI = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI AND [R80_MARROCCO_TEST].dbo.MANPROG.MPCODIMP = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.CODINTE ON [R80_MARROCCO_TEST].dbo.MANPROG.MPCODINT = [R80_MARROCCO_TEST].dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT /*and TCCODICE=picodtec*/ and MPDATPRO=PIDATMAN) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' +and MANPROG.MPCODAZI='GITSR' +GO diff --git a/ApiPolo/SQL/CreaVisteLifta.txt b/ApiPolo/SQL/CreaVisteLifta.txt new file mode 100644 index 0000000..2e6c1b0 --- /dev/null +++ b/ApiPolo/SQL/CreaVisteLifta.txt @@ -0,0 +1,273 @@ +USE [R80_LIFTA] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 01/02/2023 15:02:43 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from [R80_MARROCCO_TEST].dbo.LIFTACAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 01/02/2023 15:08:38 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM [R80_MARROCCO_TEST].dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' and CCCODAZI='LIFTA' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 01/02/2023 16:53:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +CREATE VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM [R80_MARROCCO_TEST].dbo.LIFTACONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 01/02/2023 15:10:15 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from [R80_MARROCCO_TEST].dbo.LIFTAPAG_AMEN +GO + + + +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 01/02/2023 16:55:27 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +CREATE VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM [R80_MARROCCO_TEST].dbo.RAPP_NEW where AZIENDA_IMPIANTO='LIFTA' +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 01/02/2023 15:13:05 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_STO_RAPP] +AS +select + +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,/*RAPPMAST.NOTE_ESITO,*/'' as NOTE_ESITO,DATA_RAPPORTINO +, STATO_FINALE,/*RAPPMAST.ESITO_INTERVENTO,*/'' as ESITO_INTERVENTO,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO,DIFETTI_RISCONTRATI,LAVORO_ESEGUITO,NOTE_INTERVENTO +,ORE_LAVORO,MATERIALE,DIRITTO_CHIAMATA,ANTICIPO, MANODOPERA, SPESE_VIAGGIO,pagamento,CODICE_IMPIANTO, +TOTALE,NOTE_PAGAMENTO,TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from [R80_MARROCCO_TEST].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from [R80_MARROCCO_TEST].dbo.LIFTARAPPMAST RAPPMAST left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join [R80_MARROCCO_TEST].dbo.TECNICI on RACODTE1=TCCODICE +left outer join [R80_MARROCCO_TEST].dbo.CHIAMATE on CHCODAZI='LIFTA' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +left outer join [R80_MARROCCO_TEST].dbo.PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='LIFTA' +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.CODINTE ON PICODINT = [R80_MARROCCO_TEST].dbo.CODINTE.CICODICE +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.MIMPIANTI ON AZIENDA_IMPIANTO = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 01/02/2023 15:24:18 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_IMPIANTI] +AS +SELECT +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDCL, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTAMM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTTAM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI3, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI4, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODCAP, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCOMUNE, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODNAZ, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONMAN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMFLPUPR, [R80_MARROCCO_TEST].dbo.MIMPIANTI.UTDC, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.UTDV, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPIAMAN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDATATT, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONCHI, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONSUP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDAINMA, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDAFIMA, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDATCOS, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTELESO, [R80_MARROCCO_TEST].dbo.API_CLIENTI.AN_EMAIL,'' as IMAZIRIF +FROM +[R80_MARROCCO_TEST].dbo.MIMPIANTI INNER JOIN +[R80_MARROCCO_TEST].dbo.API_CLIENTI ON [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI = [R80_MARROCCO_TEST].dbo.API_CLIENTI.ANCODICE +where [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI='LIFTA' +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 01/02/2023 15:31:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_TECNICI] +AS +SELECT +[R80_MARROCCO_TEST].dbo.TECNICI.TCCODICE, [R80_MARROCCO_TEST].dbo.TECNICI.TCDESCRI, [R80_MARROCCO_TEST].dbo.TECNICI.TCTELEF1, [R80_MARROCCO_TEST].dbo.TECNICI.TCCHIAM, [R80_MARROCCO_TEST].dbo.TECNICI.TCMANUT, +[R80_MARROCCO_TEST].dbo.TECNICI.TCCODAZI, [R80_MARROCCO_TEST].dbo.TECNICI.TCSUPER, [R80_MARROCCO_TEST].dbo.TECNICI.TCUSER, [R80_MARROCCO_TEST].dbo.TECNICI.TCPWD, +[R80_MARROCCO_TEST].dbo.TECDISP.TDCODZON, [R80_MARROCCO_TEST].dbo.TECDISP.TDDATAIN, [R80_MARROCCO_TEST].dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno, +TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM +[R80_MARROCCO_TEST].dbo.TECNICI INNER JOIN +[R80_MARROCCO_TEST].dbo.TECDISP ON [R80_MARROCCO_TEST].dbo.TECNICI.TCCODICE = [R80_MARROCCO_TEST].dbo.TECDISP.TDCODTEC AND [R80_MARROCCO_TEST].dbo.TECNICI.TCCODAZI = [R80_MARROCCO_TEST].dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 01/02/2023 15:38:15 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSERIAL, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODESE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTIPO, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHNUMERO, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORA, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMIN, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHOPASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHOPCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODIMP, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHAZIIMP, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTATO, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTAPP, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORAAPI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINAPI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHORAAPF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINAPF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHRIFER, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTELEF, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODSEG, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTOPI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHNOTE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTASS, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHORASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINASS, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORACHI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINCHI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTLIN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORALI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINLI, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHDTLFI, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHORALF, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHMINLF, [R80_MARROCCO_TEST].dbo.CHIAMATE.cpccchk, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHNRAP1, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSRAP1, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHNRAP2, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSRAP2, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHMODRAC, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHPRGANN, [R80_MARROCCO_TEST].dbo.CHIAMATE.UTCC, [R80_MARROCCO_TEST].dbo.CHIAMATE.UTCV, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHIMPMAN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHPERMAN, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHFLSTIM, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHFLESTE, +[R80_MARROCCO_TEST].dbo.CHIAMATE.CHTCHIAM as TCCODICE, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSEREXT, API_IMPIANTI.IMDESCRI, API_IMPIANTI.IMTIPOIM, +API_IMPIANTI.IMMATRIC, API_IMPIANTI.IMNUMIMP, API_IMPIANTI.IMULTAMM, API_IMPIANTI.IMULTDAM, +API_IMPIANTI.IMULTTAM, API_IMPIANTI.IMINDIRI1, API_IMPIANTI.IMINDIRI2, API_IMPIANTI.IMINDIRI3, +API_IMPIANTI.IMINDIRI4, API_IMPIANTI.IMINDIRI5, API_IMPIANTI.IMLOCALI, +API_IMPIANTI.IMCODCAP, API_IMPIANTI.IMCOMUNE, API_IMPIANTI.IMPROVIN, API_IMPIANTI.IMCODNAZ, +API_IMPIANTI.IMUBICAZ, API_IMPIANTI.IMZONMAN, API_IMPIANTI.IMFLPUPR, API_IMPIANTI.IMZONCHI, +API_IMPIANTI.IMZONSUP, API_IMPIANTI.IMDAINMA, API_IMPIANTI.IMDAFIMA, API_IMPIANTI.IMDATCOS, +API_IMPIANTI.IMTELESO, API_IMPIANTI.AN_EMAIL,API_IMPIANTI.IMULTCLI, [R80_MARROCCO_TEST].dbo.LIFTACONTI.ANCODICE, +[R80_MARROCCO_TEST].dbo.LIFTACONTI.ANTIPCON, [R80_MARROCCO_TEST].dbo.LIFTACONTI.ANDESCRI, [R80_MARROCCO_TEST].dbo.LIFTACONTI.ANTELEFO, [R80_MARROCCO_TEST].dbo.CODSEGN.CSDESCR, [R80_MARROCCO_TEST].dbo.CHIAMATE.CHTCHIAM +,'' as IMAZIRIF +,(select top 1 tcdescri from dbo.API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from [R80_MARROCCO_TEST].dbo.LIFTAMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO_TEST].dbo.LIFTAMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from [R80_MARROCCO_TEST].dbo.CHIAMATE +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join [R80_MARROCCO_TEST].dbo.CODSEGN ON [R80_MARROCCO_TEST].dbo.CODSEGN.CSCODICE = [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODSEG AND [R80_MARROCCO_TEST].dbo.CODSEGN.CSCODAZI = [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.LIFTACONTI +INNER JOIN dbo.API_IMPIANTI ON [R80_MARROCCO_TEST].dbo.LIFTACONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND [R80_MARROCCO_TEST].dbo.LIFTACONTI.ANTIPCON = 'C' ON [R80_MARROCCO_TEST].dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHSTATO = 'C' +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) +and [R80_MARROCCO_TEST].dbo.CHIAMATE.CHCODAZI='LIFTA' +GO + +/****** Object: View [dbo].[API_MANPROG] Script Date: 01/02/2023 15:43:35 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_MANPROG] +AS + +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,[R80_MARROCCO_TEST].dbo.MANPROG.MPCODAZI AS CTCODAZI, [R80_MARROCCO_TEST].dbo.MANPROG.MPCODIMP AS CTCODIMP, [R80_MARROCCO_TEST].dbo.MANPROG.MPCODINT AS CTCODINT, +[R80_MARROCCO_TEST].dbo.CODINTE.CIDESCRI AS CTDESINT, [R80_MARROCCO_TEST].dbo.MANPROG.MPDATPRO AS CTDATPRO, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTAMM, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI3, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI4, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODCAP, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCOMUNE, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODNAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONMAN, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMRIFERI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONCHI, [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMZONSUP,[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTTAM as TELEFONO1, +[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTFAM as TELEFONO2,[R80_MARROCCO_TEST].dbo.MIMPIANTI.IMULTCLI as CLIENTE,[R80_MARROCCO_TEST].dbo.MANPROG.MPMESGEN, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESFEB, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESMAR, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESAPR, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESMAG, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESLUG, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESGIU, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESAGO, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESSET, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESOTT, +[R80_MARROCCO_TEST].dbo.MANPROG.MPMESNOV, [R80_MARROCCO_TEST].dbo.MANPROG.MPMESDIC,T.TCDESCRI,T.TCCODICE,'' as IMAZIRIF +,(select top 1 CTIMPCHI from [R80_MARROCCO_TEST].dbo.LIFTAMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO_TEST].dbo.LIFTAMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM [R80_MARROCCO_TEST].dbo.MANPROG INNER JOIN [R80_MARROCCO_TEST].dbo.MIMPIANTI ON [R80_MARROCCO_TEST].dbo.MANPROG.MPCODAZI = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODAZI AND [R80_MARROCCO_TEST].dbo.MANPROG.MPCODIMP = [R80_MARROCCO_TEST].dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN [R80_MARROCCO_TEST].dbo.CODINTE ON [R80_MARROCCO_TEST].dbo.MANPROG.MPCODINT = [R80_MARROCCO_TEST].dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT /*and TCCODICE=picodtec*/ and MPDATPRO=PIDATMAN) +left outer join [R80_MARROCCO_TEST].dbo.RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' +and MANPROG.MPCODAZI='LIFTA' +GO diff --git a/ApiPolo/SQL/CreaVisteMarrocco.txt b/ApiPolo/SQL/CreaVisteMarrocco.txt new file mode 100644 index 0000000..1d17483 --- /dev/null +++ b/ApiPolo/SQL/CreaVisteMarrocco.txt @@ -0,0 +1,222 @@ +/* +[API_CAUS_RAPP] +[API_CHIUSURE] +[API_CLIENTI] +[API_PAGAMENTI] +[API_RAPP_NEW] +[API_STO_RAPP] +[API_IMPIANTI] +[API_TECNICI] +[API_CHIAMATE] +[API_MANPROG] + +per magazzino +[API_MAG_NEW] +[API_MICOMIMP] +[API_SALDIART] +[API_SALDIART_PREZZI] +[API_STO_IMP] +*/ + +USE [R80_MARROCCO] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 19/01/2023 14:39:58 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from MARROCAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 19/01/2023 14:40:35 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 19/01/2023 14:40:54 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +CREATE VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM dbo.MARROCONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 19/01/2023 14:41:21 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from MARROPAG_AMEN +GO +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 19/01/2023 14:42:20 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM dbo.RAPP_NEW +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 19/01/2023 14:43:07 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_STO_RAPP] +AS select RAPPMAST.RACAURAP,RAPPMAST.RAAZIIMP,RAPPMAST.RACODIMP,RAPPMAST.RATIPCLI,RAPPMAST.RACODCLI,RAPPMAST.RANUMRAP,RAPPMAST.RAALFRAP,RAPPMAST.RADATRAP,RAPPMAST.RAAZITE1, +RAPPMAST.RACODTE1,CAST(RAPPMAST.RADESINT AS CHAR(250)) as RADESINT,CAST(RAPPMAST.RANOTINT AS CHAR(250)) as RANOTINT,RAPPMAST.RADESCRI +from MARRORAPPMAST RAPPMAST +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 19/01/2023 14:43:30 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_IMPIANTI] +AS +SELECT dbo.MIMPIANTI.IMCODAZI, dbo.MIMPIANTI.IMCODIMP, dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTCLI, + dbo.MIMPIANTI.IMULTDCL, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTTAM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, dbo.MIMPIANTI.IMINDIRI3, + dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, + dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMFLPUPR, dbo.MIMPIANTI.UTDC, dbo.MIMPIANTI.UTDV, dbo.MIMPIANTI.IMPIAMAN, dbo.MIMPIANTI.IMDATATT, dbo.MIMPIANTI.IMZONCHI, + dbo.MIMPIANTI.IMZONSUP, dbo.MIMPIANTI.IMDAINMA, dbo.MIMPIANTI.IMDAFIMA, dbo.MIMPIANTI.IMDATCOS, dbo.MIMPIANTI.IMTELESO, + dbo.API_CLIENTI.AN_EMAIL +FROM dbo.MIMPIANTI INNER JOIN + dbo.API_CLIENTI ON dbo.MIMPIANTI.IMULTCLI = dbo.API_CLIENTI.ANCODICE +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 19/01/2023 14:44:10 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_TECNICI] +AS +SELECT dbo.TECNICI.TCCODICE, dbo.TECNICI.TCDESCRI, dbo.TECNICI.TCTELEF1, dbo.TECNICI.TCCHIAM, dbo.TECNICI.TCMANUT, dbo.TECNICI.TCCODAZI, dbo.TECNICI.TCSUPER, dbo.TECNICI.TCUSER, dbo.TECNICI.TCPWD, + dbo.TECDISP.TDCODZON, dbo.TECDISP.TDDATAIN, dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno,TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM dbo.TECNICI INNER JOIN + dbo.TECDISP ON dbo.TECNICI.TCCODICE = dbo.TECDISP.TDCODTEC AND dbo.TECNICI.TCCODAZI = dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 19/01/2023 14:44:37 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +dbo.CHIAMATE.CHCODAZI, dbo.CHIAMATE.CHSERIAL, dbo.CHIAMATE.CHCODESE, dbo.CHIAMATE.CHTIPO, dbo.CHIAMATE.CHNUMERO, dbo.CHIAMATE.CHDATA, dbo.CHIAMATE.CHORA, dbo.CHIAMATE.CHMIN, +dbo.CHIAMATE.CHOPASS, dbo.CHIAMATE.CHOPCHI, dbo.CHIAMATE.CHCODIMP, dbo.CHIAMATE.CHAZIIMP, dbo.CHIAMATE.CHSTATO, dbo.CHIAMATE.CHDTAPP, dbo.CHIAMATE.CHORAAPI, dbo.CHIAMATE.CHMINAPI, +dbo.CHIAMATE.CHORAAPF, dbo.CHIAMATE.CHMINAPF, dbo.CHIAMATE.CHRIFER, dbo.CHIAMATE.CHTELEF, dbo.CHIAMATE.CHCODSEG, dbo.CHIAMATE.CHSTOPI, dbo.CHIAMATE.CHNOTE, dbo.CHIAMATE.CHDTASS, +dbo.CHIAMATE.CHORASS, dbo.CHIAMATE.CHMINASS, dbo.CHIAMATE.CHDTCHI, dbo.CHIAMATE.CHORACHI, dbo.CHIAMATE.CHMINCHI, dbo.CHIAMATE.CHDTLIN, dbo.CHIAMATE.CHORALI, dbo.CHIAMATE.CHMINLI, +dbo.CHIAMATE.CHDTLFI, dbo.CHIAMATE.CHORALF, dbo.CHIAMATE.CHMINLF, dbo.CHIAMATE.cpccchk, dbo.CHIAMATE.CHNRAP1, dbo.CHIAMATE.CHSRAP1, dbo.CHIAMATE.CHNRAP2, dbo.CHIAMATE.CHSRAP2, +dbo.CHIAMATE.CHMODRAC, dbo.CHIAMATE.CHPRGANN, dbo.CHIAMATE.UTCC, dbo.CHIAMATE.UTCV, dbo.CHIAMATE.CHIMPMAN, dbo.CHIAMATE.CHPERMAN, dbo.CHIAMATE.CHFLSTIM, dbo.CHIAMATE.CHFLESTE,CHIAMATE.CHTCHIAM as TCCODICE, +dbo.CHIAMATE.CHSEREXT, dbo.API_IMPIANTI.IMDESCRI, dbo.API_IMPIANTI.IMTIPOIM, dbo.API_IMPIANTI.IMMATRIC, dbo.API_IMPIANTI.IMNUMIMP, dbo.API_IMPIANTI.IMULTAMM, dbo.API_IMPIANTI.IMULTDAM, +dbo.API_IMPIANTI.IMULTTAM, dbo.API_IMPIANTI.IMINDIRI1, dbo.API_IMPIANTI.IMINDIRI2, dbo.API_IMPIANTI.IMINDIRI3, dbo.API_IMPIANTI.IMINDIRI4, dbo.API_IMPIANTI.IMINDIRI5, dbo.API_IMPIANTI.IMLOCALI, +dbo.API_IMPIANTI.IMCODCAP, dbo.API_IMPIANTI.IMCOMUNE, dbo.API_IMPIANTI.IMPROVIN, dbo.API_IMPIANTI.IMCODNAZ, dbo.API_IMPIANTI.IMUBICAZ, dbo.API_IMPIANTI.IMZONMAN, dbo.API_IMPIANTI.IMFLPUPR, +dbo.API_IMPIANTI.IMZONCHI, dbo.API_IMPIANTI.IMZONSUP, dbo.API_IMPIANTI.IMDAINMA, dbo.API_IMPIANTI.IMDAFIMA, dbo.API_IMPIANTI.IMDATCOS, dbo.API_IMPIANTI.IMTELESO, dbo.API_IMPIANTI.AN_EMAIL, +dbo.API_IMPIANTI.IMULTCLI, dbo.MARROCONTI.ANCODICE, dbo.MARROCONTI.ANTIPCON, dbo.MARROCONTI.ANDESCRI, dbo.MARROCONTI.ANTELEFO, dbo.CODSEGN.CSDESCR, dbo.CHIAMATE.CHTCHIAM + +,(select top 1 tcdescri from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from CHIAMATE +left outer join RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join CODSEGN ON dbo.CODSEGN.CSCODICE = dbo.CHIAMATE.CHCODSEG AND dbo.CODSEGN.CSCODAZI = dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN dbo.MARROCONTI +INNER JOIN dbo.API_IMPIANTI ON dbo.MARROCONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND dbo.MARROCONTI.ANTIPCON = 'C' ON dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and dbo.CHIAMATE.CHSTATO = 'C' +and CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) +--and dbo.CHIAMATE.CHSERIAL='0000282320' +--and CHIAMATE.CHTCHIAM='002' and CHIAMATE.CHCODAZI='MARRO' +GO + +/****** Object: View [dbo].[API_MANPROG] Script Date: 19/01/2023 14:45:46 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_MANPROG] +AS + +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,dbo.MANPROG.MPCODAZI AS CTCODAZI, dbo.MANPROG.MPCODIMP AS CTCODIMP, dbo.MANPROG.MPCODINT AS CTCODINT, dbo.CODINTE.CIDESCRI AS CTDESINT, dbo.MANPROG.MPDATPRO AS CTDATPRO, + dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, + dbo.MIMPIANTI.IMINDIRI3, dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, + dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMRIFERI, dbo.MIMPIANTI.IMZONCHI, dbo.MIMPIANTI.IMZONSUP, + dbo.MIMPIANTI.IMULTTAM as TELEFONO1,dbo.MIMPIANTI.IMULTFAM as TELEFONO2,dbo.MIMPIANTI.IMULTCLI as CLIENTE, + dbo.MANPROG.MPMESGEN, dbo.MANPROG.MPMESFEB, dbo.MANPROG.MPMESMAR, dbo.MANPROG.MPMESAPR, dbo.MANPROG.MPMESMAG, dbo.MANPROG.MPMESLUG, + dbo.MANPROG.MPMESGIU, dbo.MANPROG.MPMESAGO, dbo.MANPROG.MPMESSET, dbo.MANPROG.MPMESOTT, dbo.MANPROG.MPMESNOV, dbo.MANPROG.MPMESDIC, + T.TCDESCRI,T.TCCODICE +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM dbo.MANPROG INNER JOIN dbo.MIMPIANTI ON dbo.MANPROG.MPCODAZI = dbo.MIMPIANTI.IMCODAZI AND dbo.MANPROG.MPCODIMP = dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN dbo.CODINTE ON dbo.MANPROG.MPCODINT = dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT /*and TCCODICE=picodtec*/ and MPDATPRO=PIDATMAN) +left outer join RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +--and MANPROG.MPDATPRO<=DATEADD(month, 2, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' + +GO \ No newline at end of file diff --git a/ApiPolo/SQL/Discovery_1_8.txt b/ApiPolo/SQL/Discovery_1_8.txt new file mode 100644 index 0000000..c40d839 --- /dev/null +++ b/ApiPolo/SQL/Discovery_1_8.txt @@ -0,0 +1,266 @@ +USE [TEST_APP_NEW] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 22/03/2023 14:15:42 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from DISCOCAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 22/03/2023 14:18:36 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' and coalesce(CCCODICE,'')<>'' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 22/03/2023 14:19:54 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM dbo.DISCOCONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 22/03/2023 14:20:28 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from DISCOPAG_AMEN +GO +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 22/03/2023 14:21:13 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, SER_BUONO,CODICE_INTERVENTO, + + '' as DIFETTI_RISCONTRATI, '' as LAVORO_ESEGUITO, '' as ESITO_INTERVENTO,'' as NOTE_ESITO, '' as NOTE_INTERVENTO,'' as NUOVO_CONTRATTO, 0.00 as ORE_LAVORO, '' as CAUSALE, + 0.00 as MATERIALE, 0.00 as DIRITTO_CHIAMATA, 0.00 as MANODOPERA, 0.00 as SPESE_VIAGGIO, + '' as PAGAMENTO, 0.00 as ANTICIPO, 0.00 as TOTALE, '' as NOTE_PAGAMENTO, '' as TIPO_INTERVENTO, '' as RAFOTO1, '' as RAFOTO2, '' as RAFOTO3, '' as RAFOTO4, '' as RAFOTO5, + '' as RAFOTO6, '' as RAFOTO7, '' as RAFOTO8, '' as RAFOTO9, '' as RAFOTO10, + DATA_EFFETTIVA +FROM dbo.RAPP_NEW +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 22/03/2023 14:22:26 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +ALTER VIEW [dbo].[API_STO_RAPP] +AS + +select +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,DATA_RAPPORTINO +, STATO_FINALE,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO, +--campi rappmast +'' as NOTE_ESITO,'' as ESITO_INTERVENTO, +--fine campi rappmast +'' as DIFETTI_RISCONTRATI,'' as LAVORO_ESEGUITO,'' as NOTE_INTERVENTO +,0.00 as ORE_LAVORO,0.00 as MATERIALE,0.00 as DIRITTO_CHIAMATA,0.00 as ANTICIPO, 0.00 as MANODOPERA, 0.00 as SPESE_VIAGGIO,'' as pagamento,CODICE_IMPIANTO, +0.00 as TOTALE,'' as NOTE_PAGAMENTO,'' as TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from CCHIUSA where CCCODAZI='DISCO' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from DISCORAPPMAST RAPPMAST left outer join RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join TECNICI on RACODTE1=TCCODICE and TCCODAZI='DISCO' +left outer join CHIAMATE on CHCODAZI='DISCO' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +left outer join PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='DISCO' and PIDATMAN=DATA_EFFETTIVA +LEFT OUTER JOIN CODINTE ON PICODINT = dbo.CODINTE.CICODICE +LEFT OUTER JOIN dbo.MIMPIANTI ON AZIENDA_IMPIANTO = dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 22/03/2023 14:26:02 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_IMPIANTI] +AS +SELECT dbo.MIMPIANTI.IMCODAZI, dbo.MIMPIANTI.IMCODIMP, dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTCLI, + dbo.MIMPIANTI.IMULTDCL, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTTAM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, dbo.MIMPIANTI.IMINDIRI3, + dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, + dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMFLPUPR, dbo.MIMPIANTI.UTDC, dbo.MIMPIANTI.UTDV, dbo.MIMPIANTI.IMPIAMAN, dbo.MIMPIANTI.IMDATATT, dbo.MIMPIANTI.IMZONCHI, + dbo.MIMPIANTI.IMZONSUP, dbo.MIMPIANTI.IMDAINMA, dbo.MIMPIANTI.IMDAFIMA, dbo.MIMPIANTI.IMDATCOS, dbo.MIMPIANTI.IMTELESO, + dbo.API_CLIENTI.AN_EMAIL,dbo.MIMPIANTI.IMAZIRIF,dbo.MIMPIANTI.IMREFREF +FROM dbo.MIMPIANTI INNER JOIN + dbo.API_CLIENTI ON dbo.MIMPIANTI.IMULTCLI = dbo.API_CLIENTI.ANCODICE +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 22/03/2023 14:27:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_TECNICI] +AS +SELECT dbo.TECNICI.TCCODICE, dbo.TECNICI.TCDESCRI, dbo.TECNICI.TCTELEF1, dbo.TECNICI.TCCHIAM, dbo.TECNICI.TCMANUT, dbo.TECNICI.TCCODAZI, dbo.TECNICI.TCSUPER, dbo.TECNICI.TCUSER, dbo.TECNICI.TCPWD, + dbo.TECDISP.TDCODZON, dbo.TECDISP.TDDATAIN, dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno,TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM dbo.TECNICI INNER JOIN + dbo.TECDISP ON dbo.TECNICI.TCCODICE = dbo.TECDISP.TDCODTEC AND dbo.TECNICI.TCCODAZI = dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 20/03/2023 08:58:18 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +dbo.CHIAMATE.CHCODAZI, dbo.CHIAMATE.CHSERIAL, dbo.CHIAMATE.CHCODESE, dbo.CHIAMATE.CHTIPO, dbo.CHIAMATE.CHNUMERO, dbo.CHIAMATE.CHDATA, dbo.CHIAMATE.CHORA, dbo.CHIAMATE.CHMIN, +dbo.CHIAMATE.CHOPASS, dbo.CHIAMATE.CHOPCHI, dbo.CHIAMATE.CHCODIMP, dbo.CHIAMATE.CHAZIIMP, dbo.CHIAMATE.CHSTATO, dbo.CHIAMATE.CHDTAPP, dbo.CHIAMATE.CHORAAPI, dbo.CHIAMATE.CHMINAPI, +dbo.CHIAMATE.CHORAAPF, dbo.CHIAMATE.CHMINAPF, dbo.CHIAMATE.CHRIFER, dbo.CHIAMATE.CHTELEF, dbo.CHIAMATE.CHCODSEG, dbo.CHIAMATE.CHSTOPI, dbo.CHIAMATE.CHNOTE, dbo.CHIAMATE.CHDTASS, +dbo.CHIAMATE.CHORASS, dbo.CHIAMATE.CHMINASS, dbo.CHIAMATE.CHDTCHI, dbo.CHIAMATE.CHORACHI, dbo.CHIAMATE.CHMINCHI, dbo.CHIAMATE.CHDTLIN, dbo.CHIAMATE.CHORALI, dbo.CHIAMATE.CHMINLI, +dbo.CHIAMATE.CHDTLFI, dbo.CHIAMATE.CHORALF, dbo.CHIAMATE.CHMINLF, dbo.CHIAMATE.cpccchk, dbo.CHIAMATE.CHNRAP1, dbo.CHIAMATE.CHSRAP1, dbo.CHIAMATE.CHNRAP2, dbo.CHIAMATE.CHSRAP2, +dbo.CHIAMATE.CHMODRAC, dbo.CHIAMATE.CHPRGANN, dbo.CHIAMATE.UTCC, dbo.CHIAMATE.UTCV, dbo.CHIAMATE.CHIMPMAN, dbo.CHIAMATE.CHPERMAN, dbo.CHIAMATE.CHFLSTIM, dbo.CHIAMATE.CHFLESTE,CHIAMATE.CHTCHIAM as TCCODICE, +dbo.CHIAMATE.CHSEREXT, dbo.API_IMPIANTI.IMDESCRI, dbo.API_IMPIANTI.IMTIPOIM, dbo.API_IMPIANTI.IMMATRIC, dbo.API_IMPIANTI.IMNUMIMP, dbo.API_IMPIANTI.IMULTAMM, dbo.API_IMPIANTI.IMULTDAM, +dbo.API_IMPIANTI.IMULTTAM, dbo.API_IMPIANTI.IMINDIRI1, dbo.API_IMPIANTI.IMINDIRI2, dbo.API_IMPIANTI.IMINDIRI3, dbo.API_IMPIANTI.IMINDIRI4, dbo.API_IMPIANTI.IMINDIRI5, dbo.API_IMPIANTI.IMLOCALI, +dbo.API_IMPIANTI.IMCODCAP, dbo.API_IMPIANTI.IMCOMUNE, dbo.API_IMPIANTI.IMPROVIN, dbo.API_IMPIANTI.IMCODNAZ, dbo.API_IMPIANTI.IMUBICAZ, dbo.API_IMPIANTI.IMZONMAN, dbo.API_IMPIANTI.IMFLPUPR, +dbo.API_IMPIANTI.IMZONCHI, dbo.API_IMPIANTI.IMZONSUP, dbo.API_IMPIANTI.IMDAINMA, dbo.API_IMPIANTI.IMDAFIMA, dbo.API_IMPIANTI.IMDATCOS, dbo.API_IMPIANTI.IMTELESO, dbo.API_IMPIANTI.AN_EMAIL, +dbo.API_IMPIANTI.IMULTCLI, dbo.DISCOCONTI.ANCODICE, dbo.DISCOCONTI.ANTIPCON, dbo.DISCOCONTI.ANDESCRI, dbo.DISCOCONTI.ANTELEFO, dbo.CODSEGN.CSDESCR, dbo.CHIAMATE.CHTCHIAM +,dbo.API_IMPIANTI.IMAZIRIF as IMAZIRIF,dbo.API_IMPIANTI.IMREFREF +,(select top 1 tcdescri from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from DISCOMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from DISCOMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from CHIAMATE +left outer join RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join CODSEGN ON dbo.CODSEGN.CSCODICE = dbo.CHIAMATE.CHCODSEG AND dbo.CODSEGN.CSCODAZI = dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN dbo.DISCOCONTI +INNER JOIN dbo.API_IMPIANTI ON dbo.DISCOCONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND dbo.DISCOCONTI.ANTIPCON = 'C' ON dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and dbo.CHIAMATE.CHSTATO = 'C' +and CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) + +GO +/****** Object: View [dbo].[API_MANPROG] Script Date: 20/03/2023 08:59:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_MANPROG] +AS + +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,dbo.MANPROG.MPCODAZI AS CTCODAZI, dbo.MANPROG.MPCODIMP AS CTCODIMP, dbo.MANPROG.MPCODINT AS CTCODINT, dbo.CODINTE.CIDESCRI AS CTDESINT, dbo.MANPROG.MPDATPRO AS CTDATPRO, +dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, +dbo.MIMPIANTI.IMINDIRI3, dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, +dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMRIFERI, dbo.MIMPIANTI.IMZONCHI, dbo.MIMPIANTI.IMZONSUP, +dbo.MIMPIANTI.IMULTTAM as TELEFONO1,dbo.MIMPIANTI.IMULTFAM as TELEFONO2,dbo.MIMPIANTI.IMULTCLI as CLIENTE, +dbo.MANPROG.MPMESGEN, dbo.MANPROG.MPMESFEB, dbo.MANPROG.MPMESMAR, dbo.MANPROG.MPMESAPR, dbo.MANPROG.MPMESMAG, dbo.MANPROG.MPMESLUG, +dbo.MANPROG.MPMESGIU, dbo.MANPROG.MPMESAGO, dbo.MANPROG.MPMESSET, dbo.MANPROG.MPMESOTT, dbo.MANPROG.MPMESNOV, dbo.MANPROG.MPMESDIC, +T.TCDESCRI,T.TCCODICE,dbo.API_IMPIANTI.IMAZIRIF as IMAZIRIF,dbo.MIMPIANTI.IMREFREF +,(select top 1 CTIMPCHI from DISCOMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from DISCOMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM dbo.MANPROG INNER JOIN dbo.MIMPIANTI ON dbo.MANPROG.MPCODAZI = dbo.MIMPIANTI.IMCODAZI AND dbo.MANPROG.MPCODIMP = dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN dbo.CODINTE ON dbo.MANPROG.MPCODINT = dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PIPRESA as PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT and TCCODICE=picodtec) +left outer join RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' +GO +/****** Object: View [dbo].[API_SOSTITUZIONI] Script Date: 20/03/2023 09:01:39 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE VIEW [dbo].[API_SOSTITUZIONI] +AS +SELECT [TSCODAZI],[TSCODTEC],[TSCODZON],[TSDATAIN],[TSDATAFI],[TSCODSOS] + FROM [dbo].[TECSOS] + where [TSDATAIN]<=DATEADD(DAY, -1, GETDATE()) + and [TSDATAFI]>=DATEADD(DAY, 1, GETDATE()) + and [TSCODAZI]='DISCO' +GO \ No newline at end of file diff --git a/ApiPolo/SQL/Gitoga_1_8.txt b/ApiPolo/SQL/Gitoga_1_8.txt new file mode 100644 index 0000000..3f6c747 --- /dev/null +++ b/ApiPolo/SQL/Gitoga_1_8.txt @@ -0,0 +1,314 @@ +USE [R80_GITSR] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 20/03/2023 09:52:57 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from [R80_MARROCCO].dbo.GITSRCAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 20/03/2023 09:53:46 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM [R80_MARROCCO].dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' and CCCODAZI='GITSR' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 20/03/2023 09:54:39 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM [R80_MARROCCO].dbo.GITSRCONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 20/03/2023 09:55:24 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from [R80_MARROCCO].dbo.GITSRPAG_AMEN +GO +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 20/03/2023 09:56:43 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM [R80_MARROCCO].dbo.RAPP_NEW where AZIENDA_IMPIANTO='GITSR' +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 20/03/2023 09:57:39 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_STO_RAPP] +AS +select + +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,/*RAPPMAST.NOTE_ESITO,*/'' as NOTE_ESITO,DATA_RAPPORTINO +, STATO_FINALE,/*RAPPMAST.ESITO_INTERVENTO,*/'' as ESITO_INTERVENTO,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO,DIFETTI_RISCONTRATI,LAVORO_ESEGUITO,NOTE_INTERVENTO +,ORE_LAVORO,MATERIALE,DIRITTO_CHIAMATA,ANTICIPO, MANODOPERA, SPESE_VIAGGIO,pagamento,CODICE_IMPIANTO, +TOTALE,NOTE_PAGAMENTO,TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='GITSR' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from [R80_MARROCCO].dbo.GITSRRAPPMAST RAPPMAST left outer join [R80_MARROCCO].dbo.RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join [R80_MARROCCO].dbo.TECNICI on RACODTE1=TCCODICE and TCCODAZI='GITSR' +left outer join [R80_MARROCCO].dbo.CHIAMATE on CHCODAZI='GITSR' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +left outer join [R80_MARROCCO].dbo.PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='GITSR' and PIDATMAN=DATA_EFFETTIVA +LEFT OUTER JOIN [R80_MARROCCO].dbo.CODINTE ON PICODINT = [R80_MARROCCO].dbo.CODINTE.CICODICE +LEFT OUTER JOIN [R80_MARROCCO].dbo.MIMPIANTI ON AZIENDA_IMPIANTO = [R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = [R80_MARROCCO].dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 20/03/2023 10:01:23 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_IMPIANTI] +AS +SELECT +[R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI, [R80_MARROCCO].dbo.MIMPIANTI.IMCODIMP, [R80_MARROCCO].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO].dbo.MIMPIANTI.IMULTCLI, +[R80_MARROCCO].dbo.MIMPIANTI.IMULTDCL, [R80_MARROCCO].dbo.MIMPIANTI.IMULTAMM, [R80_MARROCCO].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO].dbo.MIMPIANTI.IMULTTAM, +[R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI3, +[R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI4, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO].dbo.MIMPIANTI.IMCODCAP, +[R80_MARROCCO].dbo.MIMPIANTI.IMCOMUNE, [R80_MARROCCO].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO].dbo.MIMPIANTI.IMCODNAZ, +[R80_MARROCCO].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO].dbo.MIMPIANTI.IMZONMAN, [R80_MARROCCO].dbo.MIMPIANTI.IMFLPUPR, [R80_MARROCCO].dbo.MIMPIANTI.UTDC, +[R80_MARROCCO].dbo.MIMPIANTI.UTDV, [R80_MARROCCO].dbo.MIMPIANTI.IMPIAMAN, [R80_MARROCCO].dbo.MIMPIANTI.IMDATATT, [R80_MARROCCO].dbo.MIMPIANTI.IMZONCHI, +[R80_MARROCCO].dbo.MIMPIANTI.IMZONSUP, [R80_MARROCCO].dbo.MIMPIANTI.IMDAINMA, [R80_MARROCCO].dbo.MIMPIANTI.IMDAFIMA, +[R80_MARROCCO].dbo.MIMPIANTI.IMDATCOS, [R80_MARROCCO].dbo.MIMPIANTI.IMTELESO, [R80_MARROCCO].dbo.API_CLIENTI.AN_EMAIL,'' as IMAZIRIF,[R80_MARROCCO].dbo.MIMPIANTI.IMREFREF +FROM [R80_MARROCCO].dbo.MIMPIANTI INNER JOIN + [R80_MARROCCO].dbo.API_CLIENTI ON [R80_MARROCCO].dbo.MIMPIANTI.IMULTCLI = [R80_MARROCCO].dbo.API_CLIENTI.ANCODICE +where [R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI='GITSR' + +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 20/03/2023 10:02:53 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_TECNICI] +AS +SELECT +[R80_MARROCCO].dbo.TECNICI.TCCODICE, [R80_MARROCCO].dbo.TECNICI.TCDESCRI, [R80_MARROCCO].dbo.TECNICI.TCTELEF1, [R80_MARROCCO].dbo.TECNICI.TCCHIAM, [R80_MARROCCO].dbo.TECNICI.TCMANUT, +[R80_MARROCCO].dbo.TECNICI.TCCODAZI, [R80_MARROCCO].dbo.TECNICI.TCSUPER, [R80_MARROCCO].dbo.TECNICI.TCUSER, [R80_MARROCCO].dbo.TECNICI.TCPWD, +[R80_MARROCCO].dbo.TECDISP.TDCODZON, [R80_MARROCCO].dbo.TECDISP.TDDATAIN, [R80_MARROCCO].dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno, +TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM +[R80_MARROCCO].dbo.TECNICI INNER JOIN +[R80_MARROCCO].dbo.TECDISP ON [R80_MARROCCO].dbo.TECNICI.TCCODICE = [R80_MARROCCO].dbo.TECDISP.TDCODTEC AND [R80_MARROCCO].dbo.TECNICI.TCCODAZI = [R80_MARROCCO].dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 20/03/2023 10:05:01 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +[R80_MARROCCO].dbo.CHIAMATE.CHCODAZI, [R80_MARROCCO].dbo.CHIAMATE.CHSERIAL, [R80_MARROCCO].dbo.CHIAMATE.CHCODESE, [R80_MARROCCO].dbo.CHIAMATE.CHTIPO, +[R80_MARROCCO].dbo.CHIAMATE.CHNUMERO, [R80_MARROCCO].dbo.CHIAMATE.CHDATA, [R80_MARROCCO].dbo.CHIAMATE.CHORA, [R80_MARROCCO].dbo.CHIAMATE.CHMIN, +[R80_MARROCCO].dbo.CHIAMATE.CHOPASS, [R80_MARROCCO].dbo.CHIAMATE.CHOPCHI, [R80_MARROCCO].dbo.CHIAMATE.CHCODIMP, [R80_MARROCCO].dbo.CHIAMATE.CHAZIIMP, +[R80_MARROCCO].dbo.CHIAMATE.CHSTATO, [R80_MARROCCO].dbo.CHIAMATE.CHDTAPP, [R80_MARROCCO].dbo.CHIAMATE.CHORAAPI, [R80_MARROCCO].dbo.CHIAMATE.CHMINAPI, +[R80_MARROCCO].dbo.CHIAMATE.CHORAAPF, [R80_MARROCCO].dbo.CHIAMATE.CHMINAPF, [R80_MARROCCO].dbo.CHIAMATE.CHRIFER, [R80_MARROCCO].dbo.CHIAMATE.CHTELEF, +[R80_MARROCCO].dbo.CHIAMATE.CHCODSEG, [R80_MARROCCO].dbo.CHIAMATE.CHSTOPI, [R80_MARROCCO].dbo.CHIAMATE.CHNOTE, [R80_MARROCCO].dbo.CHIAMATE.CHDTASS, +[R80_MARROCCO].dbo.CHIAMATE.CHORASS, [R80_MARROCCO].dbo.CHIAMATE.CHMINASS, [R80_MARROCCO].dbo.CHIAMATE.CHDTCHI, [R80_MARROCCO].dbo.CHIAMATE.CHORACHI, +[R80_MARROCCO].dbo.CHIAMATE.CHMINCHI, [R80_MARROCCO].dbo.CHIAMATE.CHDTLIN, [R80_MARROCCO].dbo.CHIAMATE.CHORALI, [R80_MARROCCO].dbo.CHIAMATE.CHMINLI, +[R80_MARROCCO].dbo.CHIAMATE.CHDTLFI, [R80_MARROCCO].dbo.CHIAMATE.CHORALF, [R80_MARROCCO].dbo.CHIAMATE.CHMINLF, [R80_MARROCCO].dbo.CHIAMATE.cpccchk, +[R80_MARROCCO].dbo.CHIAMATE.CHNRAP1, [R80_MARROCCO].dbo.CHIAMATE.CHSRAP1, [R80_MARROCCO].dbo.CHIAMATE.CHNRAP2, [R80_MARROCCO].dbo.CHIAMATE.CHSRAP2, +[R80_MARROCCO].dbo.CHIAMATE.CHMODRAC, [R80_MARROCCO].dbo.CHIAMATE.CHPRGANN, [R80_MARROCCO].dbo.CHIAMATE.UTCC, [R80_MARROCCO].dbo.CHIAMATE.UTCV, +[R80_MARROCCO].dbo.CHIAMATE.CHIMPMAN, [R80_MARROCCO].dbo.CHIAMATE.CHPERMAN, [R80_MARROCCO].dbo.CHIAMATE.CHFLSTIM, [R80_MARROCCO].dbo.CHIAMATE.CHFLESTE, +[R80_MARROCCO].dbo.CHIAMATE.CHTCHIAM as TCCODICE, [R80_MARROCCO].dbo.CHIAMATE.CHSEREXT, API_IMPIANTI.IMDESCRI, API_IMPIANTI.IMTIPOIM, +API_IMPIANTI.IMMATRIC, API_IMPIANTI.IMNUMIMP, API_IMPIANTI.IMULTAMM, API_IMPIANTI.IMULTDAM, +API_IMPIANTI.IMULTTAM, API_IMPIANTI.IMINDIRI1, API_IMPIANTI.IMINDIRI2, API_IMPIANTI.IMINDIRI3, +API_IMPIANTI.IMINDIRI4, API_IMPIANTI.IMINDIRI5, API_IMPIANTI.IMLOCALI, +API_IMPIANTI.IMCODCAP, API_IMPIANTI.IMCOMUNE, API_IMPIANTI.IMPROVIN, API_IMPIANTI.IMCODNAZ, +API_IMPIANTI.IMUBICAZ, API_IMPIANTI.IMZONMAN, API_IMPIANTI.IMFLPUPR, API_IMPIANTI.IMZONCHI, +API_IMPIANTI.IMZONSUP, API_IMPIANTI.IMDAINMA, API_IMPIANTI.IMDAFIMA, API_IMPIANTI.IMDATCOS, +API_IMPIANTI.IMTELESO, API_IMPIANTI.AN_EMAIL,API_IMPIANTI.IMULTCLI, [R80_MARROCCO].dbo.GITSRCONTI.ANCODICE, +[R80_MARROCCO].dbo.GITSRCONTI.ANTIPCON, [R80_MARROCCO].dbo.GITSRCONTI.ANDESCRI, [R80_MARROCCO].dbo.GITSRCONTI.ANTELEFO, [R80_MARROCCO].dbo.CODSEGN.CSDESCR, [R80_MARROCCO].dbo.CHIAMATE.CHTCHIAM +,'' as IMAZIRIF,dbo.API_IMPIANTI.IMREFREF +,(select top 1 tcdescri from dbo.API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from [R80_MARROCCO].dbo.GITSRMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO].dbo.GITSRMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from [R80_MARROCCO].dbo.CHIAMATE +left outer join [R80_MARROCCO].dbo.RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join [R80_MARROCCO].dbo.RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join [R80_MARROCCO].dbo.RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join [R80_MARROCCO].dbo.CODSEGN ON [R80_MARROCCO].dbo.CODSEGN.CSCODICE = [R80_MARROCCO].dbo.CHIAMATE.CHCODSEG AND [R80_MARROCCO].dbo.CODSEGN.CSCODAZI = [R80_MARROCCO].dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN [R80_MARROCCO].dbo.GITSRCONTI +INNER JOIN dbo.API_IMPIANTI ON [R80_MARROCCO].dbo.GITSRCONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND [R80_MARROCCO].dbo.GITSRCONTI.ANTIPCON = 'C' ON [R80_MARROCCO].dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND [R80_MARROCCO].dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and [R80_MARROCCO].dbo.CHIAMATE.CHSTATO = 'C' +and [R80_MARROCCO].dbo.CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and [R80_MARROCCO].dbo.CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) +and [R80_MARROCCO].dbo.CHIAMATE.CHCODAZI='GITSR' +GO +/****** Object: View [dbo].[API_MANPROG] Script Date: 20/03/2023 10:07:55 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_MANPROG] +AS + +select +[PIMPIANTO] + ,[PICODINT] + ,[PIDATMAN] + ,[SERIALE_RAPPORTINO] + ,[SER_BUONO] + ,[GENERATO] + ,[CODICE_INTERVENTO] + ,[err_title] + ,[err_detail] + ,[err_status_code] + ,[CTCODAZI] + ,[CTCODIMP] + ,[CTCODINT] + ,[CTDESINT] + ,[CTDATPRO] + ,[IMDESCRI] + ,[IMTIPOIM] + ,[IMMATRIC] + ,[IMNUMIMP] + ,[IMULTDAM] + ,[IMULTAMM] + ,[IMINDIRI1] + ,[IMINDIRI2] + ,[IMINDIRI3] + ,[IMINDIRI4] + ,[IMINDIRI5] + ,[IMLOCALI] + ,[IMCODCAP] + ,[IMCOMUNE] + ,[IMPROVIN] + ,[IMCODNAZ] + ,[IMUBICAZ] + ,[IMZONMAN] + ,[IMRIFERI] + ,[IMZONCHI] + ,[IMZONSUP] + ,[TELEFONO1] + ,[TELEFONO2] + ,[CLIENTE] + ,[MPMESGEN] + ,[MPMESFEB] + ,[MPMESMAR] + ,[MPMESAPR] + ,[MPMESMAG] + ,[MPMESLUG] + ,[MPMESGIU] + ,[MPMESAGO] + ,[MPMESSET] + ,[MPMESOTT] + ,[MPMESNOV] + ,[MPMESDIC] + ,[TCDESCRI] + ,[TCCODICE] + ,[IMAZIRIF] + ,IMREFREF + ,[chiamata] + ,[spe_viaggio] + ,[costo_ordinario] + ,[costo_notturno] + ,[costo_straordinario] + ,[costo_festivo] +from [R80_MARROCCO].dbo.API_MANPROG where CTCODAZI='GITSR' +GO +/****** Object: View [dbo].[API_SOSTITUZIONI] Script Date: 20/03/2023 10:56:17 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_SOSTITUZIONI] +AS +SELECT [TSCODAZI],[TSCODTEC],[TSCODZON],[TSDATAIN],[TSDATAFI],[TSCODSOS] + FROM [R80_MARROCCO].[dbo].[TECSOS] + where [TSDATAIN]<=DATEADD(DAY, -1, GETDATE()) + and [TSDATAFI]>=DATEADD(DAY, 1, GETDATE()) + and [TSCODAZI]='GITSR' +GO \ No newline at end of file diff --git a/ApiPolo/SQL/Lifta_1_8.txt b/ApiPolo/SQL/Lifta_1_8.txt new file mode 100644 index 0000000..17e2513 --- /dev/null +++ b/ApiPolo/SQL/Lifta_1_8.txt @@ -0,0 +1,308 @@ +USE [R80_LIFTA] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 20/03/2023 10:59:22 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from [R80_MARROCCO].dbo.LIFTACAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 20/03/2023 11:00:14 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM [R80_MARROCCO].dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' and CCCODAZI='LIFTA' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 20/03/2023 11:01:43 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM [R80_MARROCCO].dbo.LIFTACONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 20/03/2023 11:02:19 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM [R80_MARROCCO].dbo.RAPP_NEW where AZIENDA_IMPIANTO='LIFTA' +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 20/03/2023 11:03:30 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +ALTER VIEW [dbo].[API_STO_RAPP] +AS + +select +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,/*RAPPMAST.NOTE_ESITO,*/'' as NOTE_ESITO,DATA_RAPPORTINO +, STATO_FINALE,/*RAPPMAST.ESITO_INTERVENTO,*/'' as ESITO_INTERVENTO,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO,DIFETTI_RISCONTRATI,LAVORO_ESEGUITO,NOTE_INTERVENTO +,ORE_LAVORO,MATERIALE,DIRITTO_CHIAMATA,ANTICIPO, MANODOPERA, SPESE_VIAGGIO,pagamento,CODICE_IMPIANTO, +TOTALE,NOTE_PAGAMENTO,TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from [R80_MARROCCO].dbo.CCHIUSA where CCCODAZI='LIFTA' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from [R80_MARROCCO].dbo.LIFTARAPPMAST RAPPMAST left outer join [R80_MARROCCO].dbo.RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join [R80_MARROCCO].dbo.TECNICI on RACODTE1=TCCODICE and TCCODAZI='LIFTA' +left outer join [R80_MARROCCO].dbo.CHIAMATE on CHCODAZI='LIFTA' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +left outer join [R80_MARROCCO].dbo.PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='LIFTA' and PIDATMAN=DATA_EFFETTIVA +LEFT OUTER JOIN [R80_MARROCCO].dbo.CODINTE ON PICODINT = [R80_MARROCCO].dbo.CODINTE.CICODICE +LEFT OUTER JOIN [R80_MARROCCO].dbo.MIMPIANTI ON AZIENDA_IMPIANTO = [R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = [R80_MARROCCO].dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 20/03/2023 11:06:39 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_IMPIANTI] +AS +SELECT +[R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI, [R80_MARROCCO].dbo.MIMPIANTI.IMCODIMP, [R80_MARROCCO].dbo.MIMPIANTI.IMDESCRI, [R80_MARROCCO].dbo.MIMPIANTI.IMTIPOIM, +[R80_MARROCCO].dbo.MIMPIANTI.IMMATRIC, [R80_MARROCCO].dbo.MIMPIANTI.IMNUMIMP, [R80_MARROCCO].dbo.MIMPIANTI.IMULTCLI, +[R80_MARROCCO].dbo.MIMPIANTI.IMULTDCL, [R80_MARROCCO].dbo.MIMPIANTI.IMULTAMM, [R80_MARROCCO].dbo.MIMPIANTI.IMULTDAM, [R80_MARROCCO].dbo.MIMPIANTI.IMULTTAM, +[R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI1, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI2, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI3, +[R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI4, [R80_MARROCCO].dbo.MIMPIANTI.IMINDIRI5, [R80_MARROCCO].dbo.MIMPIANTI.IMLOCALI, [R80_MARROCCO].dbo.MIMPIANTI.IMCODCAP, +[R80_MARROCCO].dbo.MIMPIANTI.IMCOMUNE, [R80_MARROCCO].dbo.MIMPIANTI.IMPROVIN, [R80_MARROCCO].dbo.MIMPIANTI.IMCODNAZ, +[R80_MARROCCO].dbo.MIMPIANTI.IMUBICAZ, [R80_MARROCCO].dbo.MIMPIANTI.IMZONMAN, [R80_MARROCCO].dbo.MIMPIANTI.IMFLPUPR, [R80_MARROCCO].dbo.MIMPIANTI.UTDC, +[R80_MARROCCO].dbo.MIMPIANTI.UTDV, [R80_MARROCCO].dbo.MIMPIANTI.IMPIAMAN, [R80_MARROCCO].dbo.MIMPIANTI.IMDATATT, [R80_MARROCCO].dbo.MIMPIANTI.IMZONCHI, +[R80_MARROCCO].dbo.MIMPIANTI.IMZONSUP, [R80_MARROCCO].dbo.MIMPIANTI.IMDAINMA, [R80_MARROCCO].dbo.MIMPIANTI.IMDAFIMA, +[R80_MARROCCO].dbo.MIMPIANTI.IMDATCOS, [R80_MARROCCO].dbo.MIMPIANTI.IMTELESO, [R80_MARROCCO].dbo.API_CLIENTI.AN_EMAIL,'' as IMAZIRIF +,[R80_MARROCCO].dbo.MIMPIANTI.IMREFREF +FROM +[R80_MARROCCO].dbo.MIMPIANTI INNER JOIN +[R80_MARROCCO].dbo.API_CLIENTI ON [R80_MARROCCO].dbo.MIMPIANTI.IMULTCLI = [R80_MARROCCO].dbo.API_CLIENTI.ANCODICE +where [R80_MARROCCO].dbo.MIMPIANTI.IMCODAZI='LIFTA' +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 20/03/2023 11:07:26 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_TECNICI] +AS +SELECT +[R80_MARROCCO].dbo.TECNICI.TCCODICE, [R80_MARROCCO].dbo.TECNICI.TCDESCRI, [R80_MARROCCO].dbo.TECNICI.TCTELEF1, [R80_MARROCCO].dbo.TECNICI.TCCHIAM, [R80_MARROCCO].dbo.TECNICI.TCMANUT, +[R80_MARROCCO].dbo.TECNICI.TCCODAZI, [R80_MARROCCO].dbo.TECNICI.TCSUPER, [R80_MARROCCO].dbo.TECNICI.TCUSER, [R80_MARROCCO].dbo.TECNICI.TCPWD, +[R80_MARROCCO].dbo.TECDISP.TDCODZON, [R80_MARROCCO].dbo.TECDISP.TDDATAIN, [R80_MARROCCO].dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno, +TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM +[R80_MARROCCO].dbo.TECNICI INNER JOIN +[R80_MARROCCO].dbo.TECDISP ON [R80_MARROCCO].dbo.TECNICI.TCCODICE = [R80_MARROCCO].dbo.TECDISP.TDCODTEC AND [R80_MARROCCO].dbo.TECNICI.TCCODAZI = [R80_MARROCCO].dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 20/03/2023 11:11:13 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +[R80_MARROCCO].dbo.CHIAMATE.CHCODAZI, [R80_MARROCCO].dbo.CHIAMATE.CHSERIAL, [R80_MARROCCO].dbo.CHIAMATE.CHCODESE, [R80_MARROCCO].dbo.CHIAMATE.CHTIPO, +[R80_MARROCCO].dbo.CHIAMATE.CHNUMERO, [R80_MARROCCO].dbo.CHIAMATE.CHDATA, [R80_MARROCCO].dbo.CHIAMATE.CHORA, [R80_MARROCCO].dbo.CHIAMATE.CHMIN, +[R80_MARROCCO].dbo.CHIAMATE.CHOPASS, [R80_MARROCCO].dbo.CHIAMATE.CHOPCHI, [R80_MARROCCO].dbo.CHIAMATE.CHCODIMP, [R80_MARROCCO].dbo.CHIAMATE.CHAZIIMP, +[R80_MARROCCO].dbo.CHIAMATE.CHSTATO, [R80_MARROCCO].dbo.CHIAMATE.CHDTAPP, [R80_MARROCCO].dbo.CHIAMATE.CHORAAPI, [R80_MARROCCO].dbo.CHIAMATE.CHMINAPI, +[R80_MARROCCO].dbo.CHIAMATE.CHORAAPF, [R80_MARROCCO].dbo.CHIAMATE.CHMINAPF, [R80_MARROCCO].dbo.CHIAMATE.CHRIFER, [R80_MARROCCO].dbo.CHIAMATE.CHTELEF, +[R80_MARROCCO].dbo.CHIAMATE.CHCODSEG, [R80_MARROCCO].dbo.CHIAMATE.CHSTOPI, [R80_MARROCCO].dbo.CHIAMATE.CHNOTE, [R80_MARROCCO].dbo.CHIAMATE.CHDTASS, +[R80_MARROCCO].dbo.CHIAMATE.CHORASS, [R80_MARROCCO].dbo.CHIAMATE.CHMINASS, [R80_MARROCCO].dbo.CHIAMATE.CHDTCHI, [R80_MARROCCO].dbo.CHIAMATE.CHORACHI, +[R80_MARROCCO].dbo.CHIAMATE.CHMINCHI, [R80_MARROCCO].dbo.CHIAMATE.CHDTLIN, [R80_MARROCCO].dbo.CHIAMATE.CHORALI, [R80_MARROCCO].dbo.CHIAMATE.CHMINLI, +[R80_MARROCCO].dbo.CHIAMATE.CHDTLFI, [R80_MARROCCO].dbo.CHIAMATE.CHORALF, [R80_MARROCCO].dbo.CHIAMATE.CHMINLF, [R80_MARROCCO].dbo.CHIAMATE.cpccchk, +[R80_MARROCCO].dbo.CHIAMATE.CHNRAP1, [R80_MARROCCO].dbo.CHIAMATE.CHSRAP1, [R80_MARROCCO].dbo.CHIAMATE.CHNRAP2, [R80_MARROCCO].dbo.CHIAMATE.CHSRAP2, +[R80_MARROCCO].dbo.CHIAMATE.CHMODRAC, [R80_MARROCCO].dbo.CHIAMATE.CHPRGANN, [R80_MARROCCO].dbo.CHIAMATE.UTCC, [R80_MARROCCO].dbo.CHIAMATE.UTCV, +[R80_MARROCCO].dbo.CHIAMATE.CHIMPMAN, [R80_MARROCCO].dbo.CHIAMATE.CHPERMAN, [R80_MARROCCO].dbo.CHIAMATE.CHFLSTIM, [R80_MARROCCO].dbo.CHIAMATE.CHFLESTE, +[R80_MARROCCO].dbo.CHIAMATE.CHTCHIAM as TCCODICE, [R80_MARROCCO].dbo.CHIAMATE.CHSEREXT, API_IMPIANTI.IMDESCRI, API_IMPIANTI.IMTIPOIM, +API_IMPIANTI.IMMATRIC, API_IMPIANTI.IMNUMIMP, API_IMPIANTI.IMULTAMM, API_IMPIANTI.IMULTDAM, +API_IMPIANTI.IMULTTAM, API_IMPIANTI.IMINDIRI1, API_IMPIANTI.IMINDIRI2, API_IMPIANTI.IMINDIRI3, +API_IMPIANTI.IMINDIRI4, API_IMPIANTI.IMINDIRI5, API_IMPIANTI.IMLOCALI, +API_IMPIANTI.IMCODCAP, API_IMPIANTI.IMCOMUNE, API_IMPIANTI.IMPROVIN, API_IMPIANTI.IMCODNAZ, +API_IMPIANTI.IMUBICAZ, API_IMPIANTI.IMZONMAN, API_IMPIANTI.IMFLPUPR, API_IMPIANTI.IMZONCHI, +API_IMPIANTI.IMZONSUP, API_IMPIANTI.IMDAINMA, API_IMPIANTI.IMDAFIMA, API_IMPIANTI.IMDATCOS, +API_IMPIANTI.IMTELESO, API_IMPIANTI.AN_EMAIL,API_IMPIANTI.IMULTCLI, [R80_MARROCCO].dbo.LIFTACONTI.ANCODICE, +[R80_MARROCCO].dbo.LIFTACONTI.ANTIPCON, [R80_MARROCCO].dbo.LIFTACONTI.ANDESCRI, [R80_MARROCCO].dbo.LIFTACONTI.ANTELEFO, [R80_MARROCCO].dbo.CODSEGN.CSDESCR, [R80_MARROCCO].dbo.CHIAMATE.CHTCHIAM +,'' as IMAZIRIF,API_IMPIANTI.IMREFREF +,(select top 1 tcdescri from dbo.API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from [R80_MARROCCO].dbo.LIFTAMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from [R80_MARROCCO].dbo.LIFTAMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from [R80_MARROCCO].dbo.CHIAMATE +left outer join [R80_MARROCCO].dbo.RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join [R80_MARROCCO].dbo.RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join [R80_MARROCCO].dbo.RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join [R80_MARROCCO].dbo.CODSEGN ON [R80_MARROCCO].dbo.CODSEGN.CSCODICE = [R80_MARROCCO].dbo.CHIAMATE.CHCODSEG AND [R80_MARROCCO].dbo.CODSEGN.CSCODAZI = [R80_MARROCCO].dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN [R80_MARROCCO].dbo.LIFTACONTI +INNER JOIN dbo.API_IMPIANTI ON [R80_MARROCCO].dbo.LIFTACONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND [R80_MARROCCO].dbo.LIFTACONTI.ANTIPCON = 'C' ON [R80_MARROCCO].dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND [R80_MARROCCO].dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and [R80_MARROCCO].dbo.CHIAMATE.CHSTATO = 'C' +and [R80_MARROCCO].dbo.CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and [R80_MARROCCO].dbo.CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) +and [R80_MARROCCO].dbo.CHIAMATE.CHCODAZI='LIFTA' + +GO +/****** Object: View [dbo].[API_MANPROG] Script Date: 20/03/2023 11:19:13 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_MANPROG] +AS + +select + + [PIMPIANTO] + ,[PICODINT] + ,[PIDATMAN] + ,[SERIALE_RAPPORTINO] + ,[SER_BUONO] + ,[GENERATO] + ,[CODICE_INTERVENTO] + ,[err_title] + ,[err_detail] + ,[err_status_code] + ,[CTCODAZI] + ,[CTCODIMP] + ,[CTCODINT] + ,[CTDESINT] + ,[CTDATPRO] + ,[IMDESCRI] + ,[IMTIPOIM] + ,[IMMATRIC] + ,[IMNUMIMP] + ,[IMULTDAM] + ,[IMULTAMM] + ,[IMINDIRI1] + ,[IMINDIRI2] + ,[IMINDIRI3] + ,[IMINDIRI4] + ,[IMINDIRI5] + ,[IMLOCALI] + ,[IMCODCAP] + ,[IMCOMUNE] + ,[IMPROVIN] + ,[IMCODNAZ] + ,[IMUBICAZ] + ,[IMZONMAN] + ,[IMRIFERI] + ,[IMZONCHI] + ,[IMZONSUP] + ,[TELEFONO1] + ,[TELEFONO2] + ,[CLIENTE] + ,[MPMESGEN] + ,[MPMESFEB] + ,[MPMESMAR] + ,[MPMESAPR] + ,[MPMESMAG] + ,[MPMESLUG] + ,[MPMESGIU] + ,[MPMESAGO] + ,[MPMESSET] + ,[MPMESOTT] + ,[MPMESNOV] + ,[MPMESDIC] + ,[TCDESCRI] + ,[TCCODICE] + ,[IMAZIRIF] + ,IMREFREF + ,[chiamata] + ,[spe_viaggio] + ,[costo_ordinario] + ,[costo_notturno] + ,[costo_straordinario] + ,[costo_festivo] +from [R80_MARROCCO].dbo.API_MANPROG where CTCODAZI='LIFTA' + +GO +/****** Object: View [dbo].[API_SOSTITUZIONI] Script Date: 20/03/2023 10:56:17 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_SOSTITUZIONI] +AS +SELECT [TSCODAZI],[TSCODTEC],[TSCODZON],[TSDATAIN],[TSDATAFI],[TSCODSOS] + FROM [R80_MARROCCO].[dbo].[TECSOS] + where [TSDATAIN]<=DATEADD(DAY, -1, GETDATE()) + and [TSDATAFI]>=DATEADD(DAY, 1, GETDATE()) + and [TSCODAZI]='LIFTA' +GO \ No newline at end of file diff --git a/ApiPolo/SQL/Marrocco_1_8.txt b/ApiPolo/SQL/Marrocco_1_8.txt new file mode 100644 index 0000000..34898f6 --- /dev/null +++ b/ApiPolo/SQL/Marrocco_1_8.txt @@ -0,0 +1,323 @@ +USE [R80_MARROCCO] +GO + +/****** Object: View [dbo].[API_CAUS_RAPP] Script Date: 20/03/2023 08:50:56 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CAUS_RAPP] +AS +select CRCODICE,CRDESCRI,CRRIFATT from MARROCAUSRAPP +GO +/****** Object: View [dbo].[API_CHIUSURE] Script Date: 20/03/2023 08:51:12 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIUSURE] +AS +SELECT CCCODAZI, CCCODICE, CCDESCR, cpccchk, CCFLFATT, CCFLREP, CCDESSUP, CCTIPCOD, CCGRUPPO, CCIMPINT, CCIMPMAN, CCSERINT, CCSERMAN, CCNUMORE, CCPERMAN, CORECOM, CODTOBSO, + 0 as CCRAPABI, CCRIAPRE, '' as CCCHIINT, 0 as CCRAPOBB +FROM dbo.CCHIUSA where COALESCE(CODTOBSO, '') = '' +GO +/****** Object: View [dbo].[API_CLIENTI] Script Date: 20/03/2023 08:52:25 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CLIENTI] +AS +SELECT ANTIPCON, ANCODICE, AN_EMAIL,ANCODFIS,ANPARIVA,ANINDIRI, ANTELEFO, ANNUMCEL, AN_EMPEC,ANDESCRI,ANNUMLIS +FROM dbo.MARROCONTI +WHERE (ANTIPCON = 'C') +GO +/****** Object: View [dbo].[API_PAGAMENTI] Script Date: 20/03/2023 08:53:07 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_PAGAMENTI] +AS +select PACODICE,PADESCRI from MARROPAG_AMEN +GO +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +/****** Object: View [dbo].[API_RAPP_NEW] Script Date: 20/03/2023 08:53:42 ******/ +ALTER VIEW [dbo].[API_RAPP_NEW] +AS +SELECT SERIALE_RAPPORTINO, TIPO_RAPPORTINO, AZIENDA_IMPIANTO, CODICE_IMPIANTO, AZIENDA_CHIAMATA, SERIALE_CHIAMATA, SERIALE_COMMESSA, DATA_RAPPORTINO, ORA_INI_RAPPORTINO, + MIN_INI_RAPPORTINO, ORA_FIN_RAPPORTINO, MIN_FIN_RAPPORTINO, CODICE_CHIUSURA_1, CODICE_CHIUSURA_2, CODICE_CHIUSURA_3, CODICE_CHIUSURA_4, CODICE_CHIUSURA_5, + CODICE_CHIUSURA_6, CODICE_CHIUSURA_7, CODICE_CHIUSURA_8, CODICE_CHIUSURA_9, CODICE_CHIUSURA_10, DESCRIZIONE_INTERVENTO, STATO_FINALE, GENERATO, AZIENDA_TECNICO, + CODICE_TECNICO, RIFIUTATA, FIRMA, INCARICO, DATA_VALIDITA, IMMAGINE, '' as SER_BUONO,'' as CODICE_INTERVENTO, + DIFETTI_RISCONTRATI, LAVORO_ESEGUITO, ESITO_INTERVENTO,NOTE_ESITO, NOTE_INTERVENTO,NUOVO_CONTRATTO, ORE_LAVORO, CAUSALE, MATERIALE, DIRITTO_CHIAMATA, MANODOPERA, SPESE_VIAGGIO, + PAGAMENTO, ANTICIPO, TOTALE, NOTE_PAGAMENTO, TIPO_INTERVENTO, RAFOTO1, RAFOTO2, RAFOTO3, RAFOTO4, RAFOTO5, RAFOTO6, RAFOTO7, RAFOTO8, RAFOTO9, RAFOTO10 +FROM dbo.RAPP_NEW +GO +/****** Object: View [dbo].[API_STO_RAPP] Script Date: 20/03/2023 08:54:55 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_STO_RAPP] +AS +select + +PICODINT as codice_intervento, +PIDATMAN as data_manutenzione +,CODINTE.CIDESCRI,CIDESSUP, +TCCODICE,TCDESCRI,/*RAPPMAST.NOTE_ESITO,*/'' as NOTE_ESITO,DATA_RAPPORTINO +, STATO_FINALE,/*RAPPMAST.ESITO_INTERVENTO,*/'' as ESITO_INTERVENTO,DESCRIZIONE_INTERVENTO,FIRMA +,SERIALE_CHIAMATA,TIPO_RAPPORTINO,CHCODSEG as codice_segnalazione,SER_BUONO,DIFETTI_RISCONTRATI,LAVORO_ESEGUITO,NOTE_INTERVENTO +,ORE_LAVORO,MATERIALE,DIRITTO_CHIAMATA,ANTICIPO, MANODOPERA, SPESE_VIAGGIO,pagamento,CODICE_IMPIANTO, +TOTALE,NOTE_PAGAMENTO,TIPO_INTERVENTO,GENERATO,AZIENDA_TECNICO,AZIENDA_IMPIANTO,AZIENDA_CHIAMATA + +,CODICE_CHIUSURA_1,CODICE_CHIUSURA_2,CODICE_CHIUSURA_3,CODICE_CHIUSURA_4,CODICE_CHIUSURA_5, +CODICE_CHIUSURA_6,CODICE_CHIUSURA_7,CODICE_CHIUSURA_8,CODICE_CHIUSURA_9,CODICE_CHIUSURA_10 +,SERIALE_RAPPORTINO + +,DATA_EFFETTIVA +,IMINDIRI1 as indirizzo_tipo ,IMINDIRI2 as indirizzo,IMINDIRI3 as indirizzo_num ,IMINDIRI4 as indirizzo_num2,IMINDIRI5 as indirizzo_scala +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_1) as cc1 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_2) as cc2 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_3) as cc3 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_4) as cc4 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_5) as cc5 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_6) as cc6 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_7) as cc7 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_8) as cc8 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_9) as cc9 +,(select CCDESCR from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_10) as cc10 + +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_1) as ccds1 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_2) as ccds2 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_3) as ccds3 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_4) as ccds4 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_5) as ccds5 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_6) as ccds6 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_7) as ccds7 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_8) as ccds8 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_9) as ccds9 +,(select CCDESSUP from CCHIUSA where CCCODAZI='MARRO' and CCCODICE=CODICE_CHIUSURA_10) as ccds10 + +from MARRORAPPMAST RAPPMAST left outer join RAPP_NEW on RASERIAL=SERIALE_RAPPORTINO +left outer join TECNICI on RACODTE1=TCCODICE and TCCODAZI='MARRO' +left outer join CHIAMATE on CHCODAZI='MARRO' and CHSERIAL=SERIALE_CHIAMATA and TIPO_RAPPORTINO='3' +--left outer join MANPROG on MPCODAZI='MARRO'and MPCODIMP=CODICE_IMPIANTO and MPDATSTO=DATA_VALIDITA /*and MPDATSTO=DATA_EFFETTIVA*/ and TIPO_RAPPORTINO='2' and MPCODINT=CODICE_INTERVENTO +left outer join PIPRESA on PIMPIANTO=CODICE_IMPIANTO and PICODINT=CODICE_INTERVENTO and PICODAZI='MARRO' and PIDATMAN=DATA_EFFETTIVA +LEFT OUTER JOIN CODINTE ON PICODINT = dbo.CODINTE.CICODICE +LEFT OUTER JOIN dbo.MIMPIANTI ON AZIENDA_IMPIANTO = dbo.MIMPIANTI.IMCODAZI AND CODICE_IMPIANTO = dbo.MIMPIANTI.IMCODIMP +where SERIALE_RAPPORTINO is not null +and DATA_RAPPORTINO>=DATEADD(month, -2, GETDATE()) + +GO +/****** Object: View [dbo].[API_IMPIANTI] Script Date: 20/03/2023 08:56:34 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_IMPIANTI] +AS +SELECT dbo.MIMPIANTI.IMCODAZI, dbo.MIMPIANTI.IMCODIMP, dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTCLI, + dbo.MIMPIANTI.IMULTDCL, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTTAM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, dbo.MIMPIANTI.IMINDIRI3, + dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, + dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMFLPUPR, dbo.MIMPIANTI.UTDC, dbo.MIMPIANTI.UTDV, dbo.MIMPIANTI.IMPIAMAN, dbo.MIMPIANTI.IMDATATT, dbo.MIMPIANTI.IMZONCHI, + dbo.MIMPIANTI.IMZONSUP, dbo.MIMPIANTI.IMDAINMA, dbo.MIMPIANTI.IMDAFIMA, dbo.MIMPIANTI.IMDATCOS, dbo.MIMPIANTI.IMTELESO, + dbo.API_CLIENTI.AN_EMAIL,dbo.MIMPIANTI.IMREFREF +FROM dbo.MIMPIANTI INNER JOIN + dbo.API_CLIENTI ON dbo.MIMPIANTI.IMULTCLI = dbo.API_CLIENTI.ANCODICE +GO +/****** Object: View [dbo].[API_TECNICI] Script Date: 20/03/2023 08:57:38 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_TECNICI] +AS +SELECT dbo.TECNICI.TCCODICE, dbo.TECNICI.TCDESCRI, dbo.TECNICI.TCTELEF1, dbo.TECNICI.TCCHIAM, dbo.TECNICI.TCMANUT, dbo.TECNICI.TCCODAZI, dbo.TECNICI.TCSUPER, dbo.TECNICI.TCUSER, dbo.TECNICI.TCPWD, + dbo.TECDISP.TDCODZON, dbo.TECDISP.TDDATAIN, dbo.TECDISP.TDDATAFI,TCCOOR as costo_ordinario,TCCONO as costo_notturno,TCCOST as costo_straordinario,TCCOFE as costo_festivo +FROM dbo.TECNICI INNER JOIN + dbo.TECDISP ON dbo.TECNICI.TCCODICE = dbo.TECDISP.TDCODTEC AND dbo.TECNICI.TCCODAZI = dbo.TECDISP.TDCODAZI +GO +/****** Object: View [dbo].[API_CHIAMATE] Script Date: 20/03/2023 08:58:18 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_CHIAMATE] +AS +select +ic.SERIALE_RAPPORTINO as ser_rapp_ic,ic.TIPO_RAPPORTINO as tipo_rapp_ic,/*pc.GENERATO,pc.RIFIUTATA,*/ic.INCARICO as ic, +rif.SERIALE_RAPPORTINO as ser_rapp_rif,rif.TIPO_RAPPORTINO as tipo_rapp_rif,/*rif.GENERATO,*/rif.RIFIUTATA as rif,/*rif.INCARICO,*/ +chiu.SERIALE_RAPPORTINO as ser_rapp_chiu,chiu.TIPO_RAPPORTINO as tipo_rapp_chiu,chiu.SER_BUONO as ser_buono_chiu, +'' as err_title,''as err_detail,'' as err_status_code, +dbo.CHIAMATE.CHCODAZI, dbo.CHIAMATE.CHSERIAL, dbo.CHIAMATE.CHCODESE, dbo.CHIAMATE.CHTIPO, dbo.CHIAMATE.CHNUMERO, dbo.CHIAMATE.CHDATA, dbo.CHIAMATE.CHORA, dbo.CHIAMATE.CHMIN, +dbo.CHIAMATE.CHOPASS, dbo.CHIAMATE.CHOPCHI, dbo.CHIAMATE.CHCODIMP, dbo.CHIAMATE.CHAZIIMP, dbo.CHIAMATE.CHSTATO, dbo.CHIAMATE.CHDTAPP, dbo.CHIAMATE.CHORAAPI, dbo.CHIAMATE.CHMINAPI, +dbo.CHIAMATE.CHORAAPF, dbo.CHIAMATE.CHMINAPF, dbo.CHIAMATE.CHRIFER, dbo.CHIAMATE.CHTELEF, dbo.CHIAMATE.CHCODSEG, dbo.CHIAMATE.CHSTOPI, dbo.CHIAMATE.CHNOTE, dbo.CHIAMATE.CHDTASS, +dbo.CHIAMATE.CHORASS, dbo.CHIAMATE.CHMINASS, dbo.CHIAMATE.CHDTCHI, dbo.CHIAMATE.CHORACHI, dbo.CHIAMATE.CHMINCHI, dbo.CHIAMATE.CHDTLIN, dbo.CHIAMATE.CHORALI, dbo.CHIAMATE.CHMINLI, +dbo.CHIAMATE.CHDTLFI, dbo.CHIAMATE.CHORALF, dbo.CHIAMATE.CHMINLF, dbo.CHIAMATE.cpccchk, dbo.CHIAMATE.CHNRAP1, dbo.CHIAMATE.CHSRAP1, dbo.CHIAMATE.CHNRAP2, dbo.CHIAMATE.CHSRAP2, +dbo.CHIAMATE.CHMODRAC, dbo.CHIAMATE.CHPRGANN, dbo.CHIAMATE.UTCC, dbo.CHIAMATE.UTCV, dbo.CHIAMATE.CHIMPMAN, dbo.CHIAMATE.CHPERMAN, dbo.CHIAMATE.CHFLSTIM, dbo.CHIAMATE.CHFLESTE,CHIAMATE.CHTCHIAM as TCCODICE, +dbo.CHIAMATE.CHSEREXT, dbo.API_IMPIANTI.IMDESCRI, dbo.API_IMPIANTI.IMTIPOIM, dbo.API_IMPIANTI.IMMATRIC, dbo.API_IMPIANTI.IMNUMIMP, dbo.API_IMPIANTI.IMULTAMM, dbo.API_IMPIANTI.IMULTDAM, +dbo.API_IMPIANTI.IMULTTAM, dbo.API_IMPIANTI.IMINDIRI1, dbo.API_IMPIANTI.IMINDIRI2, dbo.API_IMPIANTI.IMINDIRI3, dbo.API_IMPIANTI.IMINDIRI4, dbo.API_IMPIANTI.IMINDIRI5, dbo.API_IMPIANTI.IMLOCALI, +dbo.API_IMPIANTI.IMCODCAP, dbo.API_IMPIANTI.IMCOMUNE, dbo.API_IMPIANTI.IMPROVIN, dbo.API_IMPIANTI.IMCODNAZ, dbo.API_IMPIANTI.IMUBICAZ, dbo.API_IMPIANTI.IMZONMAN, dbo.API_IMPIANTI.IMFLPUPR, +dbo.API_IMPIANTI.IMZONCHI, dbo.API_IMPIANTI.IMZONSUP, dbo.API_IMPIANTI.IMDAINMA, dbo.API_IMPIANTI.IMDAFIMA, dbo.API_IMPIANTI.IMDATCOS, dbo.API_IMPIANTI.IMTELESO, dbo.API_IMPIANTI.AN_EMAIL, +dbo.API_IMPIANTI.IMULTCLI, dbo.MARROCONTI.ANCODICE, dbo.MARROCONTI.ANTIPCON, dbo.MARROCONTI.ANDESCRI, dbo.MARROCONTI.ANTELEFO, dbo.CODSEGN.CSDESCR, dbo.CHIAMATE.CHTCHIAM +,'' as IMAZIRIF,dbo.API_IMPIANTI.IMREFREF +,(select top 1 tcdescri from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as TCDESCRI +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=ANCODICE and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=CHIAMATE.CHTCHIAM) as costo_festivo +from CHIAMATE +left outer join RAPP_NEW as ic on (ic.SERIALE_CHIAMATA=CHSERIAL and ic.AZIENDA_CHIAMATA=CHCODAZI and ic.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(ic.TIPO_RAPPORTINO,'')))='' /*and ic.GENERATO is NULL*/ and (ic.RIFIUTATA='N' )) +left outer join RAPP_NEW as rif on (rif.SERIALE_CHIAMATA=CHSERIAL and rif.AZIENDA_CHIAMATA=CHCODAZI and rif.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(rif.TIPO_RAPPORTINO,'')))='' /*and rif.GENERATO is NULL*/ and (rif.RIFIUTATA='S' )) +left outer join RAPP_NEW as chiu on (chiu.SERIALE_CHIAMATA=CHSERIAL and chiu.AZIENDA_CHIAMATA=CHCODAZI and chiu.CODICE_TECNICO=CHTCHIAM and LTRIM(RTRIM(coalesce(chiu.TIPO_RAPPORTINO,'')))='3' /*and chiu.GENERATO is NULL*/ ) +left outer join CODSEGN ON dbo.CODSEGN.CSCODICE = dbo.CHIAMATE.CHCODSEG AND dbo.CODSEGN.CSCODAZI = dbo.CHIAMATE.CHCODAZI +LEFT OUTER JOIN dbo.MARROCONTI +INNER JOIN dbo.API_IMPIANTI ON dbo.MARROCONTI.ANCODICE = dbo.API_IMPIANTI.IMULTCLI AND dbo.MARROCONTI.ANTIPCON = 'C' ON dbo.CHIAMATE.CHAZIIMP = dbo.API_IMPIANTI.IMCODAZI AND dbo.CHIAMATE.CHCODIMP = dbo.API_IMPIANTI.IMCODIMP + +where 1=1 +and dbo.CHIAMATE.CHSTATO = 'C' +and CHIAMATE.CHDATA>=DATEADD(month, -3, GETDATE()) +and CHIAMATE.CHDATA<=DATEADD(month, 3, GETDATE()) + +GO +/****** Object: View [dbo].[API_MANPROG] Script Date: 20/03/2023 08:59:11 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_MANPROG] +AS + +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,dbo.MANPROG.MPCODAZI AS CTCODAZI, dbo.MANPROG.MPCODIMP AS CTCODIMP, dbo.MANPROG.MPCODINT AS CTCODINT, dbo.CODINTE.CIDESCRI AS CTDESINT, dbo.MANPROG.MPDATPRO AS CTDATPRO, + dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2, + dbo.MIMPIANTI.IMINDIRI3, dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ, + dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, dbo.MIMPIANTI.IMRIFERI, dbo.MIMPIANTI.IMZONCHI, dbo.MIMPIANTI.IMZONSUP, + dbo.MIMPIANTI.IMULTTAM as TELEFONO1,dbo.MIMPIANTI.IMULTFAM as TELEFONO2,dbo.MIMPIANTI.IMULTCLI as CLIENTE, + dbo.MANPROG.MPMESGEN, dbo.MANPROG.MPMESFEB, dbo.MANPROG.MPMESMAR, dbo.MANPROG.MPMESAPR, dbo.MANPROG.MPMESMAG, dbo.MANPROG.MPMESLUG, + dbo.MANPROG.MPMESGIU, dbo.MANPROG.MPMESAGO, dbo.MANPROG.MPMESSET, dbo.MANPROG.MPMESOTT, dbo.MANPROG.MPMESNOV, dbo.MANPROG.MPMESDIC, + T.TCDESCRI,T.TCCODICE,'' as IMAZIRIF,dbo.MIMPIANTI.IMREFREF +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM dbo.MANPROG INNER JOIN dbo.MIMPIANTI ON dbo.MANPROG.MPCODAZI = dbo.MIMPIANTI.IMCODAZI AND dbo.MANPROG.MPCODIMP = dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN dbo.CODINTE ON dbo.MANPROG.MPCODINT = dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT and TCCODICE=picodtec) +left outer join RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' + + + +/* +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,dbo.MANPROG.MPCODAZI AS CTCODAZI, dbo.MANPROG.MPCODIMP AS CTCODIMP, dbo.MANPROG.MPCODINT AS CTCODINT, dbo.CODINTE.CIDESCRI AS CTDESINT, dbo.MANPROG.MPDATPRO AS CTDATPRO +, dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2 +,dbo.MIMPIANTI.IMINDIRI3, dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ +,dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, SUBSTRING(dbo.MIMPIANTI.IMRIFERI,0,499) as IMRIFERI, dbo.MIMPIANTI.IMZONCHI, dbo.MIMPIANTI.IMZONSUP +,dbo.MIMPIANTI.IMULTTAM as TELEFONO1,dbo.MIMPIANTI.IMULTFAM as TELEFONO2,dbo.MIMPIANTI.IMULTCLI as CLIENTE +,dbo.MANPROG.MPMESGEN, dbo.MANPROG.MPMESFEB, dbo.MANPROG.MPMESMAR, dbo.MANPROG.MPMESAPR, dbo.MANPROG.MPMESMAG, dbo.MANPROG.MPMESLUG +,dbo.MANPROG.MPMESGIU, dbo.MANPROG.MPMESAGO, dbo.MANPROG.MPMESSET, dbo.MANPROG.MPMESOTT, dbo.MANPROG.MPMESNOV, dbo.MANPROG.MPMESDIC +,T.TCDESCRI,T.TCCODICE,'' as IMAZIRIF,dbo.MIMPIANTI.IMREFREF +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM dbo.MANPROG INNER JOIN dbo.MIMPIANTI ON dbo.MANPROG.MPCODAZI = dbo.MIMPIANTI.IMCODAZI AND dbo.MANPROG.MPCODIMP = dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN dbo.CODINTE ON dbo.MANPROG.MPCODINT = dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT and TCCODICE=picodtec) +left outer join RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' +and MANPROG.MPCODINT<>'QUI' +UNION +SELECT +PRESA.PIMPIANTO,PRESA.PICODINT,PRESA.PIDATMAN +,RAPP_NEW.SERIALE_RAPPORTINO,RAPP_NEW.SER_BUONO,RAPP_NEW.GENERATO,RAPP_NEW.CODICE_INTERVENTO +,'' as err_title,''as err_detail,'' as err_status_code +,dbo.MANPROG.MPCODAZI AS CTCODAZI, dbo.MANPROG.MPCODIMP AS CTCODIMP, dbo.MANPROG.MPCODINT AS CTCODINT, dbo.CODINTE.CIDESCRI AS CTDESINT, dbo.MANPROG.MPDATPRO AS CTDATPRO +,dbo.MIMPIANTI.IMDESCRI, dbo.MIMPIANTI.IMTIPOIM, dbo.MIMPIANTI.IMMATRIC, dbo.MIMPIANTI.IMNUMIMP, dbo.MIMPIANTI.IMULTDAM, dbo.MIMPIANTI.IMULTAMM, dbo.MIMPIANTI.IMINDIRI1, dbo.MIMPIANTI.IMINDIRI2 +,dbo.MIMPIANTI.IMINDIRI3, dbo.MIMPIANTI.IMINDIRI4, dbo.MIMPIANTI.IMINDIRI5, dbo.MIMPIANTI.IMLOCALI, dbo.MIMPIANTI.IMCODCAP, dbo.MIMPIANTI.IMCOMUNE, dbo.MIMPIANTI.IMPROVIN, dbo.MIMPIANTI.IMCODNAZ +,dbo.MIMPIANTI.IMUBICAZ, dbo.MIMPIANTI.IMZONMAN, SUBSTRING(dbo.MIMPIANTI.IMRIFERI,0,499) as IMRIFERI, dbo.MIMPIANTI.IMZONCHI, dbo.MIMPIANTI.IMZONSUP +,dbo.MIMPIANTI.IMULTTAM as TELEFONO1,dbo.MIMPIANTI.IMULTFAM as TELEFONO2,dbo.MIMPIANTI.IMULTCLI as CLIENTE +,dbo.MANPROG.MPMESGEN, dbo.MANPROG.MPMESFEB, dbo.MANPROG.MPMESMAR, dbo.MANPROG.MPMESAPR, dbo.MANPROG.MPMESMAG, dbo.MANPROG.MPMESLUG +,dbo.MANPROG.MPMESGIU, dbo.MANPROG.MPMESAGO, dbo.MANPROG.MPMESSET, dbo.MANPROG.MPMESOTT, dbo.MANPROG.MPMESNOV, dbo.MANPROG.MPMESDIC +,T.TCDESCRI,T.TCCODICE,'' as IMAZIRIF,dbo.MIMPIANTI.IMREFREF +,(select top 1 CTIMPCHI from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as chiamata +,(select top 1 CTIMPVIA from MARROMCONMAST where CTCODCLI=IMULTCLI and CTFLSTAT='A' order by CTDATREG desc) as spe_viaggio +,(select top 1 costo_ordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_ordinario +,(select top 1 costo_notturno from API_TECNICI where TCCODICE=T.TCCODICE) as costo_notturno +,(select top 1 costo_straordinario from API_TECNICI where TCCODICE=T.TCCODICE) as costo_straordinario +,(select top 1 costo_festivo from API_TECNICI where TCCODICE=T.TCCODICE) as costo_festivo + +FROM dbo.MANPROG INNER JOIN dbo.MIMPIANTI ON dbo.MANPROG.MPCODAZI = dbo.MIMPIANTI.IMCODAZI AND dbo.MANPROG.MPCODIMP = dbo.MIMPIANTI.IMCODIMP +LEFT OUTER JOIN dbo.CODINTE ON dbo.MANPROG.MPCODINT = dbo.CODINTE.CICODICE +INNER JOIN API_TECNICI T ON MIMPIANTI.IMZONMAN=T.TDCODZON AND MANPROG.MPCODAZI=T.TCCODAZI and t.TDDATAFI>=GETDATE() +left outer join PRESA on (PICODAZI=MPCODAZI and MPCODIMP=PIMPIANTO and MPCODINT=PICODINT and TCCODICE=picodtec) +left outer join RAPP_NEW on (MANPROG.MPCODAZI=AZIENDA_CHIAMATA and MANPROG.MPCODIMP=CODICE_IMPIANTO and LTRIM(RTRIM(coalesce(TIPO_RAPPORTINO,'')))='2' and MANPROG.MPCODINT=CODICE_INTERVENTO /*and GENERATO is null*/and MPDATPRO=DATA_VALIDITA) +where MANPROG.MPDATPRO>=DATEADD(month, -3, GETDATE()) +--and MANPROG.MPDATPRO<=EOMONTH(GETDATE(),0) +and MANPROG.MPDATPRO<=DATEADD(DAY, 14, GETDATE()) +and LTRIM(rtrim(coalesce(GENERATO,'')))<>'S' +and MANPROG.MPCODINT='QUI' +*/ + +GO +/****** Object: View [dbo].[API_SOSTITUZIONI] Script Date: 20/03/2023 09:01:39 ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER VIEW [dbo].[API_SOSTITUZIONI] +AS +SELECT [TSCODAZI],[TSCODTEC],[TSCODZON],[TSDATAIN],[TSDATAFI],[TSCODSOS] + FROM [dbo].[TECSOS] + where [TSDATAIN]<=DATEADD(DAY, -1, GETDATE()) + and [TSDATAFI]>=DATEADD(DAY, 1, GETDATE()) + and [TSCODAZI]='MARRO' +GO \ No newline at end of file diff --git a/ApiPolo/SQL/_README_DISCO.txt b/ApiPolo/SQL/_README_DISCO.txt new file mode 100644 index 0000000..c2ec244 --- /dev/null +++ b/ApiPolo/SQL/_README_DISCO.txt @@ -0,0 +1,2 @@ +IMAZIRIF deve essere letto da api_IMPIANTI in API_CHIAMATE e in API_MANPROG. negli altri per far funzionare le viste lo leggo a '' +deve essere pirifazi(su Azirif)=imazirif(su Chiamate_out e Manprog_out) \ No newline at end of file diff --git a/ApiPolo/Services/CronJobService.cs b/ApiPolo/Services/CronJobService.cs new file mode 100644 index 0000000..1aaad1c --- /dev/null +++ b/ApiPolo/Services/CronJobService.cs @@ -0,0 +1,113 @@ +using Cronos; + +namespace ApiPolo.Services +{ + /// + public abstract class CronJobService : IHostedService, IDisposable + { + private System.Timers.Timer? _timer; + private readonly CronExpression _expression; + private readonly TimeZoneInfo _timeZoneInfo; + + /// + protected CronJobService(string cronExpression, TimeZoneInfo timeZoneInfo) + { + _expression = CronExpression.Parse(cronExpression); + _timeZoneInfo = timeZoneInfo; + } + + /// + public virtual async Task StartAsync(CancellationToken cancellationToken) + { + await ScheduleJob(cancellationToken); + } + + /// + protected virtual async Task ScheduleJob(CancellationToken cancellationToken) + { + var next = _expression.GetNextOccurrence(DateTimeOffset.Now, _timeZoneInfo); + if (next.HasValue) + { + var delay = next.Value - DateTimeOffset.Now; + if (delay.TotalMilliseconds <= 0) // prevent non-positive values from being passed into Timer + { + await ScheduleJob(cancellationToken); + } + _timer = new System.Timers.Timer(delay.TotalMilliseconds); + _timer.Elapsed += async (_, _) => + { + _timer.Dispose(); // reset and dispose timer + _timer = null; + + if (!cancellationToken.IsCancellationRequested) + { + await DoWork(cancellationToken); + } + + if (!cancellationToken.IsCancellationRequested) + { + await ScheduleJob(cancellationToken); // reschedule next + } + }; + _timer.Start(); + } + await Task.CompletedTask; + } + + /// + public virtual async Task DoWork(CancellationToken cancellationToken) + { + await Task.Delay(5000, cancellationToken); // do the work + } + + /// + public virtual async Task StopAsync(CancellationToken cancellationToken) + { + _timer?.Stop(); + await Task.CompletedTask; + } + + /// + public virtual void Dispose() + { + _timer?.Dispose(); + GC.SuppressFinalize(this); + } + } + + /// + public interface IScheduleConfig + { + string CronExpression { get; set; } + TimeZoneInfo TimeZoneInfo { get; set; } + } + + /// + public class ScheduleConfig : IScheduleConfig + { + public string CronExpression { get; set; } = string.Empty; + public TimeZoneInfo TimeZoneInfo { get; set; } = TimeZoneInfo.Local; + } + + /// + public static class ScheduledServiceExtensions + { + public static IServiceCollection AddCronJob(this IServiceCollection services, Action> options) where T : CronJobService + { + if (options == null) + { + throw new ArgumentNullException(nameof(options), @"Please provide Schedule Configurations."); + } + var config = new ScheduleConfig(); + options.Invoke(config); + if (string.IsNullOrWhiteSpace(config.CronExpression)) + { + throw new ArgumentNullException(nameof(ScheduleConfig.CronExpression), @"Empty Cron Expression is not allowed."); + } + + services.AddSingleton>(config); + services.AddHostedService(); + return services; + } + } +} diff --git a/ApiPolo/Services/MyCronJob1.cs b/ApiPolo/Services/MyCronJob1.cs new file mode 100644 index 0000000..0a40015 --- /dev/null +++ b/ApiPolo/Services/MyCronJob1.cs @@ -0,0 +1,664 @@ +using FirebaseAdmin.Messaging; +using FirebaseAdmin; +using Google.Apis.Auth.OAuth2; +using static ApiPolo.Controllers.PoloController; +using static Google.Apis.Requests.BatchRequest; +using System.Text; +using ApiPolo.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Options; +using System.Net; +using Newtonsoft.Json; +using RestSharp; +using System.Net.Http.Headers; +using Nancy.Json; + +namespace ApiPolo.Services +{ + /* https://www.netiq.com/documentation/cloud-manager-2-5/ncm-reference/data/bexyssf.html sintassi intervalli cron */ + + /// + public class MyCronJob1 : CronJobService + { + /// Configuration + public IConfiguration Configuration { get; } + + /// Startup + private readonly ILogger _logger; + + /// Costruttore + public MyCronJob1(IScheduleConfig config, ILogger logger, IConfiguration configuration) : base(config.CronExpression, config.TimeZoneInfo) + { + _logger = logger; + Configuration = configuration; + } + + /// + public override Task StartAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("MessagePushJob 1 starts."); + return base.StartAsync(cancellationToken); + } + + /// + public override Task DoWork(CancellationToken cancellationToken) + { + _logger.LogInformation("{now} MessagePushJob 1 is working.", DateTime.Now.ToString("T")); + + try + { + //cerco le notifiche da mandare + List l = readNotify(); + //List l=new List (); + + foreach (Notifiche n in l) + { + StringBuilder sb = new StringBuilder(); + sb.Append("tecnico: " + n.picodtec + " "); + sb.Append("azienda: " + n.picodazi + " "); + sb.Append("data: " + n.piserial + " "); + + _logger.LogInformation(sb.ToString()); + + } + + //se ci sono cerco il token dispositivo per l'invio + //e li metto in una lista di oggetti pronti per l'invio + + List ll = fillMex(l); + foreach (MexPush p in ll) + { + //PushFCM_Sync(p.token, "Title", p.body); + //PushFCM_SyncNew(null, "Title", "test"); + GenerateFCM_Auth_SendNotifcn(p.token); + } + + + //TODO logica di aggiornamento della tabella delle notifiche + //markNotify(ll); + + //markNotify2(l); + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + _logger.LogInformation(" MessagePushJob KO !!!! :"+errmsg, string.Empty); + } + + + return Task.CompletedTask; + } + + /// + public override Task StopAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("MessagePushJob 1 is stopping."); + return base.StopAsync(cancellationToken); + } + + private List readNotify() + { + List lst = new List(); + //#region Marrocco + //var optionsBuilder = new DbContextOptionsBuilder(); + //optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO")); + + //using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options)) + //{ + // var listaNot = dbContext.Notif.Where(t => t.pidattim == null&& t.picodazi!=null && t.picodazi.Equals("MARRO") && t.picodtec!=null && t.picodtec.Equals("ZZZ")).OrderBy(t=>t.piserial).Take(1).ToList(); + + // foreach(Notifiche n in listaNot) + // { + // lst.Add(n); + // } + //} + //#endregion + + return lst; + } + + //private void markNotify(List lst) + //{ + // #region MARRO + // var optionsBuilder = new DbContextOptionsBuilder(); + // optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO")); + // using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options)) + // { + // foreach (MexPush n in lst) + // { + // Notifiche r = n.notifi; + // r.pidattim = DateTime.Now; + // dbContext.Entry(r).State = EntityState.Modified; + // dbContext.SaveChanges(); + + // } + // } + // #endregion + //} + //private void markNotify2(List lst) + //{ + // #region MARRO + // var optionsBuilder = new DbContextOptionsBuilder(); + // optionsBuilder.UseSqlServer(Configuration.GetConnectionString("MARRO")); + // using (var dbContext = new MARRO_NOTIFICHEDbContext(optionsBuilder.Options)) + // { + // foreach (Notifiche n in lst) + // { + // Notifiche r = n; + // r.pidattim = DateTime.Now; + // dbContext.Entry(r).State = EntityState.Modified; + // dbContext.SaveChanges(); + + // } + // } + // #endregion + //} + + private List fillMex(List lst) + { + List mess = new List(); + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseSqlServer(Configuration.GetConnectionString("ApiStr")); + + + foreach(Notifiche nn in lst) + { + using (var dbContext = new TokenDbContext(optionsBuilder.Options)) + { + string rif = nn.piserial; + var t= dbContext.tok.Where(c=>c.usr.Equals(nn.picodtec)&& c.tenant.Equals(nn.picodazi)).ToList(); + + foreach (Token n in t) + { + MexPush m = new MexPush(); + m.tenant = n.tenant; + m.usr = n.usr; + m.token = n.token; + m.body = rif; + m.notifi = nn; + + mess.Add(m); + } + + //TODO logica di aggiornamento della tabella delle notifiche + } + } + + + return mess; + } + + //private void pushMex(string title,string body, string tokenDevice) + //{ + // //string log = string.Empty; + // StringBuilder sb = new StringBuilder(); + // string _title = title +"-"+ getCpccchk(4); + // string _body = body + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); + // //_logger.LogInformation("{now} MessagePushJob is working.", DateTime.Now.ToString("T")); + // try + // { + // if (FirebaseApp.DefaultInstance == null) + // { + // FirebaseApp.Create(new AppOptions() + // { + // Credential = GoogleCredential.FromFile("private_key.json") + + + // }); + // } + // //var registrationToken = "dDxUDIC3QcWytp6UeVMDyT:APA91bH9y0N7Iff39Ncv0m_EjJ-hv7YTWYaL_5P37-2dob2PRuArvpfl6kmrk10GO2eJiAQ2tVT3tZX9khUD-NPyfljGbpBn1iUyjbTpL6tDF-0IgJN960v95I4_2SWM_crtSH-ZrXAK"; + // var registrationToken = tokenDevice; + + // var message = new Message() + // { + // Apns = new ApnsConfig() + // { + // Aps = new Aps() + // { + // //Change this for the sound you would like + // Sound = "default" + // } + // }, + // Android = new AndroidConfig() + // { + // Notification = new AndroidNotification() + // { + // Sound = "default", + // Priority = NotificationPriority.MAX + + // }, + // Data = new Dictionary() + // { + // { "myData3", "1234522222" } + + // } + // }, + + // Token = registrationToken, + // Data = new Dictionary() + // { + // { "myData", "123457777" } + + // }, + // Notification = new Notification() + // { + // Title = _title, + // Body = _body + // } + + // }; + + + // string response = FirebaseMessaging.DefaultInstance.SendAsync(message).Result; + // //string response = FirebaseMessaging.DefaultInstance.SendMulticastAsync(msg2send).Result; + + // sb.AppendLine("MessagePushJob OK"); + // sb.AppendLine("response:" + response); + // sb.AppendLine("title:" + _title); + // sb.AppendLine("body:" + _body); + // sb.AppendLine("==================="); + + // _logger.LogInformation(sb.ToString()); + // } + // catch (Exception ex) + // { + // string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + // _logger.LogInformation(" MessagePushJob KO !!!! :", errmsg); + // } + // // return log; + //} + + private string PushFCM_Notification(string deviceId, string title, string body) + { + StringBuilder sb = new StringBuilder(); + string _title = title + "-" + getCpccchk(4); + string _body = body + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); + try + { + string SERVER_API_KEY = "AAAAGBwLmNY:APA91bG5GmgYcaxsU8HrOqvZbb9r82tH9RAEifgKhwoj_zwBe7qei8u3BSxMzFl9Dwykd0TWRuM7ffNe6ehhDDRUqaRPj_vKM9KreJnNrqB6f2hxjPAxzk5De2Ys437-dnSAuS_8SVJV"; + var SENDER_ID = "103549737174"; + var value = body; + WebRequest tRequest; + tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); + tRequest.Method = "post"; + tRequest.Method = "post"; + tRequest.ContentType = "application/json"; + tRequest.Headers.Add(string.Format("Authorization: key={0}", SERVER_API_KEY)); + + tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); + + var msg = new + { + to = deviceId, + data = new + { + body = _body, + title = _title + } + }; + + //var serializer = new JavaScriptSerializer(); + //var json = serializer.Serialize(data); + var json = JsonConvert.SerializeObject(msg, Formatting.Indented); + + Byte[] byteArray = Encoding.UTF8.GetBytes(json); + + tRequest.ContentLength = byteArray.Length; + + Stream dataStream = tRequest.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + + WebResponse tResponse = tRequest.GetResponse(); + + dataStream = tResponse.GetResponseStream(); + + StreamReader tReader = new StreamReader(dataStream); + + String sResponseFromServer = tReader.ReadToEnd(); + + + tReader.Close(); + dataStream.Close(); + tResponse.Close(); + + sb.AppendLine("MessagePushJob OK"); + sb.AppendLine("response:" + sResponseFromServer); + sb.AppendLine("title:" + _title); + sb.AppendLine("body:" + _body); + sb.AppendLine("==================="); + + _logger.LogInformation(sb.ToString()); + + return sResponseFromServer; + } + catch (Exception ex) + { + string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + _logger.LogInformation(" MessagePushJob KO !!!! :", errmsg); + return errmsg; + } + } + + private string PushFCM_Sync(string deviceId, string title, string body) + { + StringBuilder sb = new StringBuilder(); + string _title = title + "-" + getCpccchk(4); + string _body = body + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); + //try + //{ + string SERVER_API_KEY = "AAAAGBwLmNY:APA91bG5GmgYcaxsU8HrOqvZbb9r82tH9RAEifgKhwoj_zwBe7qei8u3BSxMzFl9Dwykd0TWRuM7ffNe6ehhDDRUqaRPj_vKM9KreJnNrqB6f2hxjPAxzk5De2Ys437-dnSAuS_8SVJV"; + var SENDER_ID = "103549737174"; + var value = body; + WebRequest tRequest; + tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); + tRequest.Method = "post"; + tRequest.Method = "post"; + tRequest.ContentType = "application/json"; + tRequest.Headers.Add(string.Format("Authorization: key={0}", SERVER_API_KEY)); + + tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); + + var msg = new + { + to = deviceId, + data = new + { + bg_sync = true + } + }; + + //var serializer = new JavaScriptSerializer(); + //var json = serializer.Serialize(data); + var json = JsonConvert.SerializeObject(msg, Formatting.Indented); + + Byte[] byteArray = Encoding.UTF8.GetBytes(json); + + tRequest.ContentLength = byteArray.Length; + + Stream dataStream = tRequest.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + + WebResponse tResponse = tRequest.GetResponse(); + + dataStream = tResponse.GetResponseStream(); + + StreamReader tReader = new StreamReader(dataStream); + + String sResponseFromServer = tReader.ReadToEnd(); + + + tReader.Close(); + dataStream.Close(); + tResponse.Close(); + + sb.AppendLine("MessagePushJob Sync OK"); + sb.AppendLine("response:" + sResponseFromServer); + sb.AppendLine("==================="); + + _logger.LogInformation(sb.ToString()); + + return sResponseFromServer; + //} + //catch (Exception ex) + //{ + // string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; + // _logger.LogInformation(" MessagePushJob KO !!!! :", errmsg); + // return errmsg; + //} + } + + #region HTTP V1 API FCM Auth & Send Notification To Mobile //notify FCM Code + + public class Data + { + + public string body + { + get; + set; + } + + public string title + { + get; + set; + } + + public string key_1 + { + get; + set; + } + + public string key_2 + { + get; + set; + } + + } + + public class Message + { + + public string token + { + get; + set; + } + + public Data data + { + get; + set; + } + + public Notification notification + { + get; + set; + } + + } + + public class Notification + { + + public string title + { + get; + set; + } + + public string body + { + get; + set; + } + + } + + public class Root + { + + public Message message + { + get; + set; + } + + } + + public void GenerateFCM_Auth_SendNotifcn(string deviceID) + + { + //----------Generating Bearer token for FCM--------------- + + string fileName = Path.Combine(Directory.GetCurrentDirectory(), "apipolo-952c6-firebase-adminsdk-tioa9-fbb9ba6d66.json") ; //Download from Firebase Console ServiceAccount + + string scopes = "https://www.googleapis.com/auth/firebase.messaging"; + var bearertoken = ""; // Bearer Token in this variable + using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) + { + + bearertoken = GoogleCredential + .FromStream(stream) // Loads key file + .CreateScoped(scopes) // Gathers scopes requested + .UnderlyingCredential // Gets the credentials + .GetAccessTokenForRequestAsync().Result; // Gets the Access Token + + } + _logger.LogInformation("bearertoken: " + bearertoken); + ///--------Calling FCM----------------------------- + + var clientHandler = new HttpClientHandler(); + var client = new HttpClient(clientHandler); + + client.BaseAddress = new Uri("https://fcm.googleapis.com/v1/projects/apipolo-952c6/messages:send"); // FCM HttpV1 API + + client.DefaultRequestHeaders.Accept.Clear(); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + //client.DefaultRequestHeaders.Accept.Add("Authorization", "Bearer " + bearertoken); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearertoken); // Authorization Token in this variable + + //---------------Assigning Of data To Model -------------- + + Root rootObj = new Root(); + rootObj.message = new Message(); + + //rootObj.message.token = "dfYGNx8lTtuCIJZCDKg4WU:APA91bHVY4tBrXKOvnqJvWA5s2By_8Nt8XyRnadDkuGey0C3E45CoasJUUACVp0PCgNkZcXiDnA2WAfX1jfJXcPgM5L6EJFa4IAOccj_GR0uRBO9gXOcwNkh6dSYWb6fOvGFHhuSEoXz"; //FCM Token id + rootObj.message.token = deviceID; + + rootObj.message.data = new Data(); + rootObj.message.data.title = "Data Title"; + rootObj.message.data.body = "Data Body"; + rootObj.message.data.key_1 = "Sample Key"; + rootObj.message.data.key_2 = "Sample Key2"; + rootObj.message.notification = new Notification(); + rootObj.message.notification.title = "Notify Title"; + rootObj.message.notification.body = "Notify Body"; + + //-------------Convert Model To JSON ---------------------- + + var jsonObj = new JavaScriptSerializer().Serialize(rootObj); + + //------------------------Calling Of FCM Notify API------------------- + + var data = new StringContent(jsonObj, Encoding.UTF8, "application/json"); + data.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + var response = client.PostAsync("https://fcm.googleapis.com/v1/projects/apipolo-952c6/messages:send", data).Result; // Calling The FCM httpv1 API + + //---------- Deserialize Json Response from API ---------------------------------- + + var jsonResponse = response.Content.ReadAsStringAsync().Result; + _logger.LogInformation("RESPONSE: "+jsonResponse); + var responseObj = new JavaScriptSerializer().DeserializeObject(jsonResponse); + + } + + #endregion + + + + + + //private async Task getAuthToken() + //{ + // var scopes = new string[] { "https://www.googleapis.com/auth/firebase.messaging" }; + // var path = Path.Combine(Directory.GetCurrentDirectory(), "apipolo-952c6-firebase-adminsdk-tioa9-fbb9ba6d66.json"); + // var cred = GoogleCredential.FromFile(path).CreateScoped(scopes); + // var token = await cred.UnderlyingCredential.GetAccessTokenForRequestAsync(); + // return token; + //} + //private (bool, T) SendRequest(string url, object requestBody = null, Method method = Method.Post) + //{ + // ServicePointManager.Expect100Continue = true; + // ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + + // RestClient client = new(url); + // var request = new RestRequest(); + // var token = getAuthToken().Result; + // request.AddHeader("Content-Type", "application/json"); + // request.AddHeader("Authorization", $"Bearer {token}"); + // request.AddHeader("access_token_auth", "true"); + // request.AddHeader("project_id", "SENDER_ID"); + // request.Method = Method.Post; + + + // if (requestBody != null) + // { + // request.AddJsonBody(JsonConvert.SerializeObject(requestBody)); + // } + // RestResponse iResponse = client.Execute(request); + + // if (iResponse.StatusCode != HttpStatusCode.OK) + // { + // return (false, default(T)); + // } + // else + // { + // try + // { + // return (true, JsonConvert.DeserializeObject(iResponse.Content)); + // } + // catch (Exception) + // { + // return (false, default(T)); + // } + // } + //} + + //public NotificationMessageResponse sendMessageToGroup(string notification_key, object notification, object data) + //{ + // var requestObj = new + // { + // token = notification_key, //to + // data = data, + // notification = notification, + // apns = new + // { + // payload = new + // { + // aps = new + // { + // alert = notification, + // sound = "default", + // badge = 1, + // data + // } + // } + // } + // }; + // var baseUrl = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send"; + // var resp = SendRequest(baseUrl, requestObj); + // return resp.Item2; + //} + + private class MexPush + { + /// tenant azienda + public string? tenant { get; set; } + + /// utente login + public string? usr { get; set; } + + /// token device + public string? token { get; set; } + + /// title + public string? title { get; set; } + + /// body + public string? body { get; set; } + + /// not + public Notifiche? notifi { get; set; } + } + + } +} diff --git a/ApiPolo/Startup.cs b/ApiPolo/Startup.cs new file mode 100644 index 0000000..38b3d6d --- /dev/null +++ b/ApiPolo/Startup.cs @@ -0,0 +1,207 @@ +using ApiPolo.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.OpenApi.Models; +using ApiPolo.Services; +using ApiPolo.Models.VT_dbcontext; +using ApiPolo.Interfaces; +//using ApiPolo.Data; +using Api_VT.Models; +using Api_VT.Models.VT_dbcontext; + +namespace ApiPolo +{ + /// Startup + public class Startup + { + /// Configuration + public IConfiguration Configuration { get; } + /// Startup + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + /// ConfigureServices + public void ConfigureServices(IServiceCollection services) + { + try + { + const int commandTimeoutInSeconds = 300; + services.AddControllers(); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr"))); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("ApiStr"))); + + #region VIRTUAL TASK + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK") + , options => { options.CommandTimeout(commandTimeoutInSeconds); } + )); + + #endregion + + //TEST + + //services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("MARAS") + // , options => { options.CommandTimeout(commandTimeoutInSeconds); } + // )); + //services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("MARRO") + // , options => { options.CommandTimeout(commandTimeoutInSeconds); } + // )); + + + // FACTORY MUTI-TENANT + services.AddScoped(); + + + services.AddSwaggerGen(gen => + { + + gen.ResolveConflictingActions(apiDescription => apiDescription.First()); + //gen.SwaggerDoc("v1", new OpenApiInfo { Title = "POLO API WS2016", Version = "v3.3" }); + DateTime oggi = DateTime.Now; + string dt = oggi.ToString(); + gen.SwaggerDoc("v1", new OpenApiInfo { Title = "POLO API - v.app 1.30", Version = dt }); + + var filePath = Path.Combine(System.AppContext.BaseDirectory, "ApiPolo.xml"); + gen.IncludeXmlComments(filePath); + }); + + //services.AddCronJob(c => + //{ + // c.TimeZoneInfo = TimeZoneInfo.Local; + // //c.CronExpression = @"*/10 * * * *"; + + // c.CronExpression = @"* * * * *"; + //}); + + services.AddLogging(opt => + { + opt.AddConsole(c => + { + c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] "; + }); + }); + + } + catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } + + /// Configure:This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment() || env.IsProduction()) + { + //app.UseDeveloperExceptionPage(); + app.UseSwagger(); + //app.UseSwaggerUI(); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "POLO API V2"); + + }); + //app.UseHttpsRedirection(); + } + + app.UseRouting(); + + app.UseAuthentication(); + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + app.UseStaticFiles(); + } + } +} diff --git a/ApiPolo/Storico versioni.txt b/ApiPolo/Storico versioni.txt new file mode 100644 index 0000000..a9b923b --- /dev/null +++ b/ApiPolo/Storico versioni.txt @@ -0,0 +1,8 @@ +verione 1.13 + +- gestione rapportino da commessa o da impianto: l'app diventa in grado di inserire chiamate (Chiamate, seriale chiamate, num progressivo chiamate e presa in carico) e poi restituisce +la chiamata appena inserita per poterla poi lavorare come una normale chiamata e farne il buono. + +- aggiunta la gestione da Api della parte del buono che descrive l'impianto, al solito in formato html + campo riferimento_impianto su Chiamate_out +************************************************************************************* \ No newline at end of file diff --git a/ApiPolo/api_VT-952c6-firebase-adminsdk-tioa9-fbb9ba6d66.json b/ApiPolo/api_VT-952c6-firebase-adminsdk-tioa9-fbb9ba6d66.json new file mode 100644 index 0000000..67f837e --- /dev/null +++ b/ApiPolo/api_VT-952c6-firebase-adminsdk-tioa9-fbb9ba6d66.json @@ -0,0 +1,13 @@ +{ + "type": "service_account", + "project_id": "apipolo-952c6", + "private_key_id": "fbb9ba6d66d83350f3b982036d8da40580180426", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDaTP2pnqO/zjXd\nPPE3217BcCKlGPd4jemA2YQSHvfPMMFWAxb7JuBbg+vf+POpJrv2hhDbUFncctNI\nUP/esH+bFs2UiR6ApI+pqEBltuUHdcN7mpGKos8YVQFqnQEmECm4LByDxQhe39d9\nK+0r4byllQVtmSJto0e8o1Hg4TzdXz2lQxZHk9OnaPQ18uPOq0CXuAjrqLl1+qUw\nmuighelsIfb9GA0/QHWSHt14sf08Gs9UxILSY1mHR1DXAJJ9emVJWWQMOhX2NoJo\nTycx5lERZsv9FaX+scYY16WFRondeyLoGg2n/WmXsdW1sZMREtaKiTzme+HTVl2n\n9V8PkXVbAgMBAAECggEAAtjQuKSNl586h5qy1fljWeUWON2Y5M7nFGrvgLDmv1kn\nBdl/RomoR7lBjAeeuX5FkHVehPTteP2Yj0Z5P2bHVq3aGERoGE+ibpMD8SBoRwv8\nYn5CY1FAq7vHf1rBQTL9qvYxQzLDdIo/gAYwFSQQxil5Ahopd6mSu4Z3KyiZZj+o\nJBPwskiVaT5h387n2WpjdC9z6Q6TZ6Nzsbu0icl1E6Oek9M3+ps8bng3pUhdwuRq\n2mn+Rd0KuUHFq4KfZGcWVyIaLGmNZ5Pw1WapEkqGDZ+AgBRcX5hO0py3lh15cxxk\nSNEJXNC5eynrN2muywnNFHx4QugTXwQNSW7qxjIXxQKBgQD8yXh0oqC3OH55mLj+\nC2sC6jWU9ofy96HTKN3UmGaLIn7rQTddzUESpD5L7CvKCW97pIe2gryIblw4M3mB\nsS0Oj3CyLRiShm5+iGinMuoYfgaKJdj6vDQmWjLHLURLmuBYma1MAT0eO6nHByDP\n7ihKo1VxKmfLzvOc8athtkrz1wKBgQDdE06140uIkfqyRLuhMI5HBPLS98GuUVU7\nw3+qeS/Y6BN5Nk70WGjV/7Cf4EmVTNEg/bXZeAr+4LOtgMYPGa2Vj2TQAxzycUSo\nYcKLQ5rO73aHEgylKxv2D1qMcEt1E3LbSczXvxJyOy9m8vykp33KhkUmry0rgWj1\nkXNiDDAaHQKBgG35uM4FcqZDjcKZDuJ3VTcPbgBAwSSTV3Pmc5vqMbKWb2EqHkxQ\n396cVf3x4ZskP7wq+GAOwLcaTESnIFWsH04WWZEqzWXx1mB2OBGFtRKywWWY0a1D\n8+w7kZvVtcCuwKvLL/nBEDX2/wX3s+7CTgUqyiFRsZaZkqLVARqhlDpBAoGAeGVq\naT4GxbKScAFkmY0i/uRgBaquDOv4WhrG7SUgfKUu7cU4zHNVbK3aF8eC608xWSEy\npuNsQZBH6gaGVnTqhtfX1DzNx+8NsBHFbCh+J5Jb34Vh45WNnbyQ2IjTX0gfNfOE\nHj7Noe4/i3ZrRpR8ug3TnRSrqdTJP2teBhiTHbUCgYEA5sWu0fGbacwzblmRZ4UM\nmNMAgeNsCL18dQMk22kj1UQvd7H88mjb+i+ojNN+yBIu45JxKuVPofrBRm9FOqxC\ntJYGXW0ujQxqrNIVOxI4zKw9E67tmaxYigTV5PX6A2l/UN2LQzVC7jRJK1CwDnpT\nZv+3uacaBhpqJS0wGCQxaik=\n-----END PRIVATE KEY-----\n", + "client_email": "firebase-adminsdk-tioa9@apipolo-952c6.iam.gserviceaccount.com", + "client_id": "110564565566804338065", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-tioa9%40apipolo-952c6.iam.gserviceaccount.com", + "universe_domain": "googleapis.com" +} diff --git a/ApiPolo/appsettings.Development.json b/ApiPolo/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/ApiPolo/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/ApiPolo/appsettings.json b/ApiPolo/appsettings.json new file mode 100644 index 0000000..4137566 --- /dev/null +++ b/ApiPolo/appsettings.json @@ -0,0 +1,67 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ConnectionStrings": { + + //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=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",*/ + "FERRA": "Data Source=37.159.179.14;Initial Catalog=AHR80_TEST;User Id=AppPolo; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;Encrypt=False;Trust Server Certificate=True", + + /*"MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO_TEST;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + /*"MARRO": "Data Source=poloinformatico57.clienti.init-s.it;Initial Catalog=R80_MARROCCO;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + + "GITSR": "Data Source=172.25.30.177;Initial Catalog=R80_GITSR;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + /*"GITSR": "Data Source=172.25.30.177;Initial Catalog=R80_GITSR_TEST;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "GITSR_MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + //"GITSR_MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO_TEST;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + "LIFTA": "Data Source=172.25.30.177;Initial Catalog=R80_LIFTA;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + /*"LIFTA": "Data Source=172.25.30.177;Initial Catalog=R80_LIFTA_TEST;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "LIFTA_MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + //"LIFTA_MARRO": "Data Source=172.25.30.177;Initial Catalog=R80_MARROCCO_TEST;User Id=app; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + /*"SICILIA": "Data Source=10.0.0.10;Initial Catalog=AHR_SICILIA;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "SICILIA": "Data Source=studioliuzzo.selfip.net;Initial Catalog=AHR_TEST_APP;User Id=sa; Password=1Zucchetti;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + /*"DISCO": "Data Source=10.0.0.10;Initial Catalog=AHR60_FERRARI_VISTE_DISCO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + /*"DISCO": "Data Source=MARCO_PC\\SQL_2022;Initial Catalog=DISCOVERY_80;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + /*"DISCO": "Data Source=discoverylift.dyndns.org;Initial Catalog=DISCOVERY_80;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "DISCO": "Data Source=172.25.30.244;Initial Catalog=DISCOVERY_80;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + "SAROM": "Data Source=37.159.179.14;Initial Catalog=AHR60_SAROM_TEST80;User Id=sa; Password=Poloinf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + /*"SAROM": "Data Source=10.0.0.10;Initial Catalog=AHR80_SAROM;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + + /*"SINER": "Data Source=10.0.0.10;Initial Catalog=AHR_SINERGO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"*/ + "SINER": "Data Source=ufficio.sinergogroup.it,31433;Initial Catalog=AHR_TECLI;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + /*"SIET2": "Data Source=194.50.74.66;Initial Catalog=R65_SIET;User Id=sa; Password=W1ld1x42;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "SIET2": "Data Source=172.25.30.29;Initial Catalog=R65_SIET;User Id=sa; Password=W1ld1x42;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + "PMS": "Data Source=10.0.0.10;Initial Catalog=PMS_DEMO;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + /*"VIRTUAL_TASK": "Data Source=MARCO_PC\\SQL_2022;Initial Catalog=VIRTUAL_TASK;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "VIRTUAL_TASK": "Data Source=172.25.30.1;Initial Catalog=VIRTUAL_TASK;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "LIFT_WEB": "Data Source=docker1.polo;Initial Catalog= AHRW42_LIFT;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + /*"SYSCOM": "Data Source=docker1.polo;Initial Catalog= AHRW_SYSCOM;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",*/ + "SYSCOM": "Data Source=dbsql01.poloinformatico.it;Initial Catalog= AHRW_SYSCOM;User Id=syscom; Password=4@QLHV?cpVYbr+GB;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + + "TEDESCO": "Data Source=172.25.30.38;Initial Catalog= AHR_80;User Id=sa; Password=ZS1c1l1@;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" + + //"MARAS": "Data Source=docker1.polo;Initial Catalog= AHRW_MARAS;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;Encrypt=False" + }, + "JWT": { + "ValidAudience": "http://localhost:4200", + "ValidIssuer": "http://localhost:61955", + "Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM" + } +} diff --git a/ApiPolo/loghi/disco_app2.jpg b/ApiPolo/loghi/disco_app2.jpg new file mode 100644 index 0000000..320584d Binary files /dev/null and b/ApiPolo/loghi/disco_app2.jpg differ diff --git a/ApiPolo/private_key.json b/ApiPolo/private_key.json new file mode 100644 index 0000000..81ef1c5 --- /dev/null +++ b/ApiPolo/private_key.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "testpolo-5e86a", + "private_key_id": "80c027bfe39f398545dd21f60b92dd257bc50bbf", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQCpmJDlg4ayXKDh\nb58MgM/IpYlY90ktO5Wg9HrUWoNQrAYKUVReVZxT1ZagvCNDZMRRPsVMYKc60ru/\nVjhjv3igraKO78TjSF9BiWl019KObmVZ1h5mPAsLC2+8hzWSWspRC/Gvnhc5d6/f\nzD1UbVi9gCYaSGoRZjwa79PFYvH0v+CIf3BBxmj7vxD+PEY4p7Eh4J/QOMNGbsJr\nMzODfOGly8Vl7FEHiMLnNZHdNyN5GLgjlCJmH5wKBiPp5H22D0l23GCdDsvlHM1d\n6oF/lLcQF9raXrN7rNRkGgz9KLLz0vMAg/OGi2CK1WRa4CkXElo0fZn74mLoeNu8\neqdQowx/AgMBAAECgf8OSl8P006GS0fVbgAde090mMdnt7e7823xazqlPGj40POx\nWJbDXCo9wZ0UN1h4MLxaHDkWEepOnODr9Vfvog4aV2KkX4/J4Cq47Uj1j4MufUN6\nvCJl6KlOsqgAzRq2g4I/my/CU2tYbE+usIcMurxRzcOxTrHqfEUmkjNqkxBijxMI\nxuybqv3z4/+G3nZIlh9hol1fdx0196QTFNQSGWZOr7EvIuFhxR3vPFvwY1jIvcHP\nmhJtmq/wcTgpTiDGJ5XZk840O7C7K2R3lUWbE3HJjZuLeaq6zOkXfC6sP9rIsC9c\n1o21misyvocSZoupXe8Q9Xf9t/nKCt7n4BmPRkkCgYEA3c1S+EzCp8ll40bBPWFW\n7Z5R3ejOzuluKLI/ztU2tx5uFOSsV6mv7mM6ATWK4CGGkOPmfOitn8AOz0PvuXf/\nzmmhfXwiIR50wbe43VYdFpAb7xMf674YC5ULZ55Jm3IIwsZwAr9EkGtbl1qUuPjp\nIhArtEZcvRqoKRbrWVaJ27MCgYEAw76h8NfydgRFauG++ynQLrQ36oIDigIucIli\nvm0DjR7tzSsgsRkYa4TiCleZnNkRqgUqzCCm3hqndixyLhwwg3l/ZpIOIeAN/wII\nqLO/7mn47gGZgzBn44TaOmI5d78pf04l43/rA6gjMzW0AS51OchZHI4AG4nI3aUu\nmjD+NgUCgYAaHEivKEImBGR1K+gltKbKFEAo8nYeD4bDTbCLRbhKOE/XL9BGBZjL\nZGz4pXfyyJ+RwPJqM+30h2R269V1rPW1M+Qp5IoUAgTWpS0jCTclZ9OSAltYoiks\ne+A603xwyyzS2Q9ok2Gb6rd+itBFMjAnrWWntDzImjG/nI4aF0DlVwKBgB5d2ZOa\nfLPQT9CX+t/OCczlCnOn/dKQKhItThNKqC1hafTVRvoScZZkhAiktGD/z9y3dn86\nZYi5S9dqZ8A9gU00MQ6BhA2/S4yPDTbWw+TBreuGdgFDJirGtnAuQsoP7ukf/4K+\nmn/zupo8L5OrWGZBbYmfgebDxlSURpmHFjjdAoGBAIunnz+KWA/0stDB4FLZt8QS\n7Z9/CytT0F1hVnVieKpWtbhvvoLs+svcvTCvqeQmEUxhiX5r8N4xTjd0MwcyKjRi\ny724SWzJmdplqj5YRHrLGbmAsgqZZg3tAGJROhxH/utxBgfDBkki0if+DKysQAC/\nYJzjNY7HdXC2It0gH5iZ\n-----END PRIVATE KEY-----\n", + "client_email": "firebase-adminsdk-ypxny@testpolo-5e86a.iam.gserviceaccount.com", + "client_id": "118193031755958431078", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-ypxny%40testpolo-5e86a.iam.gserviceaccount.com" +} \ No newline at end of file diff --git a/ApiPolo/wwwroot/VIRTU/AZI01/AZI01_LOGO.jpg b/ApiPolo/wwwroot/VIRTU/AZI01/AZI01_LOGO.jpg new file mode 100644 index 0000000..2d37c62 Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI01/AZI01_LOGO.jpg differ diff --git a/ApiPolo/wwwroot/VIRTU/AZI02/AZI02_LOGO.jpg b/ApiPolo/wwwroot/VIRTU/AZI02/AZI02_LOGO.jpg new file mode 100644 index 0000000..7c34a5a Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI02/AZI02_LOGO.jpg differ diff --git a/ApiPolo/wwwroot/VIRTU/AZI02/No_image.png b/ApiPolo/wwwroot/VIRTU/AZI02/No_image.png new file mode 100644 index 0000000..ba2d76f Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI02/No_image.png differ diff --git a/ApiPolo/wwwroot/VIRTU/AZI02/R.png b/ApiPolo/wwwroot/VIRTU/AZI02/R.png new file mode 100644 index 0000000..55fdf68 Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI02/R.png differ diff --git a/ApiPolo/wwwroot/VIRTU/AZI02/company2.png b/ApiPolo/wwwroot/VIRTU/AZI02/company2.png new file mode 100644 index 0000000..112aa0d Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI02/company2.png differ diff --git a/ApiPolo/wwwroot/VIRTU/AZI02/img2.png b/ApiPolo/wwwroot/VIRTU/AZI02/img2.png new file mode 100644 index 0000000..ba2d76f Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/AZI02/img2.png differ diff --git a/ApiPolo/wwwroot/VIRTU/CAV00001.jpg b/ApiPolo/wwwroot/VIRTU/CAV00001.jpg new file mode 100644 index 0000000..c6673bf Binary files /dev/null and b/ApiPolo/wwwroot/VIRTU/CAV00001.jpg differ diff --git a/ApiPolo/wwwroot/logo_disco.jpg b/ApiPolo/wwwroot/logo_disco.jpg new file mode 100644 index 0000000..320584d Binary files /dev/null and b/ApiPolo/wwwroot/logo_disco.jpg differ diff --git a/ApiPolo/wwwroot/logo_ferra.jpg b/ApiPolo/wwwroot/logo_ferra.jpg new file mode 100644 index 0000000..5413b6e Binary files /dev/null and b/ApiPolo/wwwroot/logo_ferra.jpg differ diff --git a/ApiPolo/wwwroot/logo_marro.jpg b/ApiPolo/wwwroot/logo_marro.jpg new file mode 100644 index 0000000..5a0747b Binary files /dev/null and b/ApiPolo/wwwroot/logo_marro.jpg differ diff --git a/Api_VT.sln b/Api_VT.sln new file mode 100644 index 0000000..f5c4e40 --- /dev/null +++ b/Api_VT.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api_VT", "ApiPolo\Api_VT.csproj", "{FCB070A4-CB11-48F7-8245-A609151A95F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FCB070A4-CB11-48F7-8245-A609151A95F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCB070A4-CB11-48F7-8245-A609151A95F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCB070A4-CB11-48F7-8245-A609151A95F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCB070A4-CB11-48F7-8245-A609151A95F7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F4BB9AEC-7FFE-4101-8B36-F1CD5AF0DCDB} + EndGlobalSection +EndGlobal