예제 #1
0
        private void GenerateOutput(m.KIIDData data)
        {
            //Nome file--> nome fondo desunto dal template
            string outputFileName = CreaNomeFile(data);

            Log.Info("Inizio generazione documento " + (CurrentNumeroDocumenti + 1) + " di " + TotNumeroDocumenti + " " + outputFileName);
            using (KIIDWordHelper wordHelper = new KIIDWordHelper(template, outputFileName))
            {
                wordHelper.ReplaceText("@CLASSE@", data.Classe);
                wordHelper.ReplaceText("@ISIN@", data.Isin);
                wordHelper.ReplaceText("@TESTO1@", data.Testo1, "FORMATTED");
                wordHelper.ReplaceText("@CLASSEDIRISCHIO@", data.ClasseDiRischio);
                wordHelper.ReplaceText("@SPESEDISOTTOSCRIZIONE@", string.Format("{0}%", data.SpeseSottoscrizione));
                wordHelper.ReplaceText("@SPESEDIRIMBORSO@", string.Format("{0}%", data.SpeseDiRimborso));
                wordHelper.ReplaceText("@SPESEDICONVERSIONE@", string.Format("{0}%", data.SpeseDiConversione));
                wordHelper.ReplaceText("@SPESECORRENTI@", string.Format("{0}%", data.SpeseCorrenti));
                wordHelper.ReplaceText("@COMMISSIONIRENDIMENTO@", data.CommissioniRendimento);
                wordHelper.ReplaceText("@DATAGENERAZIONE@", data.DataGenerazione);
                //wordHelper.ReplaceText("@INFORMAZIONIPRATICHE", data.InformazioniPratiche);
                wordHelper.InsertProfiloRischio(data.ClasseDiRischio);
                wordHelper.EditPerformanceChart(data.Performances);
                wordHelper.ReplaceText("@TESTO2@", data.Testo2);
                wordHelper.ReplaceText("@TESTO3@", data.Testo3);
            }
            using (WordHelper wordHelper = new WordHelper(outputFileName))
            {
                wordHelper.SaveAsPDF();
            }
            Log.Info("Generazione documento " + (CurrentNumeroDocumenti + 1) + " di " + TotNumeroDocumenti + " " + outputFileName + " terminata");

            CurrentNumeroDocumenti++;
            progress = (double)CurrentNumeroDocumenti / TotNumeroDocumenti;
            NotifyPropertyChanged("progress");
        }
예제 #2
0
        private string CreaNomeFile(m.KIIDData data)
        {
            string templateName = template.Split('\\').LastOrDefault().Split('.').ElementAt(0);

            templateName = templateName.Split('_').FirstOrDefault();
            StringBuilder sb = new StringBuilder();

            sb.Append(outputfolder);
            sb.Append("\\KIID_");
            sb.Append(templateName);
            sb.Append("_");
            sb.Append(data.Classe);
            sb.Append("_");
            sb.Append(data.Isin);
            sb.Append("_");
            sb.Append(language.Split('-')[0]);
            sb.Append("_");
            sb.Append(country);
            sb.Append("_");
            sb.Append(datagenerazione.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture));
            sb.Append(".docx");
            return(sb.ToString());
        }
