Beispiel #1
0
        public override void OnClick()
        {
            System.Data.IDbConnection resultConnection = CheckApplication.CurrentTask.ResultConnection as System.Data.OleDb.OleDbConnection;
            if (resultConnection == null)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("当前任务状态被标记为已创建,但结果库可能已被移除。");
                return;
            }

            System.Windows.Forms.SaveFileDialog dlgShpFile = new System.Windows.Forms.SaveFileDialog();
            dlgShpFile.FileName = Environment.CurrentDirectory + "\\" + CheckApplication.CurrentTask.Name + ".xls";
            dlgShpFile.Filter   = "SHP 文件|*.Shp";
            if (dlgShpFile.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string strFile = dlgShpFile.FileName;
            string strPath = System.IO.Path.GetDirectoryName(strFile);
            string strName = System.IO.Path.GetFileNameWithoutExtension(strFile);

            Hy.Check.Task.Task curTask  = CheckApplication.CurrentTask;
            ErrorExporter      exporter = new ErrorExporter();

            exporter.BaseWorkspace    = curTask.BaseWorkspace;
            exporter.ResultConnection = curTask.ResultConnection;
            exporter.SchemaID         = curTask.SchemaID;
            exporter.Topology         = curTask.Topology;
            exporter.ExportToShp(strPath, strName);
        }
Beispiel #2
0
        public override void OnClick()
        {
            System.Data.IDbConnection resultConnection = CheckApplication.CurrentTask.ResultConnection as System.Data.OleDb.OleDbConnection;
            if (resultConnection == null)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("当前任务状态被标记为已创建,但结果库可能已被移除。");
                return;
            }

            System.Windows.Forms.SaveFileDialog dlgExcelFile = new System.Windows.Forms.SaveFileDialog();
            dlgExcelFile.FileName        = Environment.CurrentDirectory + "\\" + CheckApplication.CurrentTask.Name + ".xls";
            dlgExcelFile.Filter          = "Excel 文件|*.excel";
            dlgExcelFile.OverwritePrompt = true;
            if (dlgExcelFile.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            if (System.IO.File.Exists(dlgExcelFile.FileName))
            {
                try
                {
                    System.IO.File.Delete(dlgExcelFile.FileName);
                }
                catch
                {
                    XtraMessageBox.Show("文件删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            string strFile = dlgExcelFile.FileName;

            CheckApplication.ProgressBar.ShowHint("正在读取错误记录……");
            System.Data.DataTable dtError = ErrorExporter.GetError(resultConnection);
            if (ErrorExporter.ExportToExcel(CheckApplication.ProgressBar, dtError, strFile))
            {
                XtraMessageBox.Show("导出错误记录到Excel文件成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                XtraMessageBox.Show("导出错误记录到Excel文件失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            CheckApplication.ProgressBar.Hide();
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            System.Data.IDbConnection resultConnection = CheckApplication.CurrentTask.ResultConnection as System.Data.OleDb.OleDbConnection;
            if (resultConnection == null)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("当前任务状态被标记为已创建,但结果库可能已被移除。");
                return;
            }

            System.Windows.Forms.SaveFileDialog dlgShpFile = new System.Windows.Forms.SaveFileDialog();
            dlgShpFile.FileName        = Environment.CurrentDirectory + "\\" + CheckApplication.CurrentTask.Name + ".shp";
            dlgShpFile.Filter          = "SHP 文件|*.Shp";
            dlgShpFile.OverwritePrompt = true;
            if (dlgShpFile.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string strFile = dlgShpFile.FileName;
            string strPath = System.IO.Path.GetDirectoryName(strFile);
            string strName = System.IO.Path.GetFileNameWithoutExtension(strFile);

            // 检查已存在
            if (System.IO.File.Exists(strFile))
            {
                //System.IO.File.Delete(dlgShpFile.FileName);
                try
                {
                    IWorkspace ws    = Hy.Common.Utility.Esri.AEAccessFactory.OpenWorkspace(enumDataType.SHP, strPath);
                    IDataset   dsShp = (ws as IFeatureWorkspace).OpenFeatureClass(strName) as IDataset;
                    if (dsShp != null)
                    {
                        dsShp.Delete();
                    }
                }
                catch
                {
                    try
                    {
                        System.IO.File.Delete(strFile);
                    }
                    catch
                    {
                        XtraMessageBox.Show("文件删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            // 开始导出
            CheckApplication.GifProgress.ShowHint("正在导出错误结果到Shp文件,请稍候……");

            Hy.Check.Task.Task curTask  = CheckApplication.CurrentTask;
            ErrorExporter      exporter = new ErrorExporter();

            exporter.BaseWorkspace    = curTask.BaseWorkspace;
            exporter.ResultConnection = curTask.ResultConnection;
            exporter.SchemaID         = curTask.SchemaID;
            exporter.Topology         = curTask.Topology;

            bool isSucceed = exporter.ExportToShp(strPath, strName);

            CheckApplication.GifProgress.Hide();
            GC.Collect();

            if (isSucceed)
            {
                XtraMessageBox.Show("导出Shp成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                XtraMessageBox.Show("导出Shp失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }