2 using System.Collections.Generic;
7 using System.Security.AccessControl;
8 using System.Security.Principal;
15 public static class clsFuncs
24 public static void Generate_Xml_Return(
string tcNode,
string tcReturn,
string tcErrorMsg =
"",
string tcAttribute =
"")
27 XmlDocument xmlConfiguracion =
new XmlDocument();
31 string lcDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
@"\Sage.ew.offline";
34 _CreateDirectory(lcDirectory);
36 string lcFitxer = lcDirectory +
@"\sage.ew.offline.xml";
39 if (!File.Exists(lcFitxer))
41 xmlConfiguracion.LoadXml(
"<?xml version = \"1.0\" encoding=\"Windows-1252\" standalone=\"yes\"?><returnvalues> </returnvalues>");
47 xmlConfiguracion.Load(lcFitxer);
51 xmlConfiguracion.LoadXml(
"<?xml version = \"1.0\" encoding=\"Windows-1252\" standalone=\"yes\"?><returnvalues> </returnvalues>");
56 XmlNode loNodeA = xmlConfiguracion.SelectSingleNode(
"returnvalues");
57 XmlNode loNode = loNodeA.SelectSingleNode(tcNode);
60 if (!
string.IsNullOrWhiteSpace(tcAttribute))
67 loNodeA.RemoveChild(loNode);
74 loNode = xmlConfiguracion.CreateElement(tcNode);
75 loNodeA.AppendChild(loNode);
79 if (!
string.IsNullOrWhiteSpace(tcAttribute))
82 newElem = xmlConfiguracion.CreateAttribute(tcAttribute);
83 newElem.InnerText = tcReturn;
84 loNode.Attributes.Append(newElem);
89 newElem = xmlConfiguracion.CreateAttribute(
"value");
90 newElem.InnerText = tcReturn;
91 loNode.Attributes.Append(newElem);
93 newElem = xmlConfiguracion.CreateAttribute(
"error_message");
94 newElem.InnerText = tcErrorMsg;
95 loNode.Attributes.Append(newElem);
97 newElem = xmlConfiguracion.CreateAttribute(
"time_stamp");
98 newElem.InnerText = DateTime.Now.ToString();
99 loNode.Attributes.Append(newElem);
103 xmlConfiguracion.PreserveWhitespace =
true;
104 xmlConfiguracion.Save(lcFitxer);
114 public static string Get_Xml_Value(
string tcNode,
string tcAttribute,
string tcTipoDatos =
"String")
117 XmlDocument xmlConfiguracion =
new XmlDocument();
140 string lcDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
@"\Sage.ew.offline";
143 _CreateDirectory(lcDirectory);
145 string lcFitxer = lcDirectory +
@"\sage.ew.offline.xml";
148 if (!File.Exists(lcFitxer))
156 xmlConfiguracion.Load(lcFitxer);
165 XmlNode loNodeA = xmlConfiguracion.SelectSingleNode(
"returnvalues");
166 XmlNode loNode = loNodeA.SelectSingleNode(tcNode);
172 if (loNode.Attributes[tcAttribute] != null)
173 lcValor = loNode.Attributes[tcAttribute].InnerText;
183 public static void _CreateDirectory(
string tcDirectory)
186 System.IO.DirectoryInfo lDirInfo =
new System.IO.DirectoryInfo(tcDirectory);
187 if (!lDirInfo.Exists)
190 Directory.CreateDirectory(tcDirectory);
194 FileSystemAccessRule lFileSysAccess =
new FileSystemAccessRule(
new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow);
195 DirectorySecurity lDirSec = null;
196 lDirSec = lDirInfo.GetAccessControl();
197 lDirSec.AddAccessRule(lFileSysAccess);
198 lDirInfo.SetAccessControl(lDirSec);
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...