using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Text; using System.Linq; using System.IO; using System.Reflection; using System.Text.RegularExpressions; namespace A69WD { public class cTools { /* * * Versione 1.0 del 2021/11 * */ #region Utility sui File: /// /// Scrive il testo in un file con append=false e Encoding UTF8 /// /// Nome completo del file da creare/sovrascrivere /// StringBuilder con il testo da riportare nel file public static void WriteTextFile(string FullFileName, StringBuilder Text) { WriteTextFile(FullFileName, Text, Encoding.UTF8); } /// /// Scrive il testo in un file con append=false e Encoding UTF8 /// /// Nome completo del file da creare/sovrascrivere /// StringBuilder con il testo da riportare nel file /// Codifica usata nel testo public static void WriteTextFile(string FullFileName, StringBuilder Text, Encoding code) { System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, code); sw.Write(Text.ToString()); sw.Flush(); sw.Close(); } public static void SaveToFile(string txtHTML, string filePath, string fileName) { System.IO.StreamWriter tsw = new System.IO.StreamWriter(System.IO.Path.Combine(filePath, fileName), false, Encoding.UTF8); tsw.Write(txtHTML); } /// /// Metodo che legge un testo da file (UTF8) /// /// Path del file da leggere /// Testo del file public static string ReadTextFile(string sPath) { //string str = ""; //try { // if (File.Exists(sPath)) { // StreamReader reader = File.OpenText(sPath); // str = reader.ReadToEnd(); // reader.Close(); // reader.Dispose(); // } //} catch (Exception exception) { // str = "ERRORE: " + exception.Message; //} //return str; string str = ""; if (File.Exists(sPath)) { StreamReader reader = File.OpenText(sPath); str = reader.ReadToEnd(); reader.Close(); reader.Dispose(); } return str; } /// /// Metodo che legge un testo da file /// /// Path del file da leggere /// Codifica usata nel testo /// Testo del file public static string ReadTextFile(string FilePath, Encoding encoding) { System.IO.StreamReader sr = null; //StringBuilder sb = null; string txt = ""; try { //Pass the file path and file name to the StreamReader constructor sr = new System.IO.StreamReader(FilePath, encoding); ////Read the first line of text //sb = new StringBuilder(); //string line = sr.ReadLine(); ////Continue to read until you reach end of file //while (line != null) { // sb.AppendLine(line); // //Read the next line // line = sr.ReadLine(); //} txt = sr.ReadToEnd(); } catch (Exception e) { throw new Exception("Errore nell'esecuzione di WebTools.Library.Tools.ReadTextFile(string FilePath, Encoding encoding):\n" + e.Message); //sb = new StringBuilder(); } finally { //close the file if (sr != null) { sr.Close(); sr.Dispose(); sr = null; } } //return sb.ToString(); return txt; } /// /// Salva la stringa passata come file con path indicato. /// /// Path del file da creare o sovrascrivere /// Testo da scrivere nel file /// Formato di codifica da adottare nel salvataggio. UTF8 per ottenere un corretto testo con editpad. /// True se tutto ok, False altrimenti public static bool SaveStringToFile(string fileName, string testo, System.Text.Encoding encoding) { try { // Salva la stringa passata come file di testo. StreamWriter sw = new StreamWriter(fileName, false, encoding); sw.Write(testo); // Libero risorse: sw.Flush(); sw.Close(); return true; } catch { return false; } } /// /// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato /// /// directory da analizzare /// Filtro da usare /// Array dei path completi, dei file trovati public static string[] ElencoFile(string path) { return ElencoFile(path, "*.*", SearchOption.TopDirectoryOnly); } /// /// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato /// /// directory da analizzare /// Filtro da usare /// Array dei path completi, dei file trovati public static string[] ElencoFile(string path, string filtro) { return ElencoFile(path, filtro, SearchOption.TopDirectoryOnly); } /// /// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato /// /// directory da analizzare /// Filtro da usare /// /// Array dei path completi, dei file trovati public static string[] ElencoFile(string path, string filtro, SearchOption option) { return Directory.GetFiles(path, filtro, option); } /// /// Metodo che esegue una copia di backup del file indicato /// /// Path completo del file da backuppare /// True se tutto ok, False altrimenti. public static bool BackupFile(string FilePath) { try { string LinkDBPathBK = Path.GetFileNameWithoutExtension(FilePath) + "_BK_" + DateTime.Now.ToString("yyyy-MM-dd"); LinkDBPathBK = FilePath.Replace(Path.GetFileNameWithoutExtension(FilePath), LinkDBPathBK); if (!File.Exists(LinkDBPathBK)) File.Move(FilePath, LinkDBPathBK); return true; } catch { return false; } } /// /// Muove i file indicati, nella directory di destinazione indicata /// /// Array con l'elenco dei file da spostare /// Path della directory in cui spostare i file /// True se tutto OK, False altrimenti. public static bool MoveFiles(string[] Files, string PathDestination) { // Sposta tutti i file indicati nella directory indicata: try { foreach (string file in Files) { string dst = Path.Combine(PathDestination, Path.GetFileName(file)); if (System.IO.File.Exists(dst)) System.IO.File.Delete(dst); File.Move(file, dst); } return true; } catch { return false; } } /// /// Legge il file e ne ritorna l'array di byte che lo compone /// /// Nome completo del file da leggere /// Array con i byte letti dal file public static byte[] ReadFully(string filename) { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] result = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); return result; } #endregion #region Assembly Attribute Accessors #region Assembly Property: Title, Version, Description, Product, Copyright, Company public static string AssemblyTitle { get { object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyTitleAttribute), false); if (attributes.Length > 0) { System.Reflection.AssemblyTitleAttribute titleAttribute = (System.Reflection.AssemblyTitleAttribute)attributes[0]; if (titleAttribute.Title != "") { return titleAttribute.Title; } } return System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); } } public static string AssemblyVersion { get { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); } } public static string AssemblyDescription { get { object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyDescriptionAttribute), false); if (attributes.Length == 0) { return ""; } return ((System.Reflection.AssemblyDescriptionAttribute)attributes[0]).Description; } } public static string AssemblyProduct { get { object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyProductAttribute), false); if (attributes.Length == 0) { return ""; } return ((System.Reflection.AssemblyProductAttribute)attributes[0]).Product; } } public static string AssemblyCopyright { get { object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyCopyrightAttribute), false); if (attributes.Length == 0) { return ""; } return ((System.Reflection.AssemblyCopyrightAttribute)attributes[0]).Copyright; } } public static string AssemblyCompany { get { object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyCompanyAttribute), false); if (attributes.Length == 0) { return ""; } return ((System.Reflection.AssemblyCompanyAttribute)attributes[0]).Company; } } #endregion /// /// Carica l'assemby da un array di byte /// /// Array di byte che definiscono l'assembly /// Assembly decodificato dal'array di byte public static Assembly LoadAssemblyFromBinaries(byte[] binaries) { Assembly asm = null; try { asm = Assembly.Load(binaries); } catch { } return asm; } /// /// Carica l'assembly dal file indicato /// /// Nome completo del file assembly da leggere /// Assembly decodificato dal file public static Assembly LoadAssemblyFromFile(string filename) { byte[] binaries = ReadFully(filename); return LoadAssemblyFromBinaries(binaries); } #endregion #region Shell DOS: /// /// Esegue un comando dos dalla shell /// /// Comando da eseguire in shell public static void ExecDosCmd(string cmd) { string argu = string.Format("/C \"{0}\"", cmd); System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); info.FileName = "cmd.exe"; info.Arguments = argu; info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; System.Diagnostics.Process.Start(info); } /// /// Esegue un comando dos dalla shell e cattura il risultato /// /// Comando da eseguire /// Argomenti da passare /// Testo ritornato dal comando. public static string ExecDosCmd(string cmd, string args) { System.Diagnostics.ProcessStartInfo ProcInfo = new System.Diagnostics.ProcessStartInfo(cmd, args); ProcInfo.RedirectStandardOutput = true; ProcInfo.UseShellExecute = false; System.Diagnostics.Process p = System.Diagnostics.Process.Start(ProcInfo); System.IO.TextReader tr = p.StandardOutput; string result = tr.ReadToEnd(); tr.Close(); return result; } /// /// Apre il file indicato in notepad e lo visualizza. /// /// File da aprire /// True se tutto ok, false altrimenti public static bool ShowOnNotepad(string file) { try { System.Diagnostics.Process proc = new System.Diagnostics.Process(); // proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // proc.StartInfo.Verb = "print"; //proc.StartInfo.FileName = @"C:\Program Files\Notepad++\notepad++.exe"; proc.StartInfo.FileName = Cfg.Settings.TextEditor; proc.StartInfo.Arguments = String.Format(@" {0}", file); Logger.Log(proc.StartInfo.FileName + proc.StartInfo.Arguments); proc.Start(); return true; } catch (Exception ex) { Logger.Log(new object[] { "Error Code: EG0284", ex }); return false; } } #endregion /// /// Metodo che analizza il file indicato ed inserisce nella lista tutti i link trovati. /// /// Path del file da analizzare /// Lista di tutti i link trovati /// True se tutto Ok, False altrimenti public static bool EstraiLink(string FileSrcPath, List links) { try { Regex regex = new Regex("(?<=href=\")\\S+?(?=\")"); string input = ReadTextFile(FileSrcPath); Match matchObj = regex.Match(input); while (matchObj.Success) { links.Add(matchObj.Value); if (matchObj.Groups.Count > 1) { for (int i = 1; i < matchObj.Groups.Count; i++) { Group group = matchObj.Groups[i]; if (group.Success) { links.Add(group.Value); } } } matchObj = matchObj.NextMatch(); } return true; } catch { return false; } } /// /// Metodo che analizza il file indicato e restituisce l'insieme di tutti i link trovati ordinato e privo di doppioni /// /// Path del file da analizzare /// Insieme con i vari link trovati public static List GetOrderLink(string FileSrcPath) { List links = new List(); try { // Estraggo tutti i link: if (!EstraiLink(FileSrcPath, links)) return new List(); // Verifico di aver trovato dei link: if (links.Count == 0) return links; // Ordino i link estratti: links.Sort(); // Elimino i duplicati: string[] tmp = links.ToArray(); links.Clear(); string oldLink = tmp[0]; links.Add(oldLink); for (int i = 1; i < tmp.Length; i++) { if (tmp[i] != oldLink) { oldLink = tmp[1]; links.Add(oldLink); } } return links; } catch (Exception ex) { Logger.Log(ex); return links; } } /// /// Metodo che legge il DB dei link dal file di testo in cui è stato salvato. /// /// Elenco ordinato di tutti i link del DB public static List ReadLinkDB(string PathLinkBD) { StreamReader reader = null; try { List buffer = new List(); string row; reader = new StreamReader(PathLinkBD); do { row = reader.ReadLine().Trim(); if (row.StartsWith("http://")) { buffer.Add(row); } } while (!reader.EndOfStream); reader.Close(); reader = null; // Ordino buffer.Sort(); return buffer; } catch { if (reader != null) { reader.Close(); reader = null; } return new List(); } } /// /// Esegue una formattazione del testo ricavato da un file html per scremarlo delle parti html /// /// Testo da formattare /// Abilitare l'eliminazione di tutti i generici tag /// Testo formattato public static string FormattaTesto(string txt, bool eliminaTagHtml = true) { try { // Analisi dei tag prima di levarli: string testo = Regex.Replace(txt, @"

", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"<<", "«", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @">>", "»", RegexOptions.IgnoreCase); // Se richiesto, elimino i tag html: if (eliminaTagHtml) { // Preparo la Regex: string htmlPattern = @"\<[^\>]*\>"; Regex re = new Regex(htmlPattern, RegexOptions.IgnoreCase); // Applico l'espressione regolare per togliere tutti i tag: testo = re.Replace(testo, ""); } // Special Entities dal sito https://www.htmlhelp.com/reference/html40/entities/special.html // More can be added, see http://hotwired.lycos.com/webmonkey/reference/special_characters/ // Correggo risultato togliendo doppie linee e caratteri html: testo = Regex.Replace(testo, @" ", " ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"•", " * ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"…", "…", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"™", "(tm)", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"©", "(c)", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"®", "(r)", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"⁄", "/", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"à", "à", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"è", "è", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ì", "ì", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ò", "ò", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ù", "ù", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"'", "'", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"Č", "Č", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"č", "č", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"Ě", "Ě", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ě", "ě", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"…", "…", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"
", " ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"", " ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase); // Correggo accenti per formati sbagliati: while (testo.Contains("à")) { testo = testo.Replace("à", "à"); } while (testo.Contains("è")) { testo = testo.Replace("è", "è"); } while (testo.Contains("é")) { testo = testo.Replace("é", "é"); } while (testo.Contains("ì")) { testo = testo.Replace("ì", "ì"); } while (testo.Contains("ò")) { testo = testo.Replace("ò", "ò"); } while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); } while (testo.Contains("’")) { testo = testo.Replace("’", "'"); } // Correggo scritto: testo = testo.Replace("\r", "\n"); while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); } while (testo.Contains("...")) { testo = testo.Replace("...", "…"); } while (testo.Contains("….")) { testo = testo.Replace("….", "…"); } while (testo.Contains("……")) { testo = testo.Replace("……", "…"); } while (testo.Contains(" ")) { testo = testo.Replace(" ", " "); } while (testo.Contains(" \n")) { testo = testo.Replace(" \n", "\n"); } while (testo.Contains("\n ")) { testo = testo.Replace("\n ", "\n"); } while (testo.Contains("\n\n")) { testo = testo.Replace("\n\n", "\n"); } return testo; } catch (Exception ex) { return string.Format(" Errore: Errore durante la formattazione del testo:\n{0}\n\n", ex.Message); } } public static bool WriteStyleSheet(string FullFileName) { try { StringBuilder sb = new StringBuilder(); sb.Append("BODY{\n\tmargin-left : 5px;\n\tmargin-right : 5px;\n\tcolor : #000099;\n\tfont-family : Verdana,Arial,Helvetica;\n\tbackground-color : #F4F4F4;\n}\n.Title {\n\ttext-align : center; \n\tfont-family : \"Helvetica\";\n\tfont-size : x-large;\n}\n.SubTitle {\n\ttext-align : center; \n\ttext-indent : 16px;\n\tfont-family : \"Helvetica\";\n\tfont-size : large;\n\tfont-style : italic;\n}\n.Property {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Origine {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Autore {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Data {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Trama {\n\ttext-align : justify; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.Menu {\n\ttext-align : right; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.MsgTitle {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.MsgText {\n\ttext-align : justify; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.ReportTitle {\n\ttext-align : center; \n\tfont-family : \"Helvetica\";\n\tfont-size : x-large;\n}\n.ReportText {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Menu_Row {\n\tfont-size:70%;\n\twhite-space:nowrap;\n}\n.Menu_sx {\n\ttext-align:left; width:50%; float: left;\n}\n.Menu_dx {\n\ttext-align:right; width:50%; float: right;\n}\n"); WriteTextFile(FullFileName, sb); return true; } catch (Exception ex) { Logger.Log(new object[] { "Error Code: eBook000", "Errore in ATlib.Tools.WriteStyleS(FullFileName)", ex }); return false; } } public static void Insert_Format_Tags(ref List dst, List items) { try { // // Rimuove duplicati e ordina alfabeticamente // items = items // .OrderBy(s => s) // ordina alfabeticamente // .Distinct() // elimina duplicati // .ToList(); if (dst is null) { dst = new List(); } // Ordino ed elimino duplicati items.Sort(); string tmp = ""; foreach (string item in items) { string it = item.Trim().ToLower(); if (tmp != it) { #region switch per formattare il testo switch (it) { case "altro": // Src: Old_Milu dst.Add("Altro"); break; case "autoerotismo": // Src: Old_Milu dst.Add("Masturbazione"); break; case "bdsm": // Src: A69 dst.Add("BDSM"); break; case "cuckold": // Src: Old_Milu dst.Add("Cuckold"); break; case "dominazione": // Src: Old_Milu dst.Add("Dominazione"); break; case "gay": // Src: Old_Milu dst.Add("Gay"); break; case "gay & bisex": // Src: A69 dst.Add("Bisex"); dst.Add("Gay"); break; case "incesto": // Src: A69, Old_Milu dst.Add("Incesto"); break; case "lesbo": // Src: A69 case "saffico": // Src: Old_Milu dst.Add("Lesbo"); break; case "lirica": // Src: Old_Milu dst.Add("Lirica"); break; case "lui & lei": // Src: A69 case "etero": // Src: Old_Milu dst.Add("Etero"); break; case "orge": // Src: A69 case "orgia": // Src: Old_Milu dst.Add("Orge"); break; case "poesia": // Src: Old_Milu dst.Add("Poesia"); break; case "prime esperienze": // Src: A69 dst.Add("Prime Esperienze"); break; case "scambio di coppia": // Src: A69 dst.Add("Scambismo"); break; case "sensazioni": // Src: Old_Milu dst.Add("Sensazioni"); break; case "tradimenti": // Src: A69 dst.Add("Tradimenti"); break; case "trans": // Src: A69, Old_Milu dst.Add("Trans"); break; case "trio": // Src: A69, Old_Milu dst.Add("trio"); break; //case "": // dst.Add(""); // break; default: dst.Add(item); break; } #endregion tmp = it; }//if }//foreach } catch (Exception ex) { Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); } finally { if (dst.Count == 0) dst.Add("_None_"); } }//function } // class Tools } // namespace A69WD