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));
        }
Example #2
0
        /// <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);
            }
        }