Пример #1
0
 /// <summary>                                                          
 /// 桥梁Csv文件查询结果转换成泛型集合                                         
 /// </summary>                                                                            
 /// <param name="filePath">文件路径</param>                         
 /// <returns>以实体类为元素的泛型集合</returns>
 public List<Bridge> ImportBridgeList(string filePath)
 {
     List<Bridge> b = new List<Bridge>();
     StreamReader fileReader = new StreamReader(filePath, Encoding.Default);
     try
     {
         //列之间的分隔符
         char cv = ',';
         while (fileReader.EndOfStream == false)
         {
             Bridge t = new Bridge();
             string line = fileReader.ReadLine();
             string[] y = line.Split(cv);
             t.Stake = y[0].Trim().ToString();
             t.StartStake = y[1].Trim().ToString();
             t.EndStake = y[2].Trim().ToString();
             t.Type = Convert.ToInt32(y[3].Trim().ToString());
             t.Name = y[4].Trim().ToString();
             t.Angle = Convert.ToDouble(y[5].Trim().ToString());
             t.LeftWidth = Convert.ToDouble(y[6].Trim().ToString());
             t.RightWidth = Convert.ToDouble(y[7].Trim().ToString());
             t.SpanDescription = y[8].Trim().ToString();
             b.Add(t);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         fileReader.Close();
         fileReader.Dispose();
     }
     return b;
 }
Пример #2
0
 /// <summary>
 /// 加载桥梁
 /// </summary>
 /// <param name="RouteID"></param>
 /// <returns></returns>
 public List<Bridge> Load(int RouteID)
 {
     List<Bridge> list = new List<Bridge>();
     if (DbConnection == null) return null;
     string sql = @"select * from RDC_Bridge where RouteID='" + RouteID + "'";
     DataSet ds = DbConnection.GetDataSet(sql);
     foreach (DataRow r in ds.Tables[0].Rows)
     {
         Bridge b = new Bridge();
         b.BridgeID = r["BridgeID"] == DBNull.Value ? 0 : Convert.ToInt32(r["BridgeID"]);
         b.RouteID = r["RouteID"] == DBNull.Value ? 0 : Convert.ToInt32(r["RouteID"]);
         b.Stake = r["Stake"].ToString();
         b.StartStake = r["StartStake"].ToString();
         b.EndStake = r["EndStake"].ToString();
         b.Type = r["Type"] == DBNull.Value ? 0 : Convert.ToInt32(r["Type"]);
         b.Name = r["Name"].ToString();
         b.Angle = r["Angle"] == DBNull.Value ? 0 : Convert.ToDouble(r["Angle"]);
         b.LeftWidth = r["LeftWidth"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftWidth"]);
         b.RightWidth = r["RightWidth"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightWidth"]);
         b.SpanDescription = r["SpanDescription"].ToString();
         list.Add(b);
     }
     return list;
 }