.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Squadron: Empty List Addin

Posted By:Jean Paul       Posted Date: November 30, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we can explore a new Addin inside Squadron for SharePoint 2010 tool.
 

In this article we can explore a new Addin inside Squadron for SharePoint 2010 tool.

Empty List Addin

The Empty List Addin can be applied for:

1. Lists

2. Libraries

The Addin performs the following:

1. Empty the list or library by deleting all items

2. Delete the list or library

The Addin is a quick utility as it helps in one click emptying/deleting of multiple lists/libraries.

clip_image002

Squadron is a SharePoint 2010 tool containing multiple addins. You can download the tool freely from Code Plex using following url.

http://squadron2010.codeplex.com/

clip_image004

After downloading & installing you can run the Squadron tool from Start Menu > Squadron.

clip_image006

EMPTY Operation

Click on the Empty List item from the left pane. You will get the following screen with Lists & Libraries listed.

clip_image008

clip_image009

The Lists & Libraries are selected based on the URL, Hidden properties. You can change the URL from the URL text box given.

Now we are going to perform the EMPTY operation. Please note that all the entries in the selected lists will be deleted. You an manually select the list/library to perform the EMPTY operation.

To select all the lists/libraries use the context menu associated to Check All / Uncheck All.

clip_image010

After selecting the list, click on the Empty Selected button from the right hand side.

clip_image012

Please note that the selected Tasks list contains the following data before the operation.

clip_image014

On clicking the Empty Selected button, you will get the following prompt.

clip_image016

You can click the Yes button to continue if you are sure about deleting all items in the selected list. Now returning to the SharePoint list you can see the items are deleted.

clip_image018

This concludes our EMPTY operation.

clip_image002[1]

The Show Count check box shows the item count of each list or library.

The Show Hidden check box shows the hidden lists & libraries (including Quick Launch, System)

clip_image020

DELETE Operation

Now we can try the DELETE operation. Please note that the DELETE operation deletes the selected lists and libraries. For performing this operation I prefer you use a temporary site with lists & libraries.

clip_image022clip_image022

After selecting the items, click the Delete Selected button. You will get the following confirmation dialog.

clip_image024

On confirming yes, the selected items are deleted. You will see the items missing in the next refresh.

clip_image026

Code

Following is the code for EMTPY operation.

 

private void PerformEmpty()
{
    using (SPSite site = new SPSite(SquadronContext.Url, SquadronContext.GetUserToken()))
    {
        using (SPWeb web = site.OpenWeb())
        {
            foreach (string title in NameList.CheckedItems)
            {
                SPList list = web.Lists[title];
                int count = list.Items.Count;

                for (int x = list.Items.Count - 1; x >= 0; x--)
                {
                    list.Items[x].Delete();
                }

                SquadronContext.WriteMessage(title + " EMPTY performed by deleting " + count.ToString() + " items");
            }
        }
    }

    SquadronContext.WriteMessage("Performed Empty operations.");
}

Following is the code for DELETE operation.
private void PerformDelete()
{
    using (SPSite site = new SPSite(SquadronContext.Url))
    {
        using (SPWeb web = site.OpenWeb())
        {
            foreach (string title in NameList.CheckedItems)
            {
                SPList list = web.Lists[title];

                try
                {
                    list.Delete();

                    SquadronContext.WriteMessage(title + " DELETE done.");
                }
                catch (Exception ex)
                {
                    SquadronContext.WriteMessage("DELETE Exception for " + title + " " + ex.ToString());
                }
            }
        }
    }

    SquadronContext.WriteMessage("Performed DELETE operations.");
    RefreshList();
}

References

http://squadron2010.codeplex.com/

Summary

In this article we have explored the EMPTY & DELETE operations of Squadron for SharePoint 2010 tool. I repeat that this tool is free for use and in the long run there should be more and more utilities incorporated.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend