About Me

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

Wednesday, September 14, 2011

Create SharePoint search results using FullTextSqlQuery

            DataTable search = new DataTable();
            using (SPSite site = new SPSite(SPContext.Current.Web.Site.Url))
            {
                SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue();
                SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue("Search Service Application");

                FullTextSqlQuery query = new FullTextSqlQuery(searchProxy);

                query.QueryText = "SELECT FirstName,LastName ,AccountName,WorkPhone,UserName,PreferredName,AboutMe,NationalityP,NationalityS FROM SCOPE() WHERE \"Scope\"='People' ";
                query.ResultTypes = ResultType.RelevantResults;
                query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
                query.KeywordInclusion = KeywordInclusion.AllKeywords;

                ResultTableCollection results = query.Execute();
                if (results.Count > 0)
                {
                    ResultTable relevant = results[ResultType.RelevantResults];
                    search.Load(relevant);

                    // serialize DataTable to XML
                    StringBuilder resultsXml = new StringBuilder();
                    using (StringWriter sw = new StringWriter(resultsXml))
                    {
                        search.WriteXml(sw);
                        sw.Flush();
                    }

                    // move XML to the XmlDataSource
                    XmlDataSource xds = new XmlDataSource();
                    xds.EnableCaching = false;
                    xds.Data = resultsXml.ToString();
                }
            }

Create SharePoint search results programatically

private void ComplexSearch()
        {
            SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue();
            SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue("Search_Service_CUSTOM");
            KeywordQuery keywordQuery = new KeywordQuery(searchProxy);
            string SearchScope = "PEOPLE";
            keywordQuery.HiddenConstraints = "scope:" + "\"" + SearchScope + "\"";

            keywordQuery.TrimDuplicates = true;
            keywordQuery.EnableStemming = true;
            keywordQuery.IgnoreAllNoiseQuery = true;
            keywordQuery.QueryText =  "SELECT AccountName,PreferredName,PictureUrl,WorkEmail,JobTitle,Department,InternalNumber,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,InternalTelephone,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,HitHighlightedProperties,CollapsingStatus,Path,FirstName,LastName FROM Scope() WHERE ('scope'='People')";


            keywordQuery.EnablePhonetic = true;           
            keywordQuery.ResultsProvider = SearchProvider.Default;
            keywordQuery.ResultTypes = ResultType.RelevantResults | ResultType.SpecialTermResults ;
            ResultTableCollection resultsTableCollection = keywordQuery.Execute();
            ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];
            DataTable resultsDataTable = new DataTable();
            resultsDataTable.TableName = "Results";
            resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);

            DataView view = new DataView(resultsDataTable);
            SearchGrid.DataSource = resultsDataTable;
            SearchGrid.DataBind();
        }

Wednesday, August 31, 2011

SharePoint Credential Popup disabling

It was a so much trouble to me when working SharePoint to give "Credentials" always. Even we are not thinking about it, it takes considerable amount of time. So i have decided to avoid from it. 

Internet Explorer --> Internet Options --> Security --> Trusted Sites --> User authentication


Wednesday, August 17, 2011

How to Open a DataSet using Microsoft Excel in a web application

protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            DataSet ds = CurrentApproverService.GetReportData(depID, UserID);

            DataGrid dg = new DataGrid();
            dg.DataSource = ds;
            dg.DataBind();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=" + "ReportData.xls");
            Response.ContentType = "application/excel";
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            dg.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();

            dg = null;
            dg.Dispose();
        }

Monday, August 8, 2011

How SharePoint 2010 Installation creates SQL Sever DataBases

I was able to get step by step screen shots of,
SharePoint 2010 installation Vs. SQL Server DB creation

                                                      (1) Initial DB structure


(2) While SharePoint 2010 Installing

(3) Step 3 of  "SharePoint 2010 product configuration" is the main step that creates "Config" database

(4)  When "Configure SharePoint Farm" using Central Administration

(5) SQL DB structure while running wizard

(6) After Configured All Services in "SharePoint 2010"
It is Easy And Structured :)


Localization in SharePoint

It was a horrible week for me, because of a too critical task, i.e.LOCALIZATION

Finally i was able to do it :) :) :)

*** Added "ChanaApp.resx" to App_GlobalResources folder in [Port] folder
*** Added "ChanaApp.nl.resx" to same folder
*** Added a label to .ASPX page
*** Set the Expression of the label, set the TEXT property using "Resources"

*** If only one page we can use
 protected override void InitializeCulture()
        {
            string[] languages = HttpContext.Current.Request.UserLanguages;
            string language = languages[0].ToLowerInvariant().Trim();

            string selectedLanguage = language;
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
            base.InitializeCulture();
        }

*** If for total web application then we have to use
protected void Application_BeginRequest(object sender, EventArgs e)
        {
            string[] languages = HttpContext.Current.Request.UserLanguages;
            string language = languages[0].ToLowerInvariant().Trim();
            string selectedLanguage = language;
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
        }
in GLOBAL.ASAX file.
*** Change the Culture of browser will change the TEXT in the label

Saturday, July 9, 2011

Enable "Master Page" in a team site


We cant see "Master Page" in Look and Feel section

Enable "Site Collection" feature


Enable "Site" feature

Now we can see "Master Page" under "Look and Feel" section


Monday, June 27, 2011

Download SharePoint 2010 Pre-Requisites

Microsoft SQL Server 2008 Native Client Download Here
Hotfix for Microsoft Windows (KB976462) Download Here
Windows Identity Foundation (KB974405) Download Here
Microsoft Sync Framework Runtime v1.0 (x64) Download Here
Microsoft Chart Controls for Microsoft .NET Framework 3.5 Download Here
Microsoft Filter Pack 2.0 Download Here
Microsoft SQL Server 2008 Analysis Services ADOMD.NET Download Here
Microsoft Server Speech Platform Runtime (x64) Download Here
Microsoft Server Speech Recognition Language – TELE(en-US) Download Here
SQL 2008 R2 Reporting Services SharePoint 2010 Add-in Download Here

Microsoft Office 2010 Filter Packs for SharePoint


The Microsoft Filter Pack is a single point-of-distribution for Office IFilters. IFilters are components that allow search services to index content of specific file types, letting you search for content in those files. They are intended for use with Microsoft Search Services (Sharepoint, SQL, Exchange, Windows Search). 
The Filter Pack includes:

* Legacy Office Filter (97-2003; .doc, .ppt, .xls)
* Metro Office Filter (2007; .docx, .pptx, .xlsx)
* Zip Filter
* OneNote filter
* Visio Filter
* Publisher Filter
* Open Document Format Filter

Thursday, June 23, 2011

SharePoint 2010 People Picker Programatically

PeopleEditor peoplePick = new PeopleEditor();

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

    protected void btnSave_Click(object sender, EventArgs e)
        {           
            foreach (string ent in peoplePick.CommaSeparatedAccounts.Split(','))
            {
                if (ent.Length > 0)
                {
                    PeerReviewGroup_Employee objPeerEmp = new PeerReviewGroup_Employee();
                    objPeerEmp.EmpID = Utility.GetNullableInt(GetSelectedUserIDsByName(ent));
                    objPeerEmp.GroupID = int.Parse(ddlPeerGroup.SelectedValue);

                    PeerReviewGroup_EmployeeService.Save(objPeerEmp);
                }
            }
           
        }

My Masters