/// <summary> /// 加载平面交叉口 /// </summary> /// <param name="RouteID"></param> /// <returns></returns> public List<PlaneIntersection> Load(int RouteID) { if (DbConnection == null) return null; List<PlaneIntersection> list = new List<PlaneIntersection>(); string sql = @"select *from RDC_PlaneIntersection where RouteID='" + RouteID + "'"; DataSet ds = DbConnection.GetDataSet(sql); foreach (DataRow r in ds.Tables[0].Rows) { PlaneIntersection p = new PlaneIntersection(); p.PlaneIntersectionID = r["PlaneIntersectionID"] == DBNull.Value ? 0 : Convert.ToInt32(r["PlaneIntersectionID"]); p.RouteID = r["RouteID"] == DBNull.Value ? 0 : Convert.ToInt32(r["RouteID"]); p.Stake = r["Stake"].ToString(); p.PlaneInterName = r["PlaneInterName"].ToString(); p.bCalcLeft = r["bCalcLeft"] == DBNull.Value ? 0 : Convert.ToInt32(r["bCalcLeft"]); p.LeftBt = r["LeftBt"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftBt"]); p.LeftL = r["LeftL"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftL"]); p.LeftR1 = r["LeftR1"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftR1"]); p.LeftR2 = r["LeftR2"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftR2"]); p.LeftR2 = r["LeftR2"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftR2"]); p.LeftR3 = r["LeftR3"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftR3"]); p.LeftR4 = r["LeftR4"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftR4"]); p.LeftW1 = r["LeftW1"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftW1"]); p.LeftW2 = r["LeftW2"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftW2"]); p.LeftW3 = r["LeftW3"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftW3"]); p.LeftW4 = r["LeftW4"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftW4"]); p.bCalcRight = r["bCalcRight"] == DBNull.Value ? 0 : Convert.ToInt32(r["bCalcRight"]); p.RightBt = r["RightBt"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightBt"]); p.RightL = r["RightL"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightL"]); p.RightR1 = r["RightR1"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightR1"]); p.RightR2 = r["RightR2"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightR2"]); p.RightR3 = r["RightR3"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightR3"]); p.RightR4 = r["RightR4"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightR4"]); p.RightW1 = r["RightW1"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightW1"]); p.RightW2 = r["RightW2"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightW2"]); p.RightW3 = r["RightW3"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightW3"]); p.RightW4 = r["RightW4"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightW4"]); p.Remarks = r["Remarks"].ToString(); list.Add(p); } return list; }
/// <summary> /// 平交路口Csv文件查询结果转换成泛型集合 /// </summary> /// <param name="filePath">文件路径</param> /// <returns>以实体类为元素的泛型集合</returns> public List<PlaneIntersection> ImportPlaneIntersectionList(string filePath) { List<PlaneIntersection> csc = new List<PlaneIntersection>(); StreamReader fileReader = new StreamReader(filePath, Encoding.Default); try { //列之间的分隔符 char cv = ','; while (fileReader.EndOfStream == false) { PlaneIntersection t = new PlaneIntersection(); string line = fileReader.ReadLine(); string[] y = line.Split(cv); t.Stake = y[0].Trim().ToString(); t.PlaneInterName = y[1].Trim().ToString(); t.bCalcLeft = Convert.ToInt32(y[2].Trim().ToString()); t.LeftBt = Convert.ToDouble(y[3].Trim().ToString()); t.LeftL = Convert.ToDouble(y[4].Trim().ToString()); t.LeftR1 = Convert.ToDouble(y[5].Trim().ToString()); t.LeftR2 = Convert.ToDouble(y[6].Trim().ToString()); t.LeftR3 = Convert.ToDouble(y[7].Trim().ToString()); t.LeftR4 = Convert.ToDouble(y[8].Trim().ToString()); t.bCalcRight = Convert.ToInt32(y[9].Trim().ToString()); t.RightL = Convert.ToDouble(y[10].Trim().ToString()); t.RightR1 = Convert.ToDouble(y[11].Trim().ToString()); t.RightR2 = Convert.ToDouble(y[12].Trim().ToString()); t.RightR3 = Convert.ToDouble(y[13].Trim().ToString()); t.RightR4 = Convert.ToDouble(y[14].Trim().ToString()); t.RightW1 = Convert.ToDouble(y[15].Trim().ToString()); t.RightW2 = Convert.ToDouble(y[16].Trim().ToString()); t.RightW3 = Convert.ToDouble(y[17].Trim().ToString()); t.RightW4 = Convert.ToDouble(y[18].Trim().ToString()); t.Remarks = y[19].Trim().ToString(); csc.Add(t); } } catch (Exception ex) { throw ex; } finally { fileReader.Close(); fileReader.Dispose(); } return csc; }