About Me

My photo
a Dynamic and Energetic guy.....

Monday, September 29, 2008

VSTS 2010 your ultimate tool

Today i had a chance to look about the VSTS 2010....
It's going to be the next revolution in the programming world....

It will be consists of
(1) Discover and identify existing code assets and architecture with the new Architecture Explorer.
(2) Design and share multiple diagram types, including use case, activity and sequence diagrams.
(3) Improve testing efforts with tooling for better documentation of test scenarios and more thorough collection of test data.
(4) Identify and run only the tests impacted by a code change easily with the new Test Impact View.
(5) Enhanced version control capabilities including gated check-in, branch visualization and build workflow.

There will be so many features...
The best chance that you are getting with the VSTS is, it manage all the things from the design phase to the deployment phase...
be ready with new VSTS 2010

Sunday, September 28, 2008

Add Sharepoint OOB SummaryLinkWebPart Programatically

protected override void CreateChildControls()

{
if(!_error)
{

try

{
base.CreateChildControls();
//EnterpriseAnnouncement webpart

SPWeb
web = SPContext.Current.Web;
SPList
enterpriseNoticeList = web.Lists[EnterpriseNoticeBoardUrlName”];
SPQuery
query = new SPQuery();
SPListItemCollection
collection = enterpriseNoticeList.GetItems(query);

if(collection != null)

{
SummaryLinkWebPart
announcementWP = new SummaryLinkWebPart();
announcementWP.Title = ConfigurationInfo.AnnouncementsListDisplayName;
int counter = 0;

foreach (SPListItem item in collection)

{
try
{
announcementWP.SummaryLinkValue.SummaryLinks.Add
(new SummaryLink(item["Title"].ToString()));

announcementWP.SummaryLinkValue.SummaryLinks[counter].LinkUrl = http://www.google.lk;
//
EnterpriseAnnouncement
item[“URL”].ToString();

announcementWP.SummaryLinkValue.SummaryLinks[counter].OpenInNewWindow = true; announcementWP.SummaryLinkValue.SummaryLinks[counter].Description = item["Comments"].ToString(); announcementWP.SummaryLinkValue.SummaryLinks[counter].Style = "Image on left";
announcementWP.SummaryLinkValue = announcementWP.SummaryLinkValue;
counter++;

}

catch(Exception ex)

{
}


}
this.Controls.Add(announcementWP);

}

else

{}

}

catch(Exception ex)

{
}

}
}

Common SHAREPOINT errors.......

When you are working with sharepoint... you will get common errors...
if you are aware you can resolve it easily.....


*** have you ever got a error like this....
-------> this is because of an strange character in your item. this can be a image name, file name or template name....
-------> go through the names of the items and change the names with the conventions

Friday, September 26, 2008

Modify And Add OOB webpart into your SHAREPOINT..programatically

This is very nice....
You can add any default webpart with your modification into the webpart zone programatically.
(Am using TableOfContents.webpart to show the site map of your sharepoint site...)


using (SPLimitedWebPartManager wpm = web.GetLimitedWebPartManager(siteMapPage.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
{
#region Creating SiteMap Web Part
SPList wpGallery = site.GetCatalog(SPListTemplateType.WebPartCatalog);
foreach (SPListItem item in wpGallery.Items)
{
if (string.Compare(item.Name, "TableOfContents.webpart", true,
CultureInfo.InvariantCulture) == 0)
{
SPFile wpFile = item.File;
string errorMessage = String.Empty;
XmlReader reader = XmlReader.Create(wpFile.OpenBinaryStream());
TableOfContentsWebPart tocWP = new TableOfContentsWebPart();
tocWP = (TableOfContentsWebPart)wpm.ImportWebPart(reader, out errorMessage);
tocWP.ID = "wpTableOfContents";
wpm.AddWebPart(tocWP, "MiddleRightZone", 1);
tocWP.Title = "SiteMap Dialog";

// Initialize some properties on the web part
tocWP.AllowClose = false;
tocWP.AllowEdit = true;
tocWP.AllowHide = false;
tocWP.AllowZoneChange = false;
tocWP.AllowMinimize = false;
tocWP.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;


wpm.SaveChanges(tocWP);
wpm.Web.Dispose();
}
}
#endregion
}

Wednesday, September 24, 2008

Sharepoint --- Change the default view programatically

Hi...
I had a requirement to change the default view programatically...
I tried so many code snippets, but it didnt work...
Finally i got the treat...

SPView myNewDefaultView = myList.Views["MyNewView"];
myNewDefaultView .DefaultView = true;
myNewDefaultView .Update();
myList.Update();

its really good to set
rootWeb.AllowUnsafeUpdates = true;
before you try this...
done.......

Tuesday, September 23, 2008

Create a folder inside your SHAREPOINT list or document library

public static void CreateFolder(SPWeb rootWeb, SPList eLibrary, string strFolderName)
{
try
{
using (rootWeb)
{
rootWeb.AllowUnsafeUpdates = true;
SPFolderCollection folders = rootWeb.GetFolder(eLibrary.RootFolder.ServerRelativeUrl).SubFolders;
SPFolder newFolder = folders.Add(strFolderName);
newFolder.Update();
eLibrary.Update();
}
}
catch(Exception ex)
{
Logger.LogWarning("Error configuring ELibrary Folder: " + ex.Message);
}
}

Wednesday, September 17, 2008

Create a SHAREPOINT site collection & subsites programatically

try
{
SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("http://dev3:10131"));
SPSiteCollection siteCollections = webApplication.Sites;
siteCollections.Add("http://dev3:10131/IntranetMOSS", "chanaka_temp", "chanacse@gmail.com");
}
catch(Exception ex)
{
// log the error
}

// Add subsites into the siteCollection
try
{
using (SPSite mySite = new SPSite("http://dev3:10131/IntranetMOSS"))
{
using (SPWeb myWeb = mySite.OpenWeb())
{ //path name
SPWeb newWeb = myWeb.Webs.Add("SBU", "SBU's", "Add for commercial purpose", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Newss", "News", "Update with the ", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Groups", "Groups", "As a unit", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("CorporateNews", "Corporate News", "All you need", 1033, "STS#0", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Services", "Services", "Always with you", 1033, "STS#0", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("UserManuals", "User Manuals", "Help", 1033, "STS#0", false, false);
newWeb.Update();
}
}
}

// you can set the breadcrumb of the each site through the code also
// Simple task.........


try
{
SPSite ChildSite = new SPSite(web.Url);
SPWeb DChildWeb = ChildSite.OpenWeb();
SPNavigationNode ParentNode = new SPNavigationNode(parentWeb.Title, parentWeb.Url + "/HomePage.aspx", true);
SPNavigationNode ChildNode = new SPNavigationNode(DChildWeb.Title, DChildWeb.Title + "/HomePage.aspx");
parentWeb.Navigation.TopNavigationBar.AddAsLast(ChildNode);
web.Navigation.TopNavigationBar.AddAsFirst(ParentNode);
web.Navigation.UseShared = true;
web.Update();
}
catch (Exception ex)
{
// log this error
}

Create a webpart using Visual Studio

This is an old method, but i think this will be useful if someone has very basic knowledge.
User can add a usercontrol & any code can be in your usercontrol

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace UCAddSubjectNewsWebpart
{
public class UCAddSubjectNews : WebPart
{
UserControl usercontrol;
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
usercontrol.RenderControl(writer);
}

protected override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.Clear();
usercontrol=(UserControl)this.Page.LoadControl("~/usercontrols/Name_of_user_control.ascx");
this.Controls.Add(usercontrol);
}
}
}

Saturday, September 6, 2008

Install a feature into sharepoint

1) Open Visual Studio Command Promt

2) Navigate to 12 hive folder
a. cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

3) stsadm –o installfeature – name myFeature

4) Activate the feature by using the site settings --> site administration --> site features --> Click activate button of myFeature (new feature)

When you create a Document Management System

Factors that should be considered before make a document library (SharePoint)
1) Types of document that we are going to store (upload)
2) Templates that we are going to use
3) Metadata that associated with the documents
4) Access control
5) Policy of the documents
6) Conversion of documents (if needed in future)
7) Ability to move documents away from the document library

Most of these features can be done by using the OOB features
1) Permission setting of the document libraries
2) Target audience of the document libraries
3) Select main type of the document that we are focusing on library

How to plan the document library
1) Define the roles
2) Estimate the usage of documents
3) Organize the document
4) Content types (metadata, features, properties)
5) Content control
6) Workflows
7) Policy management

My Masters