Beispiel #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                IDictionary <int, IGeometry> boundGeometrys = this.ucExtentSetting1.BoundGeometrys;
                if (boundGeometrys == null || boundGeometrys.Count <= 0)
                {
                    MessageBox.Show(@"请选择输出数据的范围!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (_layerFieldsList == null || !_layerFieldsList.Any(c => c.Checked))
                {
                    MessageBox.Show(@"请选择要输出的图层!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (string.IsNullOrWhiteSpace(this.ucSelectFile1.FileName))
                {
                    MessageBox.Show(@"请选择要输出数据的存放位置!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                AccessTools tools = new AccessTools(this.ucSelectFile1.FileName);
                foreach (UcLayerFields layerFields in _layerFieldsList)
                {
                    try
                    {
                        if (!layerFields.Checked)
                        {
                            continue;
                        }
                        DataTable dataTable =
                            FeatureClassUtil.FeatureClassToDataTable(layerFields.FeatureLayer.FeatureClass, boundGeometrys, null, layerFields.SelectedFieldDictionary);
                        if (tools.CreateTable(layerFields.SelectedFieldDictionary, layerFields.FeatureLayer.FeatureClass.AliasName))
                        {
                            tools.FillTable(dataTable);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                if (!string.IsNullOrEmpty(tools.GetStrErrorInfo()))
                {
                    MessageBox.Show(tools.GetStrErrorInfo());
                }
                else
                {
                    Process.Start(ucSelectFile1.FileName);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }