Ejemplo n.º 1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            var dialog = new FolderBrowserDialog {
                Description = "请选择数据成果所在文件夹"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                _dataPath    = dialog.SelectedPath;
                lblPath.Text = _dataPath;
                var configDoc = ConfigDocument;

                var mdbPath = string.Empty;
                if (FileListHelper.LoadFileList(_dataPath, configDoc, treeView2, ref mdbPath) == false)
                {
                    MessageBox.Show("成果中缺少必要的文件夹或文件,请检查文件列表。", "缺少文件", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tabControl2.SelectTab(1);
                }
                btnStart.Enabled = true;

                _mdbPath = mdbPath;
                if (string.IsNullOrEmpty(mdbPath) == false)
                {
                    try
                    {
                        FileListHelper.LoadMapData(_mdbPath, axMapControl1, configDoc);
                        Full();
                    }
                    catch
                    {
                        MessageBox.Show("数据库格式有误或缺少必要图层", "数据库错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            var dialog = new FolderBrowserDialog {
                Description = "请选择数据成果所在文件夹"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                _dataPath    = dialog.SelectedPath;
                lblPath.Text = _dataPath;
                var configDoc = ConfigDocument;

                var mdbPath = string.Empty;
                var mdbfile = FolderExtensions.GetFiles(_dataPath, "*.mdb").FirstOrDefault();
                this.btnIdentity3.Enabled       = false;
                this.btnAttributeSearch.Enabled = false;
                this.btnAddLayer.Enabled        = false;
                if (mdbfile == null)
                {
                    MessageBox.Show("成果中缺失空间数据库文件,请核对!");
                }
                else
                {
                    mdbPath = mdbfile.FullName;
                    this.btnIdentity3.Enabled = true;
                }
                var folder1  = System.IO.Path.Combine(_dataPath, "1空间数据库");
                var codefile = FolderExtensions.GetFiles(folder1, "*.xls").FirstOrDefault();
                if (codefile == null)
                {
                    MessageBox.Show("成果中缺失单位代码表文件,请核对!");
                }
                else
                {
                    _codePath = codefile.FullName;
                    ExcelManager.Init(_codePath);
                    this.btnAttributeSearch.Enabled = true;
                }
                this.btnXJ.Enabled    = System.IO.Directory.Exists(System.IO.Path.Combine(_dataPath, "2栅格图件", "县级成果"));
                this.btnZJ.Enabled    = System.IO.Directory.Exists(System.IO.Path.Combine(_dataPath, "2栅格图件", "乡镇级成果"));
                this.btnExcel.Enabled = System.IO.Directory.Exists(System.IO.Path.Combine(_dataPath, "3统计表格"));
                var docFolder = System.IO.Path.Combine(_dataPath, "4文档报告");
                var docus     = FolderExtensions.GetFiles(docFolder, "*.doc");
                this.btnWorkWord.Enabled  = false;
                this.btnTechnique.Enabled = false;
                _docs = docus;


                foreach (var item in docus)
                {
                    if (Regex.IsMatch(item.FileName, @"^[\u4e00-\u9fa5]{3,}\(33[0-9]{4}\)农村存量建设用地调查工作报告.doc$"))
                    {
                        this.btnWorkWord.Enabled = true;
                    }

                    if (Regex.IsMatch(item.FileName, @"^[\u4e00-\u9fa5]{3,}\(33[0-9]{4}\)农村存量建设用地调查技术报告.doc$"))
                    {
                        this.btnTechnique.Enabled = true;
                    }
                }
                this.btnAddLayer.Enabled      = true;
                this.dataGridView1.DataSource = null;
                this.dataGridView2.DataSource = null;


                _mdbPath = mdbPath;
                if (string.IsNullOrEmpty(mdbPath) == false)
                {
                    try
                    {
                        FileListHelper.LoadMapData2(_mdbPath, axMapControl1, configDoc);

                        Full();
                    }
                    catch
                    {
                        MessageBox.Show("数据库格式有误或缺少必要图层", "数据库错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                var KZMJ = FolderExtensions.GetFiles2(folder1, new string[] { "*.shp" }).FirstOrDefault();
                if (KZMJ != null)
                {
                    FileListHelper.LoadKZBJ(KZMJ, axMapControl1);
                }

                var rasterfiles = FolderExtensions.GetFiles2(folder1, new string[] { "*.img" });
                foreach (var item in rasterfiles)
                {
                    FileListHelper.LoadRasterData(item, this.axMapControl1);
                }
            }
        }