Wednesday, August 31, 2011

Alert Template Name                                                                 Description

SPAlertTemplateType.GenericList                       The first alert template in Alerttemplates.xml. GenericList
                                                                          is used unless there is a match to one of other event types.

SPAlertTemplateType.DocumentLibrary              Notification of changes in document libraries

SPAlertTemplateType.Survey                              Notification of changes in surveys

SPAlertTemplateType.Links                                Notification of changes in links

SPAlertTemplateType.Announcements                Notification of changes in announcements

SPAlertTemplateType.Contacts                          Notification of changes in contacts

SPAlertTemplateType.Events                              Notification of changes in events

SPAlertTemplateType.Tasks                               Notification of changes in tasks

SPAlertTemplateType.DiscussionBoard              Notification of changes in discussion boards

SPAlertTemplateType.PictureLibrary                  Notification of changes in picture libraries

SPAlertTemplateType.XMLForm                       Notification of changes in XML form

SPAlertTemplateType.DataConnectionLibrary            Notification of changes in data connection libraries
                
SPAlertTemplateType.AssignedtoNotification            Assigned to task / issue list notifications

SSO configuration in MOSS 2007

Open administration site Go to Administrative tools and then select Services in though services select Microsoft Single Sign-on Service make start-up type to Automatic  and then click Apply and then start the service
After starting this service Now go to Central Administration and then go to Operations Tab in this tab Under Security configuration ---> Manage settings for Single Sign-on
Over there under Server Setting click on Manage Server Settings over there you see a form fill in those fields see the image below, after filling all fields and click OK


After this SSO Name Database will be created in DB and all other links(Administration site related to SSO) which were previously disabled will get enabled
Now under Enterprise Application Definition Settings ---> Manage Settings for Enterprise Application Definition after that click on New Items
Fill Information as shown below you can give Display name & Application Name make sure that you giving Application Name a Sensible name because once given it can not be changed,after that fill E-mail address and Select Individual Under Account Type and Select Windows authentication leave Logon Account Information as it is and click ok

After that click on Manage account information for enterprise application definitions over there in drop down box of Enterprise application definition Select Application name which you just created above and enter user account name(same account which you have use in manage server settings) and click on update account information check box and click OK

SSO Configuration is Done

WSS,MOSS 2007,Sharepoint 2010: Uploading Files to moss 2007 using WinForm

WSS,MOSS 2007,Sharepoint 2010: Uploading Files to moss 2007 using WinForm: Hi Guys my client wanted application which can upload files from client folder to MOSS 2007 Site Library Scenario:- When client past any f...

Uploading Files to moss 2007 using WinForm

Hi Guys my client wanted application which can upload files from client folder to MOSS 2007 Site Library

Scenario:- When client past any file in a Folder call XYZ File upload should start!
Conclusion :- Apply File Watcher on folder XYZ folder so that all the activities can be traced

Code for Reference :-
//Attach Watch on particular folder
FileSystemWatcher oFileSystemWatcher = new FileSystemWatcher("D:\\redhatabhi\\xyz\\");
 //add watch on folder when New file is Created/Pasted/Moved
oFileSystemWatcher.Created += new FileSystemEventHandler(oFileSystemWatcher_Created);
// use following Property to Enable Event Raise in when new file are been added
oFileSystemWatcher.EnableRaisingEvents = true;
// use following Property for including Sub-folders also
oFileSystemWatcher.IncludeSubdirectories = true;

After applying this event you job is now to upload File in MOSS 2007.
Example :-
            FileInfo file = new FileInfo(e.FullPath);
            if (file.Extension == ".exe")
            notify.ShowBalloonTip(100, "Warning", "Uploading of Executable File is Not Allowed", ToolTipIcon.Warning);          
             using (SPSite oSPSite = new SPSite(siteURL))
            {
                using (SPWeb oSPWeb = oSPSite.OpenWeb())
                {
                    SPFolder oSPFolder = oSPWeb.GetFolder(oSPWeb.Url + "/DocumentLibrary/");
                    oSPFolder.Files.Add(file.Name, File.ReadAllBytes(file.FullName), true);
                    file.Delete();
                }        
             }

Tuesday, August 30, 2011

Web Service

hi guys while i was working in Project one requirement cam across,
requirement was as follows
using/referencing web-service but should work on which ever machine my code runs(for e.g. staging server & production server).
so i came across a solution,when you add reference of any web-service you get .disco file on project-explorer window click on show all files you then be able to see some file in Reference Folder in that open .cs file
and search for this.Url after that just place code below 

ConfigurationManager.AppSettings["EmployeeLog"].ToString();

function looks like this.

public EmployeeStatus()
    {
        string str = ConfigurationManager.AppSettings["EmployeeLog"].ToString();
        if (str != null)
        {
            this.Url = str;
        }
        else
        {
            this.Url = "";
        }
    }

now make Entry in web.config App-setting
that's it you are now all set to access web-service on any server.at-least you don't need to rebuild code again and again

Friday, August 26, 2011

How to set Favicon for SharePoint 2010 site?

