zoukankan      html  css  js  c++  java
  • 锁定方式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);
        }
    }
  • 相关阅读:
    Understanding identities in IIS
    Name your feature branches by convention
    Branch policies on Azure Repos
    Use Git Credential Managers to Authenticate to Azure Repos
    How do I force my .NET application to run as administrator?
    UML的类型
    ASP.NET Error Handling
    通过泛型,将string转换为指定类型
    Spring Session + Redis实现分布式Session共享
    MongoDB中的数据导出为excel CSV 文件
  • 原文地址:https://www.cnblogs.com/liwenqiang/p/4109457.html
Copyright © 2011-2022 走看看