Book a Demo

Author Topic: Check out branch ...  (Read 5621 times)

sunbird

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Check out branch ...
« on: October 16, 2009, 11:35:39 pm »
Hello together,

I work successfully with a versioncontrolled modell in EA.
For the make of a baseline I need to check out all subpackages.
It would be nice to have an option to "check out branch ...", like there is the "check in branch..." option.

Regards

Sunbird

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Check out branch ...
« Reply #1 on: October 19, 2009, 07:35:40 pm »
You can do this with the Scripting window (and someone can improve those scripts...):

"CHECK-OUT BRANCH" SCRIPT:

If GetTreeSelectedItemType = 5 Then
      Call IteratePackages (GetTreeSelectedPackage, inputbox("Comment: ", "Check-Out branch", date & " - " & time))
Else
      MsgBox "The selected object doesn’t support this functionality. Select a Model, View or Package.", vbInformation
End If

Sub IteratePackages (Package, Comment)
    Status = Package.VersionControlGetStatus
    If Status <> 1 Then 'If isn’t in Check-in state
        If Status <> 2 Then 'If isn’t in Check-out for me
            MsgBox "Impossible to make Check-Out of the Package " & Package.Name
        End If
    Else
        Package.VersionControlCheckout (Comment)
        RefreshModelView (Package.PackageID)
    End If
    For i = 0 To Package.Packages.Count - 1
        Call IteratePackages(Package.Packages.GetAt(i), Comment)
    Next
End Sub

"UNCONFIGURE BRANCH" SCRIPT:

If GetTreeSelectedItemType = 5 Then
      Call IteratePackages (GetTreeSelectedPackage())
Else
      MsgBox " The selected object doesn’t support this functionality. Select a Model, View or Package.", vbInformation
End If

Sub IteratePackages (Package)
    Status = Package.VersionControlGetStatus
    If Status <> 0 Then
        If Status = 2 Then
            MsgBox "The Package '" & Package.Name & "' can’t be unconfigured until it’s in Check-In state.", , "Checked-Out Package"
        Else
            Package.VersionControlRemove
            RefreshModelView (Package.PackageID)
        End If
    End If
    For i = 0 To Package.Packages.Count - 1
        Call IteratePackages (Package.Packages.GetAt(i))
    Next
End Sub

Henrique Narciso

  • EA User
  • **
  • Posts: 86
  • Karma: +0/-0
    • View Profile
Re: Check out branch ...
« Reply #2 on: October 27, 2009, 10:04:19 pm »
hello!

has anyone tried this code?

any improvements?

I'm doing it in C#, once it's done I'll paste it here.

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Check out branch ...
« Reply #3 on: October 27, 2009, 10:13:58 pm »
The code works, I use this functions everyday... but obviously it could be improved, with i.e. "OK to all" button when the subpackages can't be checked-out... possibility to stop during massive process...
« Last Edit: October 27, 2009, 10:20:07 pm by Deiser »

Henrique Narciso

  • EA User
  • **
  • Posts: 86
  • Karma: +0/-0
    • View Profile
Re: Check out branch ...
« Reply #4 on: October 27, 2009, 10:31:08 pm »
great Luis!

Anyone has it in C#?

Henrique Narciso

  • EA User
  • **
  • Posts: 86
  • Karma: +0/-0
    • View Profile
Re: Check out branch ...
« Reply #5 on: October 28, 2009, 12:08:17 am »
Here is the C# code!


public void EA_checkout(EA.Repository Repository, string Location, string MenuName, string ItemName)
        {

            //"CHECK-OUT BRANCH" SCRIPT:
            
           // EA.Package pck;
            string  TreeSelectedItemType = Repository.GetTreeSelectedItemType().ToString();
            
            string comment = "Comment: Check-Out branch" + DateTime.Now.ToString();

            EA.Package EAPackage = Repository.GetTreeSelectedPackage();

            if (TreeSelectedItemType == "otPackage"){
                 IteratePackages (Repository , EAPackage, comment );
            }            
            else{
                MessageBox.Show("The selected object doesn’t support this functionality. Select a Model, View or Package.");
            }
            

        }
            private void IteratePackages (EA.Repository Repository,EA.Package Package, string Comment)
            {
               int Status = Package.VersionControlGetStatus();
               if (Status != 1)
                {//If isn’t in Check-in state
                   if (Status != 2)
                    { //If isn’t in Check-out for me
                       MessageBox.Show  ("Impossible to make Check-Out of the Package " + Package.Name);
                   }
               }

               Package.VersionControlCheckout (Comment);
               Repository.RefreshModelView (Package.PackageID);
              
                
                for (short i = 0; i < Package.Packages.Count; i++)
                {

                    EA.Package thisPackage = (EA.Package)Package.Packages.GetAt(i);

                    IteratePackages(Repository ,thisPackage,Comment );

                }
                              
        }