I have a CRM application that is written on the top of Asp.NET MVC 5 framework. I need to add a button to allow my users to click to place a call. Once the call is placed, I need to be able to retrieve the CallIdKey from the interaction and store it into my CRM records.
Each time I try to access the `CallIdKey` attribute i get the following exception
Additional information: The requested object or attribute is not being watched. Name: Eic_CallIdKey
Questions
1) How do I get the `CallIdKey` attribute or how to I add a watch to be able to that info?
2) Currently as you can see from my code, I make a new connection/session for each request to the server, I am guessing this is a bad practice. How can I establish a connection between my app and the IC server and keep that connection alive until the user logout from my app?
Here is my code
using ININ.IceLib.Connection;
using ININ.IceLib.Interactions;
using System;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace IceLibTest.Controllers
{
public class HomeController : Controller
{
private Session _dialerSession;
private InteractionsManager _interactionsManager;
// Sign in and set the dialer session
protected void SignIn()
{
SessionSettings sessionSettings = new SessionSettings();
var hostSettings = new HostSettings(new HostEndpoint("MyServerName"));
var authSettings = new WindowsAuthSettings();
var stationSettings = new StationlessSettings();
_dialerSession = new Session();
_dialerSession.Connect(sessionSettings, hostSettings, authSettings, stationSettings);
}
// Get an instance of the interaction manager
protected InteractionsManager GetInteractionManager()
{
if (_interactionsManager == null)
{
if(_dialerSession == null) {
SignIn();
}
_interactionsManager = InteractionsManager.GetInstance(_dialerSession);
}
return _interactionsManager;
}
// Make a call
public JsonResult MakeCall(string phone, int taskId)
{
var call = new CallInteractionParameters(phone);
call.AdditionalAttributes["TaskId"] = taskId.ToString();
var interaction = GetInteractionManager().MakeCall(call);
if (interaction == null)
{
return Json(new { CallIdKey = null, Result = "Failed"}, JsonRequestBehavior.AllowGet);
}
return Json(new { CallIdKey = interaction.CallIdKey, Result = "Success"}, JsonRequestBehavior.AllowGet);
}
}
}