Customized Retrieval of Index Panel Values Using the KnowledgeLake SDK

In this post I will demonstrate how to pass values from a Windows Form into the KnowledgeLake SharePoint 2010 Client Index Panel. The ideas expressed in this example can easily be transposed to accommodate web
service calls, etc. You will need the following prerequisites in order to get
started:

  • A KnowledgeLake client program (Capture, Connect, Capture Server Index Client) installed and configured to release to a SharePoint 2010 site
  • Visual Studio 2010
  • KnowledgeLake Capture Suite SDK product (only one is needed)
    • Capture 4.8 SDK or later
    • Capture Server 4.3.2 SDK or later
  • A basic understanding of C# and WPF
  • A basic understanding of creating custom SP2010
  • KnowledgeLake Index Panel components

Getting Started

Start by opening Visual Studio 2010. From File Go to New > Project. Select the InheritedIndexPanelTemplate
template from the folder you installed it to. For instance, mine is under Visual C# > KnowledgeLake. Name your
project and click OK.

Create Project.png

 

You will see several warnings when the project is created.
These warnings indicate that the paths to the references could not be found. We
will need to add these manually. Listed below are the references to add:

  • Knowledgelake.Index.Client
  • KnowledgeLake.Index.Contracts
  • KnowledgeLake.Index.Controls
  • KnowledgeLake.WPF
  • System.ComponentModel.Composition

The exact version of these references you add is dependent
on which product you are developing the index panel for and the product’s
version. For instance, I will deploy this panel to the Capture Server index
Client which ships with Capture Server 4.3.2. Therefore, my references would be
the following:

·
Knowledgelake.Index.Client – 1.0.0.5

·
KnowledgeLake.Index.Contracts – 1.0.0.5

·
KnowledgeLake.Index.Controls – 1.0.0.10

·
KnowledgeLake.WPF – 1.1.0.0

·
System.ComponentModel.Composition – 2010.2.11.0

To find which references you will need to make, please see
the help file associated with each SDK release.

Once you added the references, recompile the project.

 

Setting the XAML?

On the index panel we will want to have a button we use to
open an instance of our LOB window. Add an instance of a
System.Windows.Controls.Button into the Grid for the panel. The
template should already have a definition for a row with a Height of 30 units by
default. Add the following code below the RowDefinitions for our Grid:

<Button x:Name=”BtnLaunch” Content=”Launch LOB” Grid.Row=”0″/>?


Index Panel Class?

 

Open the CustomIndexPanel
class next. We will first want to create a property of type Button which we can
link to the one created in our XAML file. Add the following line above the
class constructor:

private Button
_btnLaunch = null;

Next we will need to create our Button property. This can be
placed under the constructor:

protected Button
BtnLaunch

{

get { return this._btnLaunch; }

set

{

this._btnLaunch = value;

if (this._btnLaunch
!= null)

{

this._btnLaunch.Click += new
RoutedEventHandler(_btnLaunch_Click);

}

}

}

When this property is set it checks to make sure that the
_btnLaunch is not null. If that check is passed it then adds a new event
handler for the Button’s Click event. When typing the last code line make sure
to tab twice in order to automatically generate the new event handler below the
property.

Index Panel Class

 

Let’s take a step back from the Index Panel class for the
time being and create our test form.

Add a new Windows Form to the project. I named mine LOBForm:

For this next part you will need to have a content type in
mind for the example. Mine is going to be a content type called Personnel. In
this content type I have two fields, FirstName and Last Name (The latter being
a custom column which was created with a space in the name) which I am going to
populate from this form. Make sure to name and label your objects according to
the two fields you select from your content type. Add the following objects to
the form:

Type

Name

Text
(if applicable)

Tag
(if applicable)

Label

lblFName

First Name:

 

Label

lblLName

Last Name:

 

TextBox

txtFName

 

FirstName

TextBox

txtLName

 

Last Name

Button

btnSubmit

Submit

 

 

Below is a screenshot of how the form should look:

Once this is done, double click on the button while in
Design Mode in order to register a new event handler for btnSubmit. The
following code will need to be added to the generated method in the form’s
code-behind:

private void
btnSubmit_Click(object sender, EventArgs e)

{

Values = new Dictionary<string, string>();


Values.Add(txtFName.Tag.ToString(), txtFName.Text);


Values.Add(txtLName.Tag.ToString(), txtLName.Text);

this.DialogResult = DialogResult.OK;

this.Close();

}

 

In this method we are creating a value of dictionaries which
will be retrieved from our index panel. The key value is assigned as what we
put in the Tag properties of our TextBox controls. We also want to set the DialogResult property which gets tied
back to our index panel.

We will need to actually create a property Named Values
next. Create the following variable above the constructor:

private Dictionary<string,
string> _values = null;

 

Then add the following property below the constructor:

public Dictionary<string, string>
Values

{

get { return _values;
}

set { _values = value;
}

}


Linking the Form and the Index Panel

Switch back over to the Index Panel class. We will now
populate the btnLaunch.Click event handler. Below is the code for the method:

void _btnLaunch_Click(object
sender, RoutedEventArgs e)

{

LOBForm window = new
LOBForm();


window.ShowDialog();

if (window.DialogResult == System.Windows.Forms.DialogResult.OK)

{

Dictionary<string,
string> values = window.Values;

if (values != null)

{


SetAllValues(values);

}

}

}

 

We create an instance of our form and choose to ShowDialog(). Our process then waits
for a value to be assigned to the Form’s DialogResult property, which we do
after we set the values from the form. Once the OK is received we create a
local dictionary to store the values.

SetAllValues() is
a method inherited from the KnowledgeLake.Index.Controls.IndexPanel
class. It takes the dictionary of <columnName,
value>
pairs and updates the appropriate columns on the panel.

Lastly, for our OnApplyTemplates() method, insert the
following code:

public override void OnApplyTemplate()

{

base.OnApplyTemplate();

this.BtnLaunch = this.GetTemplateChild(“BtnLaunch”) as
Button;

}

 

This code attaches the Button created in the XAML to the
property in the code-behind class.

 

Deployment

Build the index panel project. Once that is done, copy the
output dll into the Extensions
folder of the program you would like to test with. For me, it is the Capture
Server Index Client:

 

Windows Explorer.png

The default location for this directory is C:\Program Files
(x86)\KnowledgeLake\(product)\Extensions

Once the dll is deployed, index a document in the respective
application. Upon indexing you should see the button displayed at the top of
the panel:

Clicking the button should present a dialog box which
accepts our two values. Once that window is closed, the values should populate
to their respective fields in the panel:

 

Summary

Integrating an external form to the Index Panel is a fairly
straightforward procedure. There are many additional possibilities for this
extensibility as well. Values can be grabbed from Web Services or other
databases and easily pushed into the Index panel Fields. For more information
on modifying the KnowledgeLake SharePoint 2010 Client index Panel please refer
to the Help Files distributed with each KnowledgeLake SDK Release.

2 Responses to Customized Retrieval of Index Panel Values Using the KnowledgeLake SDK

  1. Jithendra Mani says:

    I would like to customize index panel of the connect app. Please explain me how I can edit it and integrate to the application. I couldnt find a folder called ‘extensions’ in the installation folder. It would be very helpful if you explain me in a step by step way. Thanks in advance

    • Nicholas Heembrock says:

      For Connect, the “Extensions” folder needs to be created manually. Step by step instructions for implementing index panel customization for Connect is available in the Connect SDK documentation.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>