287 lines
13 KiB
C#
287 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using DataAccessLayer;
|
|
|
|
public static class CACHE
|
|
{
|
|
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
|
|
public const string SWVERSION = "2.0.0";
|
|
|
|
public static dIMAGES IMAGES = null;
|
|
private const Int32 PAGESIZEDEFAULT = 16;
|
|
private static Config _config = null;
|
|
public const string PASSKEY = "ACCENTURE";
|
|
public static List<DataTemplate> DirectTemplates=null;
|
|
public static List<DataTemplate> LetterTemplates = null;
|
|
#region variabili_statiche
|
|
|
|
public static string LANCIO = string.Empty;
|
|
public static string CNS { get; private set; }
|
|
public static string CNSFTP { get; private set; }
|
|
public static Int32 CommandTimeout { get; private set; }
|
|
public static string AMBIENTE { get; private set; }
|
|
public static string LICENZA_Dynamic_PDF { get; private set; }
|
|
public static Int32 volThreads { get; private set; }
|
|
public static string QueryContratti { get; set; }
|
|
public static Int32 circle_size { get; private set; }
|
|
public static Int32 resolution { get; private set; }
|
|
public static Int32 page_size { get; private set; }
|
|
private static bool _usepagesize = true;
|
|
public static bool UsePageSize => _usepagesize;
|
|
public static bool Periodico { get; private set; }
|
|
public static bool INVIO_HOST { get; private set; }
|
|
public static Int32 SavePDFtoDISK { get; private set; }
|
|
public static string SavePDFtoDISK_Folder { get; private set; }
|
|
public static string Flag_stampa { get; private set; }
|
|
public static string pathGraf { get; private set; }
|
|
public static string pathGrafTemp { get; private set; }
|
|
public static double S181_COEF_PERC_00_05 { get; private set; }
|
|
public static double S181_COEF_PERC_05_10 { get; private set; }
|
|
public static double S181_COEF_PERC_15_20 { get; private set; }
|
|
public static double S181_COEF_PERC_20_25 { get; private set; }
|
|
public static double S181_COEF_PERC_25_30 { get; private set; }
|
|
public static double S181_COEF_PERC_30_35 { get; private set; }
|
|
public static double S181_COEF_PERC_40_45 { get; private set; }
|
|
public static double S181_COEF_PERC_50_55 { get; private set; }
|
|
public static double S181_COEF_PERC_60_65 { get; private set; }
|
|
public static double S181_COEF_PERC_65_70 { get; private set; }
|
|
public static double S181_COEF_PERC_70_75 { get; private set; }
|
|
public static double S181_COEF_PERC_75_80 { get; private set; }
|
|
public static double S181_COEF_PERC_80_85 { get; private set; }
|
|
public static double S181_COEF_PERC_85_90 { get; private set; }
|
|
public static double S181_COEF_PERC_90_95 { get; private set; }
|
|
public static double S181_COEF_PERC_95_00 { get; private set; }
|
|
public static string CultureToUse { get; private set; }
|
|
public static string QueryInserimento { get; private set; }
|
|
public static string QueryInserimentoTest { get; private set; }
|
|
public static string QueryLettereRecupero { get; private set; }
|
|
public static string QueryInserimentoPDF_FTP { get; private set; }
|
|
public static string GetIdReport { get; private set; }
|
|
public static bool scriviErroreNelDB { get; private set; }
|
|
public static bool SetData { get; private set; }
|
|
public static string Bug { get; private set; }
|
|
public static string FTPServerHost { get; private set; }
|
|
public static string FTPUserHost { get; private set; }
|
|
public static string FTPPasswordHost { get; private set; }
|
|
public static bool OnlyError { get; private set; }
|
|
public static string DataFineTrimestreCorrente { get; private set; }
|
|
public static string DataFineTrimestreCorrente_LetteraAccompagnamento { get; private set; }
|
|
public static int S132AndS128ShowNotesAndAsterisk { get; private set; }
|
|
public static string DataLotto { get; private set; }
|
|
public static string SP_SimpleTextGeneratorProvider { get; private set; }
|
|
public static string SP_SimpleTextGeneratorProvider_GetTemplateTexts { get; private set; }
|
|
public static string getLogsProcedure { get; private set; }
|
|
public static string statisticsPrepare { get; private set; }
|
|
public static bool includecommercialletter { get; private set; }
|
|
public static string Author { get; private set; }
|
|
|
|
#endregion
|
|
public static Config config
|
|
{
|
|
get { return _config; }
|
|
set
|
|
{
|
|
_config = value;
|
|
try
|
|
{
|
|
ValorizzaVariabiliStatiche();
|
|
}
|
|
catch (Exception ex) { }
|
|
|
|
IMAGES = new dIMAGES();//metto in cache tutte le immagini
|
|
}
|
|
}
|
|
public static void GetTemplates()
|
|
{
|
|
//[dbo].[GetPDFTemplateConfiguration_Rosaspina]
|
|
string basesql = @"select distinct t.rete,t.contracttype, reporttypefontcolor_r, reporttypefontcolor_g, reporttypefontcolor_b,
|
|
chapterbackground_r, chapterbackground_g, chapterbackground_b, chapterfontcolor_r, chapterfontcolor_g, chapterfontcolor_b,
|
|
tableheaderfontcolor_r, tableheaderfontcolor_g, tableheaderfontcolor_b,templatereportpath, templatecopertinapath, templateglossariopath, templatewelcomeletterpath
|
|
from dbo.reporttemplate t inner join dbo.pdftemplateconfiguration_rosaspina c on c.pdfconfigurationid = t.pdfconfigurationid";
|
|
|
|
string DirectSql = string.Format(basesql+" where t.istrimestrale={0} order by t.rete,t.contracttype", (CACHE.Periodico ? 1 : 0));
|
|
string LetterSql = basesql + " where t.istrimestrale=0 order by t.rete,t.contracttype";
|
|
|
|
using (SQLServer db = new SQLServer())
|
|
{
|
|
var dt = db.executeQuery(DirectSql);
|
|
DirectTemplates = dt.ConvertToList<DataTemplate>();
|
|
if (CACHE.Periodico)
|
|
{ // periodico false x le lettere
|
|
dt = db.executeQuery(LetterSql);
|
|
LetterTemplates = dt.ConvertToList<DataTemplate>();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public static void GetDtColors()
|
|
{
|
|
using (SQLServer db = new SQLServer())
|
|
{
|
|
DtColors = db.GetDataTableFromProcedure("sp_getColors");
|
|
}
|
|
}
|
|
|
|
public static void SetLancio(Assembly caller)
|
|
{
|
|
using (SQLServer db = new SQLServer())
|
|
{
|
|
CACHE.LANCIO = db.executeScalarStr("dbo.GetLancio",
|
|
new List<SqlParameter>
|
|
{
|
|
new SqlParameter
|
|
{
|
|
ParameterName="Tipo",
|
|
Value=GetTipoLancio()
|
|
},
|
|
new SqlParameter
|
|
{
|
|
ParameterName="Client",
|
|
Value=GetClient(caller)
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
private static string GetTipoLancio()
|
|
{
|
|
if (Periodico)
|
|
return "Monitoraggio";
|
|
else
|
|
return "Diagnosi";
|
|
}
|
|
|
|
private static string GetClient(Assembly Caller)
|
|
{
|
|
return System.IO.Path.GetFileName(Caller.Location);
|
|
}
|
|
|
|
public static void AddHeader(Assembly a)
|
|
{
|
|
logger.Info(Environment.NewLine +
|
|
"============================================================" +
|
|
Environment.NewLine +
|
|
a.GetName().Name + " - Version: " +
|
|
CACHE.SWVERSION +
|
|
Environment.NewLine +
|
|
"============================================================" +
|
|
Environment.NewLine);
|
|
}
|
|
|
|
public static void Start(Assembly a)
|
|
{
|
|
CACHE.config = new Config();
|
|
CACHE.AddHeader(a);
|
|
SQLServer.ConnectionString = CACHE.CNS;
|
|
SQLServer.ConnectionStringS = CACHE.CNSFTP;
|
|
SQLServer.SqlCommandTimeout = CACHE.CommandTimeout;
|
|
CACHE.SetLancio(a);
|
|
if (CACHE.LANCIO != "")
|
|
{
|
|
NLog.GlobalDiagnosticsContext.Set("uid", CACHE.LANCIO);
|
|
}
|
|
CACHE.GetTemplates();
|
|
CACHE.GetDtColors();
|
|
}
|
|
|
|
public static void Track(int page, List<MinimalTrack> data)
|
|
{
|
|
string filename= System.IO.Path.Combine(Environment.CurrentDirectory + "\\logs", DateTime.Now.ToString("yyyy-MM-dd") + "-" + CACHE.LANCIO + "-" + page.ToString() + ".csv");
|
|
List<string> minimal = new List<string>();
|
|
minimal.Add("codicefiscale;rete;tipocontratto;SeiDa;");
|
|
foreach(var x in data)
|
|
minimal.Add(x.codicefiscale + ";" + x.rete + ";" + x.tipocontratto + ";" + x.SeiDa);
|
|
System.IO.File.WriteAllLines(filename, minimal.ToArray());
|
|
}
|
|
|
|
public static DataTable DtColors { get; set; }
|
|
|
|
private static void ValorizzaVariabiliStatiche()
|
|
{
|
|
CNS = "CNS".read();
|
|
CNSFTP = "CNSFTP".read();
|
|
CommandTimeout = "sqlcommandtimeout".read().ToInt32(200);
|
|
AMBIENTE = "ambiente".read();
|
|
LICENZA_Dynamic_PDF = "licenza".read();
|
|
volThreads = "volthreads".read().ToInt32(16);
|
|
page_size = "page_size".read().ToInt32();
|
|
if (page_size <= 0 || page_size > volThreads) page_size = PAGESIZEDEFAULT;
|
|
QueryContratti = "querycontratti".read();
|
|
circle_size = "circle_size".read().ToInt32(130);
|
|
resolution = "resolution".read().ToInt32(144);
|
|
Periodico = "periodico".read().ToInt32(0) == 1;
|
|
INVIO_HOST = "invio_host".read().ToBool();
|
|
SavePDFtoDISK = "savepdftodisk".read().ToInt32(1);
|
|
SavePDFtoDISK_Folder = "savepdftodisk_folder".read();
|
|
Flag_stampa = "flag_stampa".read();
|
|
pathGraf = "pathGraf".read();
|
|
pathGrafTemp = "pathGrafTemp".read();
|
|
S181_COEF_PERC_00_05 = "S181_COEF_PERC_00_05".read().ToInt32(5);
|
|
S181_COEF_PERC_05_10 = "S181_COEF_PERC_15_20".read().ToInt32(15);
|
|
S181_COEF_PERC_15_20 = "S181_COEF_PERC_20_25".read().ToInt32(20);
|
|
S181_COEF_PERC_20_25 = "S181_COEF_PERC_25_30".read().ToInt32(25);
|
|
S181_COEF_PERC_25_30 = "S181_COEF_PERC_30_35".read().ToInt32(30);
|
|
S181_COEF_PERC_30_35 = "S181_COEF_PERC_40_45".read().ToInt32(35);
|
|
S181_COEF_PERC_40_45 = "S181_COEF_PERC_50_55".read().ToInt32(45);
|
|
S181_COEF_PERC_50_55 = "S181_COEF_PERC_60_65".read().ToInt32(55);
|
|
S181_COEF_PERC_60_65 = "S181_COEF_PERC_65_70".read().ToInt32(65);
|
|
S181_COEF_PERC_65_70 = "S181_COEF_PERC_70_75".read().ToInt32(70);
|
|
S181_COEF_PERC_70_75 = "S181_COEF_PERC_75_80".read().ToInt32(75);
|
|
S181_COEF_PERC_75_80 = "S181_COEF_PERC_80_85".read().ToInt32(80);
|
|
S181_COEF_PERC_80_85 = "S181_COEF_PERC_85_90".read().ToInt32(85);
|
|
S181_COEF_PERC_85_90 = "S181_COEF_PERC_90_95".read().ToInt32(90);
|
|
S181_COEF_PERC_90_95 = "S181_COEF_PERC_95_00".read().ToInt32(95);
|
|
S181_COEF_PERC_95_00 = "S181_COEF_PERC_95_00".read().ToInt32(100);
|
|
CultureToUse = "CultureToUse".read("it-IT");
|
|
QueryInserimento = "QueryInserimento".read();
|
|
QueryInserimentoTest = "QueryInserimentoTest".read();
|
|
QueryInserimentoPDF_FTP = "QueryInserimentoPDF_FTP".read();
|
|
QueryLettereRecupero = "QueryLettereRecupero".read();
|
|
GetIdReport = "GetIdReport".read();
|
|
scriviErroreNelDB = "scriviErroreNelDB".read().ToInt32(1) == 1;
|
|
SetData = "SetData".read().ToInt32(1) == 1;
|
|
Bug = "Bug".read();
|
|
FTPServerHost = "FTPServerHost".read();
|
|
FTPUserHost = "FTPUserHost".read();
|
|
FTPPasswordHost = "FTPPasswordHost".read();
|
|
OnlyError = "OnlyError".read().ToBool();
|
|
DataFineTrimestreCorrente = "DataFineTrimestreCorrente".read();
|
|
DataFineTrimestreCorrente_LetteraAccompagnamento = "DataFineTrimestreCorrente_LetteraAccompagnamento".read();
|
|
S132AndS128ShowNotesAndAsterisk = "S132AndS128ShowNotesAndAsterisk".read().ToInt32();
|
|
DataLotto = "DataLotto".read();
|
|
SP_SimpleTextGeneratorProvider = "SP_SimpleTextGeneratorProvider".read();
|
|
SP_SimpleTextGeneratorProvider_GetTemplateTexts = "SP_SimpleTextGeneratorProvider_GetTemplateTexts".read();
|
|
getLogsProcedure = "getLogsProcedure".read();
|
|
statisticsPrepare = "statisticsPrepare".read();
|
|
includecommercialletter = "IncludeCommercialLetter".read().ToInt32() == 1;
|
|
Author = "Author".read("FIDEURAM INTESA SANPAOLO");
|
|
}
|
|
|
|
public static string read(this string key, string defaultvalue = "")
|
|
{
|
|
string ret = defaultvalue;
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
var oggetto = _config.KeyValues.FirstOrDefault(x => x.key == key);
|
|
if (oggetto != null)
|
|
ret = oggetto.value;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
|