首页 > 代码库 > 锁定方式SDE中插入要素
锁定方式SDE中插入要素
[C#]
public static void LoadOnlyModeInsert(IFeatureClass featureClass, List < IGeometry > geometryList){ // Cast the feature class to the IFeatureClassLoad interface. IFeatureClassLoad featureClassLoad = (IFeatureClassLoad)featureClass; // Acquire an exclusive schema lock for the class. ISchemaLock schemaLock = (ISchemaLock)featureClass; try { schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); // Enable load-only mode on the feature class. featureClassLoad.LoadOnlyMode = true; using(ComReleaser comReleaser = new ComReleaser()) { // Create the feature buffer. IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer(); comReleaser.ManageLifetime(featureBuffer); // Create an insert cursor. IFeatureCursor insertCursor = featureClass.Insert(true); comReleaser.ManageLifetime(insertCursor); // All of the features to be created are classified as Primary Highways. int typeFieldIndex = featureClass.FindField("TYPE"); featureBuffer.set_Value(typeFieldIndex, "Primary Highway"); foreach (IGeometry geometry in geometryList) { // Set the feature buffer‘s shape and insert it. featureBuffer.Shape = geometry; insertCursor.InsertFeature(featureBuffer); } // Flush the buffer to the geodatabase. insertCursor.Flush(); } } catch (Exception) { // Handle the failure in a way appropriate to the application. } finally { // Disable load-only mode on the feature class. featureClassLoad.LoadOnlyMode = false; // Demote the exclusive schema lock to a shared lock. schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); }}
锁定方式SDE中插入要素
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。