Task 1 – Beginning the Exercise

In this task, you will open the project and configure it to run with your accounts.

  1. Navigate to Start>> All Programs >> Microsoft Visual Studio 2010.
  2. Click on the Microsoft Visual Studio 2010 icon to start Visual Studio 2010.
  3. Select File >> Open Project.
  4. Navigate to the folder C:\%UC14TrainingKit%\Labs\3\Source\Before.
  5. Open the AddingContexttoConversations.sln solution.
  6. In Solution Explorer, right-click the LaunchLink project and select Set as Startup Project.
  7. Open the LaunchLink project.
  8. In Solution Explorer, open the App.config file.
  9. Change the PrimaryLabUserId and SecondaryLabUserId values to the SIP URI of your primary and secondary lab accounts.
  10. Replace the ApplicatonGuid with a new Guid.
  11. Select View >> Task List and select Comments from the menu.
  12. Start a remote desktop session as the secondary lab user.
  13. Return to the primary lab user’s session.
Note:
Generate a new Guid with the Guid Generator tool. Go to Tools >> Create Guid in the Visual Studio 2010 menu or go to Start >> All Programs >> Visual Studio 2010 >> Microsoft Windows SDK Tools >> Guid Generator. Select option 4. Registry Format, click the New Guid button, click the Copy button and paste that value into the App.config file.

Task 2 – Registering the Package

In this task, you will add the registry settings to deploy the contextual conversation components.

  1. In Solution Explorer, open PackageRegistration_LaunchLink.reg.
  2. Copy the new GUID from Task 1 into the [HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{<GUID>}] value.
  3. Change the Path entry to the path of LaunchLink.exe in the project’s output directory, i.e. bin\Debug. When entering the Path, use “\\” instead of “\”.
  4. Save the file.
  5. Right-click the Launch Link project and select Open Folder in Windows Explorer.
  6. Double click the .reg file to run it.
  7. Open the Registry Editor by going to the Start menu and typing regedit.exe into the search field.
  8. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\<GUID>.
    1. This is the GUID from the .reg file.
  9. Confirm that the settings match those in the .reg file.

  10. Copy the .reg file to the clipboard and switch to the secondary lab user’s remote desktop session.
  11. Paste the file to the desktop and double click to run it and create the same registry settings on the secondary lab user’s desktop.
Note:
If the secondary user does not have permission to view the solution, or is logged in to a different computer, copy the solution over and modify the path in the .reg file to point to the local copy of LaunchLink.exe.

Task 3 – Setting Contextual Data

In this task, you will add launch link contextual data to the Lync Controls.

  1. Navigate to TODO: 3.1.1.
  2. Add the following code after the TODO: 3.1.1 comment. This defines the contextual information for the conversation.

    C#

    ConversationContextualInfo context = new ConversationContextualInfo(); context.Subject = selectedAccount.AccountName; context.ApplicationId = _applicationGuid; context.ApplicationData = "AccountId:" + selectedAccount.ID.ToString();
  3. The Subject specifies the text displayed in the invite to join the conversation, the ApplicationId specifies GUID of the registered application, and the ApplicationData specifies the command line arguments when the application is run. This configures the conversation window with a launch link for the application.
  4. Navigate to TODO: 3.1.2.
  5. Add the following code after the TODO: 3.1.2 comment. This sets the context of the StartInstantMessagingButton and StartAudioCallButton controls to the object defined previously.

    C#

    startInstantMessagingButton.ContextualInformation = context; startAudioCallButton.ContextualInformation = context;
  6. Navigate to TODO: 3.1.3
  7. Add the following code after the TODO: 3.1.3 comment. This retrieves the ConversationContextualInfo.ApplicationData conversation context from the command line arguments used to launch the application from the LaunchLink.

    C#

    if (App.CommandLineArgs.Count > 0 && App.CommandLineArgs["AccountId"] != null) { LoadSelectedAccount(Convert.ToInt32(App.CommandLineArgs["AccountId"])); }
  8. Navigate to TODO: 3.1.4.
  9. Add the following code after the TODO: 3.1.4 comment. This selects the account specified in the command line arguments in the list of accounts.

    C#

    foreach (var account in _accounts) { if(account.ID == accountId) { accountsList.SelectedItem = account; break; } }
  10. Go to Start >> Start Without Debugging or press [Ctrl]+[F5] to start the application.
  11. Select the Separate Parts Corporation account from the list.

  12. Click the IM icon at the bottom of the window.
  13. Type “Can you discuss this account?” into the conversation window and press the Enter key.

  14. Switch to the secondary lab user’s remote desktop session and click the toast message to receive the IM.
  15. The toast message will display the name of the selected account.
  16. Click on the link in the IM conversation window to launch the application.
  17. The application is launch and the Separate Parts Corporation account is selected in the list of accounts.

  18. Close the application and all Lync 2010 conversation windows.
  19. Return to the primary lab user’s remote desktop session.

Task 4 – Registering the Application

In this task, you will register the application so a contextual conversation can interact with a running instance of the application.

  1. Navigate to TODO: 3.1.5.
  2. Add the following code after the TODO: 3.1.5 comment. This instantiates the ApplicationRegistration object and allows the conversation window to interact with a running application.

    C#

    private ApplicationRegistration _applicationRegistration;
  3. Navigate to TODO: 3.1.6.
  4. Add the following code after the TODO: 3.1.6 comment. This registers the application by its GUID and name.

    C#

    _applicationRegistration = _lyncClient.CreateApplicationRegistration( _applicationGuid, _applicationName); _applicationRegistration.AddRegistration();
  5. Repeat steps 10–17 from Task 3 to confirm the application still works as it did in the previous task.
  6. In the secondary lab user’s session, close the IM window, but leave the application running.
  7. Return to the primary lab user’s session and close the IM window.
  8. Select the Central Discount Store account in the application.
  9. Click on the IM icon to start another conversation.
  10. Type a message and press the Enter key.
  11. Switch to the secondary lab user’s session.
  12. Click the link in the conversation window.
  13. Verify that the application automatically selects the account selected in the primary lab user’s session.

  14. Close the IM windows and applications.