Home > Lucene Search > Step 2: How to Display Search Results in the Desktop

Step 2: How to Display Search Results in the Desktop

Create a class called Launchresult.cs – This class allows user to open files found in Quick Search in the Developer Center.

Launchresult.cs

Include the following namespaces:

namespace FileCrawler.FileSystem
{
  using System.IO;
  using Sitecore;
  using Sitecore.Shell.Framework;
  using Sitecore.Shell.Framework.Pipelines;
  using Sitecore.Web.UI.Sheer;

When a user selects a search result that points to a file in the file system, the following function processes the request and opens the file in Developer Center:

public class LaunchResult
  {
    public void Process(LaunchSearchResultArgs args)
    {
      if (args.HasResult)
      {
        return;
      }
      if (!args.Url.StartsWith("file://"))
      {
        return;
      }

      string path = args.Url.Substring("file://".Length);
      if (File.Exists(path))
      {
        Windows.RunApplication("Layouts/IDE", "fi=" + path);
      }
      args.AbortPipeline();
    }
  }
}

This section of code contains the path to the file that the Sitecore.Search Crawler has found.

string path = args.Url.Substring("file://".Length);
      if (File.Exists(path))

file crawler dev center

This function opens the developer center, using the file path as a parameter. When you see a file name in the search results, click the file name and open it directly in the Developer Center. The fi query string parameter allows you to open the developer center to view or edit the specific file.

Windows.RunApplication("Layouts/IDE", "fi=" + path);

Step 3: Create a File Crawler Config File

Categories: Lucene Search Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.