SharePoint 2010 Document management: Outdated archiving tools

Source: Internet
Author: User
Tags object model

Anyone who has ever used SharePoint knows that SharePoint for the operation is convenient, but for the data load is not satisfactory, so that we need to more reasonable use, standardize the use of rules and habits, so, regular cleaning unnecessary documents has become a problem.

With this in mind, I think it's convenient to write a gadget that implements document archiving. Of course, if you want, it can be encapsulated as Timerjob or Windows service is not a problem, even the Windows planning task is feasible, as long as you want.

First, the interface design:

As shown above, first you need to enter the download document required username, password, domain name, otherwise we do not have permission to download the document;

Then is the site address, open SPSite, together with the loading out of all the SPWeb;

Then select the SPWeb we need and automatically load all the document libraries;

Select the document library we need, select the date, and all documents older than this date are within the scope of the archive;

Check automatically deletes archived documents, which deletes documents that have been downloaded to the specified path and does not appear in the Recycle Bin.

Second, design ideas:

Very simple idea, big God not to spray, thanks!

The server-side object model, which needs to run on the server, is based on the SharePoint version.

By using the server-side object model, get all the SPListItem collections, download all documents older than the archive date, and then Item.delete () the downloaded document, of course, just to complete the task of archiving, not too much functionality.

If you don't delete documents from a document library, you can also use it to download documents from a document library, and it feels faster to copy and paste than to open in Windows Explorer.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/sharepoint/

Third, part of the code:

Bulk Delete part of the code, not through the CAML statement filter, may be some very x very violent, please forgive me, if needed, can be optimized.

SPList list = web.Lists[ListID];
SPListItemCollection itemcoll = list.Items;
string strURL = string.Empty;
int maxNum = itemcoll.Count;
progressBarBackUp.Maximum = maxNum;
for (int i = maxNum - 1; i >= 0; i--)
{
try
{
if (Convert.ToDateTime(itemcoll[i]["Created"].ToString()) > Convert.ToDateTime(dateTimePicker1.Text))//可以优化~~~~~~~~~
{
continue;
}
strURL = web.Url + "/" + itemcoll[i].Url;
BackUpDoc(strURL);
if (cbAutoDel.Checked)
{
itemcoll[i].Delete();
//itemcoll[i].Update();
}
}
catch
{
}
progressBarBackUp.Value ++;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.