Context Manager Interface

The Context Manager interface (ICcfContextManager) contains the hosted control that provides Context Management methods. The interface uses the customer information provided by the Customer interface to set the opening context. The context is then used to create a session name, and used during the session to pass information to the session.

The following figure shows the public structure of the ICcfContextManager interface:

Ee712803.82588c59-dec5-4c52-90a9-ce4ddd9ef02b(en-us,MSDN.10).png


The following table describes the methods in the ICcfContextManager interface:

Method

Description

DesktopContextChange

 

GenerateSessionName

The method is used to create a session name for the session.

RenewSession

The method is used to renew an existing session and all controls within the session.

SetContext

The method is used to set context for hosted applications to use.


The following example of the SetContext method is a code snippet from the project Microsoft.Ccf.Samples.Csr.AgentDesktop. The sample illustrates how you can set the context in CCF, and use them in the hosted applications.



                    private void SetContext(CallClassProvider call)
  {
    Context context = new Context();
    Cursor saveCursor = Cursor.Current;
    try
      {
        Cursor.Current = Cursors.WaitCursor;
        if (customer != null)
        {
        context["CustomerID"] = customer.CustomerID;
        context["CustomerAuthenticated"] = customerAuthenticated.ToString();
        context["CustomerFirstName"] = customer.FirstName;
        context["CustomerLastName"] = customer.LastName;

// Set this so later UI elements can show the name as found in the database.  //Especially useful when a call center doesn't get the name from the phone network //(ANI doesn't include name)
          if (call != null)
          {
          //Check if there is a firstname
          if (customer.FirstName != null && !customer.FirstName.Length.Equals(0))
            {
            call.UserTag = customer.FirstName + " " + customer.LastName;
            }
          else
          {
            call.UserTag = customer.LastName;
          }
        }

        context["Street"] = customer.Street;
        context["City"] = customer.City;
        context["State"] = customer.State;
        context["ZipCode"] = customer.ZipCode;
        context["Landline"] = customer.PhoneHome;
        context["MobilePrepaid"] = customer.PhoneMobile;

      }
        // If we have call information, store that too.
        if (ctiHostedControl != null)
          {
          if (call != null)
            {
            context["ANI"] = call.CallerNumber;
            context["DNIS"] = call.CalledNumber;

        // to assist any hosted apps that wish to work with the call
        context["CallID"] = call.CallID.ToString();

        // to assist any hosted apps that wish to work with the call
            context["CallGuid"] = call.ID.ToString();
          }
        }

        // In case the hosted apps couldn't start.  Not sure what use the app is
        // without them though.
        if (AppHost != null)
          {
        //SetContext calls CreateContext if it needs to create a new GUID
          AppHost.SetContext(context);
          AppHost.ExecuteDefaultActions();
            if (customer != null)
            {
            AppHost.CreateApplicationState(customer.CustomerID);
              if (customer.CustomerID != String.Empty)
              {
              AppHost.ExecuteApplicationState();
              }
            }
          }
        }
        catch (Exception ex)
        {
        if (IsCriticalException(ex)) throw;
        Logging.Error(Application.ProductName, Strings.DESKTOP_ERR_SETTING_CONTEXT_APP, ex);
        }

        finally
        {
        Cursor.Current = saveCursor;
        }
    }

                  

Show: