16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

Chapter 36: Building Applications for <strong>Microsoft</strong> Office SharePoint Portal Server 2003 995<br />

else<br />

{<br />

//15. Message the user that no resources were returned<br />

listBox1.Items.Add("No resources were returned.");<br />

}<br />

}<br />

else<br />

{<br />

//16. Message the user if search is not ONLINE<br />

// Currently, the only other value is OFFLINE<br />

listBox1.Items.Add("Search is currently "<br />

+ queryWS.Status());<br />

}<br />

Notice that in line 1 of the code we set up a variable containing the XML<br />

required for querying the Web service. To do an MSSQLFT search instead of a<br />

STRING search, just change type=\"STRING\" to type=\"MSSQLFT\". But if you do that,<br />

the text box needs to contain a query rather than just a string when the button is<br />

clicked.<br />

In line 7 of the code, you submit the query XML using QueryEx to return a<br />

dataset. Using Query rather than QueryEx will return an xmlNode with basically the<br />

same data. The dataset is just a little easier to work with, even though the names of<br />

the fields are long. Speaking of the field names, notice that %3a is the escape<br />

sequence for a colon. Mentally substituting those three characters when looking at<br />

the preceding code will make the field names easier to underst<strong>and</strong>.<br />

Finally, place the following code in the treeView1_AfterSelect function:<br />

private void treeView1_AfterSelect(object sender,<br />

System.Windows.Forms.TreeViewEventArgs e)<br />

{<br />

//1. Setup a variable representing a latent process with<br />

// IE (iexplore.exe) as the application <strong>and</strong> the URL<br />

// in the clicked node's tag as the document to open<br />

System.Diagnostics.ProcessStartInfo iexploreStartInfo = new<br />

System.Diagnostics.ProcessStartInfo(<br />

"iexplore.exe", e.Node.Tag.ToString());<br />

}<br />

//2. Starting the process opens IE to the URL<br />

System.Diagnostics.Process iexplore =<br />

System.Diagnostics.Process.Start(iexploreStartInfo);<br />

Replace the text in the text box with the keywords you want to search for. In<br />

our example, you searched for the word “microsoft”. Click the button. If searching<br />

a br<strong>and</strong> new portal site, there should be a number of resources found (typically<br />

five), as shown in Figure 36-3.<br />

Click any resource listed in the tree view <strong>and</strong> your browser will open directly<br />

to that resource’s URL.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!