Monday, December 22, 2008

Better way to get informations like Survey, Feedback, Status Report

Requesting information through Email?

Tired of Consolidating the email response received with information from the mail recipients?InfoPath and Outlook 2007 there to rescue. Move all the response to a folder
and click on export to excel button in outlook 2007 to get all the
information with response from all the respondents in a excel file.

Design an InfoPath form by just dragging and dropping controls into the form.


Go to Tools Form Options Security and Trust Tab

Enable full Trust and check on Sign this form Template. If the name doesn’t appear click on create certificate.


Select File Publish and select To a list of e-mail recipients.



Add the Columns that is required to be displayed in the outlook view



Enter the list of recipients in the To list and/or CC list



Create a new folder in Outlook with folder content type as InfoPath form Items as shown in
the screen shot below



Move all the response mails to the newly created folder. You can even write a rule to
automatically move mail responses to the folder created, Click on export to excel button in Outlook 2007







Get the consolidated information in the excel file without even opening the mail responses.



Monday, October 27, 2008

Visual Studio 2010 and .NET Framework 4.0 CTP Available

Visual Studio 2010 and .Net Framework the future technology is ready for the community technology preview

Some bits of the preview

C# 4.0, Domain Specific Language feature, Functional Language features, Democratizing Application Lifecycle Management, Enabling emerging trends, Inspiring developer delight and Riding the next generation platform wave.

The overview is available here

The CTP Download is available here

Friday, July 4, 2008

First day of the month oracle SQL Query

pretty much simple way get the First day of any month using SQL Query is

select trunc(sysdate,'MONTH') from dual

Trunc Function of PL/SQL when passed with a 'Month' parameter will return the first date of a month.

instead of sysdate use the date value you want

sysdate trunc(my_birth_day,'MONTH') from My_Details

Wednesday, June 18, 2008

The Sharepoint Developer Introduction for .NET Developers

A good resource for dotnet developers for a hands on Microsoft Office Sharepoint Server 2007 Development.

There are not much developers who are experts in MOSS 2007 Developments. This is the Microsoft's step for the .net communities to gain momentum in sharepoint development.

Video Tutorials and hands on Sessions are included and are really informative.

The Sharepoint Developer Introduction for .NET Developers

Tuesday, June 17, 2008

Architect Webcast Series

Aspiring Architect Series 2008 - A Web Cast series for aspiring architects.
Checkout the following link

Architect Webcast series

Sunday, June 15, 2008

Software Patterns

Architectural Patterns

• Highest level patterns
• Determines overall system architecture and provides the skeleton for the system
• Determines and specifies the relationship, roles and responsibilities of each subsystem
• It organizes the relationship between the sub systems
Eg.. SOA, Layered Architecture

Design Patterns

Used to fine tune the overall architecture and solve problems specific to the subsystem
It does structuring components, delegating and distributing workloads and organizing the communication and creation of components

Three Categories
• Creational Pattern
• Structural Pattern
• Behavioral Pattern

Implementation Patterns or Idioms

Defines solutions specific to a language
Even if I know the syntax in a language, to do efficient implementation one should use some specific styles that the language provides.

Tuesday, June 3, 2008

Yet Another reason why Properties should be used instead of Fields


Today, I did a little experiments on Properties VS Fields. It is better to use properties especially when that property is to interact with the other DLLs or external Assemblies.


Scenario: library.library.Name is a field in my library which I refer in my winapp. I executed it worked fine. I wanted to validate Name field for special characters so I decided to change “Name” (At present a Field in library) to a property so that I could validate it in the set property.


As the member name and the return type (string) did not change I did not recompile my winapp. But I got the following exception “Field not found” as it’s a property now.



Conclusion: When you need a member to interact with the external assemblies or DLLs or EXEs make it a property instead of field. This enables you to add validators later within your class.




Tuesday, May 27, 2008

want to use Session Variables in Sharepoint?

SharePoint by default does not use session state. You need to explicitly change it in the Web.Config file of your sharepoint web application
<httpmodules>
<clear>
<add type="System.Web.Caching.OutputCacheModule" name="OutputCache">
<add type="System.Web.Security.WindowsAuthenticationModule" name="WindowsAuthentication">
<add type="System.Web.SessionState.SessionStateModule" name="Session">
</httpmodules>

and also

<pages enablesessionstate="true" enableviewstate="true" enableviewstatemac="true" validaterequest="false">

Friday, May 23, 2008

Sick of unexpected error in sharepoint? Want to see asp.net like error page with stack trace?

In the web.config of the sharepoint web application set the following settings
"<"SafeMode MaxControls=“200“ CallStack=“true">"
"<"customErrors mode=“Off“/">"

Wednesday, April 23, 2008

Steps for creating features

