Esempio n. 1
0
        private void btnReadData_Click(object sender, EventArgs e)
        {
            Reset();
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (string.IsNullOrEmpty(ucAxfFolder.SelectedPath))
                {
                    return;
                }
                if (ucTargetFeatureClass.SelectFeatureLayer == null)
                {
                    return;
                }

                _axfInfoList = new List <AxfInfo>();
                List <FileInfo> axfFileInfos = FolderHelper.GetFileInfos(this.ucAxfFolder.SelectedPath,
                                                                         new List <string>()
                {
                    ".axf"
                });

                foreach (FileInfo axfFileInfo in axfFileInfos)
                {
                    if (axfFileInfo.Name.StartsWith("BackgroundLayers"))
                    {
                        continue;
                    }

                    if (db.Open(axfFileInfo.FullName))
                    {
                        System.Data.SqlServerCe.SqlCeResultSet pSqlCeResultSet = db.GetTableData("AXF_TABLES", null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                        dataGridView1.DataSource = pSqlCeResultSet;
                        List <AxfTables> pAxfTablesList = AxfTables.GetAxfTablesList(pSqlCeResultSet, dataGridView1);
                        foreach (AxfTables axfTables in pAxfTablesList)
                        {
                            if (axfTables.TableName != this.ucTargetFeatureClass.SelectFeatureLayer.Name)
                            {
                                continue;
                            }
                            pSqlCeResultSet          = db.GetTableData(axfTables.TableName, null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                            dataGridView1.DataSource = pSqlCeResultSet;
                            List <AxfField> pAxfFieldList = AxfField.GetAxfFieldList(pSqlCeResultSet, dataGridView1);
                            AxfInfo         pAxfInfo      = new AxfInfo
                            {
                                AddCount        = pAxfFieldList.Count(c => c.AxfStatus == 1),
                                ModifyCount     = pAxfFieldList.Count(c => c.AxfStatus == 2),
                                DeleteCount     = pAxfFieldList.Count(c => c.AxfStatus == 128),
                                NoEditCount     = pAxfFieldList.Count(c => c.AxfStatus == 0),
                                AxfFieldList    = pAxfFieldList,
                                SourceLayerName = axfTables.TableName
                            };
                            IFeatureClass sourceFeatureClass = FeatureClassUtil.GetFeatureClass(axfFileInfo.FullName, axfTables.TableName);
                            if (sourceFeatureClass == null)
                            {
                                pAxfInfo.IsSelect = false;
                            }
                            else
                            {
                                pAxfInfo.IsSelect = true;
                            }
                            pAxfInfo.SourceFeatureClass = sourceFeatureClass;
                            pAxfInfo.TargetLayerName    = this.ucTargetFeatureClass.SelectFeatureLayer.Name;
                            pAxfInfo.TargetFeatureLayer = this.ucTargetFeatureClass.SelectFeatureLayer;
                            pAxfInfo.AxfFilePath        = axfFileInfo.FullName;

                            _axfInfoList.Add(pAxfInfo);
                        }

                        db.Close();
                    }
                }
                dataGridView2.DataSource = _axfInfoList;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 2
0
        private void LoadDatabase(string fileName)
        {
            Reset();
            try
            {
                if (!File.Exists(fileName))
                {
                    throw new Exception(string.Format(GlobalText.GetValue("FileNotFound") + ": '{0}'", fileName));
                }

                this.Cursor = Cursors.WaitCursor;

                if (db.Open(fileName))
                {
                    System.Data.SqlServerCe.SqlCeResultSet pSqlCeResultSet = db.GetTableData("AXF_TABLES", null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                    dataGridView1.DataSource = pSqlCeResultSet;
                    List <AxfTables> pAxfTablesList = AxfTables.GetAxfTablesList(pSqlCeResultSet, dataGridView1);
                    pSqlCeResultSet          = db.GetTableData("GEOMETRY_COLUMNS", null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                    dataGridView1.DataSource = pSqlCeResultSet;
                    List <AXF_GEOMETRY_COLUMNS> pAxfGeometryColumnss =
                        AXF_GEOMETRY_COLUMNS.GetAxfGeometryColumns(pSqlCeResultSet, dataGridView1);
                    pSqlCeResultSet          = db.GetTableData("AXF_LAYERS", null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                    dataGridView1.DataSource = pSqlCeResultSet;
                    List <AXF_LAYERS> pAxfLayerss = AXF_LAYERS.GetAxfLayerss(pSqlCeResultSet, dataGridView1);
                    _axfInfoList = new List <AxfInfo>();
                    foreach (AxfTables axfTables in pAxfTablesList)
                    {
                        pSqlCeResultSet          = db.GetTableData(axfTables.TableName, null, SortOrder.None) as System.Data.SqlServerCe.SqlCeResultSet;
                        dataGridView1.DataSource = pSqlCeResultSet;
                        List <AxfField> pAxfFieldList = AxfField.GetAxfFieldList(pSqlCeResultSet, dataGridView1);
                        AxfInfo         pAxfInfo      = new AxfInfo
                        {
                            AddCount        = pAxfFieldList.Count(c => c.AxfStatus == 1),
                            ModifyCount     = pAxfFieldList.Count(c => c.AxfStatus == 2),
                            DeleteCount     = pAxfFieldList.Count(c => c.AxfStatus == 128),
                            NoEditCount     = pAxfFieldList.Count(c => c.AxfStatus == 0),
                            AxfFieldList    = pAxfFieldList,
                            SourceLayerName = axfTables.TableName
                        };

                        AXF_GEOMETRY_COLUMNS axfGeometryColumns = pAxfGeometryColumnss.FirstOrDefault(c => c.TableName == pAxfInfo.SourceLayerName);
                        if (axfGeometryColumns == null)
                        {
                            return;
                        }
                        int        pAxfTableId = axfGeometryColumns.TableId;
                        AXF_LAYERS axfLayers   = pAxfLayerss.FirstOrDefault(c => c.TableId == pAxfTableId);
                        if (axfLayers == null)
                        {
                            return;
                        }
                        string layerName = axfLayers.Name;

                        //IFeatureLayer tempFeatureLayer = _featureLayerList.FirstOrDefault(c => c.Name == layerName);
                        //if (tempFeatureLayer != null)
                        //    if (CheckIsAxfLayer(tempFeatureLayer))
                        //    {
                        //        pAxfInfo.SourceLayerName = tempFeatureLayer.Name;
                        //        pAxfInfo.SourceFeatureLayer = tempFeatureLayer;
                        //    }
                        //    else
                        //    {
                        //        pAxfInfo.TargetLayerName = tempFeatureLayer.Name;
                        //        pAxfInfo.TargetFeatureLayer = tempFeatureLayer;
                        //    }

                        _axfInfoList.Add(pAxfInfo);
                    }

                    dataGridView2.DataSource = _axfInfoList;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            this.Cursor = Cursors.Default;
        }