Basically I am working on a project where I can select an excel document within clearCase and run my ribbon program which updates the tables onto it. What I want to do in VisualStudio is make it so that the document, gets checked out when you run my addin, but then checks it back in once it is done running.
Is this possible?
Thanks for the help.
There is a very powerfull command tool for ClearCase named cleartool.
Here the full reference ClearTool Help
I would suggest you use Process.Start() to trigger check-in/check-out operations.
The syntax might be very simple like:
cleartool checkout "filename"
Another option would be to use ClearCase COM API. I am not sure they have a .NET library as well. Jus google for "ClearCase Automation Library (CAL)".
In fact those do the same job the same way. There are only twotop-level CAL objects that can be used to execute a cleartool sub-command. One of them is Clearcase.Cleartool object (which only has one method CMDEXE).
You can use the CAL interface (Rational ClearCase Automation Library) and call the appropriate command from a VB script (or a VB macro from Excel).
In this CAL script example, you can see several ways to do just that, including creating a cleartool object.
Set CL = CreateObject("ClearCase.ClearTool")
Here is another example, where a checkout is performed from a VB script:
Dim CC As object
Dim Ver As object
Dim CheckedOutFile As object
On Error Resume Next
Set CC = CreateObject("ClearCase.Application")
'Return message regarding ability to connect to Clearcase
If CC Is Nothing Then
MsgBox "NOTHING"
Exit Sub
Else
MsgBox "CONNECTED"
End If
'Find the Version of the ClearCase File
Set Ver = CC.Version("\\view\gustaf-pc_localView\ScriptTest\testModel.mdl")
MsgBox "version = " & Ver
'Checkout file
Set CheckedOutFile = Ver.CheckOut(ccReserved, "test checkout")
If Err.Number <> 0 Then
MsgBox "Checkout Error: " & Err.Description
Else
MsgBox "Checkout successful"
End If
The OP Berbies reports:
ClearCase.ClearTool checkingOut = new ClearCase.ClearTool();
string fileOut = @"fileName";
checkingOut.CmdExec(@"checkout """ + fileOut + @"""");
Then just changed the variables for when you check it back in.
Unfortunately, it doesn't work properly with the answer I stated before because what it ends up doing is adding another version to your branch instead of creating another version in the main branch, I fixed this issue with this:
void GetVersions(string sourcefile)
{
ClearCase.CCElement element = m_CC.get_Element(sourcefile);
if (element != null)
{
ClearCase.CCVersion latestVersion = null;
FileInfo fi = new FileInfo(sourcefile);
latestVersion = element.get_Version();
if (latestVersion != null)
{
ClearCase.CCBranch branch = latestVersion.Branch;
ClearCase.CCCheckedOutFile file = latestVersion.CheckOut(ClearCase.CCReservedState.ccReserved, "", false, ClearCase.CCVersionToCheckOut.ccVersion_SpecificVersion, true, false);
string path = file.ExtendedPath;
}
}
}
void checkIn(string sourcefile)
{
ClearCase.CCElement element = m_CC.get_Element(sourcefile);
element.CheckedOutFile.CheckIn("", true, sourcefile, ClearCase.CCKeepState.ccKeep);
}
This way you can check it back in using your own branch to create another version for the main document. This is really important when using source control.