Click or drag to resize

IVersionableItemPutUnderVersionControl Method

IT Hit WebDAV Classes Reference
Puts or removes current item from version control.

Namespace: ITHit.WebDAV.Server.DeltaV
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 4.5.3121.0
Syntax
void PutUnderVersionControl(
	bool enable
)

Parameters

enable
Type: SystemBoolean

[Missing <param name="enable"/> documentation for "M:ITHit.WebDAV.Server.DeltaV.IVersionableItem.PutUnderVersionControl(System.Boolean)"]

Return Value

Type: 
.
Exceptions
ExceptionCondition
LockedExceptionThis item was locked. Client did not provide the lock token.
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
MultistatusExceptionErrors has occurred during processing of the subtree.
DavExceptionIn other cases.
Remarks

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.

Examples

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);
    }
}
See Also