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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

994 Part IX: Maintaining a Server in Windows SharePoint Services<br />

//4. Clear the list box <strong>and</strong> treeview from previous searches<br />

treeView1.Nodes.Clear();<br />

listBox1.Items.Clear();<br />

//5. Verify that the search Web service status is ONLINE<br />

if(queryWS.Status().Equals("ONLINE"))<br />

{<br />

//6. Replace the search string in the XML with the string<br />

// of keywords that the user wants to search for.<br />

string query = queryString.Replace(<br />

"SEARCHSTRING",<br />

textBox1.Text);<br />

//7. Submit the query returning a dataset<br />

DataSet ds = queryWS.QueryEx(query);<br />

//8. Process the results of the query, one row in the dataset<br />

// for each resource found by the search<br />

foreach(DataRow row in ds.Tables["table"].Rows)<br />

{<br />

//9. We will use the link to the resource <strong>and</strong> its title<br />

string hrefLink =<br />

row["DAV%3ahref"].ToString();<br />

string displayTitle =<br />

row["urn%3aschemas.microsoft.com%3afulltextqueryinfo%3adisplaytitle"].ToString();<br />

//10. The last modified date, content length, description,<br />

// rank, sourceGroup, <strong>and</strong> sdid1 (search ID)<br />

// are returned from the default search<br />

// but are not used in this example<br />

string getLastModified =<br />

row["DAV%3agetlastmodified"].ToString();<br />

string getContentLength =<br />

row["DAV%3agetcontentlength"].ToString();<br />

string description =<br />

row["urn%3aschemas.microsoft.com%3afulltextqueryinfo%3adescription"].ToString();<br />

string rank =<br />

row["urn%3aschemas.microsoft.com%3afulltextqueryinfo%3arank"].ToString();<br />

string sourceGroup =<br />

row["urn%3aschemas.microsoft.com%3afulltextqueryinfo%3asourcegroup"].ToString();<br />

string sdid1 =<br />

row["urn%3aschemas.microsoft.com%3afulltextqueryinfo%3asdid1"].ToString();<br />

}<br />

//11. Add each resource into the treeview<br />

TreeNode node = treeView1.Nodes.Add(displayTitle);<br />

//12. Save the URL with the node<br />

node.Tag = hrefLink;<br />

//13. Determine if any resources were found by the search<br />

if (treeView1.Nodes.Count > 0)<br />

{<br />

//14. Message the user to click on any item to view it<br />

listBox1.Items.Add("Click on any item to view it.");<br />

}

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

Saved successfully!

Ooh no, something went wrong!