Genesys CTI User Forum
Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: alexandru.fatu on September 15, 2015, 06:32:26 AM
-
Hello everyone,
This is my first post. I'm really happy I found this forum. I think I have much to learn from this KB.
I have a question.
Let's say you want to create a new command ..let's call it "AfterMarkDone", and you want to put it here:
[img]http://s4.postimg.org/5ocivhq8t/de_urcat.png[/img]
well, this is the commandManager:
[code]
commandManager.InsertCommandToChainOfCommandBefore("InteractionOpenMediaClose", "Close", new List<CommandActivator>
{
new CommandActivator
{
CommandType = typeof(AfterMarkDone),
Name = "AfterMarkDone"
}
});
[/code]
And this is the Command:
[code]
public class AfterMarkDone : IElementOfCommand
{
private readonly IAgent agent;
private readonly IObjectContainer container;
private readonly ILogger logger;
public AfterMarkDone(IObjectContainer container) {
this.container = container;
this.logger = container.Resolve<ILogger>().CreateChildLogger("AfterMarkDoneCommand");
}
public bool Execute(IDictionary<string, object> parameters, IProgressUpdater progressUpdater) {
if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess()) {
object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send,
new ExecuteDelegate(Execute), parameters, progressUpdater);
return (bool) result;
}
else {
logger.Info("Execute");
// Prompt the alert dialog
return MessageBox.Show("Do you really want to release this call?\r\nThe call",
"Release the call?", MessageBoxButton.YesNo) == MessageBoxResult.No;
//////This Location//////
//////This Location//////
//////This Location//////
//////This Location//////
}
}
delegate bool ExecuteDelegate(IDictionary<string, object> parameters, IProgressUpdater progressUpdater);
public string Name { get; set; }
}
[/code]
The problem is that I need to send some information via a REST WS HTTP POST, and that info is in the Case.
It's obvious that I'm on an interaction in that place. How can I get the case and put my hands on the main interaction?
I tried with dependency injection like this:
[code]
IAgent agent = ContainerAccessPoint.Container.Resolve<IAgent>();
ICase ccase = ContainerAccessPoint.Container.Resolve<ICase>();
void DoSomething() {
var x = agent.UserName; //this is great
var y = ccase.MainInteraction; //this is null
}
[/code]
Can you please, give me an idea on how to get the main interaction? It's obvious that I'm on the main interaction on that spot. I thought that I can resolve that with dependency injection. Clearly I was wrong...
Thank you very much,
Alex
-
Hi Alex,
This thread should probably be in the dev forum.
See Genesys Documentation at http://docs.genesys.com/Documentation/IW/latest/Developer/UseCustomizableCommands
In this documentation under heading "Creating a Command", the example shows that the Execute method of the custom command has an IDictionary<string, object> parameter named parameters. Examining the Command reference for chain InteractionOpenMediaClose -> Close at http://docs.genesys.com/Documentation/IW/latest/Developer/OpenMedia shows that a CaseId (string) and CommandParameter (IInteractionOpenMedia) may be available in this dictionary.
Full disclaimer: I don't know if the command you chose to add your behavior to is the proper command to attach to. That will come with experience and trial/error.
My advice would be to examine IInteractionOpenMedia to see if you can get anything from the CommandParameter object in the dictionary that may lead you to your Case. Alternatively I believe you can use IInteractionManager in the following way (see below). I have not tested any of this, just writing from memory.
[code]
public class AfterMarkDone : IElementOfCommand
{
private readonly IAgent agent;
private readonly IObjectContainer container;
private readonly ILogger logger;
private readonly IInteractionManager interactionManager;
public AfterMarkDone(IObjectContainer container, IInteractionManager interactionManager) {
this.container = container;
this.logger = container.Resolve<ILogger>().CreateChildLogger("AfterMarkDoneCommand");
this.interactionManager = interactionManager;
}
public bool Execute(IDictionary<string, object> parameters, IProgressUpdater progressUpdater) {
if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess()) {
object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send,
new ExecuteDelegate(Execute), parameters, progressUpdater);
return (bool) result;
}
else {
logger.Info("Execute");
// Prompt the alert dialog
return MessageBox.Show("Do you really want to release this call?\r\nThe call",
"Release the call?", MessageBoxButton.YesNo) == MessageBoxResult.No;
string caseId = parameters["CaseId"] as string;
ICase myCase = interactionManager.GetCaseById(caseId);
//////This Location//////
//////This Location//////
//////This Location//////
//////This Location//////
}
}
delegate bool ExecuteDelegate(IDictionary<string, object> parameters, IProgressUpdater progressUpdater);
public string Name { get; set; }
}
[/code]