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))
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);
Categories: Lucene Search
Step 2