About Me

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

Sunday, August 30, 2009

Usefull code samples in C#

// Getting the pressed key
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
// Code for the "Enter" key
}


//Check Other Name that has Mr. & "Spaces"
public static bool IsOtherName(string strOtherName)
{
Regex Pattern = new Regex("[^a-zA-Z\\.\\ ?]");
return !Pattern.IsMatch(strOtherName);
}

// String format for "Money"
String.Format("{0:0,0.00}", objRenewal.policy.dblPremium.ToString())

Tuesday, July 28, 2009

Sharepoint 2010 Overview

It's time to have a look new features that we want in sharepoint !!!

  1. Look & Feel (Ribbon Control)
  2. Multi document Checkout + avoid from post backs
  3. Nice pop-up windows than response.redirects J
  4. Direct uploading & showing images from your computer to sharepoint
  5. SilverLight webpart
  6. Nice themes like "PowePoint Theme"
  7. Visio services running with sharepoint services (Visio is not necessary)
  8. Fully rich Sharepoint Designer
  9. Entities to connect SQL,LOB with Edit/Delete functions (OOB)
  10. Direct connect to the office tools like Office 2010 with a click J

Change the data in a Infopath form library programatically

First we have to take care few things
(1) We should allow unsafe upates = true
(2) We should check out the file




(3) We cant use our item update event inside "SPSecurity.RunWithElevatedPrivileges(delegate.."
Code is simple

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPFolder oFolder = objWeb.GetFolder("Participant");
SPFileCollection collFiles = oFolder.Files;
objWeb.AllowUnsafeUpdates = true;

foreach (SPFile oFile in collFiles.Folder.Files)
{
SPListItem oListItem = oFile.Item;
oListItem.File.CheckOut();
oListItem["ProgramaticField"] = "Chanaka has done it";
oListItem.SystemUpdate();
oListItem.File.CheckIn("chana did");
}

Thursday, July 23, 2009

Sharepoint hints

Web Services that we are getting
http://sharepointsvr:15613/_vti_bin/lists.asmx


How I enable Anonymous+Access
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExfqTp8opjEIK37d5Ak4m23971jeqCoa4-EHhSnu0oqx4lViqvpxT63woZntJ6w5PBKMds_vztzOULvs4wjiZdLxi6CEtipwWKv9thleI2Y4oy5wefeeXxUcVo1W1iK4IYNsUOujojU0/s1600-h/Anonymous+Access.JPG

Get the response of web request programatically

StreamReader responseReader = null;
HttpWebRequest httpRequest = null;
httpRequest = (HttpWebRequest)WebRequest.Create("http://172.21.0.60:8034/");
httpRequest.Method = "GET"; // User get data

HttpWebResponse webResponse = null;
webResponse = (HttpWebResponse)httpRequest.GetResponse();
Encoding enc = Encoding.Default;
responseReader = new StreamReader(webResponse.GetResponseStream(), enc);
String temp = responseReader.ReadToEnd();

Wednesday, July 22, 2009

Infopath data retrieve with Sharepoint

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPList objList = objWeb.Lists["Participant"];
SPQuery objQuery = new SPQuery ();
SPListItemCollection objCollection = objList.GetItems(objQuery);
SPListItem objItem = objCollection[0];
SPFile objFile = objItem.File;
byte[] xmlFormData = objFile.OpenBinary();
XPathDocument ipForm = null;
using (MemoryStream ms = new MemoryStream(xmlFormData))
{
ipForm = new XPathDocument(ms);
ms.Close();
}
XPathNavigator ipFormNav = ipForm.CreateNavigator();
XPathNavigator nodeNav = ipFormNav.SelectSingleNode("/my:myFields/my:fldFamilyName", GetFormNSM(ipForm));
string strValue = nodeNav.InnerXml;
Response.Write(strValue);


//XML Namespace Creator

private XmlNamespaceManager GetFormNSM(XPathDocument ipForm)
{
const string strMYNamespacePrefix = "my";
const string strMYNamespaceURI = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-06-25T10:50:10";

const string strDIRNamespacePrefix = "d";
const string strDICNamespaceURI = "http://schemas.microsoft.com/sharepoint/soap/directory/";


XPathNavigator formAccess = ipForm.CreateNavigator();
XmlNamespaceManager namespaceMngr = new XmlNamespaceManager(formAccess.NameTable);
namespaceMngr.AddNamespace(strMYNamespacePrefix, strMYNamespaceURI);
namespaceMngr.AddNamespace(strDIRNamespacePrefix, strDICNamespaceURI);

return namespaceMngr;
}

Monday, July 13, 2009

RunWithElevatedPrivileges in sharepoint


When we try to get data from a document library that is not assigned for current user, we are getting this error.

Solution is:::::

SPSecurity.RunWithElevatedPrivileges(delegate()
{
//any code that we have to use
});


Sometimes even we add this delegate still it's not working.
That's because the object we are using made without elevated privileges.
(Ex:- We are creating SPWeb under the delegate, but the SPSite(parent object) object is outside the delegate, then we won't get chance to access data)

Monday, June 15, 2009

Sharepoint backup & restore using STSADM

C:\Documents and Settings\Administrator>cd C:\Program Files\Common Files\Microso
ft Shared\web server extensions\12\bin

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o backup -url http://sharepoint:5555/ -filename chana.bak

///Chana.bak is the name back up file

Operation completed successfully.

//// get the file from ‘12\bin\’ folder in development machine

//// transfer to the SERVER & put into ‘12\bin\’

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o restore -url http://sharepoint:5555/ -overwrite -filename chana.bak

Operation completed successfully.

Monday, May 25, 2009

My Career After One Year + My Interests In Next Year

We did many sharepoint implementations. But......

What we did more, other than sharepoint branding & small customization

(1) ( 1) Build using feature

(2) (2) Fire feature activation events & add tracking

(3) (3) Configure RMS (Rights Management Server)

(4) (4) Change whole master pages using features & SPD (Sharepoint Designer)

(5) (5) Add Ajax enable webparts into sharepoint sites

(6) (6) Active directory users migration using SSP


We did workflows other than simple approval workflows

(1) (1) Dynamic workflows (No of levels)

(2) (2) Dynamic approvers (different approvers)

(3) (3) Configure SSL

(4) (4) Reports generations using SSRS

(5) (5)Creating Collect feedback, Collect signature workflows

(6) (6) InfoPath forms integration using X-Path to workflows








My Masters