| Author |
Message |
Christian Ernst Rysgaard
Guest
|
Posted:
Fri Mar 11, 2005 7:05 pm Post subject:
Hacking Sharepoint Document Library History |
|
|
I've implemented an eventhandler which adds extra metadata based on the users
submitted metadata for each document - fx: They enter the initials of a user
as metadata during Save from word and the eventhandler looks up the
correspondig department, division and country. The found information is saved
into metadata fields. These metadata field can then be used in datasheet
views to group documents based on department and so on.
All very nize, but changing the metadat inside the eventhandler will allways
result in a new version of the document. With >20000files and some >50mb in
size and no stocks in any storage companies, I dont want these extra versions
around! perhaps even worse to the users, the author of the latest document
version will allways be set to the user account in which my eventhandler runs.
I've made a few stunts and hacks to get around these sideeffects
1) change the editor back to original user who invoked event using this sql
directly on the site database: "update userdata set tp_editor = @user where
tp_id = @doclibrowid and tp_listid = @listid". @user & @listid being
extracted by kinky code elsewhere.
* Why aint it possible to the metadata on behalf of a specific user and
supply with a comment when i change metedata using the object model?
2) after i've saved the changes to the metadata and obtained the extra
version, i remove the previous version.
int lastidx = item.File.Versions.Count-1;
item.File.Versions.Delete(lastidx);
It feels allright to do such an ugly thing, because i know that these
versions only differ in the added metadata. This means that all version
history items will have a lot of holes in the version numbers.
But but but - it would be jolly nize to be able to supply a comment to the
latest version letting the users know why the previous version is gone!
This is easily accomplished by changing the comment in the version
history... OR NOT! completely readonly like many other usefull properties in
the awfull object model! Wonder why it is allright to delete a previous
version but NOT allright to change the actual comment.
enter hacking: version history comments are stored in the site database
docversions table in the column metainfo+metainfosize. it's an utf8 encoded
string read something like this:
string sql = @"
SELECT DocVersions.MetaInfoSize, DocVersions.MetaInfo, docversions.version
FROM Docs INNER JOIN DocVersions ON DocVersions.Id = Docs.Id
WHERE (Docs.leafname = 'x1.doc')
order by docversions.version desc";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
int arrsize = reader.GetInt32(0);
byte[] resarr = new byte[arrsize];
long got = reader.GetBytes(1, 0, resarr, 0, arrsize);
int vers = reader.GetInt32(2);
string meta = System.Text.Encoding.UTF8.GetString(resarr, 0, (int) got);
Debug.WriteLine(meta);
}
contents of metadata looking like this:
Responsible Group:SW|Software Research Group
vti_modifiedby:SR|DOMD\\cer
vti_assignedto:SR|
Owner:SW|jso
SimlinkID:SW|100094
SimlinkURL:SW|http://dk01sn183/go.aspx?doc=100094, 100094
RespGroup:SW|
Reviewed By:SW|
vti_cachedcustomprops:VX|SPSDescription Siebel Next\\ Review OwnerGroup
ManualReviewDate IMS\\ Phase vti_assignedto Owner SimlinkID SimlinkURL
RespGroup Reviewed\\ By IMS\\ Version Order vti_title Last\\ Review Public
Responsible0 Responsible Owner\\ Group Status vti_approvallevel
vti_categories Responsible\\ Group
vti_cachedtitle:SR|Owner
vti_title:SR|Owner
Public:SW|1
Owner Group:SW|Property Adm.
Status:SW|Review
* Does anybody recognize this format?
i dont! could be a hashtable but with the :SW| or :SR| prefixes to the
strings i dont dare touching it in order to add my own comments!
please help... |
|
| Back to top |
|
 |
Lloyd Cotten
Guest
|
Posted:
Wed Mar 16, 2005 10:52 pm Post subject:
Re: Hacking Sharepoint Document Library History |
|
|
Hi Christian,
I am also working on a project that requires me to touch the MetaInfo
column. I too, could not find this documented anywhere... in fact
when I began this project, my assumption was that this column would be
in a nice XML format, but instead found this text format with obscure
delimiting!
With my experimentation, it seems that any custom field values are
prefixed by <FieldName>:SW| while default SharePoint fields are
prefixed by vti_<Fieldname>:SR| with the fields for which values are
specified for listed in vti_cachedcustomprops:VX| delimited by a
single unescaped space.
I'm about two hours development away from doing an experiment with
this, so when I do that I'll post back and let you know the results?
Lloyd Cotten
Christian Ernst Rysgaard <ChristianErnstRysgaard@discussions.microsoft.com> wrote in message news:<20321FA8-4B35-44E3-8DAD-12EF006B8529@microsoft.com>...
| Quote: | I've implemented an eventhandler which adds extra metadata based on the users
submitted metadata for each document - fx: They enter the initials of a user
as metadata during Save from word and the eventhandler looks up the
correspondig department, division and country. The found information is saved
into metadata fields. These metadata field can then be used in datasheet
views to group documents based on department and so on.
All very nize, but changing the metadat inside the eventhandler will allways
result in a new version of the document. With >20000files and some >50mb in
size and no stocks in any storage companies, I dont want these extra versions
around! perhaps even worse to the users, the author of the latest document
version will allways be set to the user account in which my eventhandler runs.
I've made a few stunts and hacks to get around these sideeffects
1) change the editor back to original user who invoked event using this sql
directly on the site database: "update userdata set tp_editor = @user where
tp_id = @doclibrowid and tp_listid = @listid". @user & @listid being
extracted by kinky code elsewhere.
* Why aint it possible to the metadata on behalf of a specific user and
supply with a comment when i change metedata using the object model?
2) after i've saved the changes to the metadata and obtained the extra
version, i remove the previous version.
int lastidx = item.File.Versions.Count-1;
item.File.Versions.Delete(lastidx);
It feels allright to do such an ugly thing, because i know that these
versions only differ in the added metadata. This means that all version
history items will have a lot of holes in the version numbers.
But but but - it would be jolly nize to be able to supply a comment to the
latest version letting the users know why the previous version is gone!
This is easily accomplished by changing the comment in the version
history... OR NOT! completely readonly like many other usefull properties in
the awfull object model! Wonder why it is allright to delete a previous
version but NOT allright to change the actual comment.
enter hacking: version history comments are stored in the site database
docversions table in the column metainfo+metainfosize. it's an utf8 encoded
string read something like this:
string sql = @"
SELECT DocVersions.MetaInfoSize, DocVersions.MetaInfo, docversions.version
FROM Docs INNER JOIN DocVersions ON DocVersions.Id = Docs.Id
WHERE (Docs.leafname = 'x1.doc')
order by docversions.version desc";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
int arrsize = reader.GetInt32(0);
byte[] resarr = new byte[arrsize];
long got = reader.GetBytes(1, 0, resarr, 0, arrsize);
int vers = reader.GetInt32(2);
string meta = System.Text.Encoding.UTF8.GetString(resarr, 0, (int) got);
Debug.WriteLine(meta);
}
contents of metadata looking like this:
Responsible Group:SW|Software Research Group
vti_modifiedby:SR|DOMD\\cer
vti_assignedto:SR|
Owner:SW|jso
SimlinkID:SW|100094
SimlinkURL:SW|http://dk01sn183/go.aspx?doc=100094, 100094
RespGroup:SW|
Reviewed By:SW|
vti_cachedcustomprops:VX|SPSDescription Siebel Next\\ Review OwnerGroup
ManualReviewDate IMS\\ Phase vti_assignedto Owner SimlinkID SimlinkURL
RespGroup Reviewed\\ By IMS\\ Version Order vti_title Last\\ Review Public
Responsible0 Responsible Owner\\ Group Status vti_approvallevel
vti_categories Responsible\\ Group
vti_cachedtitle:SR|Owner
vti_title:SR|Owner
Public:SW|1
Owner Group:SW|Property Adm.
Status:SW|Review
* Does anybody recognize this format?
i dont! could be a hashtable but with the :SW| or :SR| prefixes to the
strings i dont dare touching it in order to add my own comments!
please help... |
|
|
| Back to top |
|
 |
Chanaka Siriwardana
Guest
|
Posted:
Fri Nov 11, 2005 9:51 am Post subject:
Re:Hacking Sharepoint Document Library History |
|
|
I am also trying to update the MetaInfo field found in DocVersions. Did you
get a workaround? Please let me know. |
|
| Back to top |
|
 |
colinb
Guest
|
|
| Back to top |
|
 |
|
|
|
|