Home
english
Home
.NET Server
Java Server
.NET Client
AJAX Client
AJAX Browser
Map Drive
Pricing
Contacts
info@ithit.com



Managing Version-Controlled Items on a DeltaV Server

Using version-control features you can check-in/check-out files and track file versions. Note that versioning only manages file versions and does not protect item from being updated by other users. To protect items locking must be used.

Probing Version-Control Support

To detect if item supports version control feature probe the VersionControl bit in Features enumeration:

WebDavSession session = new WebDavSession(license);

IResource resource = session.OpenResource("http://server:8580/Sales.docx");

bool versionControlSupported = (resource.SupportedFeatures().Features & Features.VersionControl) != 0;

Enabling Version Control

Usually by default all items in the WebDAV repository are not under version control. The item actually behaves like a Class 2 item. To start creating versions you must call IResource.PutUnderVersionControl passing true as a parameter:

string license = "<?xml version='1.0' encoding='u...

WebDavSession session = new WebDavSession(license);

session.Credentials = new NetworkCredential("User1", "pwd");

IResource resource = session.OpenResource("http://server/sales.docx");

resource.PutUnderVersionControl(true);

During the call to PutUnderVersionControl server will create an initial version. The item will be in a checked-in state. If the item is under version control it always has at last one version in its versions list.

To disable version control call PutUnderVersionControl passing false as a parameter. Server will usually delete all item versions during this call.

Note that IT Hit WebDAV Server Engine has Engine.AutoPutUnderVersionControl property indicating if items must be put under version control explicitly. If this property is set to true the item will be automatically put under version control before the update.

Checking if Item is Being Version-Controlled

To check if item is under version control use IResource.VersionControlled property:

 

if(resource.VersionControlled)

    MessageBox.Show("The item is being version controlled.");

else

    MessageBox.Show("The item is not under version control.");

Listing Item Versions

Each file version implements IVersion interface that is inherited from IHierarchyItem and IItemContent interfaces. To get list of versions call IResource.GetVersions:

IResource resource = session.OpenResource("http://server/sales.docx");

IVersion[] versions = resource.GetVersions();

foreach (IVersion version in versions)

{

    MessageBox.Show("Version Name: " + version.VersionName);

    MessageBox.Show("Comment: " + version.Comment);

    MessageBox.Show("Author: " + version.CreatorDisplayName);

    MessageBox.Show("Created: " + version.CreationDate);

}

You can read version content and request properties as you usually do for resources but you cannot update content or properties (the only exceptions are comment and author, see example below).

IVersion version = session.OpenVersion("http://server/ sales.docx?version=2");

using (StreamReader sr = new StreamReader(version.GetReadStream()))

{

    string versionContents = sr.ReadToEnd();

    MessageBox.Show(versionContents);

}

Updating Version-Сontrolled Item

To allow modifications on a version-controlled item it must be first checked-out. If you would like to protect item from being modified by other users you will also lock the item:

IResource resource = session.OpenResource("http://server/sales.docx");

LockInfo lockInfo = resource.Lock(LockScope.Exclusive, false, "John Walter", TimeSpan.MaxValue);

resource.CheckOut(lockInfo.LockToken.LockToken);

resource.UpdateProperties(

new Property[] {new Property(new PropertyName("amount", "server"), "2")}, null, lockInfo.LockToken.LockToken);

IVersion version = resource.CheckIn(lockInfo.LockToken.LockToken);

resource.Unlock(lockInfo.LockToken.LockToken);

version.SetCommentAndAuthor("Props updated.", "John");

Note that IResource.CheckOut only allows modifications while new version is created during the call to IResource.CheckIn.

To find out if item is in a check-out state use IResource.CheckedOut property:

 

if (resource.CheckedOut)

    MessageBox.Show("The item is checked-out.");

else

    MessageBox.Show("The item is checked-in.");

Uncheck-out

If after making some item modifications you decide to cancel your updates you can call IResource.UnCheckOut. It will restore the pre-checkout state of the item:

IResource resource = session.OpenResource("http://server/sales.docx");

LockInfo lockInfo = resource.Lock(LockScope.Exclusive, false, "John Walter", TimeSpan.MaxValue);

resource.CheckOut(lockInfo.LockToken.LockToken);

//Modify resource content or properties here.

//....

resource.UnCheckOut(lockInfo.LockToken.LockToken);

resource.Unlock(lockInfo.LockToken.LockToken);

Reverting Item Content and Properties to a Specific Version

To revert item state to a specific version use IResource.UpdateToVersion:

IResource resource = session.OpenResource("http://server/sales.docx");

LockInfo lockInfo = resource.Lock(LockScope.Exclusive, false, "John Walter", TimeSpan.MaxValue);

 

IVersion version = session.OpenVersion(new Uri("http://server/ sales.docx?version=2"));

resource.UpdateToVersion(version, lockInfo.LockToken.LockToken);

resource.Unlock(lockInfo.LockToken.LockToken);

 


What WebDAV software would you like to have?

Selected Customers:
Country: Norway
DnB NOR Group
Country: Finland
Bank of Finland
Country: United Kingdom
Bechtle Direct
Country: Sweden
BT Industries
Country: USA
California Chamber of Commerce
Country: Denmark
Danfoss Group
Country: Denmark
DFDS
Country: USA
Fluke Networks
Country: USA
HNI Corporation
Country: USA
IHS Inc
Country: USA
LandAmerica Financial Group
Country: Canada
Laurentian University
Country: USA
Microsoft
Country: Israel
RADVISION
Country: Ukraine
Raiffeisen Bank
Country: Netherlands
Sanoma Uitgevers
Country: USA
Siemens
Country: Australia
WorkCover NSW
Country: Ukraine
OTP Bank
Country: USA
Intel Corporation
Country: Austria
Austrian Federal Railways
Home .NET Server Java Server .NET Client AJAX Client AJAX Browser Map Drive Pricing Contacts

Updated: Sunday, October 26, 2008