SharePoint 2010 comes with a orange Favicon and it's present in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\. Open this folder and search for favicon.ico and rename the file to Favicon_Backup.ico. Now copy your favicon to this folder and make sure it's named as "favicon.ico". Now restart IIS(open Command Prompt -> IISReset), clear browser cache/temproary internet files. Close the browser and reopen then browse the SharePoint site.
If mulitple sites are hosted in same farm and need to set different favicons for different sites then we have to update Master Page Code. Open the site with SharePoint Designer 2010 and select Master pages -> v4.master. The default.master is still present in SharePoint 2010 for backward compatibility and visual upgrade. But SharePoint 2010 uses v4.master only. Now click "Edit File" link to add the favicon code. If it asks for check out, click yes and continue.

Find and change the path of favicon. Save and close (If you have checked out then you need to check in and site collection administrator has to approve it via Site Settings -> Galleries -> Master pages and page layouts -> Check in and Approve). Now reset IIS/clear browser cache and check.

Thursday, August 18, 2011

Javascript in Hyperlink Button in Gridview


In this Blog like to share you how we can do some scripting in Gridview hyperlink & conditional formatting.
below is example

in Text you can see i am getting value from gridview IsActive and making text change if  true the DeActive else Activate

Onclick i am opening a popup window for Activation and Deactivation on value which i get in IsActive
if it true then run a javascript function ConfirmDeActiveUsers,in this Function i can pass value with the help of following way.Command is nothing but value i need to pass it to javascript function or can even use javascript over there for example i can use Alert Function in Javascript to alert ID of that particular item

<asp:HyperLink Text='<%# Convert.ToBoolean(Eval("IsActive")) ? "Deactivate" : "Activate" %>' runat="server" ID="hyperlnkView" OnClick='<%# Convert.ToBoolean(Eval("IsActive")) ? Eval("command","return ConfirmDeActiveUsers(\"{0}\");") : Eval("command","ConfirmNonActiveUsers(\"{0}\");") %>' ></asp:HyperLink>

Wednesday, August 17, 2011

Uploading File in Sharepoint Document Library in folder

                                using (SPWeb userweb = new SPSite(url).OpenWeb())
                                {
                                    userweb.AllowUnsafeUpdates = true;
                                    //here url is nothing but site url,My Documents is Folder in document library                                    SPFolder oSPFolder = userweb.GetFolder(url + "/My Documents/");
                                    //here i have a object of file which i need to upload as SPFILE                                    SPFile file = properties.ListItem.File;
                                    if (file.ModifiedBy.LoginName == currentusr)
                                    {
                                        //get file in Byte formate for Upload bz when we say oSPFolder.Files.Add it
                                         requires Byte
                                        byte[] data = file.OpenBinary();
                                        // this will upload my file to document library in that particular folder
                                        oSPFolder.Files.Add(file.Name, data, file.Author, file.Author, file.TimeCreated, DateTime.Now);
                                    }
                                }

Wednesday, August 10, 2011

Editing UserInformation List From DB for MOSS 2007 & SharePoint 2010

Many developers have to work on VM Machine for Development,due to this they have limited acces to outside world like Domain and because of that you can't add user which have there email address.
we have a twick for this open SQL server and then go to DB to which your site is attached.

Now expand Table's Structure and search for UserInfo Table.
that's it you can open this table search for tp_Email Column and add which ever Email address you want, you can add you personal Email address also

Wednesday, August 3, 2011

Getting Attachment from List Items

with the help of following Function you can get Attached files of that particular Item

public List<SPFile> GetListItemAttachments(SPListItem listItem)
        {
            try
            {
                List<SPFile> lstSPFile = null;
                SPSecurity.RunWithElevatedPrivileges(delegate
                {
                    using (SPSite oSite = new SPSite(
                       listItem.ParentList.ParentWeb.Site.ID))
                    {
                        using (SPWeb oWeb = oSite.OpenWeb())
                        {
                            SPFolder folder = listItem.ParentList.RootFolder.
                               SubFolders["Attachments"].SubFolders[listItem.ID.ToString()];
                            if (null != folder)
                            {
                                lstSPFile = new List<SPFile>();
                                foreach (SPFile file in folder.Files)
                                {
                                    lstSPFile.Add(file);
                                }
                            }
                        }
                    }
                });
                return lstSPFile;
            }
            catch
            {
                return null;
            }
        }

Getting SPUser Object from PeoplePicker Field

if you are working on Sharepoint workflows and you want PeoplePicker Value in workflow 
with the help of following code we can get SPUser object.

SPFieldUser userField = (SPFieldUser)_activeWorkflow.ParentItem.Fields.GetField("AssignedTo");
SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(Convert.ToString(spI["AssignedTo"]));
SPUser user = fieldValue.User;

Adding SPUtility Mail Headers TO,CC,BCC

Using Following Code you can send mail TO,CC,BCC

StringDictionary headers = new StringDictionary();

headers.Add("to", sendTo);
headers.Add("cc", "");
headers.Add("bcc", "");
headers.Add("from", "admin@test.com");
headers.Add("subject", "Testing");
headers.Add("content-type", "text/html");
SPUtility.SendEmail(web,headers, Body);

Automatically Dispose SharePoint objects using C#

Follwoing Code help yoiu to automaticaly Dispose SPSite & SPWeb Object
this is because SPSite & SPWeb implements IDisposable Interface
you can use "Using" for disposing other objects which implements IDisposable Interface.

using(SPSite oSPsite = new SPSite("http://server"))
{
  using(SPWeb oSPWeb = oSPSite.OpenWeb())
   {
       str = oSPWeb.Title;
       str = oSPWeb.Url;
   }