posts - 124,  comments - 29,  trackbacks - 0
<?xml version="1.0" encoding="GB2312"?>
<Head>
<Column DisTitle="报表名" DisWidth="150">
  
<Field>tableCName</Field> 
  
<Type>string</Type>
  
<Visible>true</Visible>
</Column>
<Column DisTitle="表英文名" DisWidth="0">
  
<Field>tableEName</Field> 
  
<Type>string</Type> 
  
<Visible>false</Visible>
</Column>
<Column DisTitle="数据开始时间" DisWidth="150">
    
<Field>databtime</Field> 
    
<Type>string</Type> 
    
<Visible>true</Visible> 
</Column>
<Column DisTitle="数据结束时间" DisWidth="150">
    
<Field>dataetime</Field> 
    
<Type>string</Type> 
    
<Visible>true</Visible> 
</Column>
<Column DisTitle="汇总是否成功" DisWidth="300">
  
<Field>collectSuccess</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
<Column DisTitle="是否存在风险" DisWidth="100">
  
<Field>containDanger</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
<Column DisTitle="表描述" DisWidth="300">
  
<Field>discription</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
</Head>
    public static List<MyColumn> GetColumnInfo(string fileName, string Node)
        {
            
try
            {
                
string xmlFile = String.Format("{0}\\{1}", System.Windows.Forms.Application.StartupPath, fileName);

                XmlDocument xmldoc 
= new XmlDocument();
                xmldoc.Load(xmlFile);
                
if (xmldoc != null)
                {
                    XmlNode colnode 
= xmldoc.SelectSingleNode(Node);
                    
if (colnode != null)
                    {
                        List
<MyColumn> cols = new List<MyColumn>();
                        
foreach (XmlNode headnode in colnode.ChildNodes)
                        {
                            MyColumn col 
= new MyColumn();
                            col.Caption 
= headnode.Attributes["DisTitle"].Value;
                            col.Width 
= Convert.ToInt32(headnode.Attributes["DisWidth"].Value);
                            col.FieldName 
= headnode.SelectSingleNode("Field").InnerText;
                            col.Visible 
= Convert.ToBoolean(headnode.SelectSingleNode("Visible").InnerText);


                            
string type = headnode.SelectSingleNode("Type").InnerText;

                            
if (String.Compare(type, "int"true== 0 || String.Compare(type, "long"true== 0 || String.Compare(type, "short"true== 0)
                            {
                                col.colType 
= Type.GetType("System.Int64");
                            }
                            
else if (String.Compare(type, "double"true== 0)
                            {
                                col.colType 
= Type.GetType("System.Double");
                            }
                            
else
                            {
                                col.colType 
= Type.GetType("System.String");
                            }
                            cols.Add(col);
                        }

                        
return cols;
                    }
                }
                
return null;
            }
            
catch(Exception ex)
            {
                MessageBox.Show(ex.Message 
+ ex.StackTrace);
                
return null;
            }
        }
posted on 2010-04-23 12:00 天书 阅读(450) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2010年4月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