管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2024-09-03 a9b99add3e1baa7fc49049247b8bf071e70a6005
SimuTools/FrmMain.cs
@@ -1,5 +1,7 @@
using SimuTools.Tools;
using SimuTools.Domain;
using SimuTools.Tools;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
@@ -7,8 +9,6 @@
{
    public partial class FrmMain : Form
    {
        private bool flag;
        public FrmMain()
        {
            InitializeComponent();
@@ -36,11 +36,21 @@
        private void btnTerrainPath_Click(object sender, EventArgs e)
        {
            selectFile(this.txtTerrainPath);
        }
        private void btnBuildingPath_Click(object sender, EventArgs e)
        {
            selectFile(this.txtBuildingPath);
        }
        private void selectFile(TextBox tb)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Tif files(*.tif)|*.tif|Tiff files (*.tiff)|*.tiff";
            dialog.RestoreDirectory = true;
            string path = this.txtTerrainPath.Text.Trim();
            string path = tb.Text.Trim();
            if (File.Exists(path))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(path);
@@ -48,7 +58,7 @@
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.txtTerrainPath.Text = dialog.FileName;
                tb.Text = dialog.FileName;
            }
        }
@@ -89,6 +99,7 @@
        {
            string serviceName = this.txtServiceName.Text.Trim();
            string terrainFile = this.txtTerrainPath.Text.Trim();
            string buildingFile = this.txtBuildingPath.Text.Trim();
            string waterPath = this.txtWaterPath.Text.Trim();
            string flowPath = this.txtFlowPath.Text.Trim();
            string outPath = this.txtOutPath.Text.Trim();
@@ -98,9 +109,9 @@
                ShowErr("服务名称,要求必填!");
                return;
            }
            if (!File.Exists(terrainFile))
            if (!File.Exists(terrainFile) || !File.Exists(buildingFile))
            {
                ShowErr("地形文件,要求必须存在!");
                ShowErr("地形和建筑文件,要求必须存在!");
                return;
            }
            if (!Directory.Exists(waterPath) || !Directory.Exists(flowPath) || !Directory.Exists(outPath))
@@ -109,27 +120,23 @@
                return;
            }
            if (flag) return;
            try
            {
                flag = true;
                LogOut.Info(">> 开始运行 >>");
                this.btnRun.Enabled = false;
                LogOut.Info("开始运行 >>");
                outPath = Path.Combine(outPath, serviceName);
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                Tools.Handle.Run(new Args(serviceName, terrainFile, buildingFile, waterPath, flowPath, outPath));
                stopWatch.Stop();
                Tools.Handle.Run(terrainFile, waterPath, flowPath, outPath);
                flag = false;
                LogOut.Info("<< 运行结束 <<");
                MessageBox.Show("运行结束!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btnRun.Enabled = true;
                LogOut.Info("运行结束 <<");
                MessageBox.Show("运行结束!\n耗时:" + GetSeconds(stopWatch.ElapsedMilliseconds) + " 秒", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                flag = false;
                this.btnRun.Enabled = true;
                LogOut.Error(ex.StackTrace);
                ShowErr("运行出错:" + ex.Message);
            }
@@ -139,5 +146,10 @@
        {
            MessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        private string GetSeconds(long milliseconds)
        {
            return (milliseconds / 1000.0).ToString();
        }
    }
}