예제 #3
0
        private List <m.KIIDData> ReadFundsData()
        {
            Log.Info("Inizio generazione documenti ");
            const string      mainSheetname        = "DATI KIID";
            const string      performanceSheetname = "PERFORMANCE";
            const int         MAX_EMPTY_ROWS       = 3;
            List <m.KIIDData> result = new List <m.KIIDData>();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en");
            Log.Info("Inizio lettura dati input");
            using (ExcelHelper excelHelper = new ExcelHelper(datafile))
            {
                //Performance
                Log.Info("Inizio lettura dati input - Performance");

                int row = 2;
                Dictionary <string, SortedDictionary <string, string> > isinPerformanceAnnoMap = new Dictionary <string, SortedDictionary <string, string> >();
                string isin      = excelHelper.GetValue(performanceSheetname, "B", row.ToString());
                int    emptyRows = 0;

                while (emptyRows <= MAX_EMPTY_ROWS)
                {
                    string anno = "0", dato = "0";
                    if (string.IsNullOrEmpty(isin))
                    {
                        emptyRows++;
                    }
                    else
                    {
                        emptyRows = 0;
                        anno      = excelHelper.GetValue(performanceSheetname, "C", row.ToString());
                        dato      = excelHelper.GetValue(performanceSheetname, "D", row.ToString());
                        if (string.IsNullOrEmpty(dato))
                        {
                            dato = "0";
                        }
                        else
                        {
                            dato = (Convert.ToDouble(dato) / 100).ToString();
                        }
                        SortedDictionary <string, string> isinPerformanceAnno;
                        if (!isinPerformanceAnnoMap.TryGetValue(isin, out isinPerformanceAnno))
                        {
                            isinPerformanceAnno = new SortedDictionary <string, string>();
                        }
                        isinPerformanceAnno[anno]    = dato;
                        isinPerformanceAnnoMap[isin] = isinPerformanceAnno;
                    }
                    row++;
                    isin = excelHelper.GetValue(performanceSheetname, "B", row.ToString());
                }
                Log.Info("Termine lettura dati input - Performance");
                Log.Info("Inizio lettura dati input - Dati fondi");

                string suffix = "";
                if (!language.Equals("it-IT"))
                {
                    suffix += " - " + language.Split('-')[0].ToUpper();
                }
                Log.Info("Dati fondi: suffisso " + suffix);
                Dictionary <string, string> fieldPosition = new Dictionary <String, string>();
                //Header row
                string classeCol                = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "CLASSE", 1));
                string isinCol                  = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "ISIN", 1));
                string classeDiRischioCol       = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "CLASSE DI RISCHIO", 1));
                string testo1Col                = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "TESTO1" + suffix, 1));
                string testo2Col                = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "TESTO2" + suffix, 1));
                string testo3Col                = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "TESTO3" + suffix, 1));
                string spesesottoscrizioneCol   = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "SPESE SOTTOSCRIZIONE", 1));
                string speserimborsoCol         = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "SPESE DI RIMBORSO", 1));
                string spesecorrentiCol         = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "SPESE CORRENTI", 1));
                string spesediconversioneCol    = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "SPESE DI CONVERSIONE", 1));
                string commissioniRendimentoCol = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "COMMISSIONI LEGATE AL RENDIMENTO" + suffix, 1));
                //string informazionipraticheCol = excelHelper.GetCellColumn(excelHelper.GetCellByContent(mainSheetname, "INFORMAZIONI PRATICHE" + suffix, 1));
                string datagenerazioneStr = datagenerazione.ToString("dd MMMM yyyy", cultureInfo);
                Log.Debug("testo1Col  " + testo1Col);
                Log.Debug("testo2Col  " + testo2Col);
                Log.Debug("testo3Col  " + testo3Col);
                Log.Debug("commissioniRendimentoCol  " + commissioniRendimentoCol);
                //Log.Debug("informazionipraticheCol  " + informazionipraticheCol);
                //Dati Fondo
                row = 3;
                string classe = excelHelper.GetValue(mainSheetname, classeCol, row.ToString());
                while (!string.IsNullOrEmpty(classe))
                {
                    string currentIsin = excelHelper.GetValue(mainSheetname, isinCol, row.ToString());
                    SortedDictionary <string, string> performances = new SortedDictionary <string, string>();
                    isinPerformanceAnnoMap.TryGetValue(currentIsin, out performances);

                    m.KIIDData item = new m.KIIDData(
                        classe,
                        currentIsin,
                        excelHelper.GetValue(mainSheetname, classeDiRischioCol, row.ToString()),
                        excelHelper.GetValue(mainSheetname, testo1Col, row.ToString()),
                        excelHelper.GetValue(mainSheetname, testo2Col, row.ToString()),
                        excelHelper.GetValue(mainSheetname, testo3Col, row.ToString()),
                        (Convert.ToDouble(excelHelper.GetValue(mainSheetname, spesesottoscrizioneCol, row.ToString())) * 100).ToString(),
                        (Convert.ToDouble(excelHelper.GetValue(mainSheetname, speserimborsoCol, row.ToString())) * 100).ToString(),
                        (Convert.ToDouble(excelHelper.GetValue(mainSheetname, spesecorrentiCol, row.ToString())) * 100).ToString(),
                        (Convert.ToDouble(excelHelper.GetValue(mainSheetname, spesediconversioneCol, row.ToString())) * 100).ToString(),
                        excelHelper.GetValue(mainSheetname, commissioniRendimentoCol, row.ToString()),
                        "",//excelHelper.GetValue(mainSheetname, informazionipraticheCol, row.ToString()),
                        datagenerazioneStr,
                        performances
                        );
                    result.Add(item);
                    row++;
                    classe = excelHelper.GetValue(mainSheetname, classeCol, row.ToString());
                }
                Log.Info("Termine lettura dati input - Dati fondi");
            }
            TotNumeroDocumenti = result.Count();
            return(result);
        }