using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections; using PDFGenerator.BusinessLayer.DataSection; using PDFGenerator.BusinessLayer; using System.Collections.Generic; namespace PDFGenerator.BusinessLayer.DataSection { class DSS184TabellaCoerenzaESG : IDataSection { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); public DSS184TabellaCoerenzaESG() { } #region IDataSection Members public DataSectionResult getDataSection(List tabelleSessione, string querySql, DataThread dataThread) { DataTable dESG = new DataTable(); try { FormatNum num = new FormatNum(); DataSectionResult dsr = new DataSectionResult(); DataSetS184 ds184 = new DataSetS184(); // Verifico se vi sono dati per la sezione di ESG if (dataThread.Periodico) dESG = SectionManager.GetDataSection(tabelleSessione, "[C6MArtPeriodico].[PL_S181PreferenzeESG]", dataThread); else dESG = SectionManager.GetDataSection(tabelleSessione, "[C6MArt].[PL_S181PreferenzeESG]", dataThread); if(dESG== null || dESG.Rows.Count == 0) { dsr.Esito = 0; return dsr; } else if (dESG.Rows[0]["Preferenza_esg_cliente"].ToString() == "0") { dsr.Esito = 0; return dsr; } else { DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread); DataRow drESG; if (dt!=null && dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { drESG = ds184.TabellaCoerenzaESG.NewRow(); drESG["pesoSostESG"] = r["pesoSostESG"] == DBNull.Value ? "-" : $"{r["pesoSostESG"]}%"; drESG["percESG"] = r["percESG"] == DBNull.Value ? "-" : $"{r["percESG"]}"; drESG["Coerenza"] = r["Coerenza"] == DBNull.Value ? "-" : (r["Coerenza"].ToString().Equals("s", StringComparison.OrdinalIgnoreCase) ? "COERENTE" : (r["Coerenza"].ToString().Equals("z", StringComparison.OrdinalIgnoreCase) ? "n.a." : "NON COERENTE")); ds184.TabellaCoerenzaESG.Rows.Add(drESG); } } } dsr.DatiSezione = ds184; int esito = 0; esito = ds184.TabellaCoerenzaESG.Rows.Count; dsr.Esito = esito; return dsr; } catch (Exception ex) { logger.Error(ex); return null;// throw ex; } } #endregion } }