Create, query and edit a specific server version using service geodatabase.
Use case
Workflows often progress in discrete stages, with each stage requiring the allocation of a different set of resources and business rules. Typically, each stage in the overall process represents a single unit of work, such as a work order or job. To manage these, you can create a separate, isolated version and modify it. Once this work is complete, you can integrate the changes into the default version.
How to use the sample
Once loaded, the map will zoom to the extent of the feature layer. The current version is indicated at the top of the map. Click "Create Version" to open a dialog to specify the version information (name, access, and description). See the Additional information section for restrictions on the version name.
Click "Create" to create the version with the information that you specified. Select a feature to edit an attribute and/or click a second time to relocate the point.
Click the button in the top left corner to switch back and forth between the version you created and the default version. Edits will automatically be applied to your version when switching to the default version.
How it works
- Create and load a
ServiceGeodatabase
with a feature service URL that has enabled Version Management. - Get the
ServiceFeatureTable
from the service geodatabase. - Create a
FeatureLayer
from the service feature table. - Create
ServiceVersionParameters
with a unique name,VersionAccess
, and description.- Note - See the additional information section for more restrictions on the version name.
- Create a new version calling
ServiceGeodatabase.CreateVersionAsync
passing in the service version parameters. - Get the
Name
property from theServiceVersionInfo
of the version created. - Switch to the version you have just created using
ServiceGeodatabase.SwitchVersionAsync
, passing in the version name obtained from the service version info from step 6. - Select a
Feature
from the map to edit its "TYPDAMAGE" attribute and location. - Apply these edits to your version by calling
ServiceGeodatabase.ApplyEditsAsync
. - Switch back and forth between your version and the default version to see how the two versions differ.
Relevant API
- FeatureLayer
- ServiceFeatureTable
- ServiceGeodatabase
- ServiceGeodatabase.ApplyEditsAsync
- ServiceGeodatabase.CreateVersionAsync
- ServiceGeodatabase.SwitchVersionAsync
- ServiceVersionInfo
- ServiceVersionParameters
- VersionAccess
About the data
The feature layer used in this sample is Damage to commercial buildings located in Naperville, Illinois.
Additional information
Credentials:
- Username: editor01
- Passowrd: editor01.password
The name of the version must meet the following criteria:
- Must not exceed 62 characters
- Must not include: Period (.), Semicolon (;), Single quotation mark ('), Double quotation mark (")
- Must not include a space for the first character
- Note - the version name will have the username and a period (.) prepended to it. E.g "editor01.MyNewUniqueVersionName"
Branch versioning access permission:
- VersionAccess.Public - Any portal user can view and edit the version.
- VersionAccess.Protected - Any portal user can view, but only the version owner, feature layer owner, and portal administrator can edit the version.
- VersionAccess.Private - Only the version owner, feature layer owner, and portal administrator can view and edit the version.
Tags
branch versioning, edit, version control, version management server
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.EditBranchVersioning.EditBranchVersioning"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock
FontWeight="SemiBold" Text="Click to select a feature, then change its damage type." TextWrapping="Wrap" />
<TextBlock x:Name="CurrentVersionLabel"
Margin="5"
Text="Current version:" />
<Button x:Name="CreateVersionButton"
Content="Create version" IsEnabled="False"
Click="VersionButtonPressed" />
</StackPanel>
</Border>
<Border x:Name="VersionCreator"
Style="{StaticResource BorderStyle}"
HorizontalAlignment="Center" VerticalAlignment="Center"
Visibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0" Grid.Column="0"
Text="Name:" />
<TextBox x:Name="NameEntryBox"
Grid.Row="0" Grid.Column="1"
Margin="5" />
<TextBlock
Grid.Row="1" Grid.Column="0"
Text="Access:" />
<ComboBox x:Name="AccessBox"
Grid.Row="1" Grid.Column="1"
Margin="5" />
<TextBlock
Grid.Row="2" Grid.Column="0"
Text="Description:" />
<TextBox x:Name="DescriptionBox"
Grid.Row="2" Grid.Column="1"
Margin="5" />
<Button
Grid.Row="3" Grid.Column="0"
Margin="5"
Content="Create"
Click="ConfirmVersionClick" />
<Button
Grid.Row="3" Grid.Column="1"
Margin="5"
Content="Cancel"
Click="CancelVersionClick" />
</Grid>
</Border>
<Border x:Name="AttributePicker"
Style="{StaticResource BorderStyle}"
HorizontalAlignment="Left"
Visibility="Collapsed">
<StackPanel>
<TextBlock
Margin="5"
Text="Click to move feature."
Visibility="Collapsed"/>
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="5"
Text="Damage:" />
<ComboBox x:Name="DamageBox"
Margin="5"
SelectionChanged="DamageBox_SelectionChanged" />
</StackPanel>
<Button x:Name="CloseButton"
Margin="5"
Content="Close"
Click="CloseAttributeClick" />
</StackPanel>
</Border>
</Grid>
</UserControl>