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;
        }

silverlight 生成图表 WCF 解析XML代码.svc.cs 文件的更多相关文章

  1. XML配置silverlight ,wcf 解析xml

    XML 代码: <?xml version="1.0" encoding="utf-8" ?><ChartSet  xmlns:xsi=&qu ...

  2. Android 生成和Pull解析xml

    一.单个对象生成xml 生成以下xml,该怎么生成呢? <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <accou ...

  3. android 生成、pull解析xml文件

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...

  4. Maven在jar中生成重复的pom.xml和pom.properties文件

    eclispe maven打包的时候总是出现"生成的jar的META-INF中,重复的pom.xml和pom.properties文件.",maven命令直接打包则没有这个问题. ...

  5. WCF客户端C#代码 配置config文件

    不多说了,直接上代码吧.... 服务端Web.config文件中bindings配置 <bindings> <wsHttpBinding> <binding name=& ...

  6. 在silverlight中通过WCF连接ORACLE DB数据库(转)

    转自 http://hi.baidu.com/qianlihanse/item/458aa7c8d93d4e0cac092ff4 这不是我的原创,我也是上网学习的~ How to get data f ...

  7. WCF服务三:svc文件详解

    在前面的文章中讲述过WCF服务的宿主程序主要包括:三种,在那篇文章中,简单的描述了如何把一个WCF服务寄宿到IIS上面,这篇文章中将具体讲述如何把一个WCF服务寄宿到IIS上面. 一.新建一个WCF服 ...

  8. Javaweb学习笔记——使用Jdom解析xml

    一.前言 Jdom是什么? Jdom是一个开源项目,基于树形结构,利用纯java的技术对XML文档实现解析,生成,序列化以及多种操作.它是直接为java编程服务,利用java语言的特性(方法重载,集合 ...

  9. 解析XML的几种方法之SAX解析

    假期总结不能停,坚持坚持....接下来总结一下XMl和json的解析和生成.. 解析XML的四种方法,即:DOM.SAX.JDOM和DOM4J 下面首先给出这四种方法的jar包下载地址: DOM:在现 ...

随机推荐

  1. poj1418 Viva Confetti 判断圆是否可见

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Viva Confetti Time Limit: 1000MS   Memory ...

  2. (原)ubuntu14.04中安装gcc4.9和g++4.9

    http://stackoverflow.com/questions/28683747/installing-gcc4-9-on-ubuntu-14-04-lts http://askubuntu.c ...

  3. 在git bush中如何退出vim编辑器

    写npm的pakege.json文件的files配置时,如果有不想包含的文件,那就要创建.npmignore文件排除,但windows系统又不允许创建以点开头命名的文件,咋办? 这时候就要用到linu ...

  4. 使用接口的方式调用远程服务 ------ 利用动态调用服务,实现.net下类似Dubbo的玩法。

    分布式微服务现在成为了很多公司架构首先项,据我了解,很多java公司架构都是 Maven+Dubbo+Zookeeper基础上扩展的. Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按 ...

  5. Sublime Text 2 注册码

    ----- BEGIN LICENSE ----- Andrew Weber Single User License EA7E- 813A03DD 5E4AD9E6 6C0EEB94 BC99798F ...

  6. activity,view,window,windowmanager代码阅读总结及相互关系

    ActivityThread类:performLaunchActivity函数: activity.attach(appContext, this, getInstrumentation(), r.t ...

  7. 查看服务器IP连接数之主要命令(在服务器受攻击时用)

    查看TCP几种状态的总数 netstat -n | awk '/^tcp/ {++S[$NF]} END {fo (a in S). print a, S[a]}' 按IP查看连接数排序 netsta ...

  8. Android之断点续传下载

    今天学习了Android开发中比较难的一个环节,就是断点续传下载,很多人看到这个标题就感觉头大,的确,如果没有良好的逻辑思维,这块的确很难搞明白.下面我就将自己学到的知识和一些见解写下供那些在这个环节 ...

  9. BZOJ1270: [BeijingWc2008]雷涛的小猫

    1270: [BeijingWc2008]雷涛的小猫 Time Limit: 50 Sec  Memory Limit: 162 MBSubmit: 836  Solved: 392[Submit][ ...

  10. Android Studio:Unable to add window android.view.ViewRootImpl$W@5e2d85a -- permission denied for this window 第一行代码

    学习<第一行代码>的时候,出现的错误. java.lang.RuntimeException: Unable to start receiver com.example.sevenun.l ...