Esempio n. 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);
        }
Esempio n. 2
0
        /// <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);
            }
        }