Using a Referencer for Script Execution

In CCF, you can use scripts to drive hosted applications and thereby automate tasks. To execute, scripts need access to namespaces. For example, a simple call to Messagebox.Show() must import System.Windows.Forms in order to execute. The script compilation and execution is completed in CCF. Because each script is different, the system integrator must pass in the proper namespaces.

In CCF, the Referencer follows the Provider design pattern. All Referencer classes implement the IReferencer interface.

The following table defines the key method of the interface.

Signature

Description

Void LoadAssemblies(IvsaItems items)

This method performs the assembly load operation.


The following example is a simple Java script that shows a call to display a MessageBox.


                  import System.Windows.Forms;
MessageBox.Show(“Hello World”);

                

To set up this script to run with the sample Web application (Sample Web App)

  1. In the Admin Console, create an action called Messagebox for the sample Web application. In the Action, add the path to the script.
  2. Make sure that the sample Web application is configured to appear in the AgentDesktop solution.
  3. Open the Microsoft.Ccf.Samples.Csr.Referencer project, and add the following to the LoadAssemblies method in the ScriptReferencer.cs file.
  4. Add the following code:

  5. 
                        //systems.windows.forms.dll
    assemblyName = “systems.windows.forms.dll”;
    refItem = (IVsaReferenceItem) items.CreateItem(assemblyName, VsaItemType.Reference, VsaItemFlag.None);
    refItem.AssemblyName = assemblyName;
    
                      
    
  6. In SampleWebApp.htm add the following.
  7. <a href="ccf://SampleWebApp/MessageBox">MessageBox script</a>

  8. Compile the Microsoft.Ccf.Samples.Csr.Referencer, and then copy it to the AgentDesktop bin folder.
  9. To configure the Referencer provider, make the following changes to the App.config file of the AgentDesktop solution.
  10. Add the following:

    1. In the <sectionGroup>, add the following.
    2. In the <Microsoft.Ccf> section, add the following.

Show: