About Me

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

Friday, October 31, 2008

WORKFLOW FOUNDATION ENGINE

It's time to move from sharepoint to workflow engine. Actually i have to combine these 2 technologies.

WORKFLOW FOUNDATION (WF) has 2 main areas
(1) WCF(Windows Communication Foundation)
(2) WPF(Windows Presentation Foundation)

when design the workflow it has 3 approaches
(1) No-Code (using Sharepoint Designer)
(2) Code (Using VS++++++)
(3) Code-beside (combination of above methods)

The WF came up with many advanced concepts like,
***Validator
***Executor
***Serializer

So many will come soon... :)

Programatically Add a WORKFLOW to a SPList

private void setWorkflow()
{
try
{
SPWeb web = site.RootWeb;
SPList refList = web.Lists["DepartmentDetails"];

SPWorkflowManager wfManager = site.WorkflowManager;
SPWorkflowTemplateCollection wfTemplates = wfManager.GetWorkflowTemplatesByCategory(web, null);
string test = wfTemplates[0].Name;
test = wfTemplates[1].Name;
test = wfTemplates[2].Name;
test = wfTemplates[3].Name;
test = wfTemplates[4].Name;
SPList taskList = web.Lists["Tasks"];

Guid WorkflowHistoryGuid = web.Lists.Add("HistoryOfWorkflow", "description History", SPListTemplateType.WorkflowHistory);
SPList HistoryList = web.Lists[WorkflowHistoryGuid];
//SPList HistoryList = web.Lists["HistoryOfWorkflow"];

SPWorkflowTemplate wfTempl = wfTemplates.GetTemplateByName("Approval", CultureInfo.CurrentCulture);
SPWorkflowAssociation wfAssocite = SPWorkflowAssociation.CreateListAssociation(wfTempl, wfTempl.Name, taskList, HistoryList);

wfAssocite.AutoStartCreate = true;
refList.AddWorkflowAssociation(wfAssocite);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Wednesday, October 29, 2008

Working With SPList & CAML Queries

SPWeb web = site.RootWeb;
SPList refList = web.Lists["refLstAAProgress"];
SPQuery
query = new SPQuery();


//
WITH MORE RESCRICTIONS

query.Query= "<Where><And><Eq><FieldRefName='colFormName' /><Value Type='Text'>" + pFormName +"</Value></Eq><Eq><FieldRef Name='colGroup'/><Value Type='Text'>"+ pGroupName+"</Value></Eq></And></Where>";


//
SIMPLE FILTERING

//query.Query= "<Where><Eq><FieldRef Name='SystemName'/><ValueType='Text'>" + pstrSystemName + "</Value></Eq></Where>";


SPListItemCollection collec = refList.GetItems(query);

//
UPDATE AN ENTRY

if (collec!= null && collec.Count > 0)


{

SPListItem itemEdit = collec[0];

itemEdit["colIsDone"]= "True";

web.AllowUnsafeUpdates= true;

itemEdit.SystemUpdate();

}


web.AllowUnsafeUpdates= false;

web.Dispose();

//ADD AN ITEM TO THE LIST


SPWeb web = site.RootWeb;

web.AllowUnsafeUpdates = false;
SPList
refList = web.Lists["refLstStageTracking"];
SPListItem
newListItem =logginList.Items.Add();
newListItem["Title"] ="GOGOGO";
newListItem["colFormName"] =pFromName;
newListItem["colStage"] = pStage;

newListItem["colLoginName"] = pLoginName;

newListItem.Update();

Thursday, October 23, 2008

Enable Search In Sharepoint Easily

1) Go to CURRENT Web application through Central Administration

2) Create a site collection using "SEARCH CENTRE WITH TABS" under ENTERPRISE tab

3) Name as "SearchSiteChanaka"

3) Go to the CURRENT site

4) Go to all site settings

5) Search settings --> set as /sites/SearchSiteChanaka/Pages/

6) When user click he will be redirected to the search result page J

One small thing that you have to do now...

Go to

7) SSP

8) then go to 'Search settings'

9) Click on 'Content sources and crawl schedules'

10)Set incremental or full crawl

Now that's all

:)

Friday, October 17, 2008

MySite Creation Programatically

ServerContext context = ServerContext.GetContext(site);

UserProfileManager profileManager = new UserProfileManager(context);

foreach(UserProfile userProfile in
profileManager)

{try
{
string userName =userProfile[PropertyConstants.AccountName].Value.ToString();

Logger.LogDebug("Creating
personal site for user : "
+ userName);

userProfile.CreatePersonalSite();
Logger
.LogDebug("Created
personal site for user : "
+ userName);

SPSite personalSite = userProfile.PersonalSite;

using(SPWeb web = personalSite.OpenWeb())
{

if
(!Utility.ListExists(ConfigurationInfo.PhotoLibraryDisplayName,web))
{
SPListTemplateType templateType = SPListTemplateType.PictureLibrary;
Guid
listId = web.Lists.Add(ConfigurationInfo.PhotoLibraryDisplayName,null, templateType);

SPList PhotoLibrary = web.Lists[listId];
PhotoLibrary.Description = "This is a picture library to show photos";

PhotoLibrary.Title= ConfigurationInfo.PhotoLibraryDisplayName;
PhotoLibrary.OnQuickLaunch= true;
PhotoLibrary.Update();

web.AllowUnsafeUpdates = true;
web.Dispose();

}

}

}


catch(Exception ex)

{
Logger
.LogDebug("error while creating MySite :" + ex.Message);
}
}

Create Sharepoint People Picker Programatically

protected override void CreateChildControls()
{
PeopleEditor peoplePick = new PeopleEditor();
peoplePick.AllowEmpty = true;
peoplePick.AllowTypeIn = true;
peoplePick.BrowseButtonImageName = "Search";
peoplePick.CheckButtonImageName = "Validate User";
peoplePick.ErrorMessage = "No Names Found";
this.Controls.Add(peoplePick);
base.CreateChildControls();
}

Friday, October 10, 2008

use of Singleton Pattern

The use of the singleton pattern is, it creates only one instance. First tme it will create an instance, but when the next call it will return the current instance, not create new instance.

Practical Example:- Normally a user can’t get two credit cards from same bank

public sealed class Logger

{

static Logger instance=null;

static readonly object padlock = new object();

private TextWriterTraceListener listener;

public void Create(string filename)

{

if (listener == null)

{

listener = new TextWriterTraceListener(filename);

}

}

Logger()

{

}

public void WriteLog(string message)

{

listener.Write(message);

}

public static Logger Instance

{

get

{

lock (padlock)

{

if (instance==null)

{

instance = new Logger();

}

return instance;

}

}

}

}

Create A Web Application Using Commands

Here you have to download the Extension of the STSADM + Have to deploy the solution to the farm........
Because the
gl-createwebapp is a new feature!!!!!

stsadm -o gl-createwebapp
-url "http://testwebapp"
-directory "c:\moss\webs\testwebapp"
-port 80
-ownerlogin "domain\user1"
-owneremail "someone@example.com"
-exclusivelyusentlm
-databasename "SharePoint_TestWebApp"
-sitetemplate "SPS#0"
-description "SharePoint_TestWebApp_80"
-sethostheader testwebapp -apidname "AppPool1"
-apidtype configurableid
-apidlogin "domain\user2"
-apidpwd "password" -timezone 10

Monday, October 6, 2008

Importance of SSP(Shared Services Provider)

The application node hosts the logical layer of sharepoint. This is also called Shared Services Provider.
It consists of many functions
(1) Index Service [also called CRAWLING]
(2) Query Service
(3) Profile Management
(4) Content Management
(5) Audience Management
(6) Business Data Catalog
(7) Excel Services
(8) Form Services [deal with INFOPATH]
(9) Job Scheduling
(10)Usage Reporting

this is a list of functions that are coming with SSP.
have a fun of ........

Sunday, October 5, 2008

Add a OOB webpart programatically in to a page

//
Add a webpart programatically in a easy manner
J

I tried to find out a method to add OOB webparts directly into a page.
Today I managed to do it!!!!!!!

This
is very useful if we are going to add Events, Forum(Discussion
board), Tasks list into our page with the OOB features.

using(SPLimitedWebPartManager wpm =web.GetLimitedWebPartManager(siteMapPage.Url,
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))

{

//am creating a Task list

Guid WorkflowHistoryGuid = web.Lists.Add(ConfigurationInfo.Tasks, ConfigurationInfo.Tasks,SPListTemplateType.Tasks);


SPList TaskList = web.Lists[ConfigurationInfo.Tasks];

TaskList.OnQuickLaunch = true;
TaskList.Update();

//actual
work starts

ListViewWebPart webPart = new ListViewWebPart();
SPList
taskList = web.Lists[ConfigurationInfo.Tasks];
SPView
viewMyTasks = taskList.Views[“My Tasks”];
viewMyTasks.DefaultView = true;
viewMyTasks.Update();

taskList.Update();

webPart.ListName = taskList.ID.ToString("B").ToUpper();

webPart.ViewGuid = taskList.DefaultView.ID.ToString("B").ToUpper();
wpm.AddWebPart(webPart,"MiddleRightZone", 2);

}

My Masters