int majorVersion = 0;
int maxMajorVersion = 2;
int maxMinorVersion = 20; // default 511;
string version = string.Empty;
int counter = 1;
int id = 1;
int maxId = 512 * maxMajorVersion;
List<int> lstNxtVersionIds = new List<int>();
for (int i = 1; i <= maxMajorVersion; i++)
lstNxtVersionIds.Add(i*512);
for (int i = 1; i<=maxId & id<=maxId; i++)
{
if (counter == maxMinorVersion)
{
version = majorVersion.ToString() + "." + counter.ToString();
Console.WriteLine ("id {0}, version {1}", id, version);
if (majorVersion < maxMajorVersion)
{
majorVersion++;
foreach (int nxtVersionId in lstNxtVersionIds)
{
if (id < nxtVersionId)
{
id = nxtVersionId;
break;
}
}
}
else if (majorVersion == maxMajorVersion)
break;
counter = 0;
}
version = majorVersion.ToString() + "." + counter.ToString();
Console.WriteLine ("id {0}, version {1}", id, version);
id++;
counter++;
Blogs on .NET and LAMP Technologies
There's often more than one correct thing.
There's often more than one right thing.
There's often more than one obvious thing.
--Larry Wall
Tuesday, March 06, 2007
SharePoint Versioning Algorithm
In my current project I need to implement versioning of the document stored in the SQL Server in the same way as SharePoint. I wrote following C# code to simulate versioning of SharePoint:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment