clIVSSLibrary.CheckOutItem cannot get the last version to replace the existed file in working folder
-
Friday, June 15, 2012 8:09 AM
Hi all,
I develop an application, which implements functionalities of VSS 2005 on web application. such as check out, check in, and so on.
But when I invoke the function
public string CheckOutItem(string ItemToCheckOut, string CheckOutPath, ref string Comment, int Flags);
And set the flags as
FlagRecursiveNo();
FlagGetLocalCopyYes();
FlagMultipleCheckOutNo();The question is that the file in the working folder does not be replaced by last version when invoke CheckOutItem(...)
For example, the file in working folder with the version is V1. VSS has the last version is V2. When I check out it successfully, but the file is still V1. The expected is that the file is replaced by V2.
How to handle it?
All Replies
-
Friday, June 15, 2012 4:36 PM
Sub CreateNewPage() ' Connect to OneNote 2010. ' To see the results of the code, ' you'll want to ensure the OneNote 2010 user ' interface is visible. Dim oneNote As OneNote14.Application Set oneNote = New OneNote14.Application ' Get all of the Notebook nodes. Dim nodes As MSXML2.IXMLDOMNodeList Set nodes = GetFirstOneNoteNotebookNodes(oneNote) If Not nodes Is Nothing Then ' Get the first OneNote Notebook in the XML document. Dim node As MSXML2.IXMLDOMNode Set node = nodes(0) Dim noteBookName As String noteBookName = node.Attributes.getNamedItem("name").Text ' Get the ID for the Notebook so the code can retrieve ' the list of sections. Dim notebookID As String notebookID = node.Attributes.getNamedItem("ID").Text ' Load the XML for the Sections for the Notebook requested. Dim sectionsXml As String oneNote.GetHierarchy notebookID, hsSections, sectionsXml, xs2010 Dim secDoc As MSXML2.DOMDocument Set secDoc = New MSXML2.DOMDocument If secDoc.LoadXML(sectionsXml) Then ' select the Section nodes Dim secNodes As MSXML2.IXMLDOMNodeList Set secNodes = secDoc.DocumentElement.SelectNodes("//one:Section") If Not secNodes Is Nothing Then ' Get the first section. Dim secNode As MSXML2.IXMLDOMNode Set secNode = secNodes(0) Dim sectionName As String sectionName = secNode.Attributes.getNamedItem("name").Text Dim sectionID As String sectionID = secNode.Attributes.getNamedItem("ID").Text ' Create a new blank Page in the first Section ' using the default format. Dim newPageID As String oneNote.CreateNewPage sectionID, newPageID, npsDefault ' Get the contents of the page. Dim outXML As String oneNote.GetPageContent newPageID, outXML, piAll, xs2010 Dim doc As MSXML2.DOMDocument Set doc = New MSXML2.DOMDocument ' Load Page's XML into a MSXML2.DOMDocument object. If doc.LoadXML(outXML) Then ' Get Page Node. Dim pageNode As MSXML2.IXMLDOMNode Set pageNode = doc.SelectSingleNode("//one:Page") ' Find the Title element. Dim titleNode As MSXML2.IXMLDOMNode Set titleNode = doc.SelectSingleNode("//one:Page/one:Title/one:OE/one:T") ' Get the CDataSection where OneNote store's the Title's text. Dim cdataChild As MSXML2.IXMLDOMNode Set cdataChild = titleNode.SelectSingleNode("text()") ' Change the title in the local XML copy. cdataChild.Text = "A Page Created from VBA" ' Write the update to OneNote. oneNote.UpdatePageContent doc.XML Dim newElement As MSXML2.IXMLDOMElement Dim newNode As MSXML2.IXMLDOMNode ' Create Outline node. Set newElement = doc.createElement("one:Outline") Set newNode = pageNode.appendChild(newElement) ' Create OEChildren. Set newElement = doc.createElement("one:OEChildren") Set newNode = newNode.appendChild(newElement) ' Create OE. Set newElement = doc.createElement("one:OE") Set newNode = newNode.appendChild(newElement) ' Create TE. Set newElement = doc.createElement("one:T") Set newNode = newNode.appendChild(newElement) ' Add the text for the Page's content. Dim cd As MSXML2.IXMLDOMCDATASection Set cd = doc.createCDATASection("Text added to a new OneNote page via VBA.") newNode.appendChild cd ' Update OneNote with the new content. oneNote.UpdatePageContent doc.XML ' Print out information about the update. Debug.Print "A new page was created in " Debug.Print "Section " & sectionName & " in" Debug.Print "Notebook " & noteBookName & "." Debug.Print "Contents of new Page:" Debug.Print doc.XML End If Else MsgBox "OneNote 2010 Section nodes not found." End If Else MsgBox "OneNote 2010 Section XML Data failed to load." End If Else MsgBox "OneNote 2010 XML Data failed to load." End If End Sub Private Function GetAttributeValueFromNode(node As MSXML2.IXMLDOMNode, attributeName As String) As String If node.Attributes.getNamedItem(attributeName) Is Nothing Then GetAttributeValueFromNode = "Not found." Else GetAttributeValueFromNode = node.Attributes.getNamedItem(attributeName).Text End If End Function Private Function GetFirstOneNoteNotebookNodes(oneNote As OneNote14.Application) As MSXML2.IXMLDOMNodeList ' Get the XML that represents the OneNote notebooks available. Dim notebookXml As String ' OneNote fills notebookXml with an XML document providing information ' about what OneNote notebooks are available. ' You want all the data and thus are providing an empty string ' for the bstrStartNodeID parameter. oneNote.GetHierarchy "", hsNotebooks, notebookXml, xs2010 ' Use the MSXML Library to parse the XML. Dim doc As MSXML2.DOMDocument Set doc = New MSXML2.DOMDocument If doc.LoadXML(notebookXml) Then Set GetFirstOneNoteNotebookNodes = doc.DocumentElement.SelectNodes("//one:Notebook") Else Set GetFirstOneNoteNotebookNodes = Nothing End If End Function
-
Monday, June 18, 2012 1:56 AM
Hi ENRE CORPORATION,
All the code you posted is about OneNote. But what I want is about VSS 2005.
Does others have any idea?
Thanks,
Joey
-
Monday, June 18, 2012 5:21 AMModerator
Please check the local files attributes, try to add use ReplaceLocalReplace flag.
On the other hand, could you please try to test this action via VSS client first?
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by JoeyWang Tuesday, June 19, 2012 3:07 AM
-
Tuesday, June 19, 2012 3:07 AMThanks Bob Bao.

