Click or drag to resize

IVersionableItemUnCheckOut Method

IT Hit WebDAV Classes Reference
Cancels the checkout and restores the pre-checkout state of the version-controlled item.

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

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
In your UnCheckOut implementation you will discard changes and restore pre-checkout state. Content and properties must be copied from current version to this item. The item must be marked as checked-in.
Examples

The code below is part of 'WebDAVServer.DeltaV' sample provided with the SDK.

public void UnCheckOut()
{
    RequireHasToken();

    if (this.VersionHistory != null)
    {
        // Discard changes.
        // Copy content and properties from current version to this item. Mark item as checked in.

        Version version = (Version)VersionHistory.GetCurrentVersion();

        // Restore properties.
        Context.ExecuteNonQuery(
            "DELETE FROM Property WHERE ItemID = @ItemID",
            "@ItemId", ItemId);

        string command =
             @"INSERT INTO Property(ItemId, Name, Namespace, PropVal)
               SELECT @ItemId, Name, Namespace, PropVal
               FROM VersionProperty
               WHERE VersionId = @VersionId";

        Context.ExecuteNonQuery(
            command,
            "@VersionId", version.VersionId,
            "@ItemId", ItemId);

        string updateItemCommand =
             @"UPDATE Item
               SET Content = (SELECT Content FROM [Version] WHERE VersionId = @versionID)
               WHERE ItemId = @ItemID";

        Context.ExecuteNonQuery(
            updateItemCommand,
            "@ItemId", ItemId,
            "@VersionId", version.VersionId);
    }
    // Mark item as checked in.
    setFileCheckedOut(false, false);
}
See Also