using System;
using System.Xml;

namespace GetBaseInfo
{
 /// <summary>
 /// GetXMLBaseInfo 的摘要说明。
 /// </summary>
 public class GetXMLBaseInfo
 {
  public GetXMLBaseInfo()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }

  /// <summary>
  /// 根据节点参数  获取连接字符串
  /// </summary>
  /// <returns></returns>
  public static string GetConnectionString(string nodeName)
  {
   XmlDocument dom = new XmlDocument();
   dom.Load(@".\DataAccessBaseInfo.xml");

   XmlNode xn = dom.SelectSingleNode("//DataBase/" + nodeName);
   XmlElement xel = (XmlElement)xn;

   return xel.GetAttribute("ConnectionString");
  }  

  /// <summary>
  /// 根据节点参数  获取操作时间
  /// </summary>
  /// <param name="nodeName"></param>
  /// <returns></returns>
  public static string GetTimeInfo(string nodeName)
  {
   XmlDocument dom = new XmlDocument();
   dom.Load(@".\DataAccessBaseInfo.xml");

   XmlNode xn = dom.SelectSingleNode("//TimeSet/" + nodeName);
   XmlElement xel = (XmlElement)xn;

   return xel.GetAttribute("SetTime");
  }

  /// <summary>
  /// 根据节点参数  修改操作时间
  /// </summary>
  /// <param name="nodeName"></param>
  /// <returns></returns>
  public static void UpdateTimeInfo(string nodeName,string nodeValue)
  {
   XmlDocument dom = new XmlDocument();
   dom.Load(@".\DataAccessBaseInfo.xml");

   XmlNode xn = dom.SelectSingleNode("//TimeSet/" + nodeName);
   XmlElement xel = (XmlElement)xn;

   xel.SetAttribute("SetTime",nodeValue);
   dom.Save(@".\DataAccessBaseInfo.xml");
  }

  /// <summary>
  /// 根据节点参数  修改数据库信息
  /// </summary>
  /// <param name="nodeName"></param>
  /// <returns></returns>
  public static void UpdateDBInfo(string nodeName,string nodeValue)
  {
   XmlDocument dom = new XmlDocument();
   dom.Load(@".\DataAccessBaseInfo.xml");

   XmlNode xn = dom.SelectSingleNode("//DataBase/" + nodeName);
   XmlElement xel = (XmlElement)xn;

   xel.SetAttribute("ConnectionString",nodeValue);
   dom.Save(@".\DataAccessBaseInfo.xml");
  }
 }
}

 posted on 2006-10-11 20:41  心有灵犀  阅读(494)  评论(0编辑  收藏  举报