/// <summary> /// 读取统计数据 /// </summary> /// <returns></returns> public static List <StatisticCPT> SelectStatisticData() { // 定义统计数据列表 List <StatisticCPT> statisticList = new List <StatisticCPT>(); // 定义分层分层编号列表、分层岩土名称列表、试验类型列表 List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); // 在分层编号列表中循环,赋值统计数据列表 for (int i = 0; i < layerNumberList.Count; i++) { // 检查当前的分层编号下,数据库中是否有内容 List <double> psList = CPTDataBase.ReadLayerPs(Program.currentProject, layerNumberList[i]); if (psList.Count > 0) { // 添加一组符合筛选条件的统计数据 StatisticCPT statePs = new StatisticCPT(layerNumberList[i], layerNameList[i], psList, 6); statisticList.Add(statePs); } } // 返回 return(statisticList); }
/// <summary> /// 赋值项目数据 /// </summary> private void InitialProjectBasicInfo() { if (Program.currentProject != null) { dt.Clear(); this.DrawerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.WriterComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.CheckerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.InspectorComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.ApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.FinalApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); string prj = Program.currentProject; this.ProjectNameTextBox.Text = prj; this.ProjectProvinceTextBox.Text = ProjectDataBase.ReadProjectProvince(prj); this.ProjectCityTextBox.Text = ProjectDataBase.ReadProjectCity(prj); string[] company = ProjectDataBase.ReadProjectCompany(prj); this.CompanyNameTextBox.Text = company[0]; this.CompanyCodeTextBox.Text = company[1]; this.DrawerComboBox.Text = company[2]; this.WriterComboBox.Text = company[3]; this.CheckerComboBox.Text = company[4]; this.InspectorComboBox.Text = company[5]; this.ApproverComboBox.Text = company[6]; this.FinalApproverComboBox.Text = company[7]; InitialDataTable(ProjectDataBase.ReadLayerNumberList(prj), ProjectDataBase.ReadLayerNameList(prj), ProjectDataBase.ReadLayerGeoList(prj), ProjectDataBase.ReadLayerDescriptionList(prj)); } }
/// <summary> /// 筛选统计数据 /// </summary> /// <param name="_layerNumber">分层编号</param> /// <returns></returns> public static List <StatisticGAT> SelectStatisticData(string _layerNumber) { // 定义统计数据列表 List <StatisticGAT> _statisticList = new List <StatisticGAT>(); // 定义分层分层编号列表、分层岩土名称列表 List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); // 提取分层岩土名称 string _layerName = ""; for (int i = 0; i < layerNumberList.Count; i++) { if (layerNumberList[i] == _layerNumber) { _layerName = layerNameList[i]; } } // 赋值统计数据列表 List <GrainAnalysisTest> gatList = GrainAnalysisTestDataBase.SelectByZkAndLayer(Program.currentProject, "", _layerNumber); if (gatList.Count > 0) { StatisticGAT statistic = new StatisticGAT(_layerNumber, _layerName, gatList); _statisticList.Add(statistic); } // 返回 return(_statisticList); }
// 单击菜单"项目"-"编辑当前项目" private void EditProjectMenu_Click(object sender, RoutedEventArgs e) { // 隐藏项目基本信息窗口 foreach (TreeViewItem item in this.ProjectTreeView.Items) { item.IsSelected = false; } // 赋值要传递的参数 string name = Program.currentProject; string province = ProjectDataBase.ReadProjectProvince(name); string city = ProjectDataBase.ReadProjectCity(name); List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(name); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(name); List <string> layerGeoList = ProjectDataBase.ReadLayerGeoList(name); List <string> layerDescriptionList = ProjectDataBase.ReadLayerDescriptionList(name); string[] company = ProjectDataBase.ReadProjectCompany(name); // 实例化窗口 NewProject editProject = new NewProject(name, province, city, layerNumberList, layerNameList, layerGeoList, layerDescriptionList, company); editProject.ShowDialog(); // 更新项目数据文件 if (editProject.DialogResult == true) { GC.Collect(); GC.WaitForPendingFinalizers(); File.Move(editProject.oldFile, editProject.newFile); } // 重命名窗口 SetProgramText(Program.currentProject); }
/// <summary> /// 初始化各下拉选框 /// </summary> private void InitialComboBox() { List <string> layerNumberlist = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNamelist = ProjectDataBase.ReadLayerNameList(Program.currentProject); List <string> layerlist = new List <string>(); for (int i = 0; i < layerNumberlist.Count; i++) { layerlist.Add(layerNumberlist[i] + " " + layerNamelist[i]); } this.LayerNumberComboBox.ItemsSource = layerlist; }
/// <summary> /// 带1个参数的构造函数,用于新建分层 /// </summary> /// <param name="_lastDepth">上一层层底深度</param> public ZkLayerDetail(double _lastDepth) { InitializeComponent(); // 赋值上一层层底深度 LastDepth = _lastDepth; // 赋值各选框的候选项 this.LayerNumberComboBox.ItemsSource = ProjectDataBase.ReadLayerNumberList(Program.currentProject); this.LayerNameComboBox.ItemsSource = ProjectDataBase.ReadLayerNameList(Program.currentProject); this.LayerGeoComboBox.ItemsSource = ProjectDataBase.ReadLayerGeoList(Program.currentProject); // 定义层底深度输入框的工具提示 DefineToolTip(); }
/// <summary> /// 填充分层选框 /// </summary> private void InitialLayerComboBox() { List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); List <string> items = new List <string>(); for (int i = 0; i < layerNumberList.Count; i++) { items.Add(layerNumberList[i] + " " + layerNameList[i]); } this.LayerComboBox.ItemsSource = items; this.LayerComboBox.SelectedIndex = 0; }
/// <summary> /// 查询某个分层的标贯/动探列表 /// </summary> /// <param name="_projectName">项目名称</param> /// <param name="_layerNumber">分层编号</param> /// <param name="_type">试验类型</param> /// <returns></returns> public static List <ZkNTest> ReadLayerNTest(string _projectName, string _layerNumber, ZkNTest.ntype _type) { // 创建连接到设置信息数据库 string sql = "Data Source=" + Program.ReadProgramPath() + "\\" + _projectName + ".gsygeo"; using (SQLiteConnection conn = new SQLiteConnection(sql)) { // 打开连接 conn.Open(); // 定义要返回的列表 List <ZkNTest> ntestList = new List <ZkNTest>(); // 读取项目分层列表 List <string> layerList = ProjectDataBase.ReadLayerNumberList(_projectName); // 读取钻孔列表,在钻孔列表中循环 List <string> zkList = ReadZkList(_projectName); for (int i = 0; i < zkList.Count; i++) { // 读取该钻孔的标贯/动探列表和分层列表 List <ZkNTest> zkNtestList = ReadZkNTest(_projectName, zkList[i]); List <ZkLayer> zkLayerList = ReadZkLayer(_projectName, zkList[i]); // 在标贯/动探列表中循环 foreach (ZkNTest ntest in zkNtestList) { // 循环查找该标贯/动探所属的分层,查找试验类型,并将符合的数据添加到要返回的列表中 int layerIndex = -1; for (int j = 0; j < zkLayerList.Count; j++) { if (ntest.Depth <= zkLayerList[j].Depth) { layerIndex = j; break; } } if (layerIndex != -1 && zkLayerList[layerIndex].Number == _layerNumber && ntest.Type == _type) { ntestList.Add(ntest); } } } // 返回赋值后的列表 return(ntestList); } }
/// <summary> /// 绘制钻孔柱状图函数 /// </summary> /// <param name="_path">输出文件的路径</param> /// <param name="_checkedZkList">选中的钻孔列表</param> /// <param name="_checkedScaleList">选中的比例尺列表</param> public static void OutputToCad(string _path, List <Borehole> _checkedZkList, List <double> _checkedScaleList) { // 实例化CAD对象 CAD cad = new CAD(); // 添加文字样式 DxfTextStyle style1 = cad.AddStyle("GB2312", "仿宋_GB2312.ttf", 1); DxfTextStyle style2 = cad.AddStyle("GB2312_08", "仿宋_GB2312.ttf", 0.8); // 循环绘图 for (int i = 0; i < _checkedZkList.Count; i++) { cad.DrawZk(i, Program.currentProject, ProjectDataBase.ReadProjectCompany(Program.currentProject), _checkedZkList[i], _checkedScaleList, style1, style2); } // 保存CAD文件 cad.SaveAsDwg(_path, 195 * _checkedZkList.Count / 8, 280, 195 * _checkedZkList.Count); }
/// <summary> /// 填充筛选ComboBox函数 /// </summary> private void InitialComboBox() { List <string> zklist = BoreholeDataBase.ReadZkList(Program.currentProject); zklist.Insert(0, "全部钻孔"); List <string> layerNumberlist = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNamelist = ProjectDataBase.ReadLayerNameList(Program.currentProject); List <string> layerlist = new List <string>(); for (int i = 0; i < layerNumberlist.Count; i++) { layerlist.Add(layerNumberlist[i] + " " + layerNamelist[i]); } layerlist.Insert(0, "全部分层"); this.SelectByZkComboBox.ItemsSource = zklist; this.SelectByLayerComboBox.ItemsSource = layerlist; this.SelectByZkComboBox.SelectedIndex = 0; this.SelectByLayerComboBox.SelectedIndex = 0; }
/// <summary> /// 筛选统计数据 /// </summary> /// <returns></returns> public static List <StatisticNTest> SelectStatisticData() { // 定义统计数据列表 List <StatisticNTest> statisticList = new List <StatisticNTest>(); // 定义分层分层编号列表、分层岩土名称列表、试验类型列表 List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); ZkNTest.ntype[] typeList = new ZkNTest.ntype[] { ZkNTest.ntype.N, ZkNTest.ntype.N10, ZkNTest.ntype.N635, ZkNTest.ntype.N120 }; // 在分层编号列表中循环,赋值统计数据列表 for (int i = 0; i < layerNumberList.Count; i++) { // 在试验类型列表中循环 for (int j = 0; j < typeList.Length; j++) { // 检查当前的分层编号和试验类型的组合下在数据库中是否有内容 List <ZkNTest> nTestList = BoreholeDataBase.ReadLayerNTest(Program.currentProject, layerNumberList[i], typeList[j]); if (nTestList.Count > 0) { // 提取符合条件的标贯/动探列表中的试验数据值 List <double> dataList = new List <double>(); foreach (ZkNTest nTest in nTestList) { dataList.Add(nTest.Value); } // 添加一组符合筛选条件的统计数据 StatisticNTest stateNTest = new StatisticNTest(layerNumberList[i], layerNameList[i], typeList[j], dataList, 6); statisticList.Add(stateNTest); } } } // 返回 return(statisticList); }
/// <summary> /// 带4个参数的构造函数,用于编辑分层 /// </summary> /// <param name="_lastDepth">上一层层底深度</param> /// <param name="_number">分层编号</param> /// <param name="_depth">层底深度</param> /// <param name="_description">分层描述</param> public ZkLayerDetail(double _lastDepth, string _number, double _depth, string _description) { InitializeComponent(); // 重新赋值窗体标题 this.Title = "编辑钻孔分层"; // 赋值上一层层底深度 LastDepth = _lastDepth; // 赋值各选框的候选项 this.LayerNumberComboBox.ItemsSource = ProjectDataBase.ReadLayerNumberList(Program.currentProject); this.LayerNameComboBox.ItemsSource = ProjectDataBase.ReadLayerNameList(Program.currentProject); this.LayerGeoComboBox.ItemsSource = ProjectDataBase.ReadLayerGeoList(Program.currentProject); // 定义层底深度输入框的工具提示 DefineToolTip(); // 赋值 this.LayerNumberComboBox.SelectedValue = _number; this.LayerDepthTextBox.Text = _depth.ToString(); this.LayerDescriptionTextBox.Text = _description; }
// 程序自检函数,检查必要设置并初始化 private void ProgramCheck() { // 如果数据存储路径注册表项不存在,则新建项并设置默认路径 if (!Program.IsExitProgramPath()) { Program.SetProgramPath(Program.defaultPath); } // 如果"小熠岩土勘察"文件夹不存在,则新建文件夹 if (!System.IO.Directory.Exists(Program.ReadProgramPath())) { System.IO.Directory.CreateDirectory(Program.ReadProgramPath()); } // 如果设置信息数据库不存在,则新建数据库,并初始化数据库表 if (!System.IO.File.Exists(Program.ReadProgramPath() + "\\设置信息.gsygeo")) { SettingDataBase.Create(); } // 清理空数据文件 ProjectDataBase.ClearEmpthProject(); }
/// <summary> /// 读取统计数据 /// </summary> /// <returns></returns> public static List <StatisticGAT> SelectStatisticData() { // 定义统计数据列表 List <StatisticGAT> _statisticList = new List <StatisticGAT>(); // 定义分层分层编号列表、分层岩土名称列表 List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); // 在分层编号列表中循环,赋值统计数据列表 for (int i = 0; i < layerNumberList.Count; i++) { // 检查当前的分层编号下在数据库中是否有内容,并添加数据到统计列表 List <GrainAnalysisTest> gatList = GrainAnalysisTestDataBase.SelectByZkAndLayer(Program.currentProject, "", layerNumberList[i]); if (gatList.Count > 0) { StatisticGAT statistic = new StatisticGAT(layerNumberList[i], layerNameList[i], gatList); _statisticList.Add(statistic); } } // 返回 return(_statisticList); }
/// <summary> /// 筛选统计数据 /// </summary> /// <returns></returns> public static List <StatisticRST> SelectStatisticData() { // 定义统计数据列表 List <StatisticRST> statisticList = new List <StatisticRST>(); // 定义分层编号列表、分层岩土名称列表、试验类型列表 List <string> layerNumberList = ProjectDataBase.ReadLayerNumberList(Program.currentProject); List <string> layerNameList = ProjectDataBase.ReadLayerNameList(Program.currentProject); // 在分层编号列表中循环,赋值统计数据列表 for (int i = 0; i < layerNumberList.Count; i++) { // 层号、岩土名称 string layerNumber = layerNumberList[i]; string layerName = layerNameList[i]; // 读取分层试验数据 List <RoutineSoilTest> rsts = RoutineSoilTestDataBase.SelectByZkAndLayer(Program.currentProject, "", layerNumber); List <double> datalist_waterLevel = new List <double>(); List <double> datalist_density = new List <double>(); List <double> datalist_specificGravity = new List <double>(); List <double> datalist_voidRatio = new List <double>(); List <double> datalist_saturation = new List <double>(); List <double> datalist_liquidLimit = new List <double>(); List <double> datalist_plasticLimit = new List <double>(); List <double> datalist_plasticIndex = new List <double>(); List <double> datalist_liquidityIndex = new List <double>(); List <double> datalist_compressibility = new List <double>(); List <double> datalist_modulus = new List <double>(); List <double> datalist_frictionAngle = new List <double>(); List <double> datalist_cohesion = new List <double>(); List <double> datalist_permeability = new List <double>(); for (int j = 0; j < rsts.Count; j++) { datalist_waterLevel.Add(rsts[j].waterLevel); datalist_density.Add(rsts[j].density); datalist_specificGravity.Add(rsts[j].specificGravity); datalist_voidRatio.Add(rsts[j].voidRatio); datalist_saturation.Add(rsts[j].saturation); datalist_liquidLimit.Add(rsts[j].liquidLimit); datalist_plasticLimit.Add(rsts[j].plasticLimit); datalist_plasticIndex.Add(rsts[j].plasticIndex); datalist_liquidityIndex.Add(rsts[j].liquidityIndex); datalist_compressibility.Add(rsts[j].compressibility); datalist_modulus.Add(rsts[j].modulus); datalist_frictionAngle.Add(rsts[j].frictionAngle); datalist_cohesion.Add(rsts[j].cohesion); datalist_permeability.Add(rsts[j].permeability); } // 赋值统计数据列表 statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[0], datalist_waterLevel, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[1], datalist_density, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[2], datalist_specificGravity, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[3], datalist_voidRatio, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[4], datalist_saturation, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[5], datalist_liquidLimit, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[6], datalist_plasticLimit, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[7], datalist_plasticIndex, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[8], datalist_liquidityIndex, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[9], datalist_compressibility, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[10], datalist_modulus, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[11], datalist_frictionAngle, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[12], datalist_cohesion, 6)); statisticList.Add(new StatisticRST(layerNumber, layerName, typeList[13], datalist_permeability, 6)); } // 返回 return(statisticList); }
/// <summary> /// 选择分层编号选框时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LayerNumberComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.LayerNameComboBox.SelectedIndex = this.LayerNumberComboBox.SelectedIndex; this.LayerGeoComboBox.SelectedIndex = this.LayerNumberComboBox.SelectedIndex; this.LayerDescriptionTextBox.Text = ProjectDataBase.ReadLayerDescriptionList(Program.currentProject)[this.LayerNumberComboBox.SelectedIndex]; }
/// <summary> /// Save命令的Executed事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CommandBindingSave_Executed(object sender, ExecutedRoutedEventArgs e) { // 新建项目的操作 if (isNew == true) { // 保存项目设置 projectSetting.Name = this.ProjectNameTextBox.Text; projectSetting.Province = this.ProjectProvinceTextBox.Text; projectSetting.City = this.ProjectCityTextBox.Text; // 检查项目名是否为空 if (string.IsNullOrEmpty(projectSetting.Name) || string.IsNullOrWhiteSpace(projectSetting.Name)) { return; } // 检测是否有同名项目 List <string> projectList = ProjectDataBase.ReadProjectList(); if (projectList != null && projectList.Contains(projectSetting.Name)) { MessageBox.Show("项目数据库中已存在名为\"" + projectSetting.Name + "\"的项目,无法新建项目。", "请检查项目名称", MessageBoxButton.OK, MessageBoxImage.Error); return; } // 创建项目数据库 ProjectDataBase.Create(projectSetting.Name); // 存储项目基本数据和公司数据 ProjectDataBase.EditProjectBasicInfo(projectSetting.Name, projectSetting.Name, projectSetting.Province, projectSetting.City); ProjectDataBase.EditProjectCompany(projectSetting.Name, projectSetting.CompanyName, projectSetting.CompanyCode, projectSetting.Drawer, projectSetting.Writer, projectSetting.Checker, projectSetting.Inspector, projectSetting.Approver, projectSetting.FinalApprover); // 删除旧分层数据,存储新分层数据 if (ProjectDataBase.ReadLayerNumberList(projectSetting.Name).Count > 0) { ProjectDataBase.DeleteAllLayer(projectSetting.Name); } if (projectSetting.LayerList != null) { for (int i = 0; i < projectSetting.LayerList.Count; i++) { string number = projectSetting.LayerList[i].Number; string name = projectSetting.LayerList[i].Name; string geo = projectSetting.LayerList[i].Geo; string description = projectSetting.LayerList[i].Description; ProjectDataBase.AddLayer(projectSetting.Name, number, name, geo, description); } } } // 非新建项目的操作 else { // 保存项目设置 string oldProjectName = projectSetting.Name; projectSetting.Name = this.ProjectNameTextBox.Text; projectSetting.Province = this.ProjectProvinceTextBox.Text; projectSetting.City = this.ProjectCityTextBox.Text; // 存储项目基本数据和公司数据 ProjectDataBase.EditProjectBasicInfo(oldProjectName, projectSetting.Name, projectSetting.Province, projectSetting.City); ProjectDataBase.EditProjectCompany(oldProjectName, projectSetting.CompanyName, projectSetting.CompanyCode, projectSetting.Drawer, projectSetting.Writer, projectSetting.Checker, projectSetting.Inspector, projectSetting.Approver, projectSetting.FinalApprover); // 删除旧分层数据,存储新分层数据 if (ProjectDataBase.ReadLayerNumberList(oldProjectName).Count > 0) { ProjectDataBase.DeleteAllLayer(oldProjectName); } if (projectSetting.LayerList != null) { for (int i = 0; i < projectSetting.LayerList.Count; i++) { string number = projectSetting.LayerList[i].Number; string name = projectSetting.LayerList[i].Name; string geo = projectSetting.LayerList[i].Geo; string description = projectSetting.LayerList[i].Description; ProjectDataBase.AddLayer(oldProjectName, number, name, geo, description); } } // 更改数据库文件名称,传递给主窗口更改数据文件名 oldFile = Program.ReadProgramPath() + "\\" + oldProjectName + ".gsygeo"; newFile = Program.ReadProgramPath() + "\\" + projectSetting.Name + ".gsygeo"; } // 关闭窗口 this.DialogResult = true; Program.currentProject = projectSetting.Name; this.Close(); }
/// <summary> /// 单击菜单"工具"-"导入旧版数据" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ImportOldDataMenu_Click(object sender, RoutedEventArgs e) { // 检查是否关闭当前项目 if (Program.currentProject != null) { MessageBox.Show("您有正处于打开状态的项目,请关闭当前项目后再执行本操作。"); return; } // 选择输出目录 string folderPath; System.Windows.Forms.FolderBrowserDialog programPathBrowser = new System.Windows.Forms.FolderBrowserDialog(); if (programPathBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { folderPath = programPathBrowser.SelectedPath; } else { return; } if (folderPath.Substring(folderPath.LastIndexOf(@"\") + 1) != "金浪岩土") { MessageBox.Show("选择的文件夹不正确,请选择\"金浪岩土\"文件夹!"); return; } // 耐心等候提示 MessageBox.Show("导入过程可能需要15-30秒的时间,请耐心等候,点击\"确定\"继续。"); // 遍历项目文件夹 List <string> projectlist = new List <string>(); List <string> ignoreprojectlist = new List <string>(); DirectoryInfo dir = new DirectoryInfo(folderPath); foreach (DirectoryInfo dChild in dir.GetDirectories("*")) { // 获取项目名称 string projectName = dChild.ToString(); // 获取项目文件夹路径 string projectPath = folderPath + @"\" + dChild + @"\"; // 新建项目 if (!string.IsNullOrEmpty(projectName) && !string.IsNullOrWhiteSpace(projectName)) { ProjectDataBase.Create(projectName); } // 读取分层信息 StreamReader reader = new StreamReader(projectPath + "基本信息.txt"); int countLine = 0; while (true) { countLine++; string line = reader.ReadLine(); if (countLine <= 3) { continue; } if (line == null) { break; } string number = line.Substring(0, line.IndexOf("/")); line = line.Substring(line.IndexOf("/") + 1); string name = line.Substring(0, line.IndexOf("/")); line = line.Substring(line.IndexOf("/") + 1); string description = line; string geo = "Q4al"; ProjectDataBase.AddLayer(projectName, number, name, geo, description); } reader.Close(); // 读取钻孔信息 List <string> numlist = ProjectDataBase.ReadLayerNumberList(projectName); List <string> deslist = ProjectDataBase.ReadLayerDescriptionList(projectName); DirectoryInfo dirZk = new DirectoryInfo(projectPath + @"钻孔\"); foreach (FileInfo dZkFile in dirZk.GetFiles("*.txt")) { // 读取基本信息 StreamReader zkReader = new StreamReader(projectPath + @"钻孔\" + dZkFile.ToString()); zkReader.ReadLine(); string zkname = zkReader.ReadLine(); zkReader.ReadLine(); double zkaltitude = Convert.ToDouble(zkReader.ReadLine()); BoreholeDataBase.AddZkBasicInfo(projectName, zkname, zkaltitude, Constants.NullNumber, Constants.NullNumber, Constants.NullNumber, Constants.NullNumber); zkReader.ReadLine(); // 读取分层信息 List <string> zknumberlist = new List <string>(); List <string> zknamelist = new List <string>(); List <string> zkgeolist = new List <string>(); List <string> zkdescriptionlist = new List <string>(); List <double> zkdepthlist = new List <double>(); while (true) { string line = zkReader.ReadLine(); if (line == "===取样===") { break; } zknumberlist.Add(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); zknamelist.Add(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); zkdepthlist.Add(Convert.ToDouble(line)); zkgeolist.Add("Q4al"); int index = numlist.IndexOf(zknumberlist[zknumberlist.Count - 1]); zkdescriptionlist.Add(deslist[index]); } BoreholeDataBase.AddLayerListToZk(projectName, zkname, zknumberlist, zknamelist, zkgeolist, zkdescriptionlist, zkdepthlist); // 读取取样信息 List <string> spnumberlist = new List <string>(); List <double> spdepthlist = new List <double>(); List <int> spisdisturbedlist = new List <int>(); countLine = 0; while (true) { string line = zkReader.ReadLine(); if (line == "===标贯===") { break; } countLine++; spnumberlist.Add(countLine.ToString()); spdepthlist.Add(Convert.ToDouble(line.Substring(0, line.IndexOf("/")))); line = line.Substring(line.IndexOf("/") + 1); spisdisturbedlist.Add(line == "扰" ? 1 : 0); } BoreholeDataBase.AddSampleListToZk(projectName, zkname, spnumberlist, spdepthlist, spisdisturbedlist); // 读取标贯信息 List <string> ntnumberlist = new List <string>(); List <double> ntdepthlist = new List <double>(); List <double> ntvaluelist = new List <double>(); List <string> nttypelist = new List <string>(); countLine = 0; while (true) { string line = zkReader.ReadLine(); if (line == null) { break; } countLine++; ntnumberlist.Add(countLine.ToString()); ntdepthlist.Add(Convert.ToDouble(line.Substring(0, line.IndexOf("/")))); line = line.Substring(line.IndexOf("/") + 1); ntvaluelist.Add(Convert.ToDouble(line)); nttypelist.Add("N"); } BoreholeDataBase.AddNTestListToZk(projectName, zkname, ntnumberlist, ntdepthlist, ntvaluelist, nttypelist); zkReader.Close(); } // 读取静力触探信息 DirectoryInfo dirJk = new DirectoryInfo(projectPath + @"静力触探\"); foreach (FileInfo dJkFile in dirJk.GetFiles("*.txt")) { // 读取基本信息 StreamReader jkReader = new StreamReader(projectPath + @"静力触探\" + dJkFile.ToString()); jkReader.ReadLine(); string jkname = jkReader.ReadLine(); jkReader.ReadLine(); double jkaltitude = Convert.ToDouble(jkReader.ReadLine()); CPTDataBase.AddJkBasicInfo(projectName, jkname, jkaltitude, Constants.NullNumber, Constants.NullNumber); jkReader.ReadLine(); // 读取分层信息 List <string> jknumberlist = new List <string>(); List <string> jknamelist = new List <string>(); List <string> jkgeolist = new List <string>(); List <string> jkdescriptionlist = new List <string>(); List <double> jkdepthlist = new List <double>(); while (true) { string line = jkReader.ReadLine(); if (line == "===Ps值===") { break; } jknumberlist.Add(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); jknamelist.Add(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); jkdepthlist.Add(Convert.ToDouble(line)); jkgeolist.Add("Q4al"); int index = numlist.IndexOf(jknumberlist[jknumberlist.Count - 1]); jkdescriptionlist.Add(deslist[index]); } CPTDataBase.AddLayerListToJk(projectName, jkname, jknumberlist, jknamelist, jkgeolist, jkdescriptionlist, jkdepthlist); // 读取Ps值信息 List <double> pslist = new List <double>(); while (true) { string line = jkReader.ReadLine(); if (line == null) { break; } pslist.Add(Convert.ToDouble(line)); } CPTDataBase.AddPsListToJk(projectName, jkname, pslist); } // 读取土工试验 StreamReader rstReader = new StreamReader(projectPath + @"土工试验\NormalTest.txt"); List <RoutineSoilTest> rsts = new List <RoutineSoilTest>(); while (true) { string line = rstReader.ReadLine(); if (line == null) { break; } string zkNumber = line.Substring(0, line.IndexOf("/")); line = line.Substring(line.IndexOf("/") + 1); double sampleDepth = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); string sampleLayer = ProjectDataBase.ReadLayerNumberList(projectName)[0]; List <ZkLayer> layers = BoreholeDataBase.ReadZkLayer(projectName, zkNumber); for (int i = 0; i < layers.Count; i++) { if (sampleDepth <= layers[i].Depth) { sampleLayer = layers[i].Number; break; } } double waterLevel = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double density = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double specificGravity = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double voidRatio = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double saturation = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double liquidLimit = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double plasticLimit = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double plasticIndex = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double liquidityIndex = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double compressibility = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double modulus = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double frictionAngle = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))) == 0 ? Constants.NullNumber : Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double cohesion = Convert.ToDouble(line.Substring(0, line.IndexOf("/"))) == 0 ? Constants.NullNumber : Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); line = line.Substring(line.IndexOf("/") + 1); double permeability = line.Substring(0, line.IndexOf("/")) == "0.000000E+000" ? Constants.NullNumber : Convert.ToDouble(line.Substring(0, line.IndexOf("/"))); RoutineSoilTest rst = new RoutineSoilTest(zkNumber, sampleDepth, sampleLayer, waterLevel, density, specificGravity, voidRatio, saturation, liquidLimit, plasticLimit, plasticIndex, liquidityIndex, compressibility, modulus, frictionAngle, cohesion, permeability); rsts.Add(rst); } rstReader.Close(); GC.Collect(); GC.WaitForPendingFinalizers(); RoutineSoilTestDataBase.Refresh(projectName, rsts); projectlist.Add(projectName); } // 成功提示 StringBuilder sb = new StringBuilder(); if (projectlist.Count > 0) { sb.AppendLine("已成功导入以下项目:"); for (int i = 0; i < projectlist.Count; i++) { sb.AppendLine((i + 1).ToString() + projectlist[i]); } } else { sb.AppendLine("没有导入任何项目。"); } MessageBox.Show(sb.ToString()); }
/// <summary> /// 查询某个分层的摩阻力列表,输出为StatisticPs列表形式 /// </summary> /// <param name="_projectName">项目名称</param> /// <param name="_layerNumber">分层编号</param> /// <returns></returns> public static List <StatisticPs> ReadLayerPsAsStatePs(string _projectName, string _layerNumber) { // 创建连接到项目信息数据库 string sql = "Data Source=" + Program.ReadProgramPath() + "\\" + _projectName + ".gsygeo"; using (SQLiteConnection conn = new SQLiteConnection(sql)) { // 打开连接 conn.Open(); // 定义要返回的列表 List <StatisticPs> psList = new List <StatisticPs>(); // 读取项目分层列表 List <string> layerList = ProjectDataBase.ReadLayerNumberList(_projectName); // 读取触探孔列表,在触探孔列表中循环 List <string> jkList = ReadJkList(_projectName); for (int i = 0; i < jkList.Count; i++) { // 读取该钻孔的摩阻力列表和分层列表 List <double> jkPsList = ReadJkPs(_projectName, jkList[i]); List <ZkLayer> jkLayerList = ReadJkLayer(_projectName, jkList[i]); // 计算输入的分层的深度范围 double oldLayerDepth, layerDepth; int layerIndex = -1; for (int j = 0; j < jkLayerList.Count; j++) { if (jkLayerList[j].Number == _layerNumber) { layerIndex = j; } } if (layerIndex != -1) { if (layerIndex == 0) { oldLayerDepth = 0; layerDepth = jkLayerList[layerIndex].Depth; } else { oldLayerDepth = jkLayerList[layerIndex - 1].Depth; layerDepth = jkLayerList[layerIndex].Depth; } } else { continue; } // 将当前触探孔中符合条件的摩阻力赋值要返回的列表 for (int j = (int)(oldLayerDepth * 10) + 1; j <= (int)(layerDepth * 10); j++) { psList.Add(new StatisticPs(jkList[i], (double)j / 10, jkPsList[j - 1])); } } // 返回赋值后的列表 return(psList); } }
/// <summary> /// 计算统计结果 /// </summary> /// <param name="_dt">从土质类型窗口获取的DataTable</param> /// <param name="_rstStaList">试验指标统计列表</param> /// <param name="_cptStaList">静力触探摩阻力统计列表</param> /// <param name="_ntestStaList">标贯/动探统计列表</param> public static void CalcuOutput(DataTable _dt, List <StatisticRST> _rstStaList, List <StatisticCPT> _cptStaList, List <StatisticNTest> _ntestStaList) { // 清空统计列表结构体 statisticListOutput.Clear(); // 赋值统计结构体列表 for (int i = 0; i < _dt.Rows.Count; i++) { // 更新当前的分层编号和分层名称 LayerNumber = ProjectDataBase.ReadLayerNumberList(Program.currentProject)[i]; LayerName = ProjectDataBase.ReadLayerNameList(Program.currentProject)[i]; // 获取传递的土质参数 StatisticResult.layerInfo = _dt.Rows[i]["layerInfo"].ToString(); StatisticResult.CptType = _dt.Rows[i]["currentCptType"].ToString(); StatisticResult.NTestType = _dt.Rows[i]["currentNTestType"].ToString(); // 根据传递的土质类型重新计算参数 CalcuByRst(_rstStaList); CalcuByCpt(_cptStaList, StatisticResult.CptType); CalcuByNTest(_ntestStaList, StatisticResult.NTestType); // 赋值其他参数 StatisticResult.CptParameter = StatisticResult.CptParameter == "/" ? "/" : StatisticResult.CptParameter.Substring(StatisticResult.CptParameter.IndexOf("=") + 1); StatisticResult.NTestParameter = StatisticResult.NTestParameter == "/" ? "/" : StatisticResult.NTestParameter.Substring(StatisticResult.NTestParameter.IndexOf("=") + 1); double[] tmp = new double[3] { 9999, 9999, 9999 }; double num; if (double.TryParse(StatisticResult.FrictionByRst, out num)) { tmp[0] = num; } if (double.TryParse(StatisticResult.FrictionByCpt, out num)) { tmp[1] = num; } if (double.TryParse(StatisticResult.FrictionByNTest, out num)) { tmp[2] = num; } StatisticResult.FrictionFinal = tmp.Min() < 9999 ? tmp.Min().ToString("0") : "/"; for (int k = 0; k < 3; k++) { tmp[k] = 9999; } if (double.TryParse(StatisticResult.CohesionByRst, out num)) { tmp[0] = num; } if (double.TryParse(StatisticResult.CohesionByCpt, out num)) { tmp[1] = num; } if (double.TryParse(StatisticResult.CohesionByNTest, out num)) { tmp[2] = num; } StatisticResult.CohesionFinal = tmp.Min() < 9999 ? tmp.Min().ToString("0") : "/"; // 添加到列表 statisticListOutput.Add(StatisticResult); } }
/// <summary> /// ListView控件的数据绑定函数 /// </summary> private void SetBindListView() { List <string> projectList = ProjectDataBase.ReadProjectList(); this.ProjectListListView.ItemsSource = projectList; }