Houston TechFest Wrap-up

As they say, “everything is bigger in Texas” and the Houston TechFest is a great example of that.  A large, independently organized event covering many diverse technical subjects and disciplines.  I really had fun and got to meet some interesting people.

I enjoyed my session, and would like to thank everyone that attended.  My slide deck for the session is available here:

Houston tech fest dev intro to sharepoint searchhttp://static.slidesharecdn.com/swf/ssplayer2.swf?doc=houstontechfest-devintrotosharepointsearch-101128124443-phpapp01&stripped_title=houston-tech-fest-dev-intro-to-sharepoint-search&userName=nextconnect

View more presentations from nextconnect.

Source Code for the Manager Web Part is below:

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search.Query;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.Office.Server.UserProfiles;
using System.Collections.Specialized;
using Microsoft.SharePoint.Administration;
using System.Collections;
using System.Data;
using System.Text;

namespace NextConnect.Search.Presentation.DisplayManagers
{
[ToolboxItemAttribute(false)]
public class DisplayManagers : WebPart
{
protected Literal literalMessage;

protected override void CreateChildControls()
{
this.literalMessage = new Literal();
this.literalMessage.ID = "literalMessage";
this.Controls.Add(this.literalMessage);
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DisplayFullText();
}

protected void DisplayFullText()
{
StringBuilder messages = new StringBuilder();
DataTable results = new DataTable();

string searchProxyName = "Search Service Application";
SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue();
SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue(searchProxyName);
FullTextSqlQuery mQuery = new FullTextSqlQuery(searchProxy);

try
{
mQuery.QueryText = "SELECT LastName, FirstName, JobTitle, accountname FROM SCOPE() WHERE ("scope" = 'People') AND CONTAINS(JobTitle, 'Manager') AND NOT CONTAINS(Department, '1099')";

mQuery.ResultTypes = ResultType.RelevantResults;
mQuery.TrimDuplicates = false;
mQuery.RowLimit = 100;
//mQuery.KeywordInclusion = KeywordInclusion.AnyKeyword;
//mQuery.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;

ResultTableCollection resultTables = mQuery.Execute();
if (resultTables.Count > 0)
{
ResultTable relevantResults = resultTables[ResultType.RelevantResults];
results.Load(relevantResults, LoadOption.OverwriteChanges);
}
messages.AppendFormat(@"
Found {0} result(s).
    ", results.Rows.Count);

    foreach (DataRow row in results.Rows)
    {
    messages.AppendFormat(@"
  • {0}, {1} - {2}
  • ", row[0].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString());
    }
    messages.AppendFormat(@"
");

this.EnsureChildControls();
this.literalMessage.Text = messages.ToString();
}
catch (Exception ex)
{
this.EnsureChildControls();
this.literalMessage.Text = "Error: " + ex.Message.ToString();
}
finally
{
mQuery.Dispose();
}
}
}
}

I hope everyone else enjoyed the event as well!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: