Namespace: ITHit.WebDAV.Server.DeltaV
[Missing <param name="enable"/> documentation for "M:ITHit.WebDAV.Server.DeltaV.IVersionableItem.PutUnderVersionControl(System.Boolean)"]
Exception | Condition |
---|---|
LockedException | This item was locked. Client did not provide the lock token. |
NeedPrivilegesException | The user doesn't have enough privileges. |
InsufficientStorageException | Quota limit is reached. |
MultistatusException | Errors has occurred during processing of the subtree. |
DavException | In other cases. |
By default items in the repository are not under version control. When item is being put under version control engine calls PutUnderVersionControl(Boolean) method passing true as a parameter. In your PutUnderVersionControl(Boolean) implementation you must create a new version. The content and properties of the new version must be copied from this item. After the call to PutUnderVersionControl(Boolean)VersionHistory property must point to the object implementing IHistory interface that will contain single version. The IsCheckedOut property must return false;
If item is under version control it mast always have at last one version in its versions list.
If AutoPutUnderVersionControl is true and item is not under version control prior to any item content or properties update PutUnderVersionControl(Boolean) will be called.
When item is being removed from version control engine calls PutUnderVersionControl(Boolean) method passing false as a parameter. In your implementation you will usually delete all versions. VersionHistory property must return null after this call.
The code below is part of 'WebDAVServer.DeltaV' sample provided with the SDK.
public void PutUnderVersionControl(bool enable) { if (enable && this.VersionHistory == null) { // Create new version. The content and properties of the new version is being copied from this item. SetAutoVersion(autoVersionMode); Guid newID = Guid.NewGuid(); string insertVersionCommand = @"INSERT INTO Version( ItemId, VersionId, VersionNumber, Name, Comment, CreatorDisplayName, Content, ContentType, Created, SerialNumber) SELECT @ItemId, @Identity, 1, Name, Comment, @CreatorDisplayName, Content, ContentType, GETUTCDATE(), 0 FROM Item WHERE ItemId = @ItemId"; Context.ExecuteNonQuery( insertVersionCommand, "@ItemId", ItemId, "@CreatorDisplayName", CurrentUserName, "@Identity", newID); string insertVersionPropertyCommand = @"INSERT INTO VersionProperty(VersionId, Name, Namespace, PropVal) SELECT @VersionId, Name, Namespace, PropVal FROM Property WHERE ItemID = @ItemId"; Context.ExecuteNonQuery( insertVersionPropertyCommand, "@VersionId", newID, "@ItemId", ItemId); setFileCheckedOut(false, false); } else if (!enable) { // Delete all versions Context.ExecuteNonQuery( "DELETE FROM Version WHERE ItemId = @ItemId", "@ItemId", ItemId); } }