как узнать можно ли редактировать слой из sde

0 голосов
спросил 21 Ноя, 06 от sschainik (4,900 баллов) в категории Программные продукты Esri
как узнать можно ли редактировать слой из данные которого хранятся в базе данных и получаются через sde?
т.е. надо получить данные о привилегиях пользолвателя на данный слой и зарегистрирован ли слой как версионный. или может есть функция которая возвращает список слоев которые можно редактировать

4 Ответы

0 голосов
ответил 30 Янв, 07 от filippov70 (5,320 баллов)
Используй

IsEditable Method (esriEditor)


Syntax

object.IsEditable (layer )

The IsEditable method syntax has the following object qualifier and arguments:

Part Description
object An object expression that evaluates to an object in the Applies To list.
layer Required. An IFeatureLayer object.

Return Value

Boolean

Product Availability

Available with ArcGIS Desktop.

Remarks

Use the IsEditable method to check if a particular layer is editable. For example, when the editor is started, it calls this method for each layer added to the Map. The layers that are editable are added to the editing environment.
< id="hhpopup" ="application/x-ole" id="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" height="0" width="0">< name="Width" value="26">< name="Height" value="26">< name="Command" value="A"></>
0 голосов
ответил 06 Фев, 07 от sschainik (4,900 баллов)
Спасибо.
А может знаете почему данный метод не срабатывает на машинах, у которых нет лицензии на редактирование?
0 голосов
ответил 07 Фев, 07 от sschainik (4,900 баллов)
Я тут ранее спутал IsEditable с CanEdit.
А про IsEditable в хелпе есть пример для VBA:
Public Sub DeleteSelectedFeatures()
Dim pDeleteSet As ISet
Dim pEditLayers As IEditLayers
Dim pEditor As IEditor
Dim pEnumLayer As IEnumLayer
Dim pFeature As IFeature
Dim pFeatureEdit As IFeatureEdit
Dim pFeatureCursor As IFeatureCursor
Dim pFeatureLayer As IFeatureLayer
Dim pFeatureSelection As IFeatureSelection
Dim pID As New UID
Dim pInvalidArea As IInvalidArea
Dim pSelectionSet As ISelectionSet
Dim bInOperation As Boolean
Dim DeletedFeatureCount As Integer
Dim LayerCount As Integer

On Error GoTo ErrorHandler

''Get a handle to the Editor extension
pID = "esriEditor.Editor"
Set pEditor = Application.FindExtensionByCLSID(pID)
If Not pEditor.EditState = esriStateEditing Then Exit Sub
Set pEditLayers = pEditor

If pEditor.SelectionCount = 0 Then Exit Sub

'Set up the InvalidArea object
Set pInvalidArea = New InvalidArea
Set pInvalidArea.Display = pEditor.Display

'Loop through the selected features and delete them
pEditor.StartOperation
bInOperation = True

pID = "{40A9E885-5533-11D0-98BE-00805F7CED21}" 'IGeoFeatureLayer
Set pEnumLayer = pEditor.Map.Layers(pID, True)
pEnumLayer.Reset
Set pFeatureLayer = pEnumLayer.Next
Do While Not pFeatureLayer Is Nothing
    'Check if feature layer is editable
    If pEditLayers.IsEditable(pFeatureLayer) Then
      Set pFeatureSelection = pFeatureLayer
      Set pSelectionSet = pFeatureSelection.SelectionSet
      ''Check if there is a selection
      If Not pSelectionSet.Count = 0 Then

        'Add each feature to a Set
        'and delete the set - need a Set incase there are related features
          Set pDeleteSet = New esriSystem.Set
          pSelectionSet.Search Nothing, False, pFeatureCursor
          Set pFeature = pFeatureCursor.NextFeature
          Do While Not pFeature Is Nothing
            pInvalidArea.Add pFeature
            pDeleteSet.Add pFeature
            DeletedFeatureCount = DeletedFeatureCount + 1
            Set pFeature = pFeatureCursor.NextFeature
          Loop
          pDeleteSet.Reset
          Set pFeatureEdit = pDeleteSet.Next
          Do While Not pFeatureEdit Is Nothing
            pFeatureEdit.DeleteSet pDeleteSet
            Set pFeatureEdit = pDeleteSet.Next
          Loop

      End If
    End If
    Set pFeatureLayer = pEnumLayer.Next
Loop

If DeletedFeatureCount = 0 Then
    pEditor.AbortOperation
Else
    pEditor.StopOperation ("Delete")
    bInOperation = False
End If

'Clear the selection and refresh the display
pEditor.Map.ClearSelection
pInvalidArea.Invalidate esriAllScreenCaches

Exit Sub

ErrorHandler:
If bInOperation Then
    pEditor.AbortOperation
End If
End Sub

Не подходит для отдельной программы на VB6
Может кто нибудь все таки знает как узнать можно ли редактировать слой из sde?
0 голосов
ответил 09 Фев, 07 от filippov70 (5,320 баллов)
public static IWorkspace GDBConnect(string Server, string Instance, string Password, string Database)
        {
                       
            IPropertySet pPropSet = new PropertySet();
            IWorkspaceFactory pSdeFact = new SdeWorkspaceFactory();

            IPropertySet with_1 = pPropSet;
            with_1.SetProperty("SERVER", Server);
            with_1.SetProperty("INSTANCE", Instance);
            with_1.SetProperty("DATABASE", Database);
            with_1.SetProperty("USER", "SDE");
            with_1.SetProperty("PASSWORD", Password);
            with_1.SetProperty("VERSION", "SDE.DEFAULT");

            try
            {
                return pSdeFact.Open(pPropSet, 0);


            }
            catch
            {

                return null;

            }

        }
это получаем СДЕ воркспэйс

дальше

pGDBW = GDBConnect(sGDBConnProp[0], sGDBConnProp[1], sGDBConnProp[2], sGDBConnProp[3]);
IFeatureWorkspace pFeatureWRSP = pGDBW as IFeatureWorkspace;
IFeatureClass OutfeatureClass;
OutfeatureClass = pFeatureWRSP.OpenFeatureClass(name);

потом

IDataset pDS = OutfeatureClass.FeatureDataset as IDataset;
IWorkspaceEdit pWKSE = pDS.Workspace as IWorkspaceEdit;



pWKSE.StartEditing(true);
                Console.WriteLine("Начало редактирования");
                pWKSE.StartEditOperation();
                редактируем
                pWKSE.StopEditOperation();
                pWKSE.StopEditing(true);

Добро пожаловать на сайт Вопросов и Ответов, где вы можете задавать вопросы по GIS тематике и получать ответы от других членов сообщества.
...