106 lines
2.8 KiB
C#
106 lines
2.8 KiB
C#
using System.IO;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
|
|
namespace SCMA
|
|
{
|
|
public class utils : MTC.baseUtils
|
|
{
|
|
/// <summary>
|
|
/// folder archiviazione dati configurazione (DATA\CONF)
|
|
/// </summary>
|
|
public static string resxDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// folder archiviazione dati configurazione (DATA\CONF)
|
|
/// </summary>
|
|
public static string confDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// folder archiviazione dati storici giornalieri (DATA\DAT)
|
|
/// </summary>
|
|
public static string dataDatDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// folder archiviazione dati (DATA)
|
|
/// </summary>
|
|
public static string dataDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// File x regole di replacement USER DEFINED
|
|
/// </summary>
|
|
public static string nameRepRoleFile
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("NameRepRolesList"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// File x regole di replacement GENERATED
|
|
/// </summary>
|
|
public static string nameRepRoleFileGen
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("NameRepRolesList").Replace(".map", ".gen.map"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo di sanitizzazione XML
|
|
/// - elimina commenti
|
|
/// - formatta
|
|
/// </summary>
|
|
/// <param name="xmlOrig"></param>
|
|
/// <returns></returns>
|
|
public static string xmlSanitize(string xmlOrig)
|
|
{
|
|
string sXml = xmlOrig;
|
|
bool xmlSanitize = utils.CRB("xmlSanitize");
|
|
// se richeisto faccio sanitize xml (pulizia commenti...)
|
|
if (xmlSanitize)
|
|
{
|
|
// primo step: converto stringa in dox XML
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
xmlDoc.PreserveWhitespace = false;
|
|
xmlDoc.LoadXml(sXml);
|
|
// ora lo parso come lista eliminando i commenti
|
|
XmlNodeList list = xmlDoc.SelectNodes("//comment()");
|
|
foreach (XmlNode node in list)
|
|
{
|
|
node.ParentNode.RemoveChild(node);
|
|
}
|
|
// fix formattazione "riscrivendo" indentazione...
|
|
StringWriter string_writer = new StringWriter();
|
|
XmlTextWriter xml_text_writer = new XmlTextWriter(string_writer);
|
|
xml_text_writer.Formatting = Formatting.Indented;
|
|
xmlDoc.WriteTo(xml_text_writer);
|
|
sXml = string_writer.ToString();
|
|
}
|
|
// restituisco
|
|
return sXml;
|
|
}
|
|
}
|
|
}
|