/// <summary>
        /// Return data from local xml file.
        /// </summary>
        /// <param name="filePath">Local path in which is the file.</param>
        /// <returns></returns>
        public static Factura GetData(string filePath)
        {
            try
            {
                var path = Path.GetDirectoryName(filePath);

                if (!Directory.Exists(path))
                {
                    throw new DirectoryNotFoundException("El direcotrio no existe.");
                }

                if (!File.Exists(filePath))
                {
                    throw new FileNotFoundException("El archivo " + Path.GetFileName(filePath) + " no existe.", Path.GetFileName(filePath));
                }

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(filePath);

                return(ReadXML.GetData(xmlDoc, Path.GetFileName(filePath)));
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
示例#2
0
        /// <summary>
        /// Return data of xml in a string.
        /// </summary>
        /// <param name="xmlString"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static Factura GetData(string xmlString, string fileName)
        {
            try
            {
                string xmlName = string.Empty;

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlString);

                if (!string.IsNullOrEmpty(fileName))
                {
                    xmlName = fileName;
                }
                else
                {
                    xmlName = "Invoice-" + DateTime.Now.ToString("MM-dd-yyyy-H-mm-ss");
                }

                return(ReadXML.GetData(xmlDoc, xmlName));
            }
            catch (Exception ex) { throw (ex); }
        }