//查看中的左边的展示框--中list集合的返回 private List <TotalFile> leftlist(string Train, string txtLineName, string geoFileName) { TotalFile file = new TotalFile(); try { file.LineName = txtLineName; if (Train != null) { file.TrainCode = Train.ToString().Replace("-", "_"); } else { file.TrainCode = ""; } file.GeoFileName = geoFileName; } catch (Exception ex) { throw ex; } IOperator _dbOperator = new DbOperator(); _dbOperator.DbFilePath = Constpath; JumpPointsDAL _jumpDal = new JumpPointsDAL(_dbOperator.DbFilePath); TotalFileDAL _totalFileDal = new TotalFileDAL(_dbOperator.DbFilePath); List <TotalFile> totalData = _totalFileDal.GetList(file.LineName, file.TrainCode);//得到了数据集 return(totalData); }
public bool Add(TotalFile data) { bool isok = false; StringBuilder sbSql = new StringBuilder(); sbSql.Append("insert into TotalResult ("); sbSql.Append("LineName,TrainCode,"); sbSql.Append("GeoFileName,ResultTableName,TotalLength"); sbSql.Append(") values('"); sbSql.Append(data.LineName).Append("','").Append(data.TrainCode).Append("',"); sbSql.Append("'").Append(data.GeoFileName).Append("','"); sbSql.Append(data.ResultTableName).Append("'"); sbSql.Append(",'").Append(data.TotalLength).Append("'"); sbSql.Append(")"); bool i = _dbOperator.ExcuteSql(sbSql.ToString()); //int i = DataAccess.AccessHelper.Run_SQL(sbSql.ToString(), connStr); if (i) { isok = true; } return(isok); }
public string SaveIndexPoint(string json) { //公共方法 ResultInfo resultInfo = new ResultInfo(); try { //此处需要改动,传入应该是一个list的json JObject obj = (JObject)JsonConvert.DeserializeObject(json); string geofile = Convert.ToString(obj["geofile"]); string LineName = Convert.ToString(obj["LineName"]); //线路名 string Train = Convert.ToString(obj["Train"]); //轨检车型号 int jumpvalue = Convert.ToInt32(obj["jumpvalue"].ToString()); List <JumpPoints> listPoints = GadgetList(geofile, jumpvalue); if (listPoints.Count > 0) { TotalFileDAL totalFileDal = new TotalFileDAL(Constpath); TotalFile file = new TotalFile(); file.TotalLength = totalLength; file.LineName = LineName; if (Train != null) { file.TrainCode = Train; } file.GeoFileName = geofile; file.ResultTableName = "Result" + file.LineName + file.TrainCode + DateTime.Now.ToString("yyyyMMddHHmmss"); totalFileDal.Add(file); JumpPointsDAL jumpDal = new JumpPointsDAL(Constpath); jumpDal.CreateTable(Constpath, file.ResultTableName); jumpDal.DeleteAll(file.ResultTableName); for (int i = 0; i < listPoints.Count; i++) { jumpDal.Add(listPoints[i], file.ResultTableName); } resultInfo.flag = 1; resultInfo.msg = "成功"; resultInfo.data = Application.StartupPath + "\\" + Constpath; } else { } } catch (Exception ex) { throw ex; } return(JsonConvert.SerializeObject(resultInfo)); }
private List <TotalFile> DataTableToList_TotalFile(DataTable dt) { List <TotalFile> list = new List <TotalFile>(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TotalFile paramter = new TotalFile(); if (dt.Rows[i]["ID"] != null) { paramter.ID = Convert.ToInt32(dt.Rows[i]["ID"]); } if (dt.Rows[i]["LineName"] != null) { paramter.LineName = dt.Rows[i]["LineName"].ToString(); } if (dt.Rows[i]["TrainCode"] != null) { paramter.TrainCode = dt.Rows[i]["TrainCode"].ToString(); } if (dt.Rows[i]["GeoFileName"] != null) { paramter.GeoFileName = dt.Rows[i]["GeoFileName"].ToString(); } if (dt.Rows[i]["ResultTableName"] != null) { paramter.ResultTableName = dt.Rows[i]["ResultTableName"].ToString(); } if (dt.Rows[i]["TotalLength"] != null && dt.Rows[i]["TotalLength"].ToString() != "") { paramter.TotalLength = double.Parse(dt.Rows[i]["TotalLength"].ToString()); } list.Add(paramter); } } return(list); }
/// <summary> /// 保存索引点按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnWriteData_Click(object sender, EventArgs e) { try { if (listPoints.Count > 0) { btnWriteData.Enabled = false; TotalFileDAL totalFileDal = new TotalFileDAL(folderPath); TotalFile file = new TotalFile(); file.TotalLength = totalLength; file.LineName = this.txtLineName.Text.Trim(); if (cbxTrain.SelectedItem != null && !string.IsNullOrEmpty(cbxTrain.SelectedItem.ToString())) { file.TrainCode = this.cbxTrain.SelectedItem.ToString(); } file.GeoFileName = geoFileName; file.ResultTableName = "Result" + file.LineName + file.TrainCode + DateTime.Now.ToString("yyyyMMddHHmmss"); totalFileDal.Add(file); JumpPointsDAL jumpDal = new JumpPointsDAL(folderPath); jumpDal.CreateTable(folderPath, file.ResultTableName); jumpDal.DeleteAll(file.ResultTableName); for (int i = 0; i < listPoints.Count; i++) { jumpDal.Add(listPoints[i], file.ResultTableName); } MessageBox.Show("保存完成!"); btnWriteData.Enabled = true; } else { MessageBox.Show("不存在跳变点,请先计算!"); } } catch (Exception ex) { btnWriteData.Enabled = true; MessageBox.Show("保存数据出错:" + ex.Message); } }
/// <summary> /// 查看按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnViewResult_Click(object sender, EventArgs e) { try { TotalFile file = new TotalFile(); file.LineName = this.txtLineName.Text.Trim(); if (cbxTrain.SelectedItem != null && !string.IsNullOrEmpty(cbxTrain.SelectedItem.ToString())) { file.TrainCode = this.cbxTrain.SelectedItem.ToString().Replace("-", "_"); } else { file.TrainCode = ""; } file.GeoFileName = geoFileName; ResultViewForm from = new ResultViewForm(file); from.ShowDialog(); } catch (Exception ex) { MessageBox.Show("错误:" + ex.Message); } }
public ResultViewForm(TotalFile totalFile) { InitializeComponent(); _totalFile = totalFile; }