Click or drag to resize

IVersionableItemCheckIn Method

IT Hit WebDAV Classes Reference
Creates new version. Copies all properties and content from this item.

Namespace: ITHit.WebDAV.Server.DeltaV
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 4.5.3121.0
Syntax
string CheckIn()

Return Value

Type: String
Url of the newly created version.
Remarks
This item was locked. Client did not provide the lock token.The user doesn't have enough privileges.Quota limit is reached.Errors has occurred during processing of the subtree.In other cases.

In your 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 this method method GetCurrentVersion must return the created version.

Examples

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

public string CheckIn()
{
    string newVersionUrl;
    RequireHasToken();

    if (this.VersionHistory != null)
    {
        // Create new version. Copy content and properties from this item to new version.

        IVersion v = this.VersionHistory.GetCurrentVersion();
        Version version = v as Version;
        Debug.Assert(version != null);
        int newVersionNumber = version.VersionNumber + 1;
        string newVersionPath = Version.CreateVersionPath(Path, newVersionNumber);

        Guid newId = Guid.NewGuid();
        // Create new version.
        string command =
            @"INSERT INTO Version
                 (ItemId,
                  VersionId,
                  VersionNumber,
                  Name,
                  Comment,
                  CreatorDisplayName,
                  Content,
                  ContentType,
                  Created,
                  SerialNumber)
              SELECT
                  @ItemId,
                  @Identity,
                  @VersionNumber,
                  Name,
                  Comment,
                  IsNull(@CreatorDisplayName, CreatorDisplayName),
                  Content,
                  ContentType,
                  GETUTCDATE(),
                  COALESCE(SerialNumber, 1)
              FROM Item
              WHERE ItemId = @ItemId";
        // COALESCE returns the first nonnull expression among its arguments.

        Context.ExecuteNonQuery(
            command,
            "@ItemId", ItemId,
            "@VersionNumber", newVersionNumber,
            "@CreatorDisplayName",
            string.IsNullOrEmpty(CurrentUserName) ? (object)DBNull.Value : CurrentUserName,
            "@Identity", newId);

       Context.ExecuteNonQuery(
            "UPDATE Item SET Comment = '' WHERE ItemId = @ItemId",
            "@ItemId", ItemId);

        // Copy properties to new version
        string copyCommand =
            @"INSERT INTO VersionProperty( VersionId, Name, Namespace, PropVal)
              SELECT @VersionId, Name, Namespace, PropVal
              FROM Property
              WHERE ItemID = @ItemID";

        Context.ExecuteNonQuery(
            copyCommand,
            "@VersionId", newId,
            "@ItemId", ItemId);

        // Copy content to new version
        newVersionUrl = newVersionPath;
    }
    else
    {
        newVersionUrl = this.Path;
    }

    setFileCheckedOut(false, false);
    return newVersionUrl;
}
See Also