Hi,
I’m having some difficulty adding a group of documents as versions to some original document. We are migrating documents from another ECM system and we need to preserve versioning. Sometimes there are, say, 4 versions of a document, each having its own TIFF file. So, I’m creating these documents in LF first, and then trying to add them as versions to the original (earliest) document.
Here’s part of the relevant code:
//some other code …. if (doc.Versions > 1) { //Retrieve versions info from db dtVersions = otherCMSDB.GetDocumentVersions(doc.Number, doc.EarliestVersionID); int versionNo = 2; foreach (DataRow dr in dtVersions.Rows) { int versionTocID = CreateDocument(doc, ParentFolder, true, LFVolume, TemplateName, db); string notes = (Convert.IsDBNull(dr["AUTHOR"]) ? "" : "Author: " + dr["AUTHOR"].ToString() + ". ") + (Convert.IsDBNull(dr["VERSION_LABEL"]) ? "" : "Version Label: " + dr["VERSION_LABEL"].ToString()); AddVersion(TocID, versionTocID, versionNo, notes, db); versionNo++; } } //some other code …. public void AddVersion(int origTocID, int verTocID, int version, string notes, LFDatabase db) { LFDocument Doc = null; LFDocument VerDoc = null; LFVersionData OrigVData, NewVData; try { Doc = (LFDocument)db.GetEntryByID(origTocID); LFVersionControlInfo vControlInfo = Doc.VersionControlInfo; if (!vControlInfo.IsVersionControlled) { vControlInfo.PutUnderVersionControl(); } OrigVData = (LFVersionData)Doc.VersionData; // Create new VersionGroup if needed LFVersionGroup VGroup; if (OrigVData.Version == 0) { VGroup = OrigVData.AddToNewVersionGroup(); } else { VGroup = OrigVData.VersionGroup; } // Retrieves second version. VerDoc = (LFDocument)db.GetEntryByID(verTocID); NewVData = (LFVersionData)VerDoc.VersionData; NewVData.LockObject(Lock_Type.LOCK_TYPE_WRITE); NewVData.Version = version; NewVData.VersionNotes = notes; // Assigns the document to the new version group. NewVData.VersionGroup = VGroup; // Saves the changes. NewVData.Update(); NewVData.UnlockObject(); } catch (Exception ex) { throw ex; } finally { if (Doc != null) Doc.Dispose(); if (VerDoc != null) VerDoc.Dispose(); OrigVData = null; NewVData = null; } }
So, if I have 4 versions, only one of them appears to be added when I view the document’s Version History in LF Client. If I double-click that version, it opens another document that has the same version, and so on endlessly.
The Version and VersionNotes that I add are never there. Why? Where did all the other versions go? I’m sure I’m making a silly mistake here.
I’d appreciate your help.
Thanks