从XML中读取数据到内存的实例_XHTML/WEB_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

从XML中读取数据到内存的实例

作者:黑客防线网安XML教程基地 来源:黑客防线网安XML教程基地 浏览次数:0

本篇关键词:实例内存数据读取
黑客防线网安网讯:  public clsSimuResultByOneGoods GetOneGoodsSimulationXML(string PathAndFileName)          {              clsSimuResultByOneGoods OneGoods = new clsSimuResultByOneGoods()...

  public clsSimuResultByOneGoods GetOneGoodsSimulationXML(string PathAndFileName)
          {
              clsSimuResultByOneGoods OneGoods = new clsSimuResultByOneGoods();//自己定义的一个类
              Hashtable AllLocationResult = new Hashtable();
              System.Xml.XmlTextReader r = new XmlTextReader(PathAndFileName);
              string LocationID = "";
              DataTable LocationTable = null;
              while(r.Read())
              {
                  if(r.NodeType == XmlNodeType.Element)
                  {
                      switch(r.LocalName)
                      {
                          case "Result":
                              OneGoods.GoodsCode = r.GetAttribute("GoodsCode");
                              OneGoods.From = Convert.ToDateTime(r.GetAttribute("FromDate"));
                              OneGoods.To = Convert.ToDateTime(r.GetAttribute("ToDate"));
                              break;
                          case "Location":
                              LocationID = r.GetAttribute("ID");
                              LocationTable = new DataTable();
                              LocationTable.Columns.Add("Date",typeof(DateTime));
                              LocationTable.Columns.Add("SafetyStock",typeof(decimal));
                              LocationTable.Columns.Add("ForecastDemand",typeof(decimal));
                              LocationTable.Columns.Add("FinalOutput",typeof(decimal));
                              LocationTable.Columns.Add("FinalInput",typeof(decimal));
                              LocationTable.Columns.Add("SimuStock",typeof(decimal));
                              LocationTable.Columns.Add("SimuStockTime",typeof(decimal));
                              LocationTable.Columns.Add("ImportWorkDay",typeof(bool));
                              LocationTable.Columns.Add("ImportWorkDay",typeof(bool));
                              break;
                          case "Record":
                              if(LocationTable != null)
                              {
                                  DataRow dr = LocationTable.NewRow();
                                  dr["Date"] = Convert.ToDateTime(r.GetAttribute("Date"));
                                  if(r.GetAttribute("SafetyStock") != null && r.GetAttribute("SafetyStock") != "")
                                      dr["SafetyStock"] = Convert.ToDecimal(r.GetAttribute("SafetyStock"));
                                  if(r.GetAttribute("ForecastDemand") != null && r.GetAttribute("ForecastDemand") != "")
                                      dr["ForecastDemand"] = Convert.ToDecimal(r.GetAttribute("ForecastDemand"));
                                  if(r.GetAttribute("FinalInput") != null && r.GetAttribute("FinalInput") != "")
                                      dr["FinalInput"] = Convert.ToDecimal(r.GetAttribute("FinalInput"));
                                  if(r.GetAttribute("FinalOutput") != null && r.GetAttribute("FinalOutput") != "")
                                      dr["FinalOutput"] = Convert.ToDecimal(r.GetAttribute("FinalOutput"));
                                  if(r.GetAttribute("SimuStock") != null && r.GetAttribute("SimuStock") != "")
                                      dr["SimuStock"] = Convert.ToDecimal(r.GetAttribute("SimuStock"));
                                  if(r.GetAttribute("SimuStockTime") != null && r.GetAttribute("SimuStockTime") != "")
                                      dr["SimuStockTime"] = Convert.ToDecimal(r.GetAttribute("SimuStockTime"));
                                  if(r.GetAttribute("ImportWorkDay") != null && r.GetAttribute("ImportWorkDay") != "")
                                      dr["ImportWorkDay"] = Convert.ToBoolean(r.GetAttribute("ImportWorkDay"));
                                  if(r.GetAttribute("ExportWorkDay") != null && r.GetAttribute("ExportWorkDay") != "")
                                      dr["ExportWorkDay"] = Convert.ToBoolean(r.GetAttribute("ExportWorkDay"));
                                  LocationTable.Rows.Add(dr);

                              }
                              break;
                          default:
                              break;
                      }
                  }
                  else if(r.NodeType == XmlNodeType.EndElement)
                  {
                      switch(r.LocalName)
                      {
                          case "Location":
                              if(LocationTable != null)
                              {
                                  LocationTable.AcceptChanges();
                                  AllLocationResult.Add(LocationID,LocationTable);
                                  LocationID = "";
                                  LocationTable = null;
                              }
                              break;
                          default:
                              break;
                      }
                  }
              }
              OneGoods.AllLocationResult = AllLocationResult;
              return OneGoods;
             
          }
  

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-15932-1.html
网站维护教程更新时间:2012-04-06 01:01:39  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer