SharePoint 2010 Performance Dashboard – Farm Content Size Reporting(Post 2/2)

  Here I have mentioned the code which can be useful to get the Content DB, Site Collection Usage details.   SPFarm farm = SPFarm.Local; SPWebService service = farm.Services.GetValue<SPWebService>("");   string webappName = ""; SPWeb web = null; SPUserCollection owners = null; string OwnerString = ""; int count = 0;   foreach (SPWebApplication webapp in…

0

Silverlight Object Model code to access the current user of a SP2010 site

More details on the Silverlight Object Model, you can find here. using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using Microsoft.SharePoint.Client; using Microsoft.SharePoint; namespace SilverlightApplication1 { public partial class MainPage : UserControl { Web oWebsite; ListCollection collList; IEnumerable<List> listInfo; User user; public MainPage() { InitializeComponent(); SilverlightOM(); }…

1

Automatically restart the failed workflow instances

Recently I came across a situation in which customer had email enabled a document library and he had setup a custom workflow to start whenever any new item is added in the library. This setup was working as expected but when end-users send some higher number of emails at the same time (lets say 20-30…

1

Code snippet to copy documents from one document library to another

1: using (SPSite site = new SPSite("http://ms10:200/sites/200")) 2: { 3: using (SPWeb web = site.OpenWeb()) 4: { 5: SPList lib1 = (SPDocumentLibrary)web.Lists["Documents"]; 6: SPList lib2 = (SPDocumentLibrary)web.Lists["Site Collection Documents"]; 7: byte[] fileBytes = null; 8: string destUrl = null; 9: SPFile destFile = null; 10: foreach (SPListItem item1 in lib1.Items) 11: { 12: fileBytes =…

1

Code snippet to create a Tasks list and associate it with a Parallel Approval workflow in a Pages library

The requirement to write this code was, After export/import, workflow modification for approvers was failing. Approvers were not able to perform the Approval workflow operations and then we tested that if we create a new Tasks list and modify the existing Approval workflow association then everything starts working so we needed a code which can…

0

Code snippet to download the files along with versions from SPS 2003 document library.

1: private void Download() 2: { 3: string siteUrl = txtSite.Text.ToString(); 4: string source = txtDocLib.Text.ToString(); 5: string downloadPath= txtDownload.Text.ToString(); 6: byte[] vContent = null; 7: int count = 1; 8:   9: using (SPSite site = new SPSite(siteUrl)) 10: { 11: using (SPWeb web = site.OpenWeb()) 12: { 13: SPFolder sourceFolder = web.GetFolder(source); 14:…

0

Code snippet to add / modify columns in a list

It iterates through a whole site collection and wherever the list with name “test” it finds, It will do the changes. 1: using System; 2: using System.Collections.Generic; 3: using System.Text; 4: using Microsoft.SharePoint; 5:   6: namespace ConsoleApplication1 7: { 8: class Program 9: { 10: static void Main(string[] args) 11: { 12: using (SPSite…

0

Code sample to aggregate the text from "append changes" column to Multiline text field.

This is a code sample to copy all of the text from the “col1” column to “col2” column. To note again, “col1” is an "append changes" column so the previous edits of the comments field are stored in previous versions of the list item. 1: using System; 2: using System.Collections.Generic; 3: using System.Text; 4: using…

0