Book a Demo

Author Topic: Checkout offline leaves users stranded  (Read 13696 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Checkout offline leaves users stranded
« on: November 17, 2021, 08:53:43 pm »
We use version control on some parts of our model that are extra sensitive (generate code) or that are shared by different repositories.

Only a limited set of users needs to edit these packages, and thus only those users have access to the version control system. (Azure Devops in our case)

The other users get a popup regarding uncompleted version control settings, but when they check the checkbox "don't bother me again", this popup doesn't appear again, and all is well.

BUT,... from time to time we get a user that is too nosy, too "I'll figure it out myself" and that does a check-out despite not having configured version control.
EA then helpfully proposes to do a "Checkout Offline". The user ofcourse ignores all warnings and goes ahead to with it, ending up with a checked-out offline package.

Usually by now the users discovers he has done something wrong, and calls for help.
The problem is that there is no way to rectify this situation (that I know of) using the GUI.
The only way I know to solve that problem is to remove the "checkedOutOffline=1" flag from the t_package.PackageFlags

Is there a better way of solving this that I don't know?
Should we consider this behavior, where a user can paint himself in a corner, a bug?

For those coming across the same problem, I wrote a little script to fix the problem:

Code: [Select]
'[path=\Projects\Project A\Model Management]
'[group=Model Management]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: Remove Checkout-offline
' Author: Geert Bellekens
' Purpose: Removes the flag "Checkeout offline" from the selected package
' Date: 2019-04-03
'
const outPutName = "Remove Checkout Offline"

sub main
'create output tab
Repository.CreateOutputTab outPutName
Repository.ClearOutput outPutName
Repository.EnsureOutputVisible outPutName
'get selected package
dim selectedPackage as EA.Package
set selectedPackage = Repository.GetTreeSelectedPackage
if not selectedPackage is nothing then
'ask for confirmation
dim userIsSure
userIsSure = Msgbox("Are you sure you want to remove the checkout-offline from the package '" &selectedPackage.Name & "' '", vbYesNo+vbExclamation, "Remove Checkout-offline" )
if userIsSure = vbYes then
'Repository.WriteOutput outPutName, now() & " Starting delete package tree for package '"& selectedPackage.Name &"'", 0
'delete the package using it's parent
removeCheckoutOffline selectedPackage
' 'refresh
' Repository.RefreshModelView 0
'let user know
Repository.WriteOutput outPutName, now() & " Removed checkout-offline from '"& selectedPackage.Name &"'", 0
end if
end if
end sub

function removeCheckoutOffline(package)
dim sqlUpdate
sqlUpdate = "update p set p.PackageFlags = LEFT (p.PackageFlags, patindex('%CheckedOutOffline=1%',p.PackageFlags)-1)    " & vbNewLine & _
" from t_package p                                                                                          " & vbNewLine & _
" where p.PackageFlags like '%CheckedOutOffline=1%'                                                         " & vbNewLine & _
" and p.ea_guid = '" & package.PackageGUID & "'                                                             "
Repository.Execute sqlUpdate
'Reload package
Repository.ReloadPackage package.PackageID
end function

main

Geert