Wednesday, June 24, 2009

MOSS Expiration Issue after installing SP2 for MOSS 2007

Many people are facing problem MOSS expiration After installing SP2 for SharePoint Server 2007, because it incorrectly activates the product expiration date. This means after 180 days the SharePoint Server will become inaccessible to all end users.

As per Microsoft KB Article, follow the steps as mentioned below

  • Click Start, point to All Programs, point to Administrative Tools, and then click SharePoint 3.0 Central Administration.  
  • Click the Operations tab. 
  • Click Convert License Type.  
  • In the Enter the Product Key text box, type your product identification number, and then click OK.  
  • The License Synchronizer Job will run on all computers in the farm after a few moments. After all the computers have updated their license from the timer job, the Convert License Type page will reflect the correct license.
For more informatin, review following article
http://support.microsoft.com/kb/971620

http://blogs.msdn.com/sharepoint/archive/2009/05/21/attention-important-information-on-service-pack-2.aspx

Wednesday, June 3, 2009

How can I modify "Modified", "Modified By", "Created" and "Created By" Field Values Without Changing Version in Published Page List?

SPSite site = null;

SPWeb web = null;
site = new SPSite("http://portal/");
web = site.OpenWeb();
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
SPContentTypeId myContentType = new SPContentTypeId("MyContentTypeId");
PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(myContentType );
PageLayout pageLayout = layouts[0];
string pageName = Guid.NewGuid().ToString() + ".aspx";
SPUser user = web.EnsureUser("DOMAIN\\ashishk");
string createdDate = "2009-06-03T22:35:10Z";
string modifiedDate = "2009-06-03T22:35:10Z";
web.AllowUnsafeUpdates = true;
PublishingPage newPage = publishingWeb.GetPublishingPages().Add(pageName, pageLayout);
newPage.ListItem["Author"] = user.ID;
newPage.ListItem["Editor"] = user.ID;
newPage.ListItem["Created"] = createdDate;
newPage.ListItem["Modified"] = modifiedDate;
newPage.ListItem.UpdateOverwriteVersion();
web.AllowUnsafeUpdates = false;
web.Dispose();
site.RootWeb.Dispose();
site.Dispose();

Friday, April 10, 2009

Download Document from SharePoint Library using WebService

In  following code, I am reading the contents from the documents and creating and storing documents in local system

//Copy WebService Settings
string webUrl = "http://portal/";
WSCopy.Copy copyService = new WSCopy.Copy();

copyService.Url = webUrl+"/_vti_bin/copy.asmx";

copyService.Credentials = System.Net.CredentialCache.DefaultCredentials;

//Source and Destination Document URLs
string sourceUrl = "http://localhost:1000/Shared%20Documents/Sample.doc";
string destinationUrl = "C:\\Documents\Sample.doc";


//Variables for Reading metadata’s of a document
WSCopy.FieldInformation fieldInfo = new WSCopy.FieldInformation();
WSCopy.FieldInformation[] fieldInfoArray = { fieldInfo };
WSCopy.CopyResult cResult1 = new WSCopy.CopyResult();
WSCopy.CopyResult cResult2 = new WSCopy.CopyResult();
WSCopy.CopyResult[] cResultArray = { cResult1, cResult2 };


//Receive a Document Contents into Byte array (filecontents)
byte[] fileContents = new Byte[4096];
copyService.GetItem(sourceUrl, out fieldInfoArray, out fileContents);


//Create a new file and write contents to that document
FileStream fStream = new FileStream(destinationUrl, FileMode.Create, FileAccess.ReadWrite);
fStream.Write(fileContents, 0, fileContents.Length);
fStream.Close();

Thursday, April 9, 2009

SHAREPOINT DESIGNER 2007 IS NOW FREE!

SharePoint Designer 2007 provides the powerful tools you need to deliver compelling and attractive SharePoint sites and quickly build workflow-enabled applications and reporting tools on the SharePoint platform, all in an IT-managed environment.

You can download it at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42.

Saturday, April 4, 2009

How to delete data from Sharepoint List using API?

Normally once you delete the data from the list it goes to Recycle Bin. During reading SDK I came to know about a method  'Delete' which deletes data permanently, does not send it recycle bin. So now we have two different approach for deleting list data.

Approach 1 - Delete Data Permanently

using (SPSite siteCollection = new SPSite("http://portal/"))
{
    using (SPWeb site = siteCollection.OpenWeb())
    {
       SPList list1 = site.Lists["MyList"];
       for (int i = list1.Items.Count - 1; i >= 0; i--)
      {
          list1.Items.Delete(i);
      }
    }
}

Approach 2 - Delete Data and it goes to recycle bin

using (SPSite siteCollection = new SPSite("http://portal/"))
{
   using (SPWeb site = siteCollection.OpenWeb())
   {
   SPList list1 = site.Lists["MyList"];
   for (int i = list11.Items.Count - 1; i >= 0; i--)
   {
      SPListItem olistitem = list11.Items[i];
      olistitem.Recycle();
   }
   }
}