You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/TemplateManger/TemplateManager.cs

90 lines
2.6 KiB
C#

3 years ago
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using DSWeb.Models;
using System.Web;
namespace DSWeb.TemplateManger
{
public class TemplateManager
{
private static TemplateManager configManager = new TemplateManager();
private TemplateManager() { }
public static TemplateManager Instance()
{
return configManager;
}
public object GetConfigInfo(TemplateType tempConfigType)
{
object resultObj = null;
switch (tempConfigType)
{
case TemplateType.INVOICECONFIG:
IList<InvoiceConfigEntity> invoiceConfigEntities = new List<InvoiceConfigEntity>();
XmlNode xmlNode = GetXmlConfigObj("Templates/Templates.xml", "invoice");
int iCount = 0;
for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
{
InvoiceConfigEntity invoiceConfigEntity = new InvoiceConfigEntity();
invoiceConfigEntity.ItemName = xmlNode.ChildNodes[i].Name;
invoiceConfigEntity.ItemValue = xmlNode.ChildNodes[i].InnerText;
invoiceConfigEntities.Add(invoiceConfigEntity);
iCount++;
}
if (iCount > 0)
{
resultObj = invoiceConfigEntities;
}
else
{
resultObj = invoiceConfigEntities;
}
break;
}
return resultObj;
}
private XmlNode GetXmlConfigObj(string tempXmlUrl, string tempNodeName)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode tempNode = null;
string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri;
string xmlUrl = currentUrl.Substring(0, currentUrl.Substring(0, currentUrl.LastIndexOf("/")).LastIndexOf("/") + 1) + tempXmlUrl;
try
{
xmlDoc.Load(xmlUrl);
for(int i=0;i<xmlDoc.ChildNodes[1].ChildNodes.Count;i++)
{
if (xmlDoc.ChildNodes[1].ChildNodes[i].Name.Trim().ToLower().Equals(tempNodeName))
{
tempNode = xmlDoc.ChildNodes[1].ChildNodes[i];
}
}
}
catch(Exception)
{
}
return tempNode;
}
}
public enum TemplateType
{
INVOICECONFIG = 0
}
}