silverlight 生成图表 WCF 解析XML代码.svc.cs 文件
silverlight 调用wcf 文件代码
private ListItem AnalyzeXML(string XMLCode, string Reportdate, string ChartName, string OildomName)
{
IDataBase oDB = DBFactory.GetDBInstance();
ListItem liChart = new ListItem();
XmlDocument config;
string basePath = System.AppDomain.CurrentDomain.BaseDirectory + "Silverlight\\Config\\SCYX\\";
string configPath = basePath + XMLCode;
if (!System.IO.File.Exists(configPath))
{
throw new Exception("指定配置文件不存在!");
}
config = new XmlDocument();
config.Load(configPath);
XmlNode rootNode = config.SelectSingleNode("/ChartSet");
if (rootNode == null)
{
throw new Exception("图集合的配置不存在!");
}
for (int i = 0; i < rootNode.ChildNodes.Count; i++)
{
try
{
DataTable dt;
XmlNode ChartNode = rootNode.ChildNodes[i];
if (ChartNode == null)
{
throw new Exception("图的配置不存在!");
}
#region 获取Chart基本信息
if (ChartNode == null)
{
throw new Exception("图的配置不存在!");
}
liChart.ChartName = ChartName;
liChart.Title = ChartNode.Attributes["Title"].Value;
liChart.Title = liChart.Title.Replace("{Date}", Reportdate);
liChart.Title = liChart.Title.Replace("{OildomName}", OildomName);
liChart.ChartType = ChartNode.Attributes["ChartType"].Value;
#endregion
#region 获取Command信息
XmlNode xnCommand = ChartNode.SelectSingleNode("Command");
string sSQL = "";
if (xnCommand == null && xnCommand.ChildNodes.Count == 0)
{
throw new Exception("未找到配置数据SQL");
}
else
{
// string strBeginRepordate = Reportdate.Substring(0, 6) + "01";//月初
//string strEndRepordate = DateTime.ParseExact(strBeginRepordate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).AddMonths(1).AddDays(-1).ToString("yyyyMMdd");//月末
string strBeginRepordate = DateTime.ParseExact(Reportdate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).AddMonths(-1).ToString("yyyyMMdd");//当前日期前一个月
sSQL = (xnCommand.ChildNodes[0]).InnerText;
sSQL = sSQL.Replace("{Reportdate}", Reportdate);
sSQL = sSQL.Replace("{strBeginRepordate}", strBeginRepordate);
sSQL = sSQL.Replace("{OildomName}", OildomName);
dt = oDB.GetDataTable(sSQL);
}
#endregion
#region 获取AxisX信息
XmlNode xnAxisX = ChartNode.SelectSingleNode("AxisX");
string[] sXAXIS = new string[dt.Rows.Count];
for (int h = 0; h < dt.Rows.Count; h++)
{
sXAXIS[h] = dt.Rows[h][xnAxisX.Attributes["XField"].Value].ToString();
}
liChart.XAXIS = sXAXIS;
#endregion
#region 获取AxisY信息
XmlNode xnAxisY = ChartNode.SelectSingleNode("AxisY");
if (xnAxisY.Attributes["Unit"] != null)
liChart.YUint = xnAxisY.Attributes["Unit"].Value;
string strYear = Reportdate.Substring(0, 4);//本年
string strBegReportDate = DateTime.ParseExact(Reportdate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).AddYears(-1).ToString("yyyyMMdd").Substring(0, 4);//上一年
for (int j = 0; j < xnAxisY.ChildNodes.Count; j++)
{
XmlNode xnYChild = xnAxisY.ChildNodes[j];
YAXIS oYAXIS = new YAXIS();
oYAXIS.Name = xnYChild.Attributes["Name"].Value;
oYAXIS.Name = oYAXIS.Name.Replace("{Year-1}", strBegReportDate);
oYAXIS.Name = oYAXIS.Name.Replace("{Year}", strYear);
oYAXIS.Color = xnYChild.Attributes["Color"].Value;
oYAXIS.XField = xnYChild.Attributes["XField"].Value;
oYAXIS.YField = xnYChild.Attributes["YField"].Value;
double[] sYAXIS = new double[dt.Rows.Count];
for (int k = 0; k < dt.Rows.Count; k++)
{
sYAXIS[k] = Convert.ToDouble(dt.Rows[k][oYAXIS.YField]);
}
oYAXIS.YValue = sYAXIS;
liChart.YAXISs.Add(oYAXIS);
}
#endregion
}
catch (Exception e)
{
throw new Exception("获取配置文件失败!" + e.Message);
}
}
return liChart;
}
- XML布局文件在Activity自动生成代码(二)SAX 解析
- XML形式的配置文件解析框架以及自动代码生成(一)
- WCF_通过使用svcutil.exe将http://*.svc?wsdl生成客户端可调用的.cs文件
- xml、Json生成cs代码文件
- Java生成和解析XML格式文件和字符串的实例代码
- [置顶] WSDL文件复杂类型的解析及其实例化代码生成
- Cocos2d-x tinyxml2用于xml的解析,自动生成xml文件和解析xml文件
- PowerDesigner XML 文件直接生成 VB 实体(包含属性说明)、ibatisNet 代码
- js代码文件动态生成(此为一张页面的后端cs代码)
- Java代码生成和解析xls文件
- 对xsd文件的操作 生成java实体并解析生成的xml
- android利用pull技术来解析和生成xml文件
- 【Android技术整理】XML生成与解析伪代码
- Java生成和解析XML格式文件和字符串的实例代码【dom4j中的SAXReader对象读取并解析xml文件】
- 使用dom4j来解析,生成xml文件
- Activiti基础教程--01(简介、代码生成Activiti的25张表、Activiti配置文件activiti.cfg.xml生成25张表、在Eclipse上安装Activiti插件)
- 生成XML文件的步骤 & 解析XML文件
- xml生成cs文件
- Android下Xml解析技术(四)、pull生成Xml文件
- 分享非常有用的Java程序 (关键代码)(六)---解析/读取XML 文件(重要)