none
How to call AddSession from a hosted application RRS feed

  • Question

  • I have built a CCF2009 development system and need to host an application that will start a sesion on receipt of an external event. I have implemented the SWAI interface and can see how to use the "SessionOpen" to manipulate the session once it is created, but can find no way to create the session.  One question in the forum suggests that it may be possible to use a web service, but no details - help please !
    Monday, July 27, 2009 11:45 AM

Answers

  • Why don't you add an event in your hosted app and hook it in IAD code when AddSession is called - it's called first when the desktop loads with a global session. you can then use the code already in IAD to crate your session when the external event happens. Something like this:

    if (SessionManager.ActiveSession.Global && !initializedMyHostedApp) {
       foreach (IHostedApplication application in appHost) {
             if(application is MyHostedApp){
                  //Hook your event here
                  initializedMyHostedApp = true;
             }
       }
    }
    Hope that helps
    Mark
    • Marked as answer by PhillipsonR Wednesday, July 29, 2009 9:19 AM
    Monday, July 27, 2009 4:36 PM

All replies

  • Why don't you add an event in your hosted app and hook it in IAD code when AddSession is called - it's called first when the desktop loads with a global session. you can then use the code already in IAD to crate your session when the external event happens. Something like this:

    if (SessionManager.ActiveSession.Global && !initializedMyHostedApp) {
       foreach (IHostedApplication application in appHost) {
             if(application is MyHostedApp){
                  //Hook your event here
                  initializedMyHostedApp = true;
             }
       }
    }
    Hope that helps
    Mark
    • Marked as answer by PhillipsonR Wednesday, July 29, 2009 9:19 AM
    Monday, July 27, 2009 4:36 PM
  • Thanks,

    Your answer gave me the starting point to the solution I have implemented.  IHostedApplication3 has "SessionManager" as a property, but only implements "Put", from the hosted application I needed to "Get" SessionManager.  The simple answer is to change the Desktop code to detect applications using this interface and then push the reference to SessonManager from the Desktop into the application.
    Wednesday, July 29, 2009 2:43 PM
  • Here us the code to use SWAI

    using System;
    using System.Data;
    using System.Text;
    using System.Drawing;
    using System.Windows.Forms;
    using System.ComponentModel;
    using System.Collections.Generic;
    using Microsoft.Ccf.Csr;

    {
     public partial class SWAI : HostedControl, ISessionController
     {
      public event SessionControllerEventHandler RequestSessionChange;
      public event SessionControllerEventHandler RequestSessionClose;
      public event SessionOpenControllerEventHandler RequestSessionOpen;
      public SWAI(int appID, string appName, string initString)
       : base(appID, appName, initString)
      {
       InitializeComponent();
      }
      public override void SessionChange(bool activate, Guid sessionID)
      {
       this.sessionChangedListbox.Items.Add(sessionID);
      }
      public bool SessionClose(Guid sessionID)
      {
       this.sessionClosedListbox.Items.Add(sessionID);
       return true;
      }
      public bool SessionOpen(Guid sessionID, Guid applicationSessionID)
      {
       this.sessionOpenListbox.Items.Add(sessionID);
       return true;
      }
     }
    }

     
    SWAI only works with HostedControls
     
    Also you need to modify the AddSession method in Desktop.cs

    else

    {

    StartingNewSession = true;

                    SessionManager.AddSession(sessionName, callID, customer);

                    // New line for SWAI

    ApplicationHost.SessionOpen(SessionManager.ActiveSession.SessionID, Guid.Empty);

    Yves Pitsch
    Thursday, July 30, 2009 11:38 PM