1. create a directory structure in visual studio as follows
Featues / "<"featuesname">" / feature.xml
Add schema to feature.xml from loc -">" web server xtn\12\template\xml\wss12.xsd
"<"feature ID=”” Title=”” Description= “” Scope = “” Hidden=”false”
"<"feature id="””" title="””" description="“”" scope="“”" hidden="”false”"">" "<"!-Note users cant activate or deactivate the feature only admin can-">"
"<"elementmanifests">"
"<"elementmanifest location="”Elements.xml”"">"
"<"elementmanifests">""<"elementmanifest location="”Elements.xml”"">"
2. Add new file Elements.xml
"<"elements">""<"elements">"
"<"module name="””" path="”url”"">"
"<"file url="””" type="”Ghostable”"">"

3. Inherit from SPFeatureReceiver class
Override the events FeatureInstalled, FeatureActivated,
Featureuninstalled, Featuredeactivated, Featureuninstalling, Featuredeactivating
4. put the DLL in GAC
5. In feature.xml ad these tags
"<"Feature ID=””
ReceiverClass=
ReciverAssembly=

Steps for Creating Item Event Handlers

  1. Open VS 2005 -> Select a class Library project -> Name it ____Handlers.
  2. Inherit the class from SPItemEventReceiver.
  3. override ItemAdded, ItemUpdated (Asynchronous Events)
    Item Adding, ItemUpdating (Synchronous Events)
  4. Install the DLL in GAC
  5. There are Two ways to register an Event Handler a. Install Features b. Through code
  6. To Register through code -> Open new console project
    Open site -> web -> get the list through code use the following method to register
  7. List.EventReceivers.Add(, , );

Friday, January 4, 2008

This Code Creates Document Library, Creates Group and users and assigns it to Sharepoint Document Library

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace DocLibCreator
{
public class DocLibCreator
{
private SPWeb web;
private SPMember _Owner;
public SPGroup Group;
private string _utCode;
public Guid ListID;

public string utCode
{
get { return _utCode; }
set {
try
{
_utCode = value;
SPUser user;
if (Group != null)
{
user = web.Site.RootWeb.EnsureUser(_utCode);
AddUsersToGroup(user);
}
}
catch (SPException e)
{
//System.Windows.Forms.MessageBox.Show(e.Message);
}
}
}



public MercureSiteCreator(SPWeb web)
{
this.web = web;

}

private SPUser GetExistingUser(string _userString)
{
//parse the string after the delimiter '#'
int delimIndex = _userString.IndexOf("#");
string userStr = _userString.Substring(delimIndex + 1);
SPUser user = null;
foreach (SPUser thisUser in web.Users)
{ //if this is current user
if (thisUser.Name.ToLower().IndexOf(userStr.ToLower()) > -1)
{
user = thisUser;
break;
}
}
return user;
}

public SPMember owner
{
get { return web.CurrentUser; }
}

private string _groupName;

public string GroupName
{
get { return _groupName; }
set
{
_groupName = value;
Group = GetSiteGroup(_groupName);

}
}

private bool AddUsersToGroup(SPUser User)
{
if (!IsUserInGroup(User, Group.Name))
{
Group.AddUser(User);
web.AssociatedVisitorGroup.AddUser(User);
web.Site.RootWeb.AssociatedVisitorGroup.AddUser(User);
return true;
}

return false;
}

private bool IsUserInGroup(SPUser user, string grpName)
{
foreach (SPGroup group in user.Groups)
if (group.Name.ToLower().Trim() == grpName.ToLower().Trim())
return true;

return false;
}
public Guid createDocLibrary( string title)
{
Nullable id = GetExistingList(web, title);
if (!id.HasValue)
id = web.Lists.Add(title, "This was created Programatically", SPListTemplateType.DocumentLibrary);
ListID = id.Value;
return id.Value;
}

private Guid? GetExistingList(SPWeb myWeb, string title)
{
foreach (SPList list in myWeb.Lists)
{
if (list.Title.ToLower().Trim() == title.ToLower().Trim())
return list.ID;
}
return null;
}

private SPGroup GetSiteGroup(string groupName)
{
SPGroup group = null;
group = GetExistingSiteGroup(web.Site.RootWeb, groupName);
if (group == null)
{
web.Site.RootWeb.SiteGroups.Add(groupName, owner, null, "");
group = GetExistingSiteGroup(web.Site.RootWeb, groupName);
}




return group;
}

private SPGroup GetExistingSiteGroup(SPWeb webs, string name)
{
foreach (SPGroup group in webs.SiteGroups)
if (group.Name.ToLower().Trim() == name.ToLower().Trim())
return group;
return null;
}


public void CreatePermissions()
{
SPRoleAssignment roleAssignment = new SPRoleAssignment(Group);
SPRoleDefinition role = web.Site.RootWeb.RoleDefinitions["Read"];

if (!roleAssignment.RoleDefinitionBindings.Contains(role))
roleAssignment.RoleDefinitionBindings.Add(role);

SPList list = web.Lists[ListID];
//Check inheritance
if (!list.HasUniqueRoleAssignments)
{
list.BreakRoleInheritance(false);
}
list.RoleAssignments.Add(roleAssignment);
list.Update();
}
}
}