コード例 #1
0
 public void Write(IFeatureClassReader reader, IProgressTracker tracker, string tableName, string displayName, string description)
 {
     if (tracker != null)
     {
         tracker.StartTracking("正在读取要素...", 100);
         tracker.Tracking("正在读取要素...", 30);
     }
     Feature[] features = reader.Read(tracker);
     if (tracker != null)
     {
         tracker.Tracking("读取要素结束。", 100);
     }
     //
     try
     {
         using (IDbCommand cmd = _dbConn.CreateCommand())
         {
             TransactionManager.BeginTransaction(_dbConn, cmd);
             //Create FeatureClass Table
             string[] fields = GetFieldTypes(reader.FieldNames, features);
             _adapter.CreateTable(_dbConn, true, "OID", "SHAPE", tableName, fields, cmd);
             //Create Annotation Table
             string[] annFields = null;
             if (reader.AnnoTable != null)
             {
                 annFields = GetAnnoTableFields();
                 _adapter.CreateTable(_dbConn, true, _adapter.GetAnnonKeyField(), "SHAPE", reader.AnnoTable, annFields, cmd);
             }
             //Insert Row Into BGIS_FeatureClass
             int span = Math.Min(100, features.Length);
             if (tracker != null)
             {
                 tracker.StartTracking("正在导入要素集\"" + displayName + "\"...", features.Length / span + 1);
             }
             //
             InsertFeatureClassRow(cmd, tableName, displayName, description,
                                   (reader.SpatialReference != null ? reader.SpatialReference.ToString() : string.Empty),
                                   0,
                                   string.Empty,
                                   reader.AnnoTable,
                                   reader.Envelope,
                                   reader.ShapeType,
                                   features.Length
                                   );
             //Insert Features
             InsertFeatures(cmd, features, fields, tableName, tracker, span, reader.AnnoTable, annFields);
             //Submit
             TransactionManager.Commit();
         }
     }
     catch (Exception ex)
     {
         TransactionManager.Rollback();
         throw ex;
     }
 }
コード例 #2
0
 public void Import(ICatalogItem fetClassItem, ICatalogItem locationItem, IProgressTracker tracker, string name, string displayName, string description)
 {
     using (IFeatureClassReader fetcReader = FeatureClassReaderFactory.GetFeatureClassReader(fetClassItem))
     {
         using (IFeatureClassWriter fetcWriter = FeatureClassWriterFactory.GetFetClassWriter(locationItem))
         {
             fetcWriter.Write(fetcReader, tracker, name, displayName, description);
         }
     }
